File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 7
7
#define pr_fmt (fmt ) "iommu: " fmt
8
8
9
9
#include <linux/device.h>
10
+ #include <linux/dma-iommu.h>
10
11
#include <linux/kernel.h>
11
12
#include <linux/bits.h>
12
13
#include <linux/bug.h>
@@ -1946,6 +1947,11 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
1946
1947
/* Assume all sizes by default; the driver may override this later */
1947
1948
domain -> pgsize_bitmap = bus -> iommu_ops -> pgsize_bitmap ;
1948
1949
1950
+ /* Temporarily avoid -EEXIST while drivers still get their own cookies */
1951
+ if (type == IOMMU_DOMAIN_DMA && !domain -> iova_cookie && iommu_get_dma_cookie (domain )) {
1952
+ iommu_domain_free (domain );
1953
+ domain = NULL ;
1954
+ }
1949
1955
return domain ;
1950
1956
}
1951
1957
@@ -1957,6 +1963,7 @@ EXPORT_SYMBOL_GPL(iommu_domain_alloc);
1957
1963
1958
1964
void iommu_domain_free (struct iommu_domain * domain )
1959
1965
{
1966
+ iommu_put_dma_cookie (domain );
1960
1967
domain -> ops -> domain_free (domain );
1961
1968
}
1962
1969
EXPORT_SYMBOL_GPL (iommu_domain_free );
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ struct iommu_domain;
40
40
struct notifier_block ;
41
41
struct iommu_sva ;
42
42
struct iommu_fault_event ;
43
+ struct iommu_dma_cookie ;
43
44
44
45
/* iommu fault flags */
45
46
#define IOMMU_FAULT_READ 0x0
@@ -86,7 +87,7 @@ struct iommu_domain {
86
87
iommu_fault_handler_t handler ;
87
88
void * handler_token ;
88
89
struct iommu_domain_geometry geometry ;
89
- void * iova_cookie ;
90
+ struct iommu_dma_cookie * iova_cookie ;
90
91
};
91
92
92
93
enum iommu_cap {
You can’t perform that action at this time.
0 commit comments