@@ -2251,14 +2251,13 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
goto err_pages;
}
}
-#ifdef CONFIG_SWIOTLB
- if (swiotlb_nr_tbl()) {
+ if (swiotlb_in_use(obj->base.dev->dev)) {
st->nents++;
sg_set_page(sg, page, PAGE_SIZE, 0);
sg = sg_next(sg);
continue;
}
-#endif
+
if (!i || page_to_pfn(page) != last_pfn + 1) {
if (i)
sg = sg_next(sg);
@@ -2272,9 +2271,7 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
/* Check that the i965g/gm workaround works. */
WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL));
}
-#ifdef CONFIG_SWIOTLB
- if (!swiotlb_nr_tbl())
-#endif
+ if (!swiotlb_in_use(obj->base.dev->dev))
sg_mark_end(sg);
obj->pages = st;
@@ -506,14 +506,9 @@ struct get_pages_work {
struct task_struct *task;
};
-#if IS_ENABLED(CONFIG_SWIOTLB)
-#define swiotlb_active() swiotlb_nr_tbl()
-#else
-#define swiotlb_active() 0
-#endif
-
static int
-st_set_pages(struct sg_table **st, struct page **pvec, int num_pages)
+st_set_pages(struct device *dev, struct sg_table **st,
+ struct page **pvec, int num_pages)
{
struct scatterlist *sg;
int ret, n;
@@ -522,7 +517,7 @@ st_set_pages(struct sg_table **st, struct page **pvec, int num_pages)
if (*st == NULL)
return -ENOMEM;
- if (swiotlb_active()) {
+ if (swiotlb_in_use(dev)) {
ret = sg_alloc_table(*st, num_pages, GFP_KERNEL);
if (ret)
goto err;
@@ -549,9 +544,10 @@ static int
__i915_gem_userptr_set_pages(struct drm_i915_gem_object *obj,
struct page **pvec, int num_pages)
{
+ struct device *dev = obj->base.dev->dev;
int ret;
- ret = st_set_pages(&obj->pages, pvec, num_pages);
+ ret = st_set_pages(dev, &obj->pages, pvec, num_pages);
if (ret)
return ret;