Message ID | 20191217115750.11938-1-abdiel.janulgue@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/2] drm/i915: Add lmem fault handler | expand |
Quoting Abdiel Janulgue (2019-12-17 11:57:49) > Fault handler to handle missing pages for lmem objects. > > v4: Restore non-contigous fault handling in addition to remap_io_mapping > > Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> > Signed-off-by: Matthew Auld <matthew.auld@intel.com> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > --- > drivers/gpu/drm/i915/gem/i915_gem_lmem.c | 13 +++++ > drivers/gpu/drm/i915/gem/i915_gem_lmem.h | 4 ++ > drivers/gpu/drm/i915/gem/i915_gem_mman.c | 71 ++++++++++++++++++++++-- > 3 files changed, 84 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > index 520cc9cac471..e8326d8b66f7 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c > @@ -6,6 +6,7 @@ > #include "intel_memory_region.h" > #include "gem/i915_gem_region.h" > #include "gem/i915_gem_lmem.h" > +#include "gem/i915_gem_mman.h" > #include "i915_drv.h" > > const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = { > @@ -56,6 +57,18 @@ i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj, > return io_mapping_map_wc(&obj->mm.region->iomap, offset, size); > } > > +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, > + unsigned long n) > +{ > + struct intel_memory_region *mem = obj->mm.region; > + resource_size_t offset; > + > + offset = i915_gem_object_get_dma_address(obj, n); > + offset -= mem->region.start; > + > + return (mem->io_start + offset) >> PAGE_SHIFT; > +} > + > bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj) > { > return obj->ops == &i915_gem_lmem_obj_ops; > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h > index 7c176b8b7d2f..4d5fca1a3e0e 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h > +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h > @@ -7,6 +7,7 @@ > #define __I915_GEM_LMEM_H > > #include <linux/types.h> > +#include <linux/mman.h> > > struct drm_i915_private; > struct drm_i915_gem_object; > @@ -22,6 +23,9 @@ void __iomem * > i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj, > unsigned long n); > > +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, > + unsigned long n); > + > bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); > > struct drm_i915_gem_object * > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c > index 879fff8adc48..f5f7af745d1d 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c > @@ -11,6 +11,7 @@ > #include "gt/intel_gt.h" > #include "gt/intel_gt_requests.h" > > +#include "i915_gem_lmem.h" > #include "i915_drv.h" > #include "i915_gem_gtt.h" > #include "i915_gem_ioctls.h" > @@ -216,6 +217,7 @@ static vm_fault_t i915_error_to_vmf_fault(int err) > > case -ENOSPC: /* shmemfs allocation failure */ > case -ENOMEM: /* our allocation failure */ > + case -ENXIO: > return VM_FAULT_OOM; > > case 0: > @@ -274,6 +276,47 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) > return ret; > } > > +vm_fault_t vm_fault_iomem(struct vm_fault *vmf) > +{ > + struct vm_area_struct *area = vmf->vma; > + struct i915_mmap_offset *priv = area->vm_private_data; > + struct drm_i915_gem_object *obj = priv->obj; > + struct intel_memory_region *mem = obj->mm.region; > + unsigned long i, size = area->vm_end - area->vm_start; > + bool write = area->vm_flags & VM_WRITE; > + int ret; > + > + /* Sanity check that we allow writing into this object */ > + if (i915_gem_object_is_readonly(obj) && write) > + return VM_FAULT_SIGBUS; > + > + ret = i915_gem_object_pin_pages(obj); > + if (ret) > + return i915_error_to_vmf_fault(ret); > + > + if (obj->flags & I915_BO_ALLOC_CONTIGUOUS) { > + ret = remap_io_mapping(area, area->vm_start, > + i915_gem_object_lmem_io_pfn(obj, 0), size, > + &mem->iomap); > + i915_gem_object_unpin_pages(obj); > + return i915_error_to_vmf_fault(ret); > + } else { > + vm_fault_t vmf_ret = VM_FAULT_SIGBUS; > + if (GEM_WARN_ON(size < PAGE_SIZE)) > + return vmf_ret; > + > + for (i = 0; i < size >> PAGE_SHIFT; i++) { > + vmf_ret = vmf_insert_pfn(area, > + (unsigned long)area->vm_start + i * PAGE_SIZE, > + i915_gem_object_lmem_io_pfn(obj, i)); Sigh. -Chris
On 17/12/2019 14.14, Chris Wilson wrote: > Quoting Abdiel Janulgue (2019-12-17 11:57:49) >> Fault handler to handle missing pages for lmem objects. >> >> v4: Restore non-contigous fault handling in addition to remap_io_mapping >> >> Signed-off-by: Abdiel Janulgue <abdiel.janulgue@linux.intel.com> >> Signed-off-by: Matthew Auld <matthew.auld@intel.com> >> Cc: Chris Wilson <chris@chris-wilson.co.uk> >> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> >> --- >> drivers/gpu/drm/i915/gem/i915_gem_lmem.c | 13 +++++ >> drivers/gpu/drm/i915/gem/i915_gem_lmem.h | 4 ++ >> drivers/gpu/drm/i915/gem/i915_gem_mman.c | 71 ++++++++++++++++++++++-- >> 3 files changed, 84 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c >> index 520cc9cac471..e8326d8b66f7 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c >> @@ -6,6 +6,7 @@ >> #include "intel_memory_region.h" >> #include "gem/i915_gem_region.h" >> #include "gem/i915_gem_lmem.h" >> +#include "gem/i915_gem_mman.h" >> #include "i915_drv.h" >> >> const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = { >> @@ -56,6 +57,18 @@ i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj, >> return io_mapping_map_wc(&obj->mm.region->iomap, offset, size); >> } >> >> +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, >> + unsigned long n) >> +{ >> + struct intel_memory_region *mem = obj->mm.region; >> + resource_size_t offset; >> + >> + offset = i915_gem_object_get_dma_address(obj, n); >> + offset -= mem->region.start; >> + >> + return (mem->io_start + offset) >> PAGE_SHIFT; >> +} >> + >> bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj) >> { >> return obj->ops == &i915_gem_lmem_obj_ops; >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h >> index 7c176b8b7d2f..4d5fca1a3e0e 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h >> @@ -7,6 +7,7 @@ >> #define __I915_GEM_LMEM_H >> >> #include <linux/types.h> >> +#include <linux/mman.h> >> >> struct drm_i915_private; >> struct drm_i915_gem_object; >> @@ -22,6 +23,9 @@ void __iomem * >> i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj, >> unsigned long n); >> >> +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, >> + unsigned long n); >> + >> bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); >> >> struct drm_i915_gem_object * >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> index 879fff8adc48..f5f7af745d1d 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c >> @@ -11,6 +11,7 @@ >> #include "gt/intel_gt.h" >> #include "gt/intel_gt_requests.h" >> >> +#include "i915_gem_lmem.h" >> #include "i915_drv.h" >> #include "i915_gem_gtt.h" >> #include "i915_gem_ioctls.h" >> @@ -216,6 +217,7 @@ static vm_fault_t i915_error_to_vmf_fault(int err) >> >> case -ENOSPC: /* shmemfs allocation failure */ >> case -ENOMEM: /* our allocation failure */ >> + case -ENXIO: >> return VM_FAULT_OOM; >> >> case 0: >> @@ -274,6 +276,47 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) >> return ret; >> } >> >> +vm_fault_t vm_fault_iomem(struct vm_fault *vmf) >> +{ >> + struct vm_area_struct *area = vmf->vma; >> + struct i915_mmap_offset *priv = area->vm_private_data; >> + struct drm_i915_gem_object *obj = priv->obj; >> + struct intel_memory_region *mem = obj->mm.region; >> + unsigned long i, size = area->vm_end - area->vm_start; >> + bool write = area->vm_flags & VM_WRITE; >> + int ret; >> + >> + /* Sanity check that we allow writing into this object */ >> + if (i915_gem_object_is_readonly(obj) && write) >> + return VM_FAULT_SIGBUS; >> + >> + ret = i915_gem_object_pin_pages(obj); >> + if (ret) >> + return i915_error_to_vmf_fault(ret); >> + >> + if (obj->flags & I915_BO_ALLOC_CONTIGUOUS) { >> + ret = remap_io_mapping(area, area->vm_start, >> + i915_gem_object_lmem_io_pfn(obj, 0), size, >> + &mem->iomap); >> + i915_gem_object_unpin_pages(obj); >> + return i915_error_to_vmf_fault(ret); >> + } else { >> + vm_fault_t vmf_ret = VM_FAULT_SIGBUS; >> + if (GEM_WARN_ON(size < PAGE_SIZE)) >> + return vmf_ret; >> + >> + for (i = 0; i < size >> PAGE_SHIFT; i++) { >> + vmf_ret = vmf_insert_pfn(area, >> + (unsigned long)area->vm_start + i * PAGE_SIZE, >> + i915_gem_object_lmem_io_pfn(obj, i)); > > Sigh. :( if you really need remap_io_mapping, I'm afraid I need help with this. > -Chris >
On 17/12/2019 15.00, Patchwork wrote: > == Series Details == > > Series: series starting with [1/2] drm/i915: Add lmem fault handler > URL : https://patchwork.freedesktop.org/series/71051/ > State : failure > > == Summary == > > CI Bug Log - changes from CI_DRM_7580 -> Patchwork_15810 > ==================================================== > > Summary > ------- > > **FAILURE** > > Serious unknown changes coming with Patchwork_15810 absolutely need to be > verified manually. > > If you think the reported changes have nothing to do with the changes > introduced in Patchwork_15810, please notify your bug team to allow them > to document this new failure mode, which will reduce false positives in CI. > > External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/index.html > > Possible new issues > ------------------- > > Here are the unknown changes that may have been introduced in Patchwork_15810: > > ### IGT changes ### > > #### Possible regressions #### > > * igt@i915_selftest@live_mman: > - fi-ilk-650: [PASS][1] -> [INCOMPLETE][2] > [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-ilk-650/igt@i915_selftest@live_mman.html > [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-ilk-650/igt@i915_selftest@live_mman.html > - fi-bsw-n3050: NOTRUN -> [INCOMPLETE][3] > [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-n3050/igt@i915_selftest@live_mman.html > - fi-ivb-3770: [PASS][4] -> [DMESG-FAIL][5] > [4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-ivb-3770/igt@i915_selftest@live_mman.html > [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-ivb-3770/igt@i915_selftest@live_mman.html > - fi-hsw-4770r: [PASS][6] -> [DMESG-FAIL][7] > [6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-hsw-4770r/igt@i915_selftest@live_mman.html > [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-hsw-4770r/igt@i915_selftest@live_mman.html > - fi-bsw-kefka: [PASS][8] -> [INCOMPLETE][9] > [8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-bsw-kefka/igt@i915_selftest@live_mman.html > [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-kefka/igt@i915_selftest@live_mman.html > - fi-blb-e6850: [PASS][10] -> [INCOMPLETE][11] > [10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-blb-e6850/igt@i915_selftest@live_mman.html > [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-blb-e6850/igt@i915_selftest@live_mman.html > - fi-bwr-2160: [PASS][12] -> [INCOMPLETE][13] > [12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-bwr-2160/igt@i915_selftest@live_mman.html > [13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bwr-2160/igt@i915_selftest@live_mman.html > - fi-kbl-8809g: [PASS][14] -> [DMESG-FAIL][15] > [14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-kbl-8809g/igt@i915_selftest@live_mman.html > [15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-kbl-8809g/igt@i915_selftest@live_mman.html > - fi-bsw-nick: [PASS][16] -> [INCOMPLETE][17] > [16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-bsw-nick/igt@i915_selftest@live_mman.html > [17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-nick/igt@i915_selftest@live_mman.html > hmm, doesn't look too good with the memory regions. > * igt@runner@aborted: > - fi-ilk-650: NOTRUN -> [FAIL][18] > [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-ilk-650/igt@runner@aborted.html > - fi-pnv-d510: NOTRUN -> [FAIL][19] > [19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-pnv-d510/igt@runner@aborted.html > - fi-bxt-dsi: NOTRUN -> [FAIL][20] > [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bxt-dsi/igt@runner@aborted.html > - fi-bsw-n3050: NOTRUN -> [FAIL][21] > [21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-n3050/igt@runner@aborted.html > - fi-blb-e6850: NOTRUN -> [FAIL][22] > [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-blb-e6850/igt@runner@aborted.html > - fi-bsw-kefka: NOTRUN -> [FAIL][23] > [23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-kefka/igt@runner@aborted.html > - fi-bsw-nick: NOTRUN -> [FAIL][24] > [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bsw-nick/igt@runner@aborted.html > - fi-elk-e7500: NOTRUN -> [FAIL][25] > [25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-elk-e7500/igt@runner@aborted.html > > > Known issues > ------------ > > Here are the changes found in Patchwork_15810 that come from known issues: > > ### IGT changes ### > > #### Issues hit #### > > * igt@gem_exec_gttfill@basic: > - fi-tgl-y: [PASS][26] -> [INCOMPLETE][27] ([fdo#111593]) > [26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-tgl-y/igt@gem_exec_gttfill@basic.html > [27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-tgl-y/igt@gem_exec_gttfill@basic.html > > * igt@i915_selftest@live_blt: > - fi-ivb-3770: [PASS][28] -> [DMESG-FAIL][29] ([i915#725]) > [28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-ivb-3770/igt@i915_selftest@live_blt.html > [29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-ivb-3770/igt@i915_selftest@live_blt.html > - fi-hsw-4770r: [PASS][30] -> [DMESG-FAIL][31] ([i915#725]) > [30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-hsw-4770r/igt@i915_selftest@live_blt.html > [31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-hsw-4770r/igt@i915_selftest@live_blt.html > > * igt@i915_selftest@live_gem_contexts: > - fi-hsw-peppy: [PASS][32] -> [INCOMPLETE][33] ([i915#694]) > [32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html > [33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-hsw-peppy/igt@i915_selftest@live_gem_contexts.html > - fi-hsw-4770r: [PASS][34] -> [DMESG-FAIL][35] ([i915#722]) > [34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-hsw-4770r/igt@i915_selftest@live_gem_contexts.html > [35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-hsw-4770r/igt@i915_selftest@live_gem_contexts.html > > * igt@i915_selftest@live_mman: > - fi-bxt-dsi: [PASS][36] -> [INCOMPLETE][37] ([fdo#103927]) > [36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-bxt-dsi/igt@i915_selftest@live_mman.html > [37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-bxt-dsi/igt@i915_selftest@live_mman.html > - fi-glk-dsi: [PASS][38] -> [INCOMPLETE][39] ([i915#58] / [k.org#198133]) > [38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-glk-dsi/igt@i915_selftest@live_mman.html > [39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-glk-dsi/igt@i915_selftest@live_mman.html > - fi-byt-j1900: [PASS][40] -> [INCOMPLETE][41] ([i915#45]) > [40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-byt-j1900/igt@i915_selftest@live_mman.html > [41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-byt-j1900/igt@i915_selftest@live_mman.html > - fi-elk-e7500: [PASS][42] -> [INCOMPLETE][43] ([i915#66]) > [42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-elk-e7500/igt@i915_selftest@live_mman.html > [43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-elk-e7500/igt@i915_selftest@live_mman.html > - fi-apl-guc: [PASS][44] -> [INCOMPLETE][45] ([fdo#103927]) > [44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-apl-guc/igt@i915_selftest@live_mman.html > [45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-apl-guc/igt@i915_selftest@live_mman.html > - fi-pnv-d510: [PASS][46] -> [INCOMPLETE][47] ([i915#299]) > [46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-pnv-d510/igt@i915_selftest@live_mman.html > [47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-pnv-d510/igt@i915_selftest@live_mman.html > > * igt@kms_chamelium@hdmi-hpd-fast: > - fi-kbl-7500u: [PASS][48] -> [FAIL][49] ([fdo#111407]) > [48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html > [49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html > > * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a: > - fi-icl-u2: [PASS][50] -> [INCOMPLETE][51] ([i915#140]) > [50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-icl-u2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html > [51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-icl-u2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html > > > #### Possible fixes #### > > * igt@gem_close_race@basic-threads: > - fi-byt-n2820: [TIMEOUT][52] ([i915#816]) -> [PASS][53] > [52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-byt-n2820/igt@gem_close_race@basic-threads.html > [53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-byt-n2820/igt@gem_close_race@basic-threads.html > > * igt@i915_selftest@live_blt: > - fi-hsw-4770: [DMESG-FAIL][54] ([i915#553] / [i915#725]) -> [PASS][55] > [54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-hsw-4770/igt@i915_selftest@live_blt.html > [55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-hsw-4770/igt@i915_selftest@live_blt.html > > * igt@i915_selftest@live_gem_contexts: > - fi-skl-lmem: [INCOMPLETE][56] ([i915#424]) -> [PASS][57] > [56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html > [57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-skl-lmem/igt@i915_selftest@live_gem_contexts.html > > > #### Warnings #### > > * igt@gem_exec_suspend@basic-s4-devices: > - fi-kbl-x1275: [DMESG-WARN][58] ([fdo#107139] / [i915#62] / [i915#92]) -> [DMESG-WARN][59] ([fdo#107139] / [i915#62] / [i915#92] / [i915#95]) > [58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-kbl-x1275/igt@gem_exec_suspend@basic-s4-devices.html > [59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-kbl-x1275/igt@gem_exec_suspend@basic-s4-devices.html > > * igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy: > - fi-kbl-x1275: [DMESG-WARN][60] ([i915#62] / [i915#92]) -> [DMESG-WARN][61] ([i915#62] / [i915#92] / [i915#95]) +2 similar issues > [60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-kbl-x1275/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html > [61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-kbl-x1275/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy.html > > * igt@kms_flip@basic-flip-vs-modeset: > - fi-kbl-x1275: [DMESG-WARN][62] ([i915#62] / [i915#92] / [i915#95]) -> [DMESG-WARN][63] ([i915#62] / [i915#92]) +4 similar issues > [62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-kbl-x1275/igt@kms_flip@basic-flip-vs-modeset.html > [63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-kbl-x1275/igt@kms_flip@basic-flip-vs-modeset.html > > * igt@runner@aborted: > - fi-byt-n2820: [FAIL][64] ([i915#816]) -> [FAIL][65] ([fdo#111249]) > [64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7580/fi-byt-n2820/igt@runner@aborted.html > [65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/fi-byt-n2820/igt@runner@aborted.html > > > {name}: This element is suppressed. This means it is ignored when computing > the status of the difference (SUCCESS, WARNING, or FAILURE). > > [fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927 > [fdo#107139]: https://bugs.freedesktop.org/show_bug.cgi?id=107139 > [fdo#111249]: https://bugs.freedesktop.org/show_bug.cgi?id=111249 > [fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407 > [fdo#111593]: https://bugs.freedesktop.org/show_bug.cgi?id=111593 > [i915#140]: https://gitlab.freedesktop.org/drm/intel/issues/140 > [i915#299]: https://gitlab.freedesktop.org/drm/intel/issues/299 > [i915#424]: https://gitlab.freedesktop.org/drm/intel/issues/424 > [i915#45]: https://gitlab.freedesktop.org/drm/intel/issues/45 > [i915#476]: https://gitlab.freedesktop.org/drm/intel/issues/476 > [i915#553]: https://gitlab.freedesktop.org/drm/intel/issues/553 > [i915#58]: https://gitlab.freedesktop.org/drm/intel/issues/58 > [i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62 > [i915#66]: https://gitlab.freedesktop.org/drm/intel/issues/66 > [i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694 > [i915#722]: https://gitlab.freedesktop.org/drm/intel/issues/722 > [i915#725]: https://gitlab.freedesktop.org/drm/intel/issues/725 > [i915#816]: https://gitlab.freedesktop.org/drm/intel/issues/816 > [i915#92]: https://gitlab.freedesktop.org/drm/intel/issues/92 > [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95 > [k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133 > > > Participating hosts (51 -> 47) > ------------------------------ > > Additional (3): fi-whl-u fi-icl-u3 fi-bsw-n3050 > Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus > > > Build changes > ------------- > > * CI: CI-20190529 -> None > * Linux: CI_DRM_7580 -> Patchwork_15810 > > CI-20190529: 20190529 > CI_DRM_7580: 4154d505504bd58e3cc90d27f7221c3d29045b51 @ git://anongit.freedesktop.org/gfx-ci/linux > IGT_5349: 048f58513d8b8ec6bb307a939f0ac959bc0f0e10 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools > Patchwork_15810: ded079f2d6fcfa3e30c5a7ce63450651bf7cd3dd @ git://anongit.freedesktop.org/gfx-ci/linux > > > == Linux commits == > > ded079f2d6fc drm/i915/selftests: Add selftest for memory region PF handling > 21b92ebb9c01 drm/i915: Add lmem fault handler > > == Logs == > > For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15810/index.html >
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c index 520cc9cac471..e8326d8b66f7 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.c @@ -6,6 +6,7 @@ #include "intel_memory_region.h" #include "gem/i915_gem_region.h" #include "gem/i915_gem_lmem.h" +#include "gem/i915_gem_mman.h" #include "i915_drv.h" const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = { @@ -56,6 +57,18 @@ i915_gem_object_lmem_io_map(struct drm_i915_gem_object *obj, return io_mapping_map_wc(&obj->mm.region->iomap, offset, size); } +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, + unsigned long n) +{ + struct intel_memory_region *mem = obj->mm.region; + resource_size_t offset; + + offset = i915_gem_object_get_dma_address(obj, n); + offset -= mem->region.start; + + return (mem->io_start + offset) >> PAGE_SHIFT; +} + bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj) { return obj->ops == &i915_gem_lmem_obj_ops; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h index 7c176b8b7d2f..4d5fca1a3e0e 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_lmem.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_lmem.h @@ -7,6 +7,7 @@ #define __I915_GEM_LMEM_H #include <linux/types.h> +#include <linux/mman.h> struct drm_i915_private; struct drm_i915_gem_object; @@ -22,6 +23,9 @@ void __iomem * i915_gem_object_lmem_io_map_page_atomic(struct drm_i915_gem_object *obj, unsigned long n); +unsigned long i915_gem_object_lmem_io_pfn(struct drm_i915_gem_object *obj, + unsigned long n); + bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); struct drm_i915_gem_object * diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c index 879fff8adc48..f5f7af745d1d 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c @@ -11,6 +11,7 @@ #include "gt/intel_gt.h" #include "gt/intel_gt_requests.h" +#include "i915_gem_lmem.h" #include "i915_drv.h" #include "i915_gem_gtt.h" #include "i915_gem_ioctls.h" @@ -216,6 +217,7 @@ static vm_fault_t i915_error_to_vmf_fault(int err) case -ENOSPC: /* shmemfs allocation failure */ case -ENOMEM: /* our allocation failure */ + case -ENXIO: return VM_FAULT_OOM; case 0: @@ -274,6 +276,47 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf) return ret; } +vm_fault_t vm_fault_iomem(struct vm_fault *vmf) +{ + struct vm_area_struct *area = vmf->vma; + struct i915_mmap_offset *priv = area->vm_private_data; + struct drm_i915_gem_object *obj = priv->obj; + struct intel_memory_region *mem = obj->mm.region; + unsigned long i, size = area->vm_end - area->vm_start; + bool write = area->vm_flags & VM_WRITE; + int ret; + + /* Sanity check that we allow writing into this object */ + if (i915_gem_object_is_readonly(obj) && write) + return VM_FAULT_SIGBUS; + + ret = i915_gem_object_pin_pages(obj); + if (ret) + return i915_error_to_vmf_fault(ret); + + if (obj->flags & I915_BO_ALLOC_CONTIGUOUS) { + ret = remap_io_mapping(area, area->vm_start, + i915_gem_object_lmem_io_pfn(obj, 0), size, + &mem->iomap); + i915_gem_object_unpin_pages(obj); + return i915_error_to_vmf_fault(ret); + } else { + vm_fault_t vmf_ret = VM_FAULT_SIGBUS; + if (GEM_WARN_ON(size < PAGE_SIZE)) + return vmf_ret; + + for (i = 0; i < size >> PAGE_SHIFT; i++) { + vmf_ret = vmf_insert_pfn(area, + (unsigned long)area->vm_start + i * PAGE_SIZE, + i915_gem_object_lmem_io_pfn(obj, i)); + if (vmf_ret != VM_FAULT_NOPAGE) + break; + } + i915_gem_object_unpin_pages(obj); + return vmf_ret; + } +} + static vm_fault_t vm_fault_gtt(struct vm_fault *vmf) { #define MIN_CHUNK_PAGES (SZ_1M >> PAGE_SHIFT) @@ -560,7 +603,8 @@ __assign_mmap_offset(struct drm_file *file, } if (mmap_type != I915_MMAP_TYPE_GTT && - !i915_gem_object_has_struct_page(obj)) { + !i915_gem_object_type_has(obj, I915_GEM_OBJECT_HAS_STRUCT_PAGE | + I915_GEM_OBJECT_HAS_IOMEM)) { err = -ENODEV; goto out; } @@ -694,6 +738,25 @@ static const struct vm_operations_struct vm_ops_cpu = { .close = vm_close, }; +static const struct vm_operations_struct vm_ops_iomem = { + .fault = vm_fault_iomem, + .open = vm_open, + .close = vm_close, +}; + +static const struct vm_operations_struct * +get_vm_cpu_ops(struct drm_i915_gem_object *obj) +{ + if (i915_gem_object_type_has(obj, I915_GEM_OBJECT_HAS_STRUCT_PAGE)) + return &vm_ops_cpu; + + if (i915_gem_object_type_has(obj, I915_GEM_OBJECT_HAS_IOMEM)) + return &vm_ops_iomem; + + GEM_BUG_ON("unknown object type"); + return NULL; +} + /* * This overcomes the limitation in drm_gem_mmap's assignment of a * drm_gem_object as the vma->vm_private_data. Since we need to @@ -762,18 +825,18 @@ int i915_gem_mmap(struct file *filp, struct vm_area_struct *vma) case I915_MMAP_TYPE_WC: vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags)); - vma->vm_ops = &vm_ops_cpu; + vma->vm_ops = get_vm_cpu_ops(to_intel_bo(obj)); break; case I915_MMAP_TYPE_WB: vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); - vma->vm_ops = &vm_ops_cpu; + vma->vm_ops = get_vm_cpu_ops(to_intel_bo(obj)); break; case I915_MMAP_TYPE_UC: vma->vm_page_prot = pgprot_noncached(vm_get_page_prot(vma->vm_flags)); - vma->vm_ops = &vm_ops_cpu; + vma->vm_ops = get_vm_cpu_ops(to_intel_bo(obj)); break; case I915_MMAP_TYPE_GTT: