From patchwork Wed Oct 21 15:52:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7458071 Return-Path: X-Original-To: patchwork-linux-acpi@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 B617F9F37F for ; Wed, 21 Oct 2015 15:55:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C224D208E4 for ; Wed, 21 Oct 2015 15:55:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EEAE208E2 for ; Wed, 21 Oct 2015 15:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755818AbbJUPzV (ORCPT ); Wed, 21 Oct 2015 11:55:21 -0400 Received: from mail-by2on0072.outbound.protection.outlook.com ([207.46.100.72]:53792 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755155AbbJUPxG (ORCPT ); Wed, 21 Oct 2015 11:53:06 -0400 Received: from BY2PR12CA0006.namprd12.prod.outlook.com (10.160.121.16) by BN4PR12MB0850.namprd12.prod.outlook.com (10.164.59.12) with Microsoft SMTP Server (TLS) id 15.1.306.13; Wed, 21 Oct 2015 15:53:03 +0000 Received: from CO1NAM03FT008.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::200) by BY2PR12CA0006.outlook.office365.com (2a01:111:e400:2c84::16) with Microsoft SMTP Server (TLS) id 15.1.306.13 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 CO1NAM03FT008.mail.protection.outlook.com (10.152.80.81) with Microsoft SMTP Server id 15.1.306.8 via Frontend Transport; Wed, 21 Oct 2015 15:53:01 +0000 X-WSS-ID: 0NWKUSC-07-H0U-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 264D2CAE648; Wed, 21 Oct 2015 11:53:00 -0400 (EDT) Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 21 Oct 2015 10:53:09 -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:59 -0400 From: Suravee Suthikulpanit To: , , , , CC: , , , , , , , , Suravee Suthikulpanit Subject: [PATCH V4 4/8] device property: Adding DMA Attribute APIs for Generic Devices Date: Wed, 21 Oct 2015 08:52:07 -0700 Message-ID: <1445442731-28819-5-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)(189002)(199003)(5008740100001)(19580405001)(47776003)(19580395003)(46102003)(64706001)(5003600100002)(87936001)(5003940100001)(50226001)(11100500001)(97736004)(92566002)(5001920100001)(36756003)(229853001)(106466001)(5001770100001)(2201001)(189998001)(86362001)(50466002)(50986999)(5007970100001)(76176999)(48376002)(101416001)(77096005)(2950100001)(105586002)(53416004)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR12MB0850; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 2:Ltwl9vRmpHimTlZnRY5QS4ZoPNezK2DJ5W5mPn91GaQqfUHkc10WeKN9PyO9zg66guwsLo/QBi5qXQnnEr3LUY9gimgq1FBpGUaqyp+L0k6zjPlbyjB+osDLT7Fb2OwxuxKdkTVIlQmyF29ID5IXu8eqtG//vDmNP5hZGzMxoqk=; 3:uQysXoVrbdPQygmGZGcrhZijlV+RVHWJArcL23UE5uySyoLa42MwhAXXx4FcZcBbiywMaZ2n/Q670sfo/unArDk+l1DkBWvRy3COWlWeJQfJYNQ9jmP5/9xYwFvlRePyFQrE2L19YdELea57qDAEfDP1UimMQzCLRmwChOZfxek3cRxbXfr//HhOSHSzWILcLiZUzWcP6o8w/S6Rwvpc3B3ZbE4jd2YVh5UNzFyVmEY3SfZVXB48qrT9Cr++4cH3; 25:qH0gd9Dpn/0YpKgIOckPCACO4TlLaaHrRO0hB3o6x+hGcYYERo0q08yIlidOPArgqNjFy7+hu3C7XVZd51gGb6MkPpNPX/g2jb0uq865h2gitm9Rio8FnRuhaNmE3STDba0tSRud/F3xz+BGq5lCmyy+wSar7Y2Ot8Xk5e9qZccHTarizyGaWt/Y9IY8xw3s9MGVcsNlWkRGogM3n25Mg00uJnBFX7u75Gar/WYRtLjtOGJewg6daQg1Fxu+WXW4lJVjz8b/9d0uza9Ckp1jEQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN4PR12MB0850; X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 20:jNJc2BEnPuNbQ0Hux2CGNE8zUGJfXnLE5MbTRT62tqsVSl/zQuJnVG4YkI1RkZFzZFPmgasjxhMT0qqiK4QZe2x6fo/UZhexxuAnzihfEGT95J4ZVfZ0xUymyPNdbwcUEZWy+UlPBoUe7nwhg1KSKkeGxR3LIN7ZZt2lnJOIhgy0UNoSYFGORiE8nx1Kj4vjNBHzoQG+G6/qg1nldT4Vo+dDUlQwZIJjApoizvGPuSSLXsaEMruQp9CRzI1IAKlL4buRl8IKZC5fiXb7asLnQN7RyMMngFCTJ2U02ua1xRxhcJgnMcm6GqsszbLOltfwAXTuOUPSs32pBde1JA1NGeotpeoOfGdIwJO6E+lhYz5u0dobK471wfeomZe7GWmXgkuGAgpBohz/yuEFMHQWQVscNVz9hAyJ/tXmfq5vo3R4e72BH19bo+96a5uQVEh40cLbiXexLszdazp65pcaZJRL+2te24QIeN7y5vhpqG5iLxwXUd5NZS3k1gS21mnK; 4:Gbxvc91TVV/JcD/43I99BsA3nQFrptkyRI3D32VjY/fpsglq4xdJSD3A2qLmxGvCv/GgiBduAaR2teHOIXShnMVw4Qly6C1b2hadTPVPxNrgsaCXL4DZrOs2NBdytvsm22wCpwuN+PXB//SQO2nvP0tV9gQRiH1TBGRUCq/7TubVqDiX+UbUW4rQIXRLOxhQ+88p4MkSymmR5oex37co4Ikx/FICj1TOtYAVGfYZCwSj7q5lHUBecnaZwx5U0OApQ9eOIYHc1o4TIjCDDVe4EdVhCdJjnnN3kojZeG5UVpIi9tbnOzz7fQZBHc+f7P7rowUxss7qLyjbQOLPdRAn4TlOHY6Jet0jGFinRHUnWLUpy4ahJaGlOtbrGbCsSgFP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(3002001)(102115026); SRVR:BN4PR12MB0850; BCL:0; PCL:0; RULEID:; SRVR:BN4PR12MB0850; X-Forefront-PRVS: 073631BD3D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR12MB0850; 23:upW/h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=?us-ascii?Q?Zem+mLaRyeQrcxTVNqhtfeQnEq4oNa7cqhsJajjJiF5Qx3XgWZVa+6jTyrXD?= =?us-ascii?Q?0cNP2bUQrEV3olvHG/5dl7X70dHjbMJp5tG9BPW82DJb6DQYl6SeK+Uq6nqK?= =?us-ascii?Q?i526xCFJrVVecSCunMGsoqrzDwx0AWC6g3j2UIXXiOhqw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN4PR12MB0850; 5:hZ4MAwFEZkxu3N4Brp5C6hi0L9BY//Kc6qeZGObO2HExHDaVm+AziHOfmTIrum/zzWYdTlnZhVBiH3QKuXondhGgwHdYqTiZU5F7HLDx0dgapedW0/L4uFeIpCxrHBD2um2qGpNxvpZOw8T2Jg7bvA==; 24:guBPz+HiyjlDKJBobeQdd05S7QCTBUnborKDgHrQnsBTG1Vw6eY2/jUCH1aGmVTC67RUcM6NxapqGKSTOVhR5RXtwv9xjZKlafNe3WYA01Q=; 20:GLurHExeXkOphVrXRfr8WeXdwxhGlE4jZAPsOeylpO/j0xI/LMvBw+lf9ioquDP98pQAOjcRva4E+tF3Jd2/ivqNCQxul+oaNfIOa1MSjHJYXtncnAe1I9yHhKKccouqv5ZVMeVtuB8RikCz+199dfZi+cheg/uNnGgex0zzTw9+WXhh8IwjRfRs6KbxqfbBS7kLdWcnEFgQsiyNpaiSVcy5y89knJlwwjH6rDswCqfBxF/pl/0zEbqbsuUDhyJw SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2015 15:53:01.4794 (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: BN4PR12MB0850 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 The function device_dma_is_coherent() does not sufficiently communicate device DMA attributes. Instead, this patch introduces device_get_dma_attr(), which returns enum dev_dma_attr. It replaces the acpi_check_dma(), which will be removed in subsequent patch. This also provides a convenient function, device_dma_supported(), to check DMA support of the specified device. Signed-off-by: Suravee Suthikulpanit CC: Rafael J. Wysocki --- drivers/base/property.c | 29 +++++++++++++++++++++++++++++ include/linux/property.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 2d75366..baac186 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -547,6 +547,35 @@ bool device_dma_is_coherent(struct device *dev) } EXPORT_SYMBOL_GPL(device_dma_is_coherent); +bool device_dma_supported(struct device *dev) +{ + /* For DT, this is always supported. + * For ACPI, this depends on CCA, which + * is determined by the acpi_dma_supported(). + */ + if (IS_ENABLED(CONFIG_OF) && dev->of_node) + return true; + + return acpi_dma_supported(ACPI_COMPANION(dev)); +} +EXPORT_SYMBOL_GPL(device_dma_supported); + +enum dev_dma_attr device_get_dma_attr(struct device *dev) +{ + enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED; + + if (IS_ENABLED(CONFIG_OF) && dev->of_node) { + if (of_dma_is_coherent(dev->of_node)) + attr = DEV_DMA_COHERENT; + else + attr = DEV_DMA_NON_COHERENT; + } else + attr = acpi_get_dma_attr(ACPI_COMPANION(dev)); + + return attr; +} +EXPORT_SYMBOL_GPL(device_get_dma_attr); + /** * device_get_phy_mode - Get phy mode for given device * @dev: Pointer to the given device diff --git a/include/linux/property.h b/include/linux/property.h index 522c1bf..bde8de3 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -172,6 +172,10 @@ void device_add_property_set(struct device *dev, struct property_set *pset); bool device_dma_is_coherent(struct device *dev); +bool device_dma_supported(struct device *dev); + +enum dev_dma_attr device_get_dma_attr(struct device *dev); + int device_get_phy_mode(struct device *dev); void *device_get_mac_address(struct device *dev, char *addr, int alen);