From patchwork Tue Aug 25 17:33:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7072401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5F071C05AE for ; Tue, 25 Aug 2015 17:37:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35ECB20888 for ; Tue, 25 Aug 2015 17:37:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2776C20881 for ; Tue, 25 Aug 2015 17:37:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUI76-0002DL-98; Tue, 25 Aug 2015 17:34:24 +0000 Received: from mail-bl2on0139.outbound.protection.outlook.com ([65.55.169.139] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUI72-00027j-SF for linux-arm-kernel@lists.infradead.org; Tue, 25 Aug 2015 17:34:22 +0000 Received: from BLUPR02CA056.namprd02.prod.outlook.com (10.160.23.174) by BN3PR02MB1141.namprd02.prod.outlook.com (10.162.168.147) with Microsoft SMTP Server (TLS) id 15.1.243.23; Tue, 25 Aug 2015 17:33:58 +0000 Received: from BN1BFFO11FD037.protection.gbl (2a01:111:f400:7c10::1:142) by BLUPR02CA056.outlook.office365.com (2a01:111:e400:8ad::46) with Microsoft SMTP Server (TLS) id 15.1.256.15 via Frontend Transport; Tue, 25 Aug 2015 17:33:58 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=amd.com; arm.com; dkim=none (message not signed) header.d=none; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by BN1BFFO11FD037.mail.protection.outlook.com (10.58.144.100) with Microsoft SMTP Server id 15.1.249.14 via Frontend Transport; Tue, 25 Aug 2015 17:33:58 +0000 X-WSS-ID: 0NTNFGJ-07-23O-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 24322CAE7B9; Tue, 25 Aug 2015 13:33:55 -0400 (EDT) Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 25 Aug 2015 12:34:02 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.195.1; Tue, 25 Aug 2015 13:33:51 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma Date: Wed, 26 Aug 2015 00:33:27 +0700 Message-ID: <1440524009-5359-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1440524009-5359-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1440524009-5359-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD037; 1:Cl7t2DKoH7FpmwLlE1T1bfROtBzPEjvCzHhQ3UXQCsK+GaNczy3kAWJkdqelHE8INetahWFcUWo0fr6t+0/7J2K9fOi3eYc2usphKCj9eMoEQMHKZqwD2VqiiPEJwjSuFyYOgxIRbPsv3Wn2TG/TKouNjGDorzRRLZyUDRIy2vVPQnvr53PXssSh329Xpudbbmzk23B4x03kdhADFjjrIlrFUHD3p0+wsnNBhGKaj1yamlOXciJbG43FqqxcbW3fWXgIEbdDGWOQBCiNeowp6A2mp+JlJzFcs18WKnNXOWUV35VaEoE1egsqdK9Gv5DyjtqilDfmyM5l7fSC4a6ZsKOkqm1mx0u0dI3y0zmYFz0dREGU3tvWZca0C3lX1D3L X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(428002)(3050300001)(199003)(189002)(105586002)(101416001)(2201001)(36756003)(106466001)(68736005)(92566002)(2950100001)(5003600100002)(229853001)(5001860100001)(50466002)(575784001)(77096005)(77156002)(64706001)(62966003)(86362001)(97736004)(189998001)(5001830100001)(53416004)(5001770100001)(47776003)(4001540100001)(19580395003)(5003940100001)(5007970100001)(46102003)(87936001)(50226001)(19580405001)(48376002)(76176999)(50986999); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR02MB1141; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR02MB1141; 2:RSCcMrc+uaLjHAtr49ISRbdSnVGMreQjlanKlol5z1ByfFlPzvqPvDCK8AwomZTXBzIJ8OHeFFVFw0BO3z60XzAm2N0TTU4HsWef0b4MSg69md5LSsBbigo3N2Ak5lRBkKEtE5QSK24XociPOBOKpGw1G4hR53JEsin3BJE67Bw=; 3:UG8L0HzMqJxdEnq7wclhqHjOIB0TAHNDWtUGx3qiM6qgHQgjeoDsE24oHiqW5Q5Kqqvp3AQrs9/IVDSBSpUpPyV9OMvWomTdB3Bj/5HXvyuKkXXl4AhEgTxf6IG5PxTLl9GM050lUXdrR5OZJeRpjera0UvC2RhevVVMVx2B+/SEWtzsGCFgOtpvF7XTMwp0xh2Jz8EpTfHaJIXa5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lBEE7axz74yAMPUPMUfyQIOyp0Rntig1w4jWr1KIrIPzS+27DMKBJne88ZmNw85v0gWOSjCNWZA0hIELqKHlYFPVKVm+bM/ehO7Sz2uaTpxPsVSCSKHmD4RKU02bVXs4+pGvm8PtIm4dIuZ1lkPN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:BN3PR02MB1141; BCL:0; PCL:0; RULEID:; SRVR:BN3PR02MB1141; X-Forefront-PRVS: 06793E740F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR02MB1141; 23:EZ48WGEE8kToTlm3dByA7sFEtpUCRqXOA3aHYSyb+?= =?us-ascii?Q?lUfP/X4S4JRigW4PAZ1d9GelIWhDZjA/lSuCRZ66kgIvLzV+O7kZU9oVfSWO?= =?us-ascii?Q?hvMwHA74Pq/hXN3MiFEKX6qh1gGlz4USOL9hApRaz0CNw4+cykcAW1R7T3Py?= =?us-ascii?Q?IS+3QSTigIpwlF5kowEnDAuZ66VydWHwl7+EjRaGW9SaST2z7gKgemplOBfW?= =?us-ascii?Q?Gxr0Ausp4RQlJNm29eYFHWZStW+Jod42DjiEnSWjFgoyiY/I9NHo+RMNrGb9?= =?us-ascii?Q?kRjeL6sCBem6QChVnG6HAtPnu1mB407JeL/TB4knw7Cjt+Nqebx7XNWRm4iE?= =?us-ascii?Q?5HIwRKWqcFLbf5swroGGoR7jfVRnA10ZmC7+WVvLb1/z8IsD/I5bLfwlNZxh?= =?us-ascii?Q?Bg34VEaa5sax46XT0QLJqK+fGfi0nZrvEgQJP8Zju8dlGBHY4cwT6ETBe2JA?= =?us-ascii?Q?wbYaJa1UTjLB+yjE2DLq6PllSR4EFZ9S0+k0D1I/oWKRYjeNGVgMAB7of7/8?= =?us-ascii?Q?Tz7mU+K06qy7yFgGN5nWn4CQeluhMGZEJMi3upD/jHgMjWd6yOn4gMQsU7IL?= =?us-ascii?Q?33Iuv+Jm5J/lNPQnCDYjlF0YcWEi9kEkjimURPJQBIsR4mJUmKYaT/G/g3CU?= =?us-ascii?Q?A00tMARhjnBSeHgEmpFZl1zAnyNNuoZunpPek3ImPRW9Ii1OwMpwdMh52wh6?= =?us-ascii?Q?gzKY+03GEVbLMtYyXMjFLfKmIkbnK845EfepYavrBK/FklHb0u7gb9fTbtPT?= =?us-ascii?Q?ko3HjR/tba8oidV3ajmueUTOGYJNw19uSJrN1v+5TrtxIRkIeN6XDnOLRA7y?= =?us-ascii?Q?VbtRk52wT7/eATkWtr6bmxW12tZjTZfdXnHcu8jlSCHKyvkWrL0tMtINUBM0?= =?us-ascii?Q?ejcHucwGf5pOxXcFy0wIJqoYDkZ7UTdcMjMkutcFTCnDy0KkezdqMFD7svdN?= =?us-ascii?Q?rUuzH2wKvUtGGZxSLKzIAR+BtXQY4OmRvFPTVvGP0aAUs2ldPW18dZIEF83x?= =?us-ascii?Q?CsZ+RTPzVvrlQSswaEc/ZLQ5TmQIcWN3WnBssRdgpV+PgWFs+NOPrrvQnTAz?= =?us-ascii?Q?vNy7wd3Az8wzeDFbgKs0V8QQXBInxd94easdpPbiEwVdQ+fk6voeXsphF63Z?= =?us-ascii?Q?ZM0KkNm27hNHoptdcar0yKtuiVp9Nqq?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR02MB1141; 5:YgtU3yMqNyiHvlXe509eEnY/tT5KwJNK8telA250FD2JZgZQ9637uBkgur9yg47GFS+y9hvZXOBHCQvsc/jWmnUcg3CWPr0hMg7SVkyUq4u3tYZjF+pG/TdbtT1P2a6/52gCbiFabhDZWixgjLXfjA==; 24:bjQd/VmYKo0qQ1sjXe158VcdRI+0Madl66l97OoiodjPyaMYIqCJMS9sr68vHvnXwEYbap10mHEMyzpxy7CZzkBjcyWgLI5W1TyXu7EpPmg=; 20:JaxV8PbzGwrQaGNS+MM8d318H5qoE6cGQqX3W/hXAmsZTdFWTeS1Iae6U7jwldQ4tDGaFx3++rM11OAreXDhGw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Aug 2015 17:33:58.6171 (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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR02MB1141 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150825_103421_137519_47A727D4 X-CRM114-Status: GOOD ( 22.27 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Rob Herring , hanjun.guo@linaro.org, Suravee Suthikulpanit , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The original name of acpi_check_dma() function does not clearly tell what exactly it is checking. Also, returning two boolean values (one to indicate device is DMA capability, and the other to inidicate device coherency attribute) can be confusing. So, in order to simplify the function, this patch renames acpi_check_dma() to acpi_check_dma_coherency() to clearly indicate the purpose of this function, and only returns an integer where -1 means DMA not supported, 1 means coherent DMA, and 0 means non-coherent DMA. Also, this patch moves the function into drivers/acpi/scan.c since it is easier to follow the logic in the acpi_init_coherency() in the same file here. Signed-off-by: Suravee Suthikulpanit CC: Bjorn Helgaas CC: Catalin Marinas CC: Rob Herring CC: Will Deacon CC: Rafael J. Wysocki --- drivers/acpi/acpi_platform.c | 7 ++++++- drivers/acpi/glue.c | 5 +++-- drivers/acpi/scan.c | 39 +++++++++++++++++++++++++++++++++++++++ drivers/base/property.c | 8 ++++++-- include/acpi/acpi_bus.h | 36 ++---------------------------------- include/linux/acpi.h | 4 ++-- 6 files changed, 58 insertions(+), 41 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 06a67d5..2261e85 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -103,7 +103,12 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) pdevinfo.res = resources; pdevinfo.num_res = count; pdevinfo.fwnode = acpi_fwnode_handle(adev); - pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0; + + if (-1 != acpi_check_dma_coherency(adev)) + pdevinfo.dma_mask = DMA_BIT_MASK(32); + else + pdevinfo.dma_mask = 0; + pdev = platform_device_register_full(&pdevinfo); if (IS_ERR(pdev)) dev_err(&adev->dev, "platform device creation failed: %ld\n", diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index b9657af..55cf916 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) struct list_head *physnode_list; unsigned int node_id; int retval = -EINVAL; - bool coherent; + int coherent; if (has_acpi_companion(dev)) { if (acpi_dev) { @@ -225,7 +225,8 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev) if (!has_acpi_companion(dev)) ACPI_COMPANION_SET(dev, acpi_dev); - if (acpi_check_dma(acpi_dev, &coherent)) + coherent = acpi_check_dma_coherency(acpi_dev); + if (coherent != -1) arch_setup_dma_ops(dev, 0, 0, NULL, coherent); acpi_physnode_link_name(physical_node_name, node_id); diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ec25635..299a825 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -2182,6 +2182,45 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) kfree(pnp->unique_id); } +/** + * acpi_check_dma_coherency - Check DMA coherency for the specified device. + * @adev: The pointer to acpi device to check coherency attribute + * + * Return -1 if DMA is not supported. Otherwise, return 1 if the + * device support coherent DMA, or 0 for non-coherent DMA. + */ +int acpi_check_dma_coherency(struct acpi_device *adev) +{ + int ret = -1; + + if (!adev) + return ret; + + /** + * Currently, we only support _CCA=1 (i.e. coherent_dma=1) + * This should be equivalent to specifying dma-coherent for + * a device in OF. + * + * For the case when _CCA=0 (i.e. coherent_dma=0 && cca_seen=1), + * we have two choices: + * 1. Do not support and disable DMA. + * 2. Support but rely on arch-specific cache maintenance for + * non-coherenje DMA operations. + * Currently, we implement case 2 above. + * + * For the case when _CCA is missing (i.e. cca_seen=0) and + * platform specifies ACPI_CCA_REQUIRED, we do not support DMA, + * and fallback to arch-specific default handling. + * + * See acpi_init_coherency() for more info. + */ + if (!adev->flags.cca_seen && IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED)) + return ret; + + return adev->flags.coherent_dma; +} +EXPORT_SYMBOL_GPL(acpi_check_dma_coherency); + static void acpi_init_coherency(struct acpi_device *adev) { unsigned long long cca = 0; diff --git a/drivers/base/property.c b/drivers/base/property.c index f3f6d16..643b0fb 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -527,8 +527,12 @@ bool device_dma_is_coherent(struct device *dev) if (IS_ENABLED(CONFIG_OF) && dev->of_node) coherent = of_dma_is_coherent(dev->of_node); - else - acpi_check_dma(ACPI_COMPANION(dev), &coherent); + else { + int ac = acpi_check_dma_coherency(ACPI_COMPANION(dev)); + + if (ac != -1) + coherent = ac; + } return coherent; } diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 7ecb8e4..baf43ea 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -382,40 +382,6 @@ struct acpi_device { void (*remove)(struct acpi_device *); }; -static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) -{ - bool ret = false; - - if (!adev) - return ret; - - /** - * Currently, we only support _CCA=1 (i.e. coherent_dma=1) - * This should be equivalent to specifyig dma-coherent for - * a device in OF. - * - * For the case when _CCA=0 (i.e. coherent_dma=0 && cca_seen=1), - * There are two cases: - * case 1. Do not support and disable DMA. - * case 2. Support but rely on arch-specific cache maintenance for - * non-coherence DMA operations. - * Currently, we implement case 2 above. - * - * For the case when _CCA is missing (i.e. cca_seen=0) and - * platform specifies ACPI_CCA_REQUIRED, we do not support DMA, - * and fallback to arch-specific default handling. - * - * See acpi_init_coherency() for more info. - */ - if (adev->flags.coherent_dma || - (adev->flags.cca_seen && IS_ENABLED(CONFIG_ARM64))) { - ret = true; - if (coherent) - *coherent = adev->flags.coherent_dma; - } - return ret; -} - static inline bool is_acpi_node(struct fwnode_handle *fwnode) { return fwnode && fwnode->type == FWNODE_ACPI; @@ -640,6 +606,8 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev) return adev->power.states[ACPI_STATE_D3_COLD].flags.valid; } +int acpi_check_dma_coherency(struct acpi_device *adev); + #else /* CONFIG_ACPI */ static inline int register_acpi_bus_type(void *bus) { return 0; } diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d2445fa..530d2fa 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -562,9 +562,9 @@ static inline int acpi_device_modalias(struct device *dev, return -ENODEV; } -static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) +static inline int acpi_check_dma_coherency(struct acpi_device *adev) { - return false; + return -1; } #define ACPI_PTR(_ptr) (NULL)