From patchwork Wed Sep 27 01:20:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 114310 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4470925qgf; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) X-Received: by 10.99.6.79 with SMTP id 76mr12787993pgg.229.1506475242430; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506475242; cv=none; d=google.com; s=arc-20160816; b=bsy9ZReYHHO/u6VVhhwzfQ92CCa1prZ9Dyt4urhY+DSB6n/Yq2hcZiloDgW8ItxP7/ A5yPPjTi9GpXUU9yWa39QGK0DdvnuHV21kiC523Asj7FJ0AR25CcKNl30T01iy9mqVvQ 687sgoeFAC3oHEgZINYd9KOSj4/ZS/tWxRj/PxS6nw11n/VMCUjJoJPHd/Ptb4g0O5i3 V6WRoDhO30z3A+EbL3qsyNIxGQnGnLGe9BG+bgPsHcbKWcIY8B3UVgvnlcgh68/kv4Br exmw60f7CLcHKWRTTRlC4KjHWfC8SRrmZx7XCOXG3JvIK3IEE2157a1QlnB/fMm0hvpx o2Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=H6MM77SKR2EkaAiv+8xEZ8o99lyWHciX6ZFSWySs91M=; b=ifcwHk014j1MNQq8/znJFGp3VUXe41QdLcOny6ytX2AdcJxYrX072v2BzjWsvCQip5 NYhBFwyxXFH+D20N1kFe8Zou1kwtHhYL/Qa+yANLG0xP5Wez/sL/w1KpuCJ6dbzGilMx lOsRz6A+stRuVj9VyZMLBMCyeiV0XjFkhQfv4MilftyKi354FxtMvUcf85MgwsBz2r9w zUR9vJifW/qPHuQWtYder7JazJnaz34184KTxxLuRp2QbpOfwJ9TrSWtBOzITYsDSfcs IhFhqiuVS1Epbu6t2b+QZcth92y9Yz6Clzoj9aGrjU/W1DiX7PpSuVFKT9r9xdXIDknD 5HHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hn40YGet; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si2494136pfa.558.2017.09.26.18.20.42; Tue, 26 Sep 2017 18:20:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Hn40YGet; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969162AbdI0BUl (ORCPT + 7 others); Tue, 26 Sep 2017 21:20:41 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:46472 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969164AbdI0BUj (ORCPT ); Tue, 26 Sep 2017 21:20:39 -0400 Received: by mail-pf0-f169.google.com with SMTP id r68so6420254pfj.3 for ; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=Hn40YGetDrbOfSRMAlLSLstitzC4/gOmaTsDrGQ9OAzgt42osf+qJbEp3t/yoD4Kul k45H3dbtrr7GhmWGhD5tn8etwRUXROfdg6j+H9fzTys1cvMfmgNRfeT8Jv0MFMYhT6C9 Y2CpRqoAoCTn5OkOD41PzRkFQloXDNSgUJs3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JxUmcNWfBOvcuMFZHaNgUZ0HPgafnQxRqCK687y/6z4=; b=gqGoAydTimXotfgAl966GnVUEogvVtu1vZZ+dwWjizbz/GIqFG438OjHyYadRj19rm A32gYr0Z94HtnA8jGw8/QFr11Mzc9DBHtAYUJ6CaNVV1LHt7ycptWMbgsGw9RjTSTrND 50cbMFoVsXAvbq0l4tUY5hZ9jCkZTHipzJiqCsyKjwDSngFzPKT4kfK/C6u1a3T2AHQT 3EmEM9XnQwk4jfh4wHDPhTyf5OWoK4Dm1Ue3+XvKIUVmy3Hgahrui4yfVJWzbC8NOvEQ +wmhe6PNjOvV4E4PYGyMTmXJUT5u/uFJbzg3Pt2KGwN41SH+z8gpSdRr9iwRVwQ+3Y+W XDRA== X-Gm-Message-State: AHPjjUg3Uql8kFMESoPMw/DzifEcTuZggxK9RLkVNK7S4C0dlcyGDULl KgsxOYO9TsWSw9/ncdvwIgkfuQ== X-Google-Smtp-Source: AOwi7QBUs2Gzx9fyPe5AYLypM/zUpIt0dA3D4+fbjkIUYOwOxfjtuEtdQ54WQPtvaHHQ1Ort4BoIoA== X-Received: by 10.99.115.93 with SMTP id d29mr13013319pgn.333.1506475239354; Tue, 26 Sep 2017 18:20:39 -0700 (PDT) Received: from localhost ([70.35.39.2]) by smtp.googlemail.com with ESMTPSA id p1sm18065617pfb.53.2017.09.26.18.20.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Sep 2017 18:20:38 -0700 (PDT) From: Hanjun Guo To: Lorenzo Pieralisi , Robin Murphy Cc: "Rafael J. Wysocki" , Marc Zyngier , Lv Zheng , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com, Hanjun Guo Subject: [PATCH 4/4] ACPI: IORT: SMMUv3 nodes MSI support Date: Wed, 27 Sep 2017 09:20:15 +0800 Message-Id: <1506475215-2731-5-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> References: <1506475215-2731-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Lorenzo Pieralisi Since we make single mappings valid for SMMUv3 (and PMCG), also we have a mapping index for SMMUv3 MSI, we can directly use that index to get the map entry, then retrieve ITS parent to add SMMUv3 MSI support. Introduce a new API iort_set_device_domain() to find the MSI domain for an SMMUv3 (or any other IORT table node) to reduce the complex of doing that via acpi_configure_pmsi_domain(). Signed-off-by: Lorenzo Pieralisi Signed-off-by: Hanjun Guo --- drivers/acpi/arm64/iort.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index 1c1160e..06b38de 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -633,6 +633,49 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI); } +static void iort_set_device_domain(struct device *dev, + struct acpi_iort_node *node) +{ + struct acpi_iort_its_group *its; + struct acpi_iort_node *msi_parent; + struct acpi_iort_id_mapping *map; + struct fwnode_handle *iort_fwnode; + struct irq_domain *domain; + int index; + + index = iort_get_id_mapping_index(node); + if (index < 0) + return; + + map = ACPI_ADD_PTR(struct acpi_iort_id_mapping, node, + node->mapping_offset + index * sizeof(*map)); + + /* Firmware bug! */ + if (!map->output_reference || + !(map->flags & ACPI_IORT_ID_SINGLE_MAPPING)) { + pr_err(FW_BUG "[node %p type %d] Invalid MSI mapping\n", + node, node->type); + return; + } + + msi_parent = ACPI_ADD_PTR(struct acpi_iort_node, iort_table, + map->output_reference); + + if (!msi_parent || msi_parent->type != ACPI_IORT_NODE_ITS_GROUP) + return; + + /* Move to ITS specific data */ + its = (struct acpi_iort_its_group *)msi_parent->node_data; + + iort_fwnode = iort_find_domain_token(its->identifiers[0]); + if (!iort_fwnode) + return; + + domain = irq_find_matching_fwnode(iort_fwnode, DOMAIN_BUS_PLATFORM_MSI); + if (domain) + dev_set_msi_domain(dev, domain); +} + /** * iort_get_platform_device_domain() - Find MSI domain related to a * platform device @@ -1259,6 +1302,8 @@ static int __init iort_add_smmu_platform_device(struct acpi_iort_node *node) /* Configure DMA for the page table walker */ acpi_dma_configure(&pdev->dev, attr); + iort_set_device_domain(&pdev->dev, node); + ret = platform_device_add(pdev); if (ret) goto dma_deconfigure;