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: "Suthikulpanit, Suravee" X-Patchwork-Id: 55724 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp212867lbr; Wed, 28 Oct 2015 15:51:29 -0700 (PDT) X-Received: by 10.107.133.33 with SMTP id h33mr36921097iod.1.1446072688980; Wed, 28 Oct 2015 15:51:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k4si23615299igu.50.2015.10.28.15.51.28; Wed, 28 Oct 2015 15:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932582AbbJ1Wv0 (ORCPT + 28 others); Wed, 28 Oct 2015 18:51:26 -0400 Received: from mail-bn1on0094.outbound.protection.outlook.com ([157.56.110.94]:51808 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754680AbbJ1WvU (ORCPT ); Wed, 28 Oct 2015 18:51:20 -0400 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: , , , , CC: , , , , , , , , Suravee Suthikulpanit 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; BCL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M3PR12MB0860; 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 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/ 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 */