From patchwork Wed Jun 10 16:08:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6582961 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: X-Original-To: patchwork-linux-acpi@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 541B1C0020 for ; Wed, 10 Jun 2015 16:12:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AF8F20575 for ; Wed, 10 Jun 2015 16:12:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F22D205C1 for ; Wed, 10 Jun 2015 16:12:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964941AbbFJQLo (ORCPT ); Wed, 10 Jun 2015 12:11:44 -0400 Received: from mail-by2on0136.outbound.protection.outlook.com ([207.46.100.136]:31072 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964921AbbFJQJI (ORCPT ); Wed, 10 Jun 2015 12:09:08 -0400 Received: from BLUPR02CA054.namprd02.prod.outlook.com (10.160.23.172) by CY1PR02MB1119.namprd02.prod.outlook.com (10.163.15.145) with Microsoft SMTP Server (TLS) id 15.1.190.14; Wed, 10 Jun 2015 16:09:04 +0000 Received: from BN1AFFO11FD023.protection.gbl (2a01:111:f400:7c10::129) by BLUPR02CA054.outlook.office365.com (2a01:111:e400:8ad::44) with Microsoft SMTP Server (TLS) id 15.1.190.14 via Frontend Transport; Wed, 10 Jun 2015 16:09:03 +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 BN1AFFO11FD023.mail.protection.outlook.com (10.58.52.83) with Microsoft SMTP Server id 15.1.190.9 via Frontend Transport; Wed, 10 Jun 2015 16:09:02 +0000 X-WSS-ID: 0NPQKV1-08-K8W-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 atltwp02.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2E200D16024; Wed, 10 Jun 2015 12:09:01 -0400 (EDT) Received: from SATLEXDAG01.amd.com (10.181.40.3) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 10 Jun 2015 11:09:37 -0500 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.195.1; Wed, 10 Jun 2015 12:09:00 -0400 From: Suravee Suthikulpanit To: , , , , , , , , , , , CC: , , , , , , , , , , , "Suravee Suthikulpanit" Subject: [V6 PATCH 2/7] arm64 : Introduce support for ACPI _CCA object Date: Wed, 10 Jun 2015 11:08:53 -0500 Message-ID: <1433952538-22455-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433952538-22455-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1433952538-22455-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD023; 1:gi/JwJQ86qVecPZjwT3m+/O453n2IFcDo5RJFQ2FMkiNzh0k4HVAMdIOiXKU26b/u1V9FkH3W1T06pMljxlI3aOKvHt2nN8JRI4+BnlWq3gMm8nS+WF4c6b7HhKJBr9MaluGi+4vwGXypNwSMMjrw101tp86L/c/QTLAWdHeLdT6FX+DUYaYPfO61U0dj83omn+qxElLJOIm7WsepZGg7hyakdqsSujLTaDjdr/hF/3EvswcoFSgAgeO7Fcx4Vh6ryoqa2SaZDjF/tynNOFj6SqXF8imJBVZh5fWa1R8XoO2Sn7fCnfNazMCMarhRuAT1CuGrQu4cQ1ocbAJnjGElg== X-Forefront-Antispam-Report: CIP:165.204.84.222; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(189002)(199003)(50226001)(77156002)(189998001)(53416004)(5001770100001)(62966003)(92566002)(47776003)(19580395003)(86362001)(575784001)(2201001)(76176999)(105586002)(50986999)(229853001)(2950100001)(19580405001)(87936001)(15975445007)(36756003)(101416001)(46102003)(77096005)(48376002)(5003600100002)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR02MB1119; H:atltwp02.amd.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1119; 2:hpivHTOiD54p9a8xvxDBVUKNDRIWkNao5k0/8mm1C8e6kqLsrIoAKwgPOZs2E2/2; 2:mW3EedIXrV5aBZGQD47bn8+TM64m2AjJu3uABamf/7tXkvZjqf1T0+w3zjnyppj/VwYhzk/xykiJoYhBHmtmVQq78YdOoBoUvb84M8csfQbZ6ZDu8lHlRe86ikAXI+zf/GqSxyFkdbOtXcEqDQzhx+P7yHIhYhTyxQVtW+FMifWxFEhjJFOVdMtp8kq1xlJ4CRn3neL2l9lDa9kRWufwka94BPHegZnqbc6HUQrpwZO2pl7ozadSG1NWGMhvgnW9; 6:WxSXW8FQqb0yWlMXlwRbkKrqIkGVeL/6TjsYncMN3U4ev89Q0Bykalh4YXvU3Pa2BeViGeBrqjeiNeyI+UzoyMuHBEhHAtaj2zFBJiUWT3rUlrPjbiegVTaQ6LeZ1Q9PJpzD6SZVHzmIelRv6x0CiDu+9Nu15X/vTOVTUI4pWDZ4gpExkIO7Y/NUZ6sBOJDPjR1cFbkVTfATGjm100BFzDxuhjmBIa4VZdS13iIMB3QmsuStX3kuRTC+C5uHyIMz7YZQiyTExPx5hs3EuA+ajPSwry8MSl4Jk/tR4rl0AVR0WWKtw9lS9j3aH/RzZCXL84ShSFn8Z6a1HJT2cg8DdTlEMm7uBZCMFK6IZAkuwMTxwkw6K4LT+B4lsWQEet9XeUh9ZraKJYqm0VZp39KzaSo554no4U3TllDkmP93UKBFlVdXyvs0/gHgisbQJ7G6j+3uA3RoLFqbliy1RkV1m4Tyq0UPF2QMozrT/JK7fdCAisDJMHLxBymcybadi1nL X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1119; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:CY1PR02MB1119; BCL:0; PCL:0; RULEID:; SRVR:CY1PR02MB1119; X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1119; 3:ZvR83netp/10tyO85q4Ayr1tEXSogCJ0VAG7b8goOhrRVizN9FMrrCz9i0Wq88kqFQVHlIDmXWRx3xU+0SIOzd/Vj5yTO+JErfoeYlA0auYJmexQh4q0eRunZhmWJja8oEhUMsDb9P+rve11XSUwUzLaFN8wQLi7A/pWZiUMEeD+PKI9+i2rqWfu+MDiHMi706foJsIHQmF3vDGPj5nPa55TAEDIkRSzoZWV9brFbvBPMkIPYulMl65SoJgtawOzWDjcb+BBrYUu0LxdN5GQIHEcVQDlrTPkZZV0TC+v6tze7TMH6P3t5dmsGR96bVj4 X-Forefront-PRVS: 06036BD506 X-Microsoft-Exchange-Diagnostics: 1; CY1PR02MB1119; 9:LiAgmsMZxeN13bb5qE1iVyhRjRLCAOvUCMX+VoW/ki+GPK/t1Fcmi8+qCUKzW44nlOoZZ1yslKpPHS8gFlD8CbSYFUd80tuLCKCgWUpPOs9FJHq+6YTg3hr90ArcErzdwn7gG7q352OTmFX6WGpn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nvW1BVbGVhLB7aYcSIUYGmPq6G X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2015 16:09:02.9477 (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: CY1PR02MB1119 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 From http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf, section 6.2.17 _CCA states that ARM platforms require ACPI _CCA object to be specified for DMA-cabpable devices. Therefore, this patch specifies ACPI_CCA_REQUIRED in arm64 Kconfig. In addition, to handle the case when _CCA is missing, arm64 would assign dummy_dma_ops to disable DMA capability of the device. Acked-by: Catalin Marinas Signed-off-by: Mark Salter Signed-off-by: Suravee Suthikulpanit --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/dma-mapping.h | 18 ++++++- arch/arm64/mm/dma-mapping.c | 92 ++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 4269dba..95307b4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1,5 +1,6 @@ config ARM64 def_bool y + select ACPI_CCA_REQUIRED if ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE diff --git a/arch/arm64/include/asm/dma-mapping.h b/arch/arm64/include/asm/dma-mapping.h index 9437e3d..f0d6d0b 100644 --- a/arch/arm64/include/asm/dma-mapping.h +++ b/arch/arm64/include/asm/dma-mapping.h @@ -18,6 +18,7 @@ #ifdef __KERNEL__ +#include #include #include @@ -28,13 +29,23 @@ #define DMA_ERROR_CODE (~(dma_addr_t)0) extern struct dma_map_ops *dma_ops; +extern struct dma_map_ops dummy_dma_ops; static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) { - if (unlikely(!dev) || !dev->archdata.dma_ops) + if (unlikely(!dev)) return dma_ops; - else + else if (dev->archdata.dma_ops) return dev->archdata.dma_ops; + else if (acpi_disabled) + return dma_ops; + + /* + * When ACPI is enabled, if arch_set_dma_ops is not called, + * we will disable device DMA capability by setting it + * to dummy_dma_ops. + */ + return &dummy_dma_ops; } static inline struct dma_map_ops *get_dma_ops(struct device *dev) @@ -48,6 +59,9 @@ static inline struct dma_map_ops *get_dma_ops(struct device *dev) static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct iommu_ops *iommu, bool coherent) { + if (!acpi_disabled && !dev->archdata.dma_ops) + dev->archdata.dma_ops = dma_ops; + dev->archdata.dma_coherent = coherent; } #define arch_setup_dma_ops arch_setup_dma_ops diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index ef7d112..6e6d6ad 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -415,6 +415,98 @@ out: return -ENOMEM; } +/******************************************** + * The following APIs are for dummy DMA ops * + ********************************************/ + +static void *__dummy_alloc(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t flags, + struct dma_attrs *attrs) +{ + return NULL; +} + +static void __dummy_free(struct device *dev, size_t size, + void *vaddr, dma_addr_t dma_handle, + struct dma_attrs *attrs) +{ +} + +static int __dummy_mmap(struct device *dev, + struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t dma_addr, size_t size, + struct dma_attrs *attrs) +{ + return -ENXIO; +} + +static dma_addr_t __dummy_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + return DMA_ERROR_CODE; +} + +static void __dummy_unmap_page(struct device *dev, dma_addr_t dev_addr, + size_t size, enum dma_data_direction dir, + struct dma_attrs *attrs) +{ +} + +static int __dummy_map_sg(struct device *dev, struct scatterlist *sgl, + int nelems, enum dma_data_direction dir, + struct dma_attrs *attrs) +{ + return 0; +} + +static void __dummy_unmap_sg(struct device *dev, + struct scatterlist *sgl, int nelems, + enum dma_data_direction dir, + struct dma_attrs *attrs) +{ +} + +static void __dummy_sync_single(struct device *dev, + dma_addr_t dev_addr, size_t size, + enum dma_data_direction dir) +{ +} + +static void __dummy_sync_sg(struct device *dev, + struct scatterlist *sgl, int nelems, + enum dma_data_direction dir) +{ +} + +static int __dummy_mapping_error(struct device *hwdev, dma_addr_t dma_addr) +{ + return 1; +} + +static int __dummy_dma_supported(struct device *hwdev, u64 mask) +{ + return 0; +} + +struct dma_map_ops dummy_dma_ops = { + .alloc = __dummy_alloc, + .free = __dummy_free, + .mmap = __dummy_mmap, + .map_page = __dummy_map_page, + .unmap_page = __dummy_unmap_page, + .map_sg = __dummy_map_sg, + .unmap_sg = __dummy_unmap_sg, + .sync_single_for_cpu = __dummy_sync_single, + .sync_single_for_device = __dummy_sync_single, + .sync_sg_for_cpu = __dummy_sync_sg, + .sync_sg_for_device = __dummy_sync_sg, + .mapping_error = __dummy_mapping_error, + .dma_supported = __dummy_dma_supported, +}; +EXPORT_SYMBOL(dummy_dma_ops); + static int __init arm64_dma_init(void) { int ret;