From patchwork Wed Oct 28 22:50:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7514981 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 18DCDBEEA4 for ; Wed, 28 Oct 2015 22:53:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 288D320957 for ; Wed, 28 Oct 2015 22:53:28 +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 3275C20734 for ; Wed, 28 Oct 2015 22:53:27 +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 1ZrZZC-0004Z2-Nf; Wed, 28 Oct 2015 22:51:38 +0000 Received: from mail-bn1bn0100.outbound.protection.outlook.com ([157.56.110.100] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrZZ8-0004UR-Rj for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2015 22:51:35 +0000 Received: from BY2PR12CA0017.namprd12.prod.outlook.com (10.160.121.27) by DM3PR12MB0860.namprd12.prod.outlook.com (10.164.7.142) with Microsoft SMTP Server (TLS) id 15.1.306.13; Wed, 28 Oct 2015 22:51:17 +0000 Received: from BY2NAM03FT011.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e4a::201) by BY2PR12CA0017.outlook.office365.com (2a01:111:e400:2c84::27) with Microsoft SMTP Server (TLS) id 15.1.306.13 via Frontend Transport; Wed, 28 Oct 2015 22:51:17 +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 BY2NAM03FT011.mail.protection.outlook.com (10.152.84.233) with Microsoft SMTP Server id 15.1.318.9 via Frontend Transport; Wed, 28 Oct 2015 22:51:16 +0000 X-WSS-ID: 0NWYCTF-07-6DF-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 2F85BCAE635; Wed, 28 Oct 2015 18:51:14 -0400 (EDT) Received: from SATLEXDAG03.amd.com (10.181.40.7) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 28 Oct 2015 17:51:28 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag03.amd.com (10.181.40.7) with Microsoft SMTP Server id 14.3.266.1; Wed, 28 Oct 2015 18:51:14 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [PATCH V5 3/9] ACPI: Adding DMA Attribute APIs for ACPI Device Date: Wed, 28 Oct 2015 15:50:48 -0700 Message-ID: <1446072654-5608-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446072654-5608-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1446072654-5608-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)(86362001)(47776003)(229853001)(19580395003)(5001770100001)(5003940100001)(2950100001)(5008740100001)(2201001)(106466001)(77096005)(101416001)(19580405001)(105586002)(189998001)(76176999)(36756003)(92566002)(5007970100001)(87936001)(48376002)(50466002)(50226001)(53416004)(50986999)(11100500001)(97736004)(5003600100002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR12MB0860; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0860; 2:3mLa04hoZo+Bf66AaMJnF/zXOzc588xzl14f00bfalqpYaMj5qUoIE9mfXo40/cfR8FfezKparNPj9gtFkHuOQPmK+gma1oUjSLXK/6RqokWJWGwNi98C48/9B01832NlRHMWBgzoLLVwJPC9e250JfjSPXEe7K8AUPI7wND08k=; 3:9tQ2GMD4WgHe8HayclqCoRAsbhst8OctJCl1oIoiSpqUlCpm0rQF61BC7WQwv0BrsWz+Hc2nL9Yz20rQNm8tqBit9ut2DJQ7+feDvhQEVH8gYDIl7+QqkOJFMuFEqqBb8MjNiTzgTqR6kLKNRDFLdv9UVEDIp26Dbya9fhEUJpB9QL4TpqyjA9gasFqOK7OnMBvxkrQ/YzO+tGi4MTyFltQKT1BJMfEEJBGu2cxvcQOVWEoKIJyou9f7t9P2K4cc; 25:PDgQYwBLYmCoRv9ybKdSECWYgDqi89jNGsd+IFfur9GxMT1v5fLgFZwoV0O4KxsNLP3pUEDw+8txw3Yz47eZWlimGt0Lpb7J6EDHFjRWaJop9R1SdKb1YYbNJ/i6R5USgAC4i+32yaGaXrBU6wbdgWN4AM/lmlk7zcvnFrF2yG6IKfiZI7qRoe3/N1g02V5mNI0FJSkvTh/3ZTKlIRwwIF5nryPhxWO6igVWperTPkjP4mxG0RdkELWhXJDztKhvmBvamokso3MNTvcwt/GoVw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM3PR12MB0860; X-Microsoft-Exchange-Diagnostics: 1; DM3PR12MB0860; 20:p+hPG7nEhOlkrd5lh5rCJygPzP4X2j3QYP2K2ilyaBfWTOiQ7eAxtykIxN9WoU0jIcmNutUA/4bskcJIOra2crL79Xq5aLDuMI846tw1KSWvSbstQEODTyU9Qy/+aIhjoyskQy0DiCcEtdn2FnKpsZNwWJSX4CtXUMMGnjPdqlHQ988nonNVsFJmxO3Liejq2O3a8BZsLdY7nuTP8ZXj+YUEvnlqFoS059+fEgnnFTbcqZKJo9T5NcMpvmH0QmB/HaoogRX8hEQIiL738JQ8MlvjhBmcCHYpKndUJj4QXHneIre+a0EQY/Io6eBF/khvJz0sAVaBXKAa48XHg5HLyyoSUYnAeZ12kL9ZGl5pSIniDdxBTT/aRa2tzsBetML2ANT8gTbjM2fUwlvJfXZrTJWN17gS3qmqEETNXGEG3ykwnSGmwWWZ/WTrP4FBjBGXGn2vNTpSLk2Fv0VtcTzS0//sx5P8Y/vbLZ5i2mJNzFcAnygLf+ySSf9zcJrHWxv6; 4:7CPtZthWPlJmbymtDf5VabL2k+IBNhe+oy1ZTogUAjMGaONih5o+sSPNvZoIrnLHxlmlwrukyIMdH4dpceVXRgplVcVt5Roi6hXzIMtwPY5Z398/yA5TMMDb2oyCTl9+WYQxAShsbiioAd4k8qRacnJ5CWYfvyfWu1o1iTyOlonqrN9TcwdzeeKXHUwRPHJ747WZHQr+AMzXdd9YAK4/Wwh/6MU1ENDTpV2tiEhVwltBt+nGqDh1JAbDPUVZiqKq8+QrkyPhKhyDkQbMNDB1rIJzP6ywthMkhBWh6WUPgP4Jcv7K/NUkbFtHGtlHocGX/9n49LUXr8ue1R5GTY8Ohv3Wh3tXebhEFic3Vl+DNxsV4SZfQAJ/iG1CPtNeNkTS1mh8kuQK7+I/A2UgxWg8OA== 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)(10201501046)(102215026); SRVR:DM3PR12MB0860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 1; DM3PR12MB0860; 5:Z5VBHprcu0QbTLnQ0RYgnq4nHizmPAvFJHMs/Y6yQkz4huGbDPx1O4Aa5koAGdU9tovEGi1EsRAhAIJ8icr9HVWYnirmCg6Q/LLvrPYKVfrHs9X0RBUDx4u2k4uwv5abvKbv0cvWGgyiG2+DHE2U2Q==; 24:I5dBOUgaflS/iLgAI5r2GWJs/1gOIwiV9zV+g3TiYkzCllSzORoH5klnG45PBGqKobl8botyTVp9xUtnzR2A9pq1wiobXxPHDYELS9x1j5M=; 20:WO3FkKXVRYXaHAKQv+w1Fbeq/+G8x+oES4A36kDTVwksjjhPnDBE8j/guMDt0EhNtJAWRA4YgNwFZbyXLQdPpa+btNUTmLfhcgdTZZYQxrs+JIEwbK4bdJS0R2PeAtCILgOBJ5hKObSqO+u9G2JrZ2yTGf14lHoqC72oyAc9JyrsWxfrcEE81zfP7cOykMX0PFk2QlgI4BRrdSuQmuDelC0xcDN2BIpRRJRMhq2MxegA6JqYfLkm+uTj2MZ5M3RC SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2015 22:51:16.4516 (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: DM3PR12MB0860 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151028_155135_173198_B18FC3D3 X-CRM114-Status: GOOD ( 14.03 ) 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: thomas.lendacky@amd.com, herbert@gondor.apana.org.au, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, hanjun.guo@linaro.org, Suravee Suthikulpanit , davem@davemloft.net, 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=-4.2 required=5.0 tests=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 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 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 daf9fc8..78d5f02 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1308,6 +1308,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 0f131d2..920b774 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -596,6 +596,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 82f56bb..6527920 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -598,6 +598,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 */