From patchwork Fri May 8 00:37:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6361431 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@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 CF08C9F32E for ; Fri, 8 May 2015 00:39:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D785D203AC for ; Fri, 8 May 2015 00:39:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03D502021F for ; Fri, 8 May 2015 00:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751751AbbEHAhe (ORCPT ); Thu, 7 May 2015 20:37:34 -0400 Received: from mail-by2on0110.outbound.protection.outlook.com ([207.46.100.110]:52591 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751673AbbEHAhb (ORCPT ); Thu, 7 May 2015 20:37:31 -0400 Received: from BY1PR0201CA0021.namprd02.prod.outlook.com (25.160.191.159) by BN1PR02MB070.namprd02.prod.outlook.com (10.242.211.14) with Microsoft SMTP Server (TLS) id 15.1.154.19; Fri, 8 May 2015 00:37:29 +0000 Received: from BY2FFO11FD032.protection.gbl (2a01:111:f400:7c0c::154) by BY1PR0201CA0021.outlook.office365.com (2a01:111:e400:4814::31) with Microsoft SMTP Server (TLS) id 15.1.160.19 via Frontend Transport; Fri, 8 May 2015 00:37:28 +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 BY2FFO11FD032.mail.protection.outlook.com (10.1.14.210) with Microsoft SMTP Server id 15.1.160.8 via Frontend Transport; Fri, 8 May 2015 00:37:27 +0000 X-WSS-ID: 0NO09QB-08-2YU-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 2EC73D92013; Thu, 7 May 2015 20:37:23 -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; Thu, 7 May 2015 19:37:57 -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.195.1; Thu, 7 May 2015 20:37:24 -0400 From: Suravee Suthikulpanit To: , , , , , , , CC: , , , , , , , , , , , "Suravee Suthikulpanit" Subject: [V3 PATCH 3/5] device property: Introduces device_dma_is_coherent() Date: Thu, 7 May 2015 19:37:14 -0500 Message-ID: <1431045436-8690-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431045436-8690-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1431045436-8690-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(36756003)(106466001)(53416004)(189998001)(46102003)(50466002)(92566002)(50226001)(105586002)(48376002)(77096005)(229853001)(77156002)(62966003)(50986999)(5001770100001)(5001920100001)(76176999)(19580395003)(19580405001)(47776003)(101416001)(575784001)(2950100001)(86362001)(87936001)(2201001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR02MB070; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB070; 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:BN1PR02MB070; BCL:0; PCL:0; RULEID:; SRVR:BN1PR02MB070; X-Forefront-PRVS: 0570F1F193 X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2015 00:37:27.3834 (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: BN1PR02MB070 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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=ham 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 | 12 ++++++++++++ include/linux/property.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 1d0b116..8123c6e 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /** @@ -519,3 +520,14 @@ 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) +{ + if (IS_ENABLED(CONFIG_OF) && dev->of_node) + return of_dma_is_coherent(dev->of_node); + else if (has_acpi_companion(dev)) + return acpi_dma_is_coherent(acpi_node(dev->fwnode)); + + return false; +} +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_ */