From patchwork Wed Apr 29 13:44:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 6296031 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 319E0BEEE1 for ; Wed, 29 Apr 2015 13:47:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 37BE62015A for ; Wed, 29 Apr 2015 13:47:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3C4AC201B9 for ; Wed, 29 Apr 2015 13:47:11 +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 1YnSIh-0005pU-VV; Wed, 29 Apr 2015 13:45:19 +0000 Received: from mail-by2on0147.outbound.protection.outlook.com ([207.46.100.147] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YnSI6-0004Ri-1P for linux-arm-kernel@lists.infradead.org; Wed, 29 Apr 2015 13:44:43 +0000 Received: from BN1PR02CA0026.namprd02.prod.outlook.com (10.141.56.26) by BY1PR02MB1113.namprd02.prod.outlook.com (25.162.108.14) with Microsoft SMTP Server (TLS) id 15.1.148.16; Wed, 29 Apr 2015 13:44:17 +0000 Received: from BN1AFFO11FD030.protection.gbl (2a01:111:f400:7c10::165) by BN1PR02CA0026.outlook.office365.com (2a01:111:e400:2a::26) with Microsoft SMTP Server (TLS) id 15.1.148.16 via Frontend Transport; Wed, 29 Apr 2015 13:44:17 +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; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from atltwp01.amd.com (165.204.84.221) by BN1AFFO11FD030.mail.protection.outlook.com (10.58.52.168) with Microsoft SMTP Server id 15.1.154.14 via Frontend Transport; Wed, 29 Apr 2015 13:44:16 +0000 X-WSS-ID: 0NNKM5Q-07-8GQ-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 25BE4CAE61E; Wed, 29 Apr 2015 08:44:13 -0500 (CDT) 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, 29 Apr 2015 08:44:36 -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; Wed, 29 Apr 2015 09:44:13 -0400 From: Suravee Suthikulpanit To: , , , Subject: [PATCH 2/2] ACPI / scan: Parse _CCA and setup device coherency Date: Wed, 29 Apr 2015 08:44:09 -0500 Message-ID: <1430315049-4663-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430315049-4663-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1430315049-4663-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:(10019020)(6009001)(428002)(199003)(189002)(77156002)(76176999)(77096005)(5001770100001)(105586002)(19580395003)(229853001)(50986999)(19580405001)(53416004)(106466001)(2950100001)(62966003)(92566002)(46102003)(101416001)(47776003)(50466002)(36756003)(87936001)(50226001)(86362001)(48376002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR02MB1113; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR02MB1113; 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:BY1PR02MB1113; BCL:0; PCL:0; RULEID:; SRVR:BY1PR02MB1113; X-Forefront-PRVS: 05610E64EE X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2015 13:44:16.8487 (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.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR02MB1113 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150429_064442_133992_C7EA4F62 X-CRM114-Status: GOOD ( 14.98 ) X-Spam-Score: -0.2 (/) Cc: al.stone@linaro.org, arnd@arndb.de, linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, leo.duran@amd.com, hanjun.guo@linaro.org, Suravee Suthikulpanit , msalter@redhat.com, grant.likely@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=BAYES_00, RCVD_IN_DNSWL_MED, 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 This patch implements support for ACPI _CCA object, which is introduced in ACPIv5.1, can be used for specifying device DMA coherency attribute. The parsing logic traverses device namespace to parse coherency information, and stores it in acpi_device_flags. Then uses it to call arch_setup_dma_ops() when creating each device enumerated in DSDT during ACPI scan. This patch also introduces acpi_dma_is_coherent(), which provides an interface for device drivers to check the coherency information similarly to the of_dma_is_coherent(). Signed-off-by: Mark Salter Signed-off-by: Suravee Suthikulpanit --- drivers/acpi/acpi_platform.c | 5 ++++- drivers/acpi/scan.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 9 ++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 4bf7559..a4db208 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -108,9 +108,12 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev) if (IS_ERR(pdev)) dev_err(&adev->dev, "platform device creation failed: %ld\n", PTR_ERR(pdev)); - else + else { + arch_setup_dma_ops(&pdev->dev, 0, 0, NULL, + adev->flags.is_coherent); dev_dbg(&adev->dev, "created platform device %s\n", dev_name(&pdev->dev)); + } kfree(resources); return pdev; diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 849b699..509d0157 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -2137,6 +2138,49 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp) kfree(pnp->unique_id); } +static void acpi_init_coherency(struct acpi_device *device) +{ + unsigned long long cca; + acpi_status status; + struct acpi_device *parent = device->parent; + + if (parent && parent->flags.cca_seen) { + /* + * From ACPIv5.1, OSPM will ignore _CCA if an ancestor + * already saw one. + */ + device->flags.cca_seen = 1; + cca = acpi_dma_is_coherent(parent); + } else { + status = acpi_evaluate_integer(device->handle, "_CCA", + NULL, &cca); + if (ACPI_SUCCESS(status)) { + device->flags.cca_seen = 1; + } else if (IS_ENABLED(CONFIG_ACPI_MUST_HAVE_CCA)) { + /* + * Architecture has specified that if the device + * can do DMA, it must have ACPI _CCA object. + * Here, there could be two cases: + * 1. Not DMA-able device. + * 2. DMA-able device, but missing _CCA object. + * + * In both cases, we will default to dma non-coherent. + */ + cca = 0; + } else { + /* + * If architecture does not specify that device must + * specify ACPI _CCA (e.g. x86), we default to use + * dma coherent. + */ + cca = 1; + } + } + + device->flags.is_coherent = cca; + arch_setup_dma_ops(&device->dev, 0, 0, NULL, cca); +} + void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, int type, unsigned long long sta) { @@ -2155,6 +2199,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, device->flags.visited = false; device_initialize(&device->dev); dev_set_uevent_suppress(&device->dev, true); + acpi_init_coherency(device); } void acpi_device_add_finalize(struct acpi_device *device) diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 8de4fa9..7e8cd4c 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -208,7 +208,9 @@ struct acpi_device_flags { u32 visited:1; u32 hotplug_notify:1; u32 is_dock_station:1; - u32 reserved:23; + u32 is_coherent:1; + u32 cca_seen:1; + u32 reserved:21; }; /* File System */ @@ -380,6 +382,11 @@ struct acpi_device { void (*remove)(struct acpi_device *); }; +static inline bool acpi_dma_is_coherent(struct acpi_device *adev) +{ + return adev && adev->flags.is_coherent; +} + static inline bool is_acpi_node(struct fwnode_handle *fwnode) { return fwnode && fwnode->type == FWNODE_ACPI;