Skip to content

Commit 6f2beb2

Browse files
Claire Changkonradwilk
authored andcommitted
swiotlb: Update is_swiotlb_active to add a struct device argument
Update is_swiotlb_active to add a struct device argument. This will be useful later to allow for different pools. Signed-off-by: Claire Chang <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Tested-by: Stefano Stabellini <[email protected]> Tested-by: Will Deacon <[email protected]> Acked-by: Stefano Stabellini <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 7fd856a commit 6f2beb2

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

drivers/gpu/drm/i915/gem/i915_gem_internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)
4242

4343
max_order = MAX_ORDER;
4444
#ifdef CONFIG_SWIOTLB
45-
if (is_swiotlb_active()) {
45+
if (is_swiotlb_active(obj->base.dev->dev)) {
4646
unsigned int max_segment;
4747

4848
max_segment = swiotlb_max_segment();

drivers/gpu/drm/nouveau/nouveau_ttm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
276276
}
277277

278278
#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
279-
need_swiotlb = is_swiotlb_active();
279+
need_swiotlb = is_swiotlb_active(dev->dev);
280280
#endif
281281

282282
ret = ttm_device_init(&drm->ttm.bdev, &nouveau_bo_driver, drm->dev->dev,

drivers/pci/xen-pcifront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static int pcifront_connect_and_init_dma(struct pcifront_device *pdev)
693693

694694
spin_unlock(&pcifront_dev_lock);
695695

696-
if (!err && !is_swiotlb_active()) {
696+
if (!err && !is_swiotlb_active(&pdev->xdev->dev)) {
697697
err = pci_xen_swiotlb_init_late();
698698
if (err)
699699
dev_err(&pdev->xdev->dev, "Could not setup SWIOTLB!\n");

include/linux/swiotlb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
112112
void __init swiotlb_exit(void);
113113
unsigned int swiotlb_max_segment(void);
114114
size_t swiotlb_max_mapping_size(struct device *dev);
115-
bool is_swiotlb_active(void);
115+
bool is_swiotlb_active(struct device *dev);
116116
void __init swiotlb_adjust_size(unsigned long size);
117117
#else
118118
#define swiotlb_force SWIOTLB_NO_FORCE
@@ -132,7 +132,7 @@ static inline size_t swiotlb_max_mapping_size(struct device *dev)
132132
return SIZE_MAX;
133133
}
134134

135-
static inline bool is_swiotlb_active(void)
135+
static inline bool is_swiotlb_active(struct device *dev)
136136
{
137137
return false;
138138
}

kernel/dma/direct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ int dma_direct_supported(struct device *dev, u64 mask)
495495
size_t dma_direct_max_mapping_size(struct device *dev)
496496
{
497497
/* If SWIOTLB is active, use its maximum mapping size */
498-
if (is_swiotlb_active() &&
498+
if (is_swiotlb_active(dev) &&
499499
(dma_addressing_limited(dev) || swiotlb_force == SWIOTLB_FORCE))
500500
return swiotlb_max_mapping_size(dev);
501501
return SIZE_MAX;

kernel/dma/swiotlb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ size_t swiotlb_max_mapping_size(struct device *dev)
662662
return ((size_t)IO_TLB_SIZE) * IO_TLB_SEGSIZE;
663663
}
664664

665-
bool is_swiotlb_active(void)
665+
bool is_swiotlb_active(struct device *dev)
666666
{
667-
return io_tlb_default_mem != NULL;
667+
return dev->dma_io_tlb_mem != NULL;
668668
}
669669
EXPORT_SYMBOL_GPL(is_swiotlb_active);
670670

0 commit comments

Comments
 (0)