From patchwork Tue Sep 9 20:57:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 37153 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 34B4C20566 for ; Tue, 9 Sep 2014 20:58:24 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf86532880oag.8 for ; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=qcn39PatPhTkrUyQutmcC9qZkr/69eD3PZqtwPiyRzM=; b=hJoPBbr/hxuNGDAQlTZkBk3GNZyJ3tLShn74nM3LUtKTRCBh+CE2Il5W50dohUKKb7 pdtMNpNfhZwHdT3xqNPW4TY2e/8WIp0ldESC/8ytpzNz7OkL5r3gYLb2XOK5fSN75sOU 7x8qk1eljyHnIn52xGAQUVbJFJ0Pk+jYp8xXVhmhPeUrpk/B51ZzYxqmpQamNg96vAYX z2FOyaz07LJetj++lxu9lCFOVGvQ61XKGPhlVg24DWpMEOe6jtPjOjRAEO0k1W6ibRzC k1U3PzZWwvttIIUFqjPxM1RChjjTdWyG1c6s3U3CjanzNf2PL0lVVKHt876JWE7OsZe/ v4Qg== X-Gm-Message-State: ALoCoQkLZ2OqpqmIls6ajTqD+nPc4pgLYULpFknmVIxDyKAi+Ch2Mt1J67c6i1pChwdt9AMJ4Omk X-Received: by 10.182.171.67 with SMTP id as3mr23229276obc.34.1410296303575; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.34 with SMTP id y31ls1083731qgd.2.gmail; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) X-Received: by 10.220.168.74 with SMTP id t10mr13432241vcy.35.1410296303467; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id qb15si1515987vdb.21.2014.09.09.13.58.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 13:58:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so17283865vcb.25 for ; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) X-Received: by 10.52.34.104 with SMTP id y8mr737747vdi.37.1410296303385; Tue, 09 Sep 2014 13:58:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp342086vcb; Tue, 9 Sep 2014 13:58:22 -0700 (PDT) X-Received: by 10.66.139.106 with SMTP id qx10mr60614552pab.126.1410296302379; Tue, 09 Sep 2014 13:58:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dn3si921162pdb.205.2014.09.09.13.58.21 for ; Tue, 09 Sep 2014 13:58:22 -0700 (PDT) Received-SPF: none (google.com: linux-acpi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbaIIU6P (ORCPT + 7 others); Tue, 9 Sep 2014 16:58:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11173 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751155AbaIIU6O (ORCPT ); Tue, 9 Sep 2014 16:58:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s89KwATc008854 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Sep 2014 16:58:10 -0400 Received: from deneb.redhat.com (ovpn-113-116.phx2.redhat.com [10.3.113.116]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s89Kw85K025596; Tue, 9 Sep 2014 16:58:09 -0400 From: Mark Salter To: "Rafael J. Wysocki" Cc: Lv Zheng , linux-acpi@vger.kernel.org, Mark Salter Subject: [PATCH] acpi: add utility to test for device dma coherency Date: Tue, 9 Sep 2014 16:57:58 -0400 Message-Id: <1410296278-1244-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , ACPI 5.1 adds a _CCA object to indicate memory coherency of a bus master device. It is an integer with zero meaning non-coherent and one meaning coherent. This attribute may be inherited from a parent device. It may also be missing entirely, in which case, an architecture-specific default is assumed. This patch adds a utility function to parse a device handle (and its parents) for a _CCA object and return the coherency attribute if found. Signed-off-by: Mark Salter --- drivers/acpi/utils.c | 26 ++++++++++++++++++++++++++ include/acpi/acpi_bus.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 07c8c5a..aec9656 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -698,3 +698,29 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs) return false; } EXPORT_SYMBOL(acpi_check_dsm); + +/** + * acpi_check_coherency - check for memory coherency of a device + * @handle: ACPI device handle + * @val: Pointer to returned value + * + * Search a device and its parents for a _CCA method and return + * its value. + */ +acpi_status acpi_check_coherency(acpi_handle handle, int *val) +{ + unsigned long long data; + acpi_status status; + + do { + status = acpi_evaluate_integer(handle, "_CCA", NULL, &data); + if (!ACPI_FAILURE(status)) { + *val = data; + break; + } + status = acpi_get_parent(handle, &handle); + } while (!ACPI_FAILURE(status)); + + return status; +} +EXPORT_SYMBOL(acpi_check_coherency); diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index bcfd808..b97f09d 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -68,6 +68,8 @@ bool acpi_check_dsm(acpi_handle handle, const u8 *uuid, int rev, u64 funcs); union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const u8 *uuid, int rev, int func, union acpi_object *argv4); +acpi_status acpi_check_coherency(acpi_handle handle, int *val); + static inline union acpi_object * acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, int rev, int func, union acpi_object *argv4, acpi_object_type type)