aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Salter <msalter@redhat.com>2014-08-14 12:32:13 -0400
committerGraeme Gregory <graeme.gregory@linaro.org>2014-11-06 11:57:49 +0000
commit6204c7076c706a3f79dad7bec5daf062878a6960 (patch)
tree35aad012c2e613ec4db22ca52cd58aeec97af00c
parentfc1d8c840e7f879e9ff494aad1975a27fb259e19 (diff)
downloadleg-kernel-6204c7076c706a3f79dad7bec5daf062878a6960.tar.gz
acpi: add utility to test for device dma coherency
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 <msalter@redhat.com>
-rw-r--r--drivers/acpi/utils.c26
-rw-r--r--include/acpi/acpi_bus.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 371ac12d25b1..af325a78a4f6 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -723,3 +723,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 a361f43b1974..0d4ce14827d2 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -69,6 +69,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)