Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755166AbbHXQ4t (ORCPT ); Mon, 24 Aug 2015 12:56:49 -0400 Received: from mail-bn1bon0148.outbound.protection.outlook.com ([157.56.111.148]:31616 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754998AbbHXQ4p (ORCPT ); Mon, 24 Aug 2015 12:56:45 -0400 X-Greylist: delayed 899 seconds by postgrey-1.27 at vger.kernel.org; Mon, 24 Aug 2015 12:56:44 EDT Authentication-Results: spf=none (sender IP is 165.204.84.222) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; X-WSS-ID: 0NTLIDE-08-IFD-02 X-M-MSG: Subject: Re: [PATCH] pci: acpi: Generic function for setting up PCI device DMA coherency To: , , , , References: <1439459925-2361-1-git-send-email-Suravee.Suthikulpanit@amd.com> CC: , , , , , Rob Herring , Murali Karicheri From: Suravee Suthikulpanit Message-ID: <55DB4939.5070605@amd.com> Date: Mon, 24 Aug 2015 23:41:29 +0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1439459925-2361-1-git-send-email-Suravee.Suthikulpanit@amd.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.180.168.240] X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD028;1:Om6nxfnIAKtmpMJVxNYZKuH7y+VpuwyxE5o13jhfF06SToU6OEvXJzmd30JtFweRQVkiZBgf1jENAe5yyvW5IuEECsV5QT7lpgBV3qzf/oEH6TxJkpnsowVrTt4CQuAIH1xl/OUbAYLm4PzHBzMiaRbeQ6k6WfnmHCzxDdQCl5ji1B0AoilKrGF5mo70/8XwS1Ohx7K9t7ssHiJlRib2TtOHnK/jv9KmvUHI4bZVPcLiu/rFZDlsfbnyUzOrjRKJP6Xph64C3XbcEfz8m+WLW7zBeCYrznwhe43YqnsZZBw7Q6S2mxWkX1OwDUVPWdSlkuoHsauYdIqSUUvSXtaBARMgibsok1rTB1yptTXkCh9KTg5CJDU8I41xXzuR6DWr X-Forefront-Antispam-Report: CIP:165.204.84.222;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(428002)(3050300001)(189002)(199003)(164054003)(24454002)(479174004)(5004730100002)(59896002)(4001350100001)(36756003)(50466002)(5001770100001)(5001860100001)(19580405001)(47776003)(65806001)(92566002)(87936001)(50986999)(76176999)(19580395003)(105586002)(97736004)(101416001)(86362001)(65956001)(575784001)(87266999)(80316001)(5001830100001)(64126003)(23746002)(65816999)(4001540100001)(64706001)(2201001)(77156002)(33656002)(46102003)(5007970100001)(62966003)(106466001)(189998001)(83506001)(54356999)(68736005)(77096005)(2950100001)(41533002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR02MB1140;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB1140;2:Sl2xlSJundpgHHcEfUo+Ky7714qo8o4lQhT94fn20e1stJlOkSbYtEwHFQneCPUSU6tRS7ezK2s2tCb3oCOXmzBtwgQ/fdXrKkZ3OPungxBes1E9JUm2rbMeVTOAxFTPh1/IuIz3kyTlM8yDo5NLM9iM46xyGhyEqPRoBTcSwXY=;3:mh/H5+9MiH482s1jL4XrNQzk+VJapnLIHRkApzKCfkvy7vsun31HaX3sIXUBo4P4jHUezP1yRKynYarj7+68ICYHpNS+I5bR6yhkiWtwpJyLJSKyFTWs4I8SbwFBJQm5Uv9Q84YvgvT14JCu+/R5w/I+hQK919r8FtKcK3kHKISvObFB5pyWjxTP3x9JUnX2que/nAdwRM6VAAw6uFl0DP+sC0o7/Ry0hunJjP6uiWImLdNRaIYkE3FtnBeGFJl6;25:mODEd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LjAR1oC3Ms/fIf/ZOaBTRDkGR9OhxVz2f34UMRGrhMQY8K4ls9CzwM+3AHbT67bsq2ayqFZJsCo8oGGtl2Ml4Apm9fDJG+gz0XsRDPemuH5YtKuJdfirX2iwRfFDcNrUH+xYxnP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(8121501046)(3002001);SRVR:BLUPR02MB1140;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1140; X-Forefront-PRVS: 06780E24F8 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BLUPR02MB1140;23:WJAcZWefS6/7ndkOHDWNeUkCjitKLrFy9ErLy?= =?Windows-1252?Q?FlU/H+NM8FkEHtEyiFDoOtytUX8xwB2/Qg7QGa1I7BdolIxSYHEzRfam?= =?Windows-1252?Q?ic6LSe/MJ3ytHl6ZTRYJRJkIGJXlvS+nEYVWtRfyrIbfmV4QnP5NQb6Q?= =?Windows-1252?Q?sbY7YNCdRdDMextUDFj7/v9k41oglTmEM/Igz9IVIDyTwIEvxH5znV4N?= =?Windows-1252?Q?6NnYqN2Enn8mmwQRLi3I+LyJa9ZWE77BXEo9fXrKLhuE0Vs96IoMUopC?= =?Windows-1252?Q?3oRBQx0961lWClnfEPYN9wwNFPcuMB2xnHHBb7P6dCHZOVVCqlJ6Gj16?= =?Windows-1252?Q?mBXk5rGDAk6AsGmHFyQ1AwUd0D1AnKM2tc59z8QT7cky1EIDn/uuUXII?= =?Windows-1252?Q?eDIrT/4rF5eofQJhwOW8zHi8R3NudWlzURmbgIR87AF0U6AlGEcZItHM?= =?Windows-1252?Q?NVTLI3U7lv2n7tcLmEIvuVOWecExLL+jz4VZlhSRvG4nhw1jhSvlZh8E?= =?Windows-1252?Q?D2dF94xiP3mYtP/U/Shlu6n5q83gvgmiYFTZHKyu5HM2wr/dAGs9W2h3?= =?Windows-1252?Q?PgQ12CyF7R1JkVet7du23c6v/Feb7TwBDpeGbGaSz1UWrIMPwyZU5Agh?= =?Windows-1252?Q?RHmf/JoDlYUR1p7rlxJzWsSa91l/merD5FEKtD/HQXm5LOma6N/38xku?= =?Windows-1252?Q?PD7TFpEtsUiAbh6N0l+ZU3QkCx2blE88DuelCBy3u0O5TnSwn5YqeaaI?= =?Windows-1252?Q?TjZPlB9DpAgMBZaAHoIol/izxNvGDSPibZlISxdBAdxqgzWlUBK9E9rw?= =?Windows-1252?Q?HPKchMl5nZFPTZ+AdUcTvHoaufXQw82/eGFBx8gT+WZCk9DV9J0U/CBz?= =?Windows-1252?Q?/9+PioB4wZoxMxokVHydtioEBpxdhiV7YoeKyDOy0hoEiG7VCK+3xEuQ?= =?Windows-1252?Q?KpdbZP9qDnvqz1abMEMrAJj/Hn9S0zE+FQbYw8KPuOE+XHCZ7YQ7vyKj?= =?Windows-1252?Q?PV4WC3Fhgx1RzOZp9Qc3+9ZWgv/I55+81a4SYE4bNS3QqijAkKP8FqJO?= =?Windows-1252?Q?fQgOjuorEkDT76Aupp8JigZbltgxtI815Pi7EPPFSnsJ3r+5Stj6wL4Z?= =?Windows-1252?Q?iE9B5rR3wTe73bKr9VJFm4UW3aTYirWBJy2awoUQ8yVNNvjcSeK0nfaG?= =?Windows-1252?Q?SYb6eOJO2EpY+6/FYO29P8328iiM8B9LkCm4nuSmEfVNvIpeLePZseTM?= =?Windows-1252?Q?Vl3psEeizT6kFX4cDpR2rckKWpiR+K5YM0WnsSvRGEfB2sFduTjReQ1f?= =?Windows-1252?Q?vyTMvNRu1TEA84gcL0FFo+fzSYLbfNw42r7pN9YplSkebKl2fswUvbnY?= =?Windows-1252?Q?yJ8N3+VuZ/v81KnBQqDygniadWleevIgcYcgS8lKLUQ3xc0jtP8nnqa4?= =?Windows-1252?Q?NIJhp2ERxcJoudk9L6e80ZMx/gvLS5RGDH72JDBvAfl3J+kzZ+Mjz2fN?= =?Windows-1252?Q?ATFkkg=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR02MB1140;5:f+2pg9UgyrrJ+B6nuJwhInJaVKyUUIT53z2LNKQ6uzGeaeonr8d/2lwEMmDrJnGe8W7VDkk8ZOxzc7IlzzXOBz428glRTGiUKvaJHlllPY/0s4dZOFhLqNR5HVfZEXEDuVAJmErwV1Hp9j5FDWZ7pQ==;24:sGE/wmjLt21OEtHVeml3CqlJpQFqi1OqmB+xVIZrKn5IDc0sEELh4p3wc9OQFI5C82s/SafSu728Au4cAUR1rSuJRISp8Qlihkwjv3XYvOw=;20:166wYwOJKGl9lgWvM94l+QoORgZr3Xvzk9prJU7UHV5T+zhMXaoxiNaSoRsa4AhE6WwMBfVGVgGpGQ83HVkm6g== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2015 16:41:42.5074 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96;Ip=[165.204.84.222];Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1140 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5536 Lines: 159 Hi, Ping. Does anyone have any comments or suggestions? Thanks, Suravee On 8/13/15 16:58, Suravee Suthikulpanit wrote: > This patch refactors of_pci_dma_configure() into a more generic > pci_dma_configure(), which can be reused by non-OF code. > Then, it adds support for setting up PCI device DMA coherency from > ACPI _CCA object that should normally be specified in the DSDT node > of its PCI host bridge.. > > Signed-off-by: Suravee Suthikulpanit > CC: Bjorn Helgaas > CC: Catalin Marinas > CC: Will Deacon > CC: Rafael J. Wysocki > CC: Rob Herring > CC: Murali Karicheri > --- > Note: According to the ACPI spec, the _CCA attribute is required > for ARM64. Therefore, this patch is a pre-req for ACPI PCI > support for ARM64 which is currently in development. > > Also, this should not affect other architectures since > if CCA is not required, the default value is coherent. > Please see include/acpi/acpi_bus.h: acpi_check_dma() and > drivers/acpi/scan.c: acpi_init_coherency() for more information > > drivers/of/of_pci.c | 20 -------------------- > drivers/pci/probe.c | 35 +++++++++++++++++++++++++++++++++-- > include/linux/of_pci.h | 3 --- > 3 files changed, 33 insertions(+), 25 deletions(-) > > diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c > index 5751dc5..b66ee4e 100644 > --- a/drivers/of/of_pci.c > +++ b/drivers/of/of_pci.c > @@ -117,26 +117,6 @@ int of_get_pci_domain_nr(struct device_node *node) > } > EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); > > -/** > - * of_pci_dma_configure - Setup DMA configuration > - * @dev: ptr to pci_dev struct of the PCI device > - * > - * Function to update PCI devices's DMA configuration using the same > - * info from the OF node of host bridge's parent (if any). > - */ > -void of_pci_dma_configure(struct pci_dev *pci_dev) > -{ > - struct device *dev = &pci_dev->dev; > - struct device *bridge = pci_get_host_bridge_device(pci_dev); > - > - if (!bridge->parent) > - return; > - > - of_dma_configure(dev, bridge->parent->of_node); > - pci_put_host_bridge_device(bridge); > -} > -EXPORT_SYMBOL_GPL(of_pci_dma_configure); > - > #if defined(CONFIG_OF_ADDRESS) > /** > * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index cefd636..e2fcd3b 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -6,12 +6,14 @@ > #include > #include > #include > -#include > +#include > #include > #include > #include > #include > #include > +#include > +#include > #include > #include "pci.h" > > @@ -1544,6 +1546,35 @@ static void pci_init_capabilities(struct pci_dev *dev) > pci_enable_acs(dev); > } > > +/** > + * pci_dma_configure - Setup DMA configuration > + * @pci_dev: ptr to pci_dev struct of the PCI device > + * > + * Function to update PCI devices's DMA configuration using the same > + * info from the OF node or ACPI node of host bridge's parent (if any). > + */ > +static void pci_dma_configure(struct pci_dev *pci_dev) > +{ > + struct device *dev = &pci_dev->dev; > + struct device *bridge = pci_get_host_bridge_device(pci_dev); > + struct acpi_device *adev; > + bool coherent; > + > + if (has_acpi_companion(bridge)) { > + adev = to_acpi_node(bridge->fwnode); > + if (acpi_check_dma(adev, &coherent)) > + arch_setup_dma_ops(dev, 0, 0, NULL, coherent); > + } else { > + struct device *host = bridge->parent; > + if (!host) > + return; > + > + of_dma_configure(dev, host->of_node); > + } > + > + pci_put_host_bridge_device(bridge); > +} > + > void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) > { > int ret; > @@ -1557,7 +1588,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) > dev->dev.dma_mask = &dev->dma_mask; > dev->dev.dma_parms = &dev->dma_parms; > dev->dev.coherent_dma_mask = 0xffffffffull; > - of_pci_dma_configure(dev); > + pci_dma_configure(dev); > > pci_set_dma_max_seg_size(dev, 65536); > pci_set_dma_seg_boundary(dev, 0xffffffff); > diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h > index 29fd3fe..ce0e5ab 100644 > --- a/include/linux/of_pci.h > +++ b/include/linux/of_pci.h > @@ -16,7 +16,6 @@ int of_pci_get_devfn(struct device_node *np); > int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); > int of_pci_parse_bus_range(struct device_node *node, struct resource *res); > int of_get_pci_domain_nr(struct device_node *node); > -void of_pci_dma_configure(struct pci_dev *pci_dev); > #else > static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) > { > @@ -51,8 +50,6 @@ of_get_pci_domain_nr(struct device_node *node) > { > return -1; > } > - > -static inline void of_pci_dma_configure(struct pci_dev *pci_dev) { } > #endif > > #if defined(CONFIG_OF_ADDRESS) > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/