From patchwork Wed May 20 22:09:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6450661 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 C3E739F1C1 for ; Wed, 20 May 2015 22:11:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB8C520459 for ; Wed, 20 May 2015 22:11:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AA4020450 for ; Wed, 20 May 2015 22:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754931AbbETWLH (ORCPT ); Wed, 20 May 2015 18:11:07 -0400 Received: from mail-bn1bon0132.outbound.protection.outlook.com ([157.56.111.132]:4775 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754247AbbETWJa (ORCPT ); Wed, 20 May 2015 18:09:30 -0400 Received: from BLUPR02CA031.namprd02.prod.outlook.com (25.160.23.149) by BLUPR02MB241.namprd02.prod.outlook.com (10.242.189.142) with Microsoft SMTP Server (TLS) id 15.1.166.22; Wed, 20 May 2015 22:09:26 +0000 Received: from BN1BFFO11FD035.protection.gbl (2a01:111:f400:7c10::1:136) by BLUPR02CA031.outlook.office365.com (2a01:111:e400:8ad::21) with Microsoft SMTP Server (TLS) id 15.1.166.22 via Frontend Transport; Wed, 20 May 2015 22:09:26 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.222) 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 atltwp02.amd.com (165.204.84.222) by BN1BFFO11FD035.mail.protection.outlook.com (10.58.144.98) with Microsoft SMTP Server id 15.1.172.14 via Frontend Transport; Wed, 20 May 2015 22:09:25 +0000 X-WSS-ID: 0NOO5JM-08-AMI-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 atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2821BBD88EA; Wed, 20 May 2015 18:09:21 -0400 (EDT) Received: from SATLEXDAG06.amd.com (10.181.40.13) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 20 May 2015 17:09:37 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by satlexdag06.amd.com (10.181.40.13) with Microsoft SMTP Server id 14.3.195.1; Wed, 20 May 2015 18:09:22 -0400 From: Suravee Suthikulpanit To: , , , , , , , CC: , , , , , , , , , , , "Suravee Suthikulpanit" Subject: [V5 PATCH 3/5] device property: Introduces device_dma_is_coherent() Date: Wed, 20 May 2015 17:09:16 -0500 Message-ID: <1432159758-4486-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1432159758-4486-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1432159758-4486-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD035; 1:ZtfZncl/3xziV0mNSJ1bk2LQA9knBXInQfByTbekS/P6kxSD5wARl+HrdzV1IQ5ALvOJWjNFBUJulsKBCbKW4u/WPGnAuqWRg+Hu5sBYEJhcoGzlZB8DHN+1NL2IH7ZzffpAP+Qb6Kj/3vEdUYbDVh2ZypBAPn+Q0visQfrkWl1PpW4fDqiDLYfe/VHN/w+ePCspNCwtCXYY3Zkw2hW+v4ALjIVbkOv4jtjUqrgs8oMdigWVj8PA4ymii1msFm8ENJP2xx7tGSu5CSrXW+uc+8TYa1mfjseQIFKhccV08jj3Na0MrNoj7E2D8X5vQb1H X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(87936001)(50226001)(2201001)(105586002)(189998001)(5001770100001)(97736004)(4001540100001)(62966003)(77156002)(46102003)(5001860100001)(5001830100001)(2950100001)(92566002)(68736005)(77096005)(19580395003)(19580405001)(86362001)(575784001)(53416004)(47776003)(64706001)(50986999)(76176999)(229853001)(101416001)(106466001)(36756003)(48376002)(50466002); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR02MB241; H:atltwp02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB241; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BLUPR02MB241; BCL:0; PCL:0; RULEID:; SRVR:BLUPR02MB241; X-Forefront-PRVS: 0582641F53 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2015 22:09:25.7802 (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.222]; Helo=[atltwp02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB241 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, T_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 Currently, device drivers, which support both OF and ACPI, need to call two separate APIs, of_dma_is_coherent() and acpi_dma_is_coherent()) to determine device coherency attribute. This patch simplifies this process by introducing a new device property API, device_dma_is_coherent(), which calls the appropriate interface based on the booting architecture. Signed-off-by: Suravee Suthikulpanit --- drivers/base/property.c | 14 ++++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 1d0b116..e645852 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /** @@ -519,3 +520,16 @@ unsigned int device_get_child_node_count(struct device *dev) return count; } EXPORT_SYMBOL_GPL(device_get_child_node_count); + +bool device_dma_is_coherent(struct device *dev) +{ + bool coherent = false; + + if (IS_ENABLED(CONFIG_OF) && dev->of_node) + coherent = of_dma_is_coherent(dev->of_node); + else + acpi_check_dma(ACPI_COMPANION(dev), &coherent); + + return coherent; +} +EXPORT_SYMBOL_GPL(device_dma_is_coherent); diff --git a/include/linux/property.h b/include/linux/property.h index de8bdf4..76ebde9 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -164,4 +164,6 @@ struct property_set { void device_add_property_set(struct device *dev, struct property_set *pset); +bool device_dma_is_coherent(struct device *dev); + #endif /* _LINUX_PROPERTY_H_ */