Hi Janusz,
> > > +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> > > @@ -156,7 +156,7 @@ int shmem_sg_alloc_table(struct drm_i915_private
> > > *i915, struct sg_table *st,
> > > nr_pages = min_array(((unsigned long[]) {
> > > folio_nr_pages(folio),
> > > page_count - i,
> > > - max_segment / PAGE_SIZE,
> > > + i915_sg_segment_size(i915->drm.dev) /
> > > PAGE_SIZE,
> > I don't think we can use i915_sg_segment_size() here, please correct me
> > if I'm wrong.
>
[part of the comment cut here]
> That said, I think we need to revisit the issue identified by Krzysztof and
> try to find its root cause again. Maybe we should also revisit either the
> idea or implementation of allocating one page per scatterlist in case when
> allocating larger chunks failed, because that seems to be strictly related
> to what Krzysztof describes as problematic in his commit description ("...
> sg_set_folio() was called multiple times with nr_pages smaller than folio
> size, using many scatterlists, all pointing to the beginning pages of the
> folio and never fully covering its range of pages ...").
I wanted to avoid re-implementing the hard to read parts of the
code my changes touch in this series, but since it turns out to
be bigger deal than I thought, I may do that as well.
--
Best Regards,
Krzysztof