aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-06-18 19:17:35 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-06-18 19:17:35 -0400
commite193cd15ae98817ad82cc8bad61a200ac561e98c (patch)
treea4b645de8fe35f75e3d9459461bb89e8ffc41979
parent4def8a360fc6119e09916708cca0977a1495ccf4 (diff)
parente144cd045e123757b6b5f732c420b94dd5544407 (diff)
Merge branch 'acpi-cca'
* acpi-cca: ufs: fix TRUE and FALSE re-define build error megaraid_sas: fix TRUE and FALSE re-define build error amd-xgbe: Unify coherency checking logic with device_dma_is_coherent() crypto: ccp - Unify coherency checking logic with device_dma_is_coherent() device property: Introduces device_dma_is_coherent() arm64 : Introduce support for ACPI _CCA object ACPI / scan: Parse _CCA and setup device coherency
-rw-r--r--arch/arm64/Kconfig1
-rw-r--r--arch/arm64/include/asm/dma-mapping.h18
-rw-r--r--arch/arm64/mm/dma-mapping.c92
-rw-r--r--drivers/acpi/Kconfig3
-rw-r--r--drivers/acpi/acpi_platform.c2
-rw-r--r--drivers/acpi/glue.c5
-rw-r--r--drivers/acpi/scan.c35
-rw-r--r--drivers/base/property.c14
-rw-r--r--drivers/crypto/ccp/ccp-platform.c60
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-main.c27
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_fp.c8
-rw-r--r--drivers/scsi/ufs/unipro.h8
-rw-r--r--include/acpi/acpi_bus.h37
-rw-r--r--include/linux/acpi.h5
-rw-r--r--include/linux/property.h2
15 files changed, 228 insertions, 89 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7796af4b1d6f..6be1a6efcdd6 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,5 +1,6 @@
1config ARM64 1config ARM64
2 def_bool y 2 def_bool y
3 select ACPI_CCA_REQUIRED if ACPI
3 select ACPI_GENERIC_GSI if ACPI 4 select ACPI_GENERIC_GSI if ACPI
4 select ACPI_REDUCED_HARDWARE_ONLY if ACPI 5 select ACPI_REDUCED_HARDWARE_ONLY if ACPI
5 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 6 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 9437e3dc5833..f0d6d0bfe55c 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -18,6 +18,7 @@
18 18
19#ifdef __KERNEL__ 19#ifdef __KERNEL__
20 20
21#include <linux/acpi.h>
21#include <linux/types.h> 22#include <linux/types.h>
22#include <linux/vmalloc.h> 23#include <linux/vmalloc.h>
23 24
@@ -28,13 +29,23 @@
28 29
29#define DMA_ERROR_CODE (~(dma_addr_t)0) 30#define DMA_ERROR_CODE (~(dma_addr_t)0)
30extern struct dma_map_ops *dma_ops; 31extern struct dma_map_ops *dma_ops;
32extern struct dma_map_ops dummy_dma_ops;
31 33
32static inline struct dma_map_ops *__generic_dma_ops(struct device *dev) 34static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
33{ 35{
34 if (unlikely(!dev) || !dev->archdata.dma_ops) 36 if (unlikely(!dev))
35 return dma_ops; 37 return dma_ops;
36 else 38 else if (dev->archdata.dma_ops)
37 return dev->archdata.dma_ops; 39 return dev->archdata.dma_ops;
40 else if (acpi_disabled)
41 return dma_ops;
42
43 /*
44 * When ACPI is enabled, if arch_set_dma_ops is not called,
45 * we will disable device DMA capability by setting it
46 * to dummy_dma_ops.
47 */
48 return &dummy_dma_ops;
38} 49}
39 50
40static inline struct dma_map_ops *get_dma_ops(struct device *dev) 51static 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)
48static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, 59static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
49 struct iommu_ops *iommu, bool coherent) 60 struct iommu_ops *iommu, bool coherent)
50{ 61{
62 if (!acpi_disabled && !dev->archdata.dma_ops)
63 dev->archdata.dma_ops = dma_ops;
64
51 dev->archdata.dma_coherent = coherent; 65 dev->archdata.dma_coherent = coherent;
52} 66}
53#define arch_setup_dma_ops arch_setup_dma_ops 67#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 b0bd4e5fd5cf..d16a1cead23f 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -414,6 +414,98 @@ out:
414 return -ENOMEM; 414 return -ENOMEM;
415} 415}
416 416
417/********************************************
418 * The following APIs are for dummy DMA ops *
419 ********************************************/
420
421static void *__dummy_alloc(struct device *dev, size_t size,
422 dma_addr_t *dma_handle, gfp_t flags,
423 struct dma_attrs *attrs)
424{
425 return NULL;
426}
427
428static void __dummy_free(struct device *dev, size_t size,
429 void *vaddr, dma_addr_t dma_handle,
430 struct dma_attrs *attrs)
431{
432}
433
434static int __dummy_mmap(struct device *dev,
435 struct vm_area_struct *vma,
436 void *cpu_addr, dma_addr_t dma_addr, size_t size,
437 struct dma_attrs *attrs)
438{
439 return -ENXIO;
440}
441
442static dma_addr_t __dummy_map_page(struct device *dev, struct page *page,
443 unsigned long offset, size_t size,
444 enum dma_data_direction dir,
445 struct dma_attrs *attrs)
446{
447 return DMA_ERROR_CODE;
448}
449
450static void __dummy_unmap_page(struct device *dev, dma_addr_t dev_addr,
451 size_t size, enum dma_data_direction dir,
452 struct dma_attrs *attrs)
453{
454}
455
456static int __dummy_map_sg(struct device *dev, struct scatterlist *sgl,
457 int nelems, enum dma_data_direction dir,
458 struct dma_attrs *attrs)
459{
460 return 0;
461}
462
463static void __dummy_unmap_sg(struct device *dev,
464 struct scatterlist *sgl, int nelems,
465 enum dma_data_direction dir,
466 struct dma_attrs *attrs)
467{
468}
469
470static void __dummy_sync_single(struct device *dev,
471 dma_addr_t dev_addr, size_t size,
472 enum dma_data_direction dir)
473{
474}
475
476static void __dummy_sync_sg(struct device *dev,
477 struct scatterlist *sgl, int nelems,
478 enum dma_data_direction dir)
479{
480}
481
482static int __dummy_mapping_error(struct device *hwdev, dma_addr_t dma_addr)
483{
484 return 1;
485}
486
487static int __dummy_dma_supported(struct device *hwdev, u64 mask)
488{
489 return 0;
490}
491
492struct dma_map_ops dummy_dma_ops = {
493 .alloc = __dummy_alloc,
494 .free = __dummy_free,
495 .mmap = __dummy_mmap,
496 .map_page = __dummy_map_page,
497 .unmap_page = __dummy_unmap_page,
498 .map_sg = __dummy_map_sg,
499 .unmap_sg = __dummy_unmap_sg,
500 .sync_single_for_cpu = __dummy_sync_single,
501 .sync_single_for_device = __dummy_sync_single,
502 .sync_sg_for_cpu = __dummy_sync_sg,
503 .sync_sg_for_device = __dummy_sync_sg,
504 .mapping_error = __dummy_mapping_error,
505 .dma_supported = __dummy_dma_supported,
506};
507EXPORT_SYMBOL(dummy_dma_ops);
508
417static int __init arm64_dma_init(void) 509static int __init arm64_dma_init(void)
418{ 510{
419 int ret; 511 int ret;
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 16da18597def..35da507411a0 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -54,6 +54,9 @@ config ACPI_GENERIC_GSI
54config ACPI_SYSTEM_POWER_STATES_SUPPORT 54config ACPI_SYSTEM_POWER_STATES_SUPPORT
55 bool 55 bool
56 56
57config ACPI_CCA_REQUIRED
58 bool
59
57config ACPI_SLEEP 60config ACPI_SLEEP
58 bool 61 bool
59 depends on SUSPEND || HIBERNATION 62 depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 4bf75597f732..06a67d5f2846 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -103,7 +103,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
103 pdevinfo.res = resources; 103 pdevinfo.res = resources;
104 pdevinfo.num_res = count; 104 pdevinfo.num_res = count;
105 pdevinfo.fwnode = acpi_fwnode_handle(adev); 105 pdevinfo.fwnode = acpi_fwnode_handle(adev);
106 pdevinfo.dma_mask = DMA_BIT_MASK(32); 106 pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0;
107 pdev = platform_device_register_full(&pdevinfo); 107 pdev = platform_device_register_full(&pdevinfo);
108 if (IS_ERR(pdev)) 108 if (IS_ERR(pdev))
109 dev_err(&adev->dev, "platform device creation failed: %ld\n", 109 dev_err(&adev->dev, "platform device creation failed: %ld\n",
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 39c485b0c25c..b9657af751d1 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/rwsem.h> 14#include <linux/rwsem.h>
15#include <linux/acpi.h> 15#include <linux/acpi.h>
16#include <linux/dma-mapping.h>
16 17
17#include "internal.h" 18#include "internal.h"
18 19
@@ -167,6 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
167 struct list_head *physnode_list; 168 struct list_head *physnode_list;
168 unsigned int node_id; 169 unsigned int node_id;
169 int retval = -EINVAL; 170 int retval = -EINVAL;
171 bool coherent;
170 172
171 if (has_acpi_companion(dev)) { 173 if (has_acpi_companion(dev)) {
172 if (acpi_dev) { 174 if (acpi_dev) {
@@ -223,6 +225,9 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
223 if (!has_acpi_companion(dev)) 225 if (!has_acpi_companion(dev))
224 ACPI_COMPANION_SET(dev, acpi_dev); 226 ACPI_COMPANION_SET(dev, acpi_dev);
225 227
228 if (acpi_check_dma(acpi_dev, &coherent))
229 arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
230
226 acpi_physnode_link_name(physical_node_name, node_id); 231 acpi_physnode_link_name(physical_node_name, node_id);
227 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj, 232 retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
228 physical_node_name); 233 physical_node_name);
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 4bbc8f89257f..2649a068671d 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -11,6 +11,7 @@
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/nls.h> 13#include <linux/nls.h>
14#include <linux/dma-mapping.h>
14 15
15#include <asm/pgtable.h> 16#include <asm/pgtable.h>
16 17
@@ -2153,6 +2154,39 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
2153 kfree(pnp->unique_id); 2154 kfree(pnp->unique_id);
2154} 2155}
2155 2156
2157static void acpi_init_coherency(struct acpi_device *adev)
2158{
2159 unsigned long long cca = 0;
2160 acpi_status status;
2161 struct acpi_device *parent = adev->parent;
2162
2163 if (parent && parent->flags.cca_seen) {
2164 /*
2165 * From ACPI spec, OSPM will ignore _CCA if an ancestor
2166 * already saw one.
2167 */
2168 adev->flags.cca_seen = 1;
2169 cca = parent->flags.coherent_dma;
2170 } else {
2171 status = acpi_evaluate_integer(adev->handle, "_CCA",
2172 NULL, &cca);
2173 if (ACPI_SUCCESS(status))
2174 adev->flags.cca_seen = 1;
2175 else if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED))
2176 /*
2177 * If architecture does not specify that _CCA is
2178 * required for DMA-able devices (e.g. x86),
2179 * we default to _CCA=1.
2180 */
2181 cca = 1;
2182 else
2183 acpi_handle_debug(adev->handle,
2184 "ACPI device is missing _CCA.\n");
2185 }
2186
2187 adev->flags.coherent_dma = cca;
2188}
2189
2156void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 2190void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
2157 int type, unsigned long long sta) 2191 int type, unsigned long long sta)
2158{ 2192{
@@ -2171,6 +2205,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
2171 device->flags.visited = false; 2205 device->flags.visited = false;
2172 device_initialize(&device->dev); 2206 device_initialize(&device->dev);
2173 dev_set_uevent_suppress(&device->dev, true); 2207 dev_set_uevent_suppress(&device->dev, true);
2208 acpi_init_coherency(device);
2174} 2209}
2175 2210
2176void acpi_device_add_finalize(struct acpi_device *device) 2211void acpi_device_add_finalize(struct acpi_device *device)
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 1d0b116cae95..e645852396ba 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -14,6 +14,7 @@
14#include <linux/export.h> 14#include <linux/export.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <linux/of_address.h>
17#include <linux/property.h> 18#include <linux/property.h>
18 19
19/** 20/**
@@ -519,3 +520,16 @@ unsigned int device_get_child_node_count(struct device *dev)
519 return count; 520 return count;
520} 521}
521EXPORT_SYMBOL_GPL(device_get_child_node_count); 522EXPORT_SYMBOL_GPL(device_get_child_node_count);
523
524bool device_dma_is_coherent(struct device *dev)
525{
526 bool coherent = false;
527
528 if (IS_ENABLED(CONFIG_OF) && dev->of_node)
529 coherent = of_dma_is_coherent(dev->of_node);
530 else
531 acpi_check_dma(ACPI_COMPANION(dev), &coherent);
532
533 return coherent;
534}
535EXPORT_SYMBOL_GPL(device_dma_is_coherent);
diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c
index b1c20b2b5647..e446781b1892 100644
--- a/drivers/crypto/ccp/ccp-platform.c
+++ b/drivers/crypto/ccp/ccp-platform.c
@@ -90,58 +90,6 @@ static struct resource *ccp_find_mmio_area(struct ccp_device *ccp)
90 return NULL; 90 return NULL;
91} 91}
92 92
93#ifdef CONFIG_ACPI
94static int ccp_acpi_support(struct ccp_device *ccp)
95{
96 struct ccp_platform *ccp_platform = ccp->dev_specific;
97 struct acpi_device *adev = ACPI_COMPANION(ccp->dev);
98 acpi_handle handle;
99 acpi_status status;
100 unsigned long long data;
101 int cca;
102
103 /* Retrieve the device cache coherency value */
104 handle = adev->handle;
105 do {
106 status = acpi_evaluate_integer(handle, "_CCA", NULL, &data);
107 if (!ACPI_FAILURE(status)) {
108 cca = data;
109 break;
110 }
111 } while (!ACPI_FAILURE(status));
112
113 if (ACPI_FAILURE(status)) {
114 dev_err(ccp->dev, "error obtaining acpi coherency value\n");
115 return -EINVAL;
116 }
117
118 ccp_platform->coherent = !!cca;
119
120 return 0;
121}
122#else /* CONFIG_ACPI */
123static int ccp_acpi_support(struct ccp_device *ccp)
124{
125 return -EINVAL;
126}
127#endif
128
129#ifdef CONFIG_OF
130static int ccp_of_support(struct ccp_device *ccp)
131{
132 struct ccp_platform *ccp_platform = ccp->dev_specific;
133
134 ccp_platform->coherent = of_dma_is_coherent(ccp->dev->of_node);
135
136 return 0;
137}
138#else
139static int ccp_of_support(struct ccp_device *ccp)
140{
141 return -EINVAL;
142}
143#endif
144
145static int ccp_platform_probe(struct platform_device *pdev) 93static int ccp_platform_probe(struct platform_device *pdev)
146{ 94{
147 struct ccp_device *ccp; 95 struct ccp_device *ccp;
@@ -182,13 +130,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
182 goto e_err; 130 goto e_err;
183 } 131 }
184 132
185 if (ccp_platform->use_acpi) 133 ccp_platform->coherent = device_dma_is_coherent(ccp->dev);
186 ret = ccp_acpi_support(ccp);
187 else
188 ret = ccp_of_support(ccp);
189 if (ret)
190 goto e_err;
191
192 if (ccp_platform->coherent) 134 if (ccp_platform->coherent)
193 ccp->axcache = CACHE_WB_NO_ALLOC; 135 ccp->axcache = CACHE_WB_NO_ALLOC;
194 else 136 else
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 714905384900..6d2c702c8e4a 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -168,13 +168,8 @@ static void xgbe_init_all_fptrs(struct xgbe_prv_data *pdata)
168#ifdef CONFIG_ACPI 168#ifdef CONFIG_ACPI
169static int xgbe_acpi_support(struct xgbe_prv_data *pdata) 169static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
170{ 170{
171 struct acpi_device *adev = pdata->adev;
172 struct device *dev = pdata->dev; 171 struct device *dev = pdata->dev;
173 u32 property; 172 u32 property;
174 acpi_handle handle;
175 acpi_status status;
176 unsigned long long data;
177 int cca;
178 int ret; 173 int ret;
179 174
180 /* Obtain the system clock setting */ 175 /* Obtain the system clock setting */
@@ -195,24 +190,6 @@ static int xgbe_acpi_support(struct xgbe_prv_data *pdata)
195 } 190 }
196 pdata->ptpclk_rate = property; 191 pdata->ptpclk_rate = property;
197 192
198 /* Retrieve the device cache coherency value */
199 handle = adev->handle;
200 do {
201 status = acpi_evaluate_integer(handle, "_CCA", NULL, &data);
202 if (!ACPI_FAILURE(status)) {
203 cca = data;
204 break;
205 }
206
207 status = acpi_get_parent(handle, &handle);
208 } while (!ACPI_FAILURE(status));
209
210 if (ACPI_FAILURE(status)) {
211 dev_err(dev, "error obtaining acpi coherency value\n");
212 return -EINVAL;
213 }
214 pdata->coherent = !!cca;
215
216 return 0; 193 return 0;
217} 194}
218#else /* CONFIG_ACPI */ 195#else /* CONFIG_ACPI */
@@ -243,9 +220,6 @@ static int xgbe_of_support(struct xgbe_prv_data *pdata)
243 } 220 }
244 pdata->ptpclk_rate = clk_get_rate(pdata->ptpclk); 221 pdata->ptpclk_rate = clk_get_rate(pdata->ptpclk);
245 222
246 /* Retrieve the device cache coherency value */
247 pdata->coherent = of_dma_is_coherent(dev->of_node);
248
249 return 0; 223 return 0;
250} 224}
251#else /* CONFIG_OF */ 225#else /* CONFIG_OF */
@@ -364,6 +338,7 @@ static int xgbe_probe(struct platform_device *pdev)
364 goto err_io; 338 goto err_io;
365 339
366 /* Set the DMA coherency values */ 340 /* Set the DMA coherency values */
341 pdata->coherent = device_dma_is_coherent(pdata->dev);
367 if (pdata->coherent) { 342 if (pdata->coherent) {
368 pdata->axdomain = XGBE_DMA_OS_AXDOMAIN; 343 pdata->axdomain = XGBE_DMA_OS_AXDOMAIN;
369 pdata->arcache = XGBE_DMA_OS_ARCACHE; 344 pdata->arcache = XGBE_DMA_OS_ARCACHE;
diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c
index 4f72287860ee..e8b7a69428b6 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fp.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fp.c
@@ -66,7 +66,15 @@ MODULE_PARM_DESC(lb_pending_cmds, "Change raid-1 load balancing outstanding "
66 66
67#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) 67#define ABS_DIFF(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a)))
68#define MR_LD_STATE_OPTIMAL 3 68#define MR_LD_STATE_OPTIMAL 3
69
70#ifdef FALSE
71#undef FALSE
72#endif
69#define FALSE 0 73#define FALSE 0
74
75#ifdef TRUE
76#undef TRUE
77#endif
70#define TRUE 1 78#define TRUE 1
71 79
72#define SPAN_DEBUG 0 80#define SPAN_DEBUG 0
diff --git a/drivers/scsi/ufs/unipro.h b/drivers/scsi/ufs/unipro.h
index 3fc3e21b746b..816a8a46efb8 100644
--- a/drivers/scsi/ufs/unipro.h
+++ b/drivers/scsi/ufs/unipro.h
@@ -198,6 +198,14 @@ enum ufs_hs_gear_tag {
198#define T_TC0TXMAXSDUSIZE 0x4060 198#define T_TC0TXMAXSDUSIZE 0x4060
199#define T_TC1TXMAXSDUSIZE 0x4061 199#define T_TC1TXMAXSDUSIZE 0x4061
200 200
201#ifdef FALSE
202#undef FALSE
203#endif
204
205#ifdef TRUE
206#undef TRUE
207#endif
208
201/* Boolean attribute values */ 209/* Boolean attribute values */
202enum { 210enum {
203 FALSE = 0, 211 FALSE = 0,
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5dec08d7aa64..b43276f339ef 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -209,7 +209,9 @@ struct acpi_device_flags {
209 u32 hotplug_notify:1; 209 u32 hotplug_notify:1;
210 u32 is_dock_station:1; 210 u32 is_dock_station:1;
211 u32 of_compatible_ok:1; 211 u32 of_compatible_ok:1;
212 u32 reserved:22; 212 u32 coherent_dma:1;
213 u32 cca_seen:1;
214 u32 reserved:20;
213}; 215};
214 216
215/* File System */ 217/* File System */
@@ -380,6 +382,39 @@ struct acpi_device {
380 void (*remove)(struct acpi_device *); 382 void (*remove)(struct acpi_device *);
381}; 383};
382 384
385static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
386{
387 bool ret = false;
388
389 if (!adev)
390 return ret;
391
392 /**
393 * Currently, we only support _CCA=1 (i.e. coherent_dma=1)
394 * This should be equivalent to specifyig dma-coherent for
395 * a device in OF.
396 *
397 * For the case when _CCA=0 (i.e. coherent_dma=0 && cca_seen=1),
398 * There are two cases:
399 * case 1. Do not support and disable DMA.
400 * case 2. Support but rely on arch-specific cache maintenance for
401 * non-coherence DMA operations.
402 * Currently, we implement case 1 above.
403 *
404 * For the case when _CCA is missing (i.e. cca_seen=0) and
405 * platform specifies ACPI_CCA_REQUIRED, we do not support DMA,
406 * and fallback to arch-specific default handling.
407 *
408 * See acpi_init_coherency() for more info.
409 */
410 if (adev->flags.coherent_dma) {
411 ret = true;
412 if (coherent)
413 *coherent = adev->flags.coherent_dma;
414 }
415 return ret;
416}
417
383static inline bool is_acpi_node(struct fwnode_handle *fwnode) 418static inline bool is_acpi_node(struct fwnode_handle *fwnode)
384{ 419{
385 return fwnode && fwnode->type == FWNODE_ACPI; 420 return fwnode && fwnode->type == FWNODE_ACPI;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 81afa65e6457..400b86453ed7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -553,6 +553,11 @@ static inline int acpi_device_modalias(struct device *dev,
553 return -ENODEV; 553 return -ENODEV;
554} 554}
555 555
556static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
557{
558 return false;
559}
560
556#define ACPI_PTR(_ptr) (NULL) 561#define ACPI_PTR(_ptr) (NULL)
557 562
558#endif /* !CONFIG_ACPI */ 563#endif /* !CONFIG_ACPI */
diff --git a/include/linux/property.h b/include/linux/property.h
index de8bdf417a35..76ebde9c11d4 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -164,4 +164,6 @@ struct property_set {
164 164
165void device_add_property_set(struct device *dev, struct property_set *pset); 165void device_add_property_set(struct device *dev, struct property_set *pset);
166 166
167bool device_dma_is_coherent(struct device *dev);
168
167#endif /* _LINUX_PROPERTY_H_ */ 169#endif /* _LINUX_PROPERTY_H_ */