From patchwork Wed Oct 21 15:52:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7458211 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C146F9F30B for ; Wed, 21 Oct 2015 16:07:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E3F38208DF for ; Wed, 21 Oct 2015 16:07:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C29582051F for ; Wed, 21 Oct 2015 16:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755791AbbJUQHS (ORCPT ); Wed, 21 Oct 2015 12:07:18 -0400 Received: from mail-bl2on0054.outbound.protection.outlook.com ([65.55.169.54]:8096 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755170AbbJUQHR (ORCPT ); Wed, 21 Oct 2015 12:07:17 -0400 Received: from BY2PR12CA0035.namprd12.prod.outlook.com (10.160.121.45) by DM3PR12MB0858.namprd12.prod.outlook.com (10.164.7.140) with Microsoft SMTP Server (TLS) id 15.1.300.14; Wed, 21 Oct 2015 15:53:03 +0000 Received: from CO1NAM03FT010.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by BY2PR12CA0035.outlook.office365.com (2a01:111:e400:2c84::45) with Microsoft SMTP Server (TLS) id 15.1.300.14 via Frontend Transport; Wed, 21 Oct 2015 15:53:03 +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; arm.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by CO1NAM03FT010.mail.protection.outlook.com (10.152.80.104) with Microsoft SMTP Server id 15.1.306.8 via Frontend Transport; Wed, 21 Oct 2015 15:53:01 +0000 X-WSS-ID: 0NWKUSB-07-H0T-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (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 25DA4CAE655; Wed, 21 Oct 2015 11:52:58 -0400 (EDT) Received: from SATLEXDAG04.amd.com (10.181.40.9) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 21 Oct 2015 10:53:06 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.266.1; Wed, 21 Oct 2015 11:52:58 -0400 From: Suravee Suthikulpanit To: , , , , CC: , , , , , , , , Suravee Suthikulpanit Subject: [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device Date: Wed, 21 Oct 2015 08:52:06 -0700 Message-ID: <1445442731-28819-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1445442731-28819-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1445442731-28819-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(428002)(199003)(189002)(36756003)(19580405001)(86362001)(64706001)(229853001)(5008740100001)(50986999)(5003600100002)(87936001)(76176999)(92566002)(47776003)(2201001)(5001770100001)(5003940100001)(97736004)(189998001)(46102003)(77096005)(11100500001)(19580395003)(106466001)(53416004)(105586002)(101416001)(50466002)(2950100001)(48376002)(5007970100001)(50226001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0858; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0858; 2:qiqKof/ADR9u61d10DtJwPPoc849L4iAVvpmZdWzHf5v6F7IXNsSfTkGdUxdUNW6jE+h87FnTMDDHex/xvKUzyFMkpOEQDHJPpG3fNVQowmynwBkwcBvEjoiTbHEk3SFnRG092e7n7uYM/di9OYJ4XCjxlxQhc351EysKI4R5sU=; 3:NIyqOEDh8xypJd+yJuwBKkrXMawc0wiDYFQ7KafJNBIAhL4y0V+jMiqA92khKTgfHCEzLYNoeAGNyNF0WkZJaFytfPGtjv2+QnDsLHURNQyLEXnubdzDuujsuiSv2czupVmlekcx5x4L58uweTx1cy57gI5UB4d31tYYICC05toNYjaLpO5YFPaWYhCN+EFeMI2RL4nXGPpm+RpjczhIwB7DuyTeHS4eUeCvD7fBzOs2yXZjKRsV4+KD5qSHIMig; 25:XkOnAUh5LYwoWCZhklBwlhBscxombAqZUbpJKln5+j5YCXUq8OYewE5/oDtlFQCHKwh9yHxf1YU0PerbM/b2ESA9xoCkdBD1mnYUtrXnmXh408ddCHVpfmrRzId1Ah0NmzNCFIjjDaXKzm+aXXcd1MvIjEZs1AJdMG5FMCo+RX/W2fjsspFDmgUaCuVC8rupmTMu1CDcv/596g0guFquawyAhH/BmDDg6u6wiKCLjH86IpI7qO7N7at/GiK4DhGv61Sp3wvIDv0JNl4ZHmvkMA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM3PR12MB0858; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0858; 20:ijvcLoPktY4ZiawSltHHxJqhL6IYc6NwX8zqpZckGsTXBR4pbyw+i1IZem+bneijd9h8rEJwEU0sTWG6L7GgF3tUcsWSXgXxBdW6FF+Oxm60HUabzvA+pXeAJEkfAWKUWVS6g5inEIosnKSkZlgBdskMoyJhrgfw0JQYQq+95q6HKSVHHaKOAL+1O7MXzl0f983jmi17z7Bbso1hBM9t8Qc1HRPS5yM0MAhmhn7/M2O2xR1E7I7JgGt8PJvOqSpupNldUAuFZqI8eKTHOPblyg0KMwdxgxKq/alq3ZTTOOGSOMsY2Nh3SG9lrbMFY3xH/QkLWaQmj9Qb0HEsbJf3dDBKKMPqLT1YPj7BRuS/8+PZRdyB9WODkA+jYOJlCUje3kVo9rthCGCGTwpfOVbkQX2egW0UUFMqxV3Wsq7qDuKnolRRc2JbtjdVVDhxUnZE42x+a0a8uk468UK3zmUUxLBIr33CDN6/GES4QQcTE6wiqUApX8PY13+Sr6vwgblS; 4:QEk+NF9fDzTJsvBmnoQ76IL9y7fNFzsZj6XrrM2D2n6AndRlWpP2qcbBZO+ZcyHchrNoNDS+cTYANBFr+iGrsGAou+Q4Ux2BsFPuAD/KRMPwPQr+2ffsYeBRlxdGurHFuW6dsxKS/mAC9ri/7op7UZjgSo3tg8ISTFnVze0WklJA+vBVroBrPsLSE5yJOR3sStUtNPfl/AbqAILCvt6zWXSRnnXFltD819K85Qt2QJseJq5T9hrqSvswjZcInyF8c3wxm8ATE6nwwJiTsOjyIUyYLPTO16N0Rk+sE1o67MebhVm3l6yfb0SwfQkkjKRoEa7Yt37uGrqWYauCXd8kED1arhGboCD1oJpi8HyzO7RLIVNv9QOzQC3R0Yhwu1OE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(102115026); SRVR:DM3PR12MB0858; BCL:0; PCL:0; RULEID:; SRVR:DM3PR12MB0858; X-Forefront-PRVS: 073631BD3D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM3PR12MB0858; 23:IGH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?= =?us-ascii?Q?9PgQ3o3Mq0g9fKxsrnsK508b/UqDsPeNtRyKGVYkyY4tKow0N5lr3o1Mhl45?= =?us-ascii?Q?Q1FUfx9nNHFL0CcsV5iZBd+r0hU9ZOEIi9yWjrZsN7ajwhMLDqaa9RXz/zF9?= =?us-ascii?Q?/Q=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0858; 5:Q2DKxTRhT5W5KXjK25hRrt2z1shDwWXpPOSzfa4GRdkbZWGXAnpHOApxOPnYbKSSndF/gW4nynCEcRxmDwzi0xS6FilKPfotOYoJbS7kDuHiU40kxbABtURBXbY34cN5hH55i+HsP4z+vRrHNIkQ8Q==; 24:yXztJ7zGmFyRwgHx9wrbf5z4lu9WIap9UX1dfB51HVt8R0Y2BTo9mJaj2hnY8pU6upxEU4WpE0pxrEm6iuToxBC2bqfJTz89ui0qTEAYHGE=; 20:0kO44eI929ns+rxnz2n7qQE9edlxBATYl2aKax5nYbgsrdcSqSmRyH0IwzX0tCGjIsF4zFgJcfC+ghP4Vjtl39cPS6Ka5djjSoseZVtLXyDeGbMPa/kr5ZRrBbyLtwT4Y18gb+lx8PXXvqo+OMgiRARdR9f9y0DMAyWjQMlQkFut8bZh2Em+F8FcduyM7YvS4Nq810M8iyjE36i7WYzuSB0W1W3hqqIajALRNzs2CnhqQOlEAz6S8Of7GqopHwWy SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2015 15:53:01.6284 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB0858 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Adding acpi_get_dma_attr() to query DMA attributes of ACPI devices. It returns the enum dev_dma_attr, which communicates DMA information more clearly. This API replaces the acpi_check_dma(), which will be removed in subsequent patch. This patch also provides a convenient function, acpi_dma_supported(), to check DMA support of the specified ACPI device. Signed-off-by: Suravee Suthikulpanit Suggested-by: Bjorn Helgaas CC: Rafael J. Wysocki --- drivers/acpi/scan.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 3 +++ include/linux/acpi.h | 10 ++++++++++ 3 files changed, 55 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 01136b8..3be213e 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1328,6 +1328,48 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) kfree(pnp->unique_id); } +/** + * acpi_dma_supported - Check DMA support for the specified device. + * @adev: The pointer to acpi device + * + * Return false if DMA is not supported. Otherwise, return true + */ +bool acpi_dma_supported(struct acpi_device *adev) +{ + if (!adev) + return false; + + if (adev->flags.cca_seen) + return true; + + /* + * Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent + * DMA on "Intel platforms". Presumably that includes all x86 and + * ia64, and other arches will set CONFIG_ACPI_CCA_REQUIRED=y. + */ + if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED)) + return true; + + return false; +} + +/** + * acpi_get_dma_attr - Check the supported DMA attr for the specified device. + * @adev: The pointer to acpi device + * + * Return enum dev_dma_attr. + */ +enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) +{ + if (!acpi_dma_supported(adev)) + return DEV_DMA_NOT_SUPPORTED; + + if (adev->flags.coherent_dma) + return DEV_DMA_COHERENT; + else + return DEV_DMA_NON_COHERENT; +} + static void acpi_init_coherency(struct acpi_device *adev) { unsigned long long cca = 0; diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 5a42204..13417d0 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -567,6 +567,9 @@ struct acpi_pci_root { /* helper */ +bool acpi_dma_supported(struct acpi_device *adev); +enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev); + struct acpi_device *acpi_find_child_device(struct acpi_device *parent, u64 address, bool check_children); int acpi_is_root_bridge(acpi_handle); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index dd39202..c47892c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -569,6 +569,16 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent) return false; } +static inline bool acpi_dma_supported(struct acpi_device *adev) +{ + return false; +} + +static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev) +{ + return DEV_DMA_NOT_SUPPORTED; +} + #define ACPI_PTR(_ptr) (NULL) #endif /* !CONFIG_ACPI */