Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249AbbHMKNM (ORCPT ); Thu, 13 Aug 2015 06:13:12 -0400 Received: from mail-bl2on0102.outbound.protection.outlook.com ([65.55.169.102]:43008 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751452AbbHMKNJ (ORCPT ); Thu, 13 Aug 2015 06:13:09 -0400 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: 0NT0ME7-08-GO2-02 X-M-MSG: From: Suravee Suthikulpanit To: , , , , CC: , , , , , Suravee Suthikulpanit , Rob Herring , "Murali Karicheri" Subject: [PATCH] pci: acpi: Generic function for setting up PCI device DMA coherency Date: Thu, 13 Aug 2015 16:58:45 +0700 Message-ID: <1439459925-2361-1-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD041;1:JKypmIXwmzxs3qnmb0S6hz1EVoSfzqWICNJeuVS+d9MhqCsGjLz/ZPOhlqjq3IzrRhqYlMM35slJxyanz+5oskUHIQ205JQ8AHfqKCnLvsT+Rp4Xch5Q61wo0J3KAwtfH4E1L6KNwdiaau7WKANrI0aluXT4F0ThKCI6xlHcMglf9lQh2ogZI9B+2yb1OS5XI7q+HKaMRN4gFOwz3u1Rn9GxaoozuUpnUHI1kd39CFfJVlXU+0bnKfhRw1lRtOlk0r33TfyVMrWnOy2bZledCivK/dKU7Lv60fEPbvNQw6v/JpkYs1oHxWoNvs6pCO/ImUC/HeREugw51PGanqryqoVl2SM+bx2ETVhmfXRV60e7uU+w4SzaQ3m4OV2LwFl/ 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)(5001830100001)(575784001)(5003940100001)(2201001)(5001860100001)(86362001)(92566002)(4001540100001)(97736004)(87936001)(50986999)(50466002)(62966003)(77156002)(19580395003)(189998001)(5001770100001)(48376002)(47776003)(77096005)(105586002)(106466001)(68736005)(46102003)(5003600100002)(53416004)(36756003)(50226001)(229853001)(19580405001)(101416001)(64706001)(41533002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR02MB1148;H:atltwp02.amd.com;FPR:;SPF:None;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY1PR02MB1148;2:zUjt7uwVUOUZ3X39jBDRp+hgn8NFM5OJFLRnJ/0VNpKIoJBqS6EHRze/3zrDni7uq3qcchBLV5gvMjyDEK8ThRRDsSW07wn8dJbniJsxBfa1vT2LT9jN/QvF9gQomEtNMtzhC9RKdFyRBpKbKsCiwKwcfz/1gte9cd+u4J56hBo=;3:zrkl5Djsk/l5XtAj6D7oxSXNyYvXrKGPzPbJsqagdRje0HAg48+HplV+4OSViqkoOtndMc0vScRK/NG4a0S7V8ph+WL5I77A6slUN1KBRsCVXXPsw/lnkIvq3gYYltnlaYQ0s3abvT378OSH+kkLLystn77XMFr6do7JFPIoU+ETbTNAztFN6XUAMF584zs2qIHskRSeFL1gyVSN/ego9hlw1TW9nnTEjDg5zcHi/8HAzz8mbF7cngIgiCGijwY7;25:wmnrzeitMvKwzEI+u9sMB0OOEYk36O6OsB4TkQON0tdFPzJVYXaDxpsPDPPYOzaAATxAq4p8542iaojsurgNq4+HE6mCwCv4mx9lWt1BUZupa4bLJ8MrZxxNdGY6Xb5TkTiQTdXf8tnqxPLOoU3xchoY7BipdWkLOfNfeS9AWq2U3eBwvNxe1149DP2aCGZiUvuWUHFxLkb4NT/NNAdUIAQFfqdAwZf1VbhIvx38lxMC5t2zHcCQbYrixkCSkQMHFvjwyDt0cEhrphUYRpwYOg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR02MB1148; X-Microsoft-Exchange-Diagnostics: 1;BY1PR02MB1148;20:g0n4SvocIn2I30L98M/7GBQwcrIqxUgcRnIiIMdCcTOfhs+mzarfbaeCBpEeqT+paKrbO4aUap3WpFCa63k1LDTxqqZh4RjFl2Mt2Kn3tskqelf+itGL4lI+Oo7lryIOB3gwVcvqG2c/v1sG+gCsHhs97eNn9im1SsWCbmgqO4hNAr4ZkdJkkopQHIj6H7L75v0qu0bWzxqwseu++1a6SrKCFbD/cQZU5aidgI94HbO6gVFmtAj+ES1rZn7Zs+YpNXPKfOfj1Io80RkVDHH2yYXyq3NAmJ8DuLbY1YRGTfDVZNRVAbO3E2SPokjkIQhyE+HS42FPK/Nt4sPG700Sz9Ie6rmEeHGUR1J0acAYOteUMt5lcaXz2rJquMQa5z/Ksk45vvWE4ElL8TU1c/+qCgcymDlH4TMbe666GziGfezxWm1W87k/kmbhK0lIAu3ayT1XL8eP9u3/wPq45/ISZ18XoHwmr+2HJZMDU7kMvbXVDrbYGN3hDM20U5c+B859;4:fzZ1A5frXGORlAQQIRJXGM9d4ZbJVN/wp3WFdkxqH4it+a+QwJseP4/dezkQ4HxKeFcBIFAH6qtQHprYson49ha03IigpxIphZp2/MaU+x41SVXy7+kHS1TtKsIhMVZoBD35Y/oYFTFUGg1Ny+eDvITWIaWNHpAXVpSMWxiZ/7Pa7OgnmdgrROeWCsVFvFpEwsl7CHBKLLs+/lo4InN/3nqYFZlA3fAFVEqQtl1LxtsyrM0MvvtTkpuzKhpc+g0O89u7eXysOh5zPiOb9EQW4UAPrpF+vszBqmKys/XudIs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY1PR02MB1148;BCL:0;PCL:0;RULEID:;SRVR:BY1PR02MB1148; X-Forefront-PRVS: 0667289FF8 X-Microsoft-Exchange-Diagnostics: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E3QWF/M92trta?= =?us-ascii?Q?fMSW6R7yE/fRpvAE0t2tvM9m75hOhLPNp4Bdjwp6CDNqCVGIa9l5nR7BhopF?= =?us-ascii?Q?xFQaWNAZAqx5D1DYs8m/UL9HVA6DELFT+GWOUFWUwUBi5GM7whOhenX13A1U?= =?us-ascii?Q?xep2EjAMmqd/oBr8qCnXxkZZtjmRsOKTNibefj8s7G1yOGzkkSSk352wt5Dp?= =?us-ascii?Q?aRACrE=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR02MB1148;5:VDrH0HV+RCuF8FC/Heu8RYtQxqO+ney6dKe2ptFnrcg6ux/smOGDq7e64oHuWdSv1Avb2QWdCbZO7jZpZd8UKvTXqJQAcet54kmMsbLyRUgRv6jeQWR7MbINKxp+ej4Vi5S/YokKRnVjkBWoRvIrBA==;24:jMYv7wXBxvJDPONQU9Y6P6hIgWZif3u63AEgAga7AXOlutE3TOFYt9gCQGyOqZCfjV5Z5jaE3ZeKql+uYHX238eNANLaGhD1tfnsmhLtcr0=;20:yGBUmEwdQ91eiFMcobt7dxTCillvhmFtB3vQOoGQ5UABDc+kV6w9M5NxPCYRPx2rQ9tSmSj+mCadeJD14OMLsw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2015 09:58:57.6940 (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: BY1PR02MB1148 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5101 Lines: 153 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) -- 2.1.0 -- 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/