From patchwork Wed Oct 28 22:50:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 7515051 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 AAB58BEEA4 for ; Wed, 28 Oct 2015 22:54:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2EC420960 for ; Wed, 28 Oct 2015 22:54:38 +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 A18942097B for ; Wed, 28 Oct 2015 22:54:37 +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 1ZrZaC-00050E-Go; Wed, 28 Oct 2015 22:52:40 +0000 Received: from mail-bn1bon0059.outbound.protection.outlook.com ([157.56.111.59] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZrZZG-0004VJ-Rj for linux-arm-kernel@lists.infradead.org; Wed, 28 Oct 2015 22:51:45 +0000 Received: from BY2PR12CA0022.namprd12.prod.outlook.com (10.160.121.32) by BLUPR12MB0707.namprd12.prod.outlook.com (10.163.218.145) with Microsoft SMTP Server (TLS) id 15.1.306.13; Wed, 28 Oct 2015 22:51:20 +0000 Received: from DM3NAM03FT011.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::207) by BY2PR12CA0022.outlook.office365.com (2a01:111:e400:2c84::32) with Microsoft SMTP Server (TLS) id 15.1.312.18 via Frontend Transport; Wed, 28 Oct 2015 22:51:20 +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 DM3NAM03FT011.mail.protection.outlook.com (10.152.82.88) with Microsoft SMTP Server id 15.1.318.9 via Frontend Transport; Wed, 28 Oct 2015 22:51:19 +0000 X-WSS-ID: 0NWYCTH-07-6DI-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 2C00CCAE635; Wed, 28 Oct 2015 18:51:16 -0400 (EDT) Received: from SATLEXDAG03.amd.com (10.181.40.7) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 28 Oct 2015 17:51:32 -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:16 -0400 From: Suravee Suthikulpanit To: , , , , Subject: [PATCH V5 4/9] device property: Adding DMA Attribute APIs for Generic Devices Date: Wed, 28 Oct 2015 15:50:49 -0700 Message-ID: <1446072654-5608-5-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)(47776003)(5003600100002)(50226001)(5003940100001)(77096005)(106466001)(76176999)(101416001)(19580405001)(229853001)(2950100001)(105586002)(19580395003)(2201001)(5008740100001)(11100500001)(189998001)(86362001)(97736004)(50466002)(5001770100001)(53416004)(50986999)(92566002)(87936001)(5007970100001)(48376002)(36756003)(41533002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0707; H:atltwp01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0707; 2:OKcvcKjHeqwrSad/hMbqWetkezTrTWUZLf+Ih+tcRx/8zq8xhwt9SjrJUUO5wrTr/PJ9vw3ZXGoOEsGYvLJwQoCOAbx7+2NVHUaB7yBd1/mf6jGpcsFWV9/aJND0vy1KkIOojYYivm3VfxtnREijdaVfRmP63YMXVnxjtg4nl5Q=; 3:ToNtd/i1lkjb6Uh75hyiEIIhZfYSGPZd88mF/15H1kfKE98tcStLOn8kgtk3dmjucI0/rgTFHohni4jdIt3+2UjlSfAvazJVHxRHQfQ8MKrdn55UWri+3dr4ouixG6oDhApmLLd70vcw2s0qqSxyPwj+KAubXjBhBkM91kj091oavJnZRcWlel/Us3l5YB+DJXEJvm3Wx0qdQIjuaBhQKcVFqkqRHwfvgIuh+vkMI5NrVTnJUy2kxSNe3bScuMLm; 25:W4WA5PEZbX/L6o71auzdESVcQ1+mr7GePYRnFQGok7bDRxY/96SBXGcKRtQNctVFEsWbJG0C2bJnlJ0pPHQsZxnSfVNuReKLzfwDeGsE/qrjfgtjTOjNhB4Jo9WG/sC4DP3xpK/xxBxUFKUaIcMLbbBwoid6vm6ASXvrOMjxNY+z9LTigwuAoHyv29Ilod0jzMKTLqRbZuo8RXW3XgS5dg9Pg28PvXrOY5D4yfsT5AN5GN9j38nVZbB/x3NX1mAeDefs0cHrYNNoG1zhM8bKLg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0707; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0707; 20:NbwWGjzHqd2qwZvJDhCfcUc+mcxSMXvJeBFlLRmjdqmqva0Vz7sCxJPDtwzHcprWROuTzY/uflN9svMkW7ubGqV/HEtwvdQ7l7lMlCstkeG07FljlNdTcdjT3NWXMfQcHScZ7xrRvNrd+MOKDTIcLCCl5QZh+KZ/Z+i3k10lo+WrsIpZgVhTDdNAplwNCvoTnJmEvRGL3Zc/KRu2JKy0+24NG/00/J47+IMIzD8PRMJ2owAt9/WXhso6cOpkzbTafXsi0W8l6PithEVVkpCkR3NE3NiuNG8YN3+Ehw5jdDj78aWjAzKyHATlzQ7I95PADI+2neIYHySxy4K16W950UXNKSWCZDwP3oD18C0T/7CiF/MZi2175xeEXOdBGbSNEy23l0NDOntUYiOa357vbXm3WdjiFhlQUeus7wdYCYNwmnL/enXlLeUlAbUgIXZ0vfJqd5BOCqNC5A4s9B3+jBgNYBXBFV8CRCcRJDPzJIqgFXvvMo+UW2IgSatgrLW3; 4:RHDm2PPn7r1bA2T4Wniz2+m3fH1ix33uIr9spmM/fwx/9o95oSN7Em+B1sdTZjDDShPHSpF4DECkOPkD6bmE0EhkxV1B4UMDFm7qTpvxICdadZ0Wgo8y/tG+nUAuxmFIfLeMXqcL1ijb3IybL3t8TaCjKTR5orh5iOW3KLr0jrFmo92npiLDbCChadruPte8hipQEw51iNx7Pzk4bSx5++jPP0tpbNeG6Uos6DxqTc1RL4qTL2DMbqg1J8sEaxvFLWoFUPbbDEQ9tblukGF95GG1mW2+N83Jc1ayqgg81CmxWUcjt3uvz0Jv3AhvjQhr6o8NhSLnfiY+e+j3IsbtiNkR4cWi5J0ARfHuxeHyVPblElaqD2drYQwYBDFSw3dJ9Y8WRpgYxEJ3L/uUquz7XA== 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:BLUPR12MB0707; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0707; X-Forefront-PRVS: 0743E8D0A6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0707; 23:RytcWg1sO4fTJrWK27PDfh1cPxcaKaeG6BIKnl1zw?= =?us-ascii?Q?ovEg3uo+IcYvij0qnKNEt30VFWglAZ1jq5wx3Jqg2SEqsRyRwJ7rUQYln53Z?= =?us-ascii?Q?IXoTyTbZ4uro9Yt0Gp24kWK/j7+iyrRQoY7NcuiayNdoYDTz0oRCrUWLqqpd?= =?us-ascii?Q?AvE4Q+ORXpTJdh1K/USaEmDXASVkssnzhhY/oPMN9wkp4Ue0pzA/R4WJmXVd?= =?us-ascii?Q?0ZlNdAu6cNvuOAfc1X3bKTssBc5OMNsV72XLcLLC+yjyNzKhQqprQMtWkpMU?= =?us-ascii?Q?pR8iYVT5bIBKg2odU2HAikt9WwXzKdMFhSljYy7KBkVT44Y36sFAduIIbywC?= =?us-ascii?Q?eMZgQZAMDBZ5RNPW9/Oe00AO9x02PxygUPaWjFUhyJsaiIb/AW1F/EKBUsZy?= =?us-ascii?Q?9ic/rSNTc/SpS/E6JMEiLJcX4sXtllWuahsqoOuLWlGEeonZ72x4QgNB8mZr?= =?us-ascii?Q?96KDdsZwe5BTVehBpwnR1rjmszvCTxorBx9R9dJhTcb1oj5KQCw9z4AC7Dac?= =?us-ascii?Q?d3r0W0ZN6V4v7TdE0WtlofS4QFuG50+bXjk+Xx3nbDSynmbUOA8OGrokCw0C?= =?us-ascii?Q?C/cSE+7f83hjO3nOArm9ZmdEpnDrZ+WdWJCfN7xHZ6r/0XPKDm96ifSak6lp?= =?us-ascii?Q?JPoFqEWDoQ30gMrf/DmSmzioXYFBTfUWrD3ec25BwChMrNgHBPihLQFuvqTb?= =?us-ascii?Q?8TB0pDPh2kf/i6tN8vIvQTITSM/yvjA21vUvv2G/Hofc/8lwLmnNj6Rt3CSO?= =?us-ascii?Q?EV5+/f/B0doB9HnEyzS6PmWtp83ObQKoyh+rl8N2RsBTwIxc7ywSe81gcbjs?= =?us-ascii?Q?iKVALd+fBK6o9jSvIsm0zqfelnkca7fEbmJdWqnf/gIpp/LkI97nm/V0xqBg?= =?us-ascii?Q?cN5zlvaiTzH7/0WQcTDsYnkHQnm6U7NwpAR0/ySNwDlq19FBSfYh8TO/3kbF?= =?us-ascii?Q?61CrJgo56G54Yn3yc5YHnqgmU0Q19E8ebUXnabj/w=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0707; 5:JLIz6B1nEs7dE8BFhyrrZiYFBXRvSgcvhe0qzAXt/qzuvZugcYzoVtknUcvE6rlkCDeFYWJoiGDWOxebMcKO2E3xFM1wMeSbR4AfoTdsikxHVlQMph/XwGztDWOjM6SKKJZh+Qxf6oUArRb4pyIr5Q==; 24:q5xMszr8TGvdPXZuJ6vYAlP86CaBURBwf2Vm7gsismMlc+zvMTToB5IAo9l4sS7c1c8Ggv+ineSRRnvXz8yKyEAT6Acg3g9xdWP3aMRwBK0=; 20:pcbagf+UNKr68Vp0RjJPJeYHMY+BMIRB2T4TLWvw/CUsjzN7us2/O/R8AIbZ4drsxgQ+ntUAH5xm+l4OgRUEE6JjbtP74Qlg5wjK8yIQLybvNS7sN+UoltThU/OtQFWVhRJAi3BUryx8f6qyG+oNvwJDswqqIslCcONUm7vWCqM7QtcDEs1bDWuJw1rQ9HbXlPXnLFBEsJgzxQp1TafqE+tzUxDOpdCOkGjUa7bBXbjcpGck8li9kD/IEuWnfyFr SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2015 22:51:19.2300 (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: BLUPR12MB0707 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151028_155143_400244_CC50D886 X-CRM114-Status: GOOD ( 12.49 ) 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=BAD_ENC_HEADER,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 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 de40623..05d57a2 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -611,6 +611,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 8eecf20..7200490 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -176,6 +176,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);