From patchwork Wed Jan 11 15:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 90913 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1166707qgi; Wed, 11 Jan 2017 07:09:29 -0800 (PST) X-Received: by 10.84.196.164 with SMTP id l33mr14044988pld.150.1484147369444; Wed, 11 Jan 2017 07:09:29 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id t80si6047379pfk.213.2017.01.11.07.09.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 07:09:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cRKWm-0002OZ-Gz; Wed, 11 Jan 2017 15:09:28 +0000 Received: from mail-pg0-x232.google.com ([2607:f8b0:400e:c05::232]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cRKWb-0001jJ-Ok for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2017 15:09:20 +0000 Received: by mail-pg0-x232.google.com with SMTP id f188so282344290pgc.3 for ; Wed, 11 Jan 2017 07:08:57 -0800 (PST) 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=Qv95cakCz+u10R8lXM1SnESWs+WdKAV4AEf4fe1l34k=; b=S1D5aDNdMCgUWcIUJyza36/NmKoKoVwy8L2VxYIPX6QCDuL49RzqTYKGVYdFtddQob vymNTHEyq2u2a5q2DrLruUJL8BLXXSZ9Fyq0zOShHJ5jf0dqFvnG+WWdUyX+N3VpKyaJ J09EgsIIHUh881EHjkhXGbchxkBQJgIdQfhCw= 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=Qv95cakCz+u10R8lXM1SnESWs+WdKAV4AEf4fe1l34k=; b=eEQvx8/YNvbrdLWoqZxzAtaCaNeA4HhNnmAE/k6z3VCKDkVsN2whiYCmjKIzmIT+/L VBjz+HIGe1MdGRTDfkf9J70AOr9HIJSP9/V/k5CDUiRDqTxxC5qluxjRIorNZAGvrHPi Y9u6GUQ7SflLagSV4HMyt/AE83yk1me0lWyljvt0fMCGRpNAGoX/Cu2WgGt9HOPRZuQB c5Nql2GUwYsFXMV2W7w58wFoXf5Z/eGgmZpyT+MjTPmBjqcFg/aWjC4zbZD4+GKzPoEE 5q9QVpzGTfPJJv/ID6JCmu+pSJxhD2GS0X2PQ3pHgfJNI/gPxmU1XRPyv9z/KpRxhYEh WTkA== X-Gm-Message-State: AIkVDXJYJMTaOGTrKOnEXNhyh4XqndQKCUgchGhqDjzuoruA9Cz3vX+SR0rinOV8+JEBB5q8 X-Received: by 10.98.92.133 with SMTP id q127mr10714892pfb.152.1484147336779; Wed, 11 Jan 2017 07:08:56 -0800 (PST) Received: from localhost ([104.237.91.103]) by smtp.googlemail.com with ESMTPSA id l63sm14610348pfl.83.2017.01.11.07.08.54 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 11 Jan 2017 07:08:56 -0800 (PST) From: Hanjun Guo To: Marc Zyngier , "Rafael J. Wysocki" , Lorenzo Pieralisi Subject: [PATCH v7 11/15] ACPI: platform: setup MSI domain for ACPI based platform device Date: Wed, 11 Jan 2017 23:06:35 +0800 Message-Id: <1484147199-4267-12-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1484147199-4267-1-git-send-email-hanjun.guo@linaro.org> References: <1484147199-4267-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170111_070918_069247_8F4150B1 X-CRM114-Status: GOOD ( 18.25 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c05:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huxinwei@huawei.com, Kefeng Wang , Matthias Brugger , Jon Masters , yimin@huawei.com, Greg KH , linux-kernel@vger.kernel.org, linuxarm@huawei.com, Sinan Kaya , linux-acpi@vger.kernel.org, Xinwei Kong , Hanjun Guo , Tomasz Nowicki , Thomas Gleixner , Agustin Vega-Frias , linux-arm-kernel@lists.infradead.org, Ma Jun MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org With the platform msi domain created, we can set up the msi domain for a platform device when it's probed. In order to do that, we need to get the domain that the platform device connecting to, so the iort_get_platform_device_domain() is introduced to retrieve the domain from iort. After the domain is retrieved, we need a proper way to set the domain to paltform device, as some platform devices such as an irqchip needs the msi irqdomain to be the interrupt parent domain, we need to get irqdomain before platform device is probed but after the platform device is allocated (the time slot of setting the msi domain also works for other cases). So simply call acpi_configure_pmsi_domain() in acpi_platform_notify() for platform devices will work. Acked-by: Rafael J. Wysocki [for glue.c] Signed-off-by: Hanjun Guo Cc: Marc Zyngier Cc: Lorenzo Pieralisi Cc: Tomasz Nowicki --- drivers/acpi/arm64/iort.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/glue.c | 6 ++++++ include/linux/acpi_iort.h | 3 +++ 3 files changed, 59 insertions(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index a6c8d2d..f5a32d0 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -551,6 +551,56 @@ struct irq_domain *iort_get_device_domain(struct device *dev, u32 req_id) return irq_find_matching_fwnode(handle, DOMAIN_BUS_PCI_MSI); } +/** + * iort_get_platform_device_domain() - Find MSI domain related to a + * platform device + * @dev: the dev pointer associated with the platform device + * + * Returns: the MSI domain for this device, NULL otherwise + */ +static struct irq_domain *iort_get_platform_device_domain(struct device *dev) +{ + struct acpi_iort_node *node, *msi_parent; + struct fwnode_handle *iort_fwnode; + struct acpi_iort_its_group *its; + int i; + + /* find its associated iort node */ + node = iort_scan_node(ACPI_IORT_NODE_NAMED_COMPONENT, + iort_match_node_callback, dev); + if (!node) + return NULL; + + /* then find its msi parent node */ + for (i = 0; i < node->mapping_count; i++) { + msi_parent = iort_node_map_platform_id(node, NULL, + IORT_MSI_TYPE, i); + if (msi_parent) + break; + } + + if (!msi_parent) + return NULL; + + /* 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 NULL; + + return irq_find_matching_fwnode(iort_fwnode, DOMAIN_BUS_PLATFORM_MSI); +} + +void acpi_configure_pmsi_domain(struct device *dev) +{ + struct irq_domain *msi_domain; + + msi_domain = iort_get_platform_device_domain(dev); + if (msi_domain) + dev_set_msi_domain(dev, msi_domain); +} + static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data) { u32 *rid = data; diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index fb19e1c..ec31b43 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -6,6 +6,8 @@ * * This file is released under the GPLv2. */ + +#include #include #include #include @@ -14,6 +16,7 @@ #include #include #include +#include #include "internal.h" @@ -322,6 +325,9 @@ static int acpi_platform_notify(struct device *dev) if (!adev) goto out; + if (dev->bus == &platform_bus_type) + acpi_configure_pmsi_domain(dev); + if (type && type->setup) type->setup(dev); else if (adev->handler && adev->handler->bind) diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h index ef99fd52..33f5ac3 100644 --- a/include/linux/acpi_iort.h +++ b/include/linux/acpi_iort.h @@ -38,6 +38,7 @@ /* IOMMU interface */ void iort_set_dma_mask(struct device *dev); const struct iommu_ops *iort_iommu_configure(struct device *dev); +void acpi_configure_pmsi_domain(struct device *dev); #else static inline void acpi_iort_init(void) { } static inline bool iort_node_match(u8 type) { return false; } @@ -58,6 +59,8 @@ static inline void iort_set_dma_mask(struct device *dev) { } static inline const struct iommu_ops *iort_iommu_configure(struct device *dev) { return NULL; } + +static inline void acpi_configure_pmsi_domain(struct device *dev) { } #endif #define IORT_ACPI_DECLARE(name, table_id, fn) \