From patchwork Mon Jan 2 13:31:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 89501 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7592876qgi; Mon, 2 Jan 2017 05:34:12 -0800 (PST) X-Received: by 10.99.227.81 with SMTP id o17mr107946397pgj.69.1483364052268; Mon, 02 Jan 2017 05:34:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r4si33962076pfl.94.2017.01.02.05.34.12; Mon, 02 Jan 2017 05:34:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933152AbdABNdu (ORCPT + 25 others); Mon, 2 Jan 2017 08:33:50 -0500 Received: from mail-pg0-f43.google.com ([74.125.83.43]:33839 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933135AbdABNdr (ORCPT ); Mon, 2 Jan 2017 08:33:47 -0500 Received: by mail-pg0-f43.google.com with SMTP id y62so152060536pgy.1 for ; Mon, 02 Jan 2017 05:33:47 -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=/wqZQ9PJrPghw+FnaXZNjPeNfe2F5BgQ2duOfYCsHEk=; b=kTbEE3cdwCW0cDwrY23sc9aU6YCYKfe2ujPk6qJlP3VH35TAxpa6ADdCGB/vW2b1fa 96gSWsBEcXXolIRD9tvKd5iG3o2zhNeQKxKhsxESbAR6o/L2cSmBB5hkjArDbbia/+Xu 4lFod3RlNd8+w1RxiGwAbzlQ4oCzlOBcKTuWc= 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=/wqZQ9PJrPghw+FnaXZNjPeNfe2F5BgQ2duOfYCsHEk=; b=HnPCYX9ZI8EWsGmixKRBFdX1owbb+TRqdcW1qU8HYLyDtUpegoOVkQks53VV66HkBH RReV0VixrEma2rfgXoDMBhCpjzglWrCq4+VmiS5SLZsp7AG47uqzOKiSN05QVb9pn5Ov eMnaGx/V6GestAiH/cC9qhi8BGdgmA4/mnawKNL2NAMhbyYHY3FxohEg/C/W+tTG/Uuw BxmajBWF1yg0gT+iFLVsDM0WUnocJ+r46vP1bwFCj0EQXuGxtJel677kvPd5f5R5V2pU TxSbCzzZAYtYvt4pJwYp73eBG38a0cOqJOkeT1RCEPplvgzmPI0KXDrP6Ymlk8iXga0Z xayg== X-Gm-Message-State: AIkVDXJ7AL7JSLxpEUoyU4F7X7nmqtGlgw+jN5/P8oRQA0xPX8JocaAd8WKtmg+eRpxSJ85W X-Received: by 10.99.167.76 with SMTP id w12mr107603744pgo.90.1483364027114; Mon, 02 Jan 2017 05:33:47 -0800 (PST) Received: from localhost ([104.237.91.251]) by smtp.googlemail.com with ESMTPSA id n8sm112316330pgc.0.2017.01.02.05.33.45 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 02 Jan 2017 05:33:46 -0800 (PST) From: Hanjun Guo To: Marc Zyngier , "Rafael J. Wysocki" , Lorenzo Pieralisi Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, Thomas Gleixner , Greg KH , Tomasz Nowicki , Ma Jun , Kefeng Wang , Agustin Vega-Frias , Sinan Kaya , charles.garcia-tobin@arm.com, huxinwei@huawei.com, yimin@huawei.com, Jon Masters , Hanjun Guo Subject: [PATCH v6 09/14] ACPI: platform: setup MSI domain for ACPI based platform device Date: Mon, 2 Jan 2017 21:31:40 +0800 Message-Id: <1483363905-2806-10-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483363905-2806-1-git-send-email-hanjun.guo@linaro.org> References: <1483363905-2806-1-git-send-email-hanjun.guo@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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. Signed-off-by: Hanjun Guo Cc: Rafael J. Wysocki Cc: Marc Zyngier Cc: Lorenzo Pieralisi --- drivers/acpi/arm64/iort.c | 43 +++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/glue.c | 6 ++++++ include/linux/acpi_iort.h | 3 +++ 3 files changed, 52 insertions(+) -- 1.9.1 diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index bc68d93..6b72fcb 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -527,6 +527,49 @@ 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; + + /* 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 */ + msi_parent = iort_node_get_id(node, NULL, IORT_MSI_TYPE, 0); + 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 f8d6564..4a73f27 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" @@ -315,6 +318,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) \