<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/dma-buf, branch v5.11</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.11</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.11'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2021-01-10T17:38:21Z</updated>
<entry>
<title>dma-buf: cma_heap: Fix memory leak in CMA heap</title>
<updated>2021-01-10T17:38:21Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2021-01-07T20:26:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a0adc8eabb402cfb9f32d15edd9f65f65e35cdce'/>
<id>urn:sha1:a0adc8eabb402cfb9f32d15edd9f65f65e35cdce</id>
<content type='text'>
Bing Song noticed the CMA heap was leaking memory due to a flub
I made in commit a5d2d29e24be ("dma-buf: heaps: Move heap-helper
logic into the cma_heap implementation"), and provided this fix
which ensures the pagelist is also freed on release.

Cc: Bing Song &lt;bing.song@nxp.com&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Liam Mark &lt;lmark@codeaurora.org&gt;
Cc: Laura Abbott &lt;labbott@kernel.org&gt;
Cc: Brian Starkey &lt;Brian.Starkey@arm.com&gt;
Cc: Hridya Valsaraju &lt;hridya@google.com&gt;
Cc: Suren Baghdasaryan &lt;surenb@google.com&gt;
Cc: Sandeep Patil &lt;sspatil@google.com&gt;
Cc: Daniel Mentz &lt;danielmentz@google.com&gt;
Cc: Chris Goldsworthy &lt;cgoldswo@codeaurora.org&gt;
Cc: Ørjan Eide &lt;orjan.eide@arm.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Cc: Ezequiel Garcia &lt;ezequiel@collabora.com&gt;
Cc: Simon Ser &lt;contact@emersion.fr&gt;
Cc: James Jones &lt;jajones@nvidia.com&gt;
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reported-by: Bing Song &lt;bing.song@nxp.com&gt;
Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20210107202616.75170-1-john.stultz@linaro.org
</content>
</entry>
<entry>
<title>dmabuf: fix use-after-free of dmabuf's file-&gt;f_inode</title>
<updated>2021-01-07T12:40:30Z</updated>
<author>
<name>Charan Teja Reddy</name>
<email>charante@codeaurora.org</email>
</author>
<published>2021-01-05T14:36:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=05cd84691eafcd7959a1e120d5e72c0dd98c5d91'/>
<id>urn:sha1:05cd84691eafcd7959a1e120d5e72c0dd98c5d91</id>
<content type='text'>
It is observed 'use-after-free' on the dmabuf's file-&gt;f_inode with the
race between closing the dmabuf file and reading the dmabuf's debug
info.

Consider the below scenario where P1 is closing the dma_buf file
and P2 is reading the dma_buf's debug info in the system:

P1						P2
					dma_buf_debug_show()
dma_buf_put()
  __fput()
    file-&gt;f_op-&gt;release()
    dput()
    ....
      dentry_unlink_inode()
        iput(dentry-&gt;d_inode)
        (where the inode is freed)
					mutex_lock(&amp;db_list.lock)
					read 'dma_buf-&gt;file-&gt;f_inode'
					(the same inode is freed by P1)
					mutex_unlock(&amp;db_list.lock)
      dentry-&gt;d_op-&gt;d_release()--&gt;
        dma_buf_release()
          .....
          mutex_lock(&amp;db_list.lock)
          removes the dmabuf from the list
          mutex_unlock(&amp;db_list.lock)

In the above scenario, when dma_buf_put() is called on a dma_buf, it
first frees the dma_buf's file-&gt;f_inode(=dentry-&gt;d_inode) and then
removes this dma_buf from the system db_list. In between P2 traversing
the db_list tries to access this dma_buf's file-&gt;f_inode that was freed
by P1 which is a use-after-free case.

Since, __fput() calls f_op-&gt;release first and then later calls the
d_op-&gt;d_release, move the dma_buf's db_list removal from d_release() to
f_op-&gt;release(). This ensures that dma_buf's file-&gt;f_inode is not
accessed after it is released.

Cc: &lt;stable@vger.kernel.org&gt; # 5.4.x-
Fixes: 4ab59c3c638c ("dma-buf: Move dma_buf_release() from fops to dentry_ops")
Acked-by: Christian König &lt;christian.koenig@amd.com&gt;
Signed-off-by: Charan Teja Reddy &lt;charante@codeaurora.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Signed-off-by: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/1609857399-31549-1-git-send-email-charante@codeaurora.org
</content>
</entry>
<entry>
<title>Merge tag 'drm-next-2020-12-24' of git://anongit.freedesktop.org/drm/drm</title>
<updated>2020-12-24T20:14:29Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-12-24T20:14:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ef2c8b81b88868f042579b9dd021cc9edbc2d0c6'/>
<id>urn:sha1:ef2c8b81b88868f042579b9dd021cc9edbc2d0c6</id>
<content type='text'>
Pull drm fixes from Dave Airlie:
 "Xmas eve pull request present.

  Just some fixes that trickled in this past week: Mostly amdgpu fixes,
  with a dma-buf/mips build fix and some misc komeda fixes.

  dma-buf:
   - fix build on mips

  komeda:
   - fix commit tail operation order
   - NULL pointer fix
   - out of bounds access fix

  ttm:
   - remove an unused function

  amdgpu:
   - Vangogh SMU fixes
   - Arcturus gfx9 fixes
   - Misc display fixes
   - Sienna Cichlid SMU update
   - Fix S3 display memory leak
   - Fix regression caused by DP sub-connector support

  amdkfd:
   - Properly require pcie atomics for gfx10"

* tag 'drm-next-2020-12-24' of git://anongit.freedesktop.org/drm/drm: (31 commits)
  drm/amd/display: Fix memory leaks in S3 resume
  drm/amdgpu: Fix a copy-pasta comment
  drm/amdgpu: only set DP subconnector type on DP and eDP connectors
  drm/amd/pm: bump Sienna Cichlid smu_driver_if version to match latest pmfw
  drm/amd/display: add getter routine to retrieve mpcc mux
  drm/amd/display: always program DPPDTO unless not safe to lower
  drm/amd/display: [FW Promotion] Release 0.0.47
  drm/amd/display: updated wm table for Renoir
  drm/amd/display: Acquire DSC during split stream for ODM only if top_pipe
  drm/amd/display: Multi-display underflow observed
  drm/amd/display: Remove unnecessary NULL check
  drm/amd/display: Update RN/VGH active display count workaround
  drm/amd/display: change SMU repsonse timeout to 2s.
  drm/amd/display: gradually ramp ABM intensity
  drm/amd/display: To modify the condition in indicating branch device
  drm/amd/display: Modify the hdcp device count check condition
  drm/amd/display: Interfaces for hubp blank and soft reset
  drm/amd/display: handler not correctly checked at remove_irq_handler
  drm/amdgpu: check gfx pipe availability before toggling its interrupts
  drm/amdgpu: remove unnecessary asic type check
  ...
</content>
</entry>
<entry>
<title>Merge tag 'drm-next-2020-12-18' of git://anongit.freedesktop.org/drm/drm</title>
<updated>2020-12-18T20:38:28Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-12-18T20:38:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=c59c7588fc922e27c378a7e2a920b889bd6bf872'/>
<id>urn:sha1:c59c7588fc922e27c378a7e2a920b889bd6bf872</id>
<content type='text'>
Pull more drm updates from Daniel Vetter:
 "UAPI Changes:

   - Only enable char/agp uapi when CONFIG_DRM_LEGACY is set

  Cross-subsystem Changes:

   - vma_set_file helper to make vma-&gt;vm_file changing less brittle,
     acked by Andrew

  Core Changes:

   - dma-buf heaps improvements

   - pass full atomic modeset state to driver callbacks

   - shmem helpers: cached bo by default

   - cleanups for fbdev, fb-helpers

   - better docs for drm modes and SCALING_FITLER uapi

   - ttm: fix dma32 page pool regression

  Driver Changes:

   - multi-hop regression fixes for amdgpu, radeon, nouveau

   - lots of small amdgpu hw enabling fixes (display, pm, ...)

   - fixes for imx, mcde, meson, some panels, virtio, qxl, i915, all
     fairly minor

   - some cleanups for legacy drm/fbdev drivers"

* tag 'drm-next-2020-12-18' of git://anongit.freedesktop.org/drm/drm: (117 commits)
  drm/qxl: don't allocate a dma_address array
  drm/nouveau: fix multihop when move doesn't work.
  drm/i915/tgl: Fix REVID macros for TGL to fetch correct stepping
  drm/i915: Fix mismatch between misplaced vma check and vma insert
  drm/i915/perf: also include Gen11 in OATAILPTR workaround
  Revert "drm/i915: re-order if/else ladder for hpd_irq_setup"
  drm/amdgpu/disply: fix documentation warnings in display manager
  drm/amdgpu: print mmhub client name for dimgrey_cavefish
  drm/amdgpu: set mode1 reset as default for dimgrey_cavefish
  drm/amd/display: Add get_dig_frontend implementation for DCEx
  drm/radeon: remove h from printk format specifier
  drm/amdgpu: remove h from printk format specifier
  drm/amdgpu: Fix spelling mistake "Heterogenous" -&gt; "Heterogeneous"
  drm/amdgpu: fix regression in vbios reservation handling on headless
  drm/amdgpu/SRIOV: Extend VF reset request wait period
  drm/amdkfd: correct amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu log.
  drm/amd/display: Adding prototype for dccg21_update_dpp_dto()
  drm/amdgpu: print what method we are using for runtime pm
  drm/amdgpu: simplify logic in atpx resume handling
  drm/amdgpu: no need to call pci_ignore_hotplug for _PR3
  ...
</content>
</entry>
<entry>
<title>dma-buf: cma_heap: Include linux/vmalloc.h to fix build failures on MIPS</title>
<updated>2020-12-16T17:32:45Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2020-12-16T00:49:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8075c3005e4b1efa12dbbf6e84bc412a713de92c'/>
<id>urn:sha1:8075c3005e4b1efa12dbbf6e84bc412a713de92c</id>
<content type='text'>
We need to include &lt;linux/vmalloc.h&gt; in order for MIPS to find
vmap(), as it doesn't otherwise get included there.

Without this patch, one can hit the following build error:
  drivers/dma-buf/heaps/cma_heap.c: In function 'cma_heap_do_vmap':
  drivers/dma-buf/heaps/cma_heap.c:195:10: error: implicit declaration of function 'vmap'

Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Liam Mark &lt;lmark@codeaurora.org&gt;
Cc: Laura Abbott &lt;labbott@kernel.org&gt;
Cc: Brian Starkey &lt;Brian.Starkey@arm.com&gt;
Cc: Hridya Valsaraju &lt;hridya@google.com&gt;
Cc: Suren Baghdasaryan &lt;surenb@google.com&gt;
Cc: Sandeep Patil &lt;sspatil@google.com&gt;
Cc: Daniel Mentz &lt;danielmentz@google.com&gt;
Cc: Chris Goldsworthy &lt;cgoldswo@codeaurora.org&gt;
Cc: Ørjan Eide &lt;orjan.eide@arm.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Cc: Ezequiel Garcia &lt;ezequiel@collabora.com&gt;
Cc: Simon Ser &lt;contact@emersion.fr&gt;
Cc: James Jones &lt;jajones@nvidia.com&gt;
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
Reported-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20201216004931.113505-1-john.stultz@linaro.org
</content>
</entry>
<entry>
<title>Merge branch 'akpm' (patches from Andrew)</title>
<updated>2020-12-15T20:53:37Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-12-15T20:53:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ac73e3dc8acd0a3be292755db30388c3580f5674'/>
<id>urn:sha1:ac73e3dc8acd0a3be292755db30388c3580f5674</id>
<content type='text'>
Merge misc updates from Andrew Morton:

 - a few random little subsystems

 - almost all of the MM patches which are staged ahead of linux-next
   material. I'll trickle to post-linux-next work in as the dependents
   get merged up.

Subsystems affected by this patch series: kthread, kbuild, ide, ntfs,
ocfs2, arch, and mm (slab-generic, slab, slub, dax, debug, pagecache,
gup, swap, shmem, memcg, pagemap, mremap, hmm, vmalloc, documentation,
kasan, pagealloc, memory-failure, hugetlb, vmscan, z3fold, compaction,
oom-kill, migration, cma, page-poison, userfaultfd, zswap, zsmalloc,
uaccess, zram, and cleanups).

* emailed patches from Andrew Morton &lt;akpm@linux-foundation.org&gt;: (200 commits)
  mm: cleanup kstrto*() usage
  mm: fix fall-through warnings for Clang
  mm: slub: convert sysfs sprintf family to sysfs_emit/sysfs_emit_at
  mm: shmem: convert shmem_enabled_show to use sysfs_emit_at
  mm:backing-dev: use sysfs_emit in macro defining functions
  mm: huge_memory: convert remaining use of sprintf to sysfs_emit and neatening
  mm: use sysfs_emit for struct kobject * uses
  mm: fix kernel-doc markups
  zram: break the strict dependency from lzo
  zram: add stat to gather incompressible pages since zram set up
  zram: support page writeback
  mm/process_vm_access: remove redundant initialization of iov_r
  mm/zsmalloc.c: rework the list_add code in insert_zspage()
  mm/zswap: move to use crypto_acomp API for hardware acceleration
  mm/zswap: fix passing zero to 'PTR_ERR' warning
  mm/zswap: make struct kernel_param_ops definitions const
  userfaultfd/selftests: hint the test runner on required privilege
  userfaultfd/selftests: fix retval check for userfaultfd_open()
  userfaultfd/selftests: always dump something in modes
  userfaultfd: selftests: make __{s,u}64 format specifiers portable
  ...
</content>
</entry>
<entry>
<title>dma-buf: use krealloc_array()</title>
<updated>2020-12-15T20:13:37Z</updated>
<author>
<name>Bartosz Golaszewski</name>
<email>bgolaszewski@baylibre.com</email>
</author>
<published>2020-12-15T03:04:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a47fc51d8e1e9ce0f2d8fd9e5197649f00bac4ca'/>
<id>urn:sha1:a47fc51d8e1e9ce0f2d8fd9e5197649f00bac4ca</id>
<content type='text'>
Use the helper that checks for overflows internally instead of manually
calculating the size of the new array.

Link: https://lkml.kernel.org/r/20201109110654.12547-10-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski &lt;bgolaszewski@baylibre.com&gt;
Acked-by: Christian König &lt;christian.koenig@amd.com&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Andy Shevchenko &lt;andriy.shevchenko@linux.intel.com&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Borislav Petkov &lt;bp@suse.de&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Daniel Vetter &lt;daniel@ffwll.ch&gt;
Cc: Daniel Vetter &lt;daniel.vetter@ffwll.ch&gt;
Cc: David Airlie &lt;airlied@linux.ie&gt;
Cc: David Rientjes &lt;rientjes@google.com&gt;
Cc: Gustavo Padovan &lt;gustavo@padovan.org&gt;
Cc: James Morse &lt;james.morse@arm.com&gt;
Cc: Jaroslav Kysela &lt;perex@perex.cz&gt;
Cc: Jason Wang &lt;jasowang@redhat.com&gt;
Cc: Joonsoo Kim &lt;iamjoonsoo.kim@lge.com&gt;
Cc: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Cc: Maarten Lankhorst &lt;maarten.lankhorst@linux.intel.com&gt;
Cc: Mauro Carvalho Chehab &lt;mchehab@kernel.org&gt;
Cc: Maxime Ripard &lt;mripard@kernel.org&gt;
Cc: "Michael S . Tsirkin" &lt;mst@redhat.com&gt;
Cc: Pekka Enberg &lt;penberg@kernel.org&gt;
Cc: Robert Richter &lt;rric@kernel.org&gt;
Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Takashi Iwai &lt;tiwai@suse.com&gt;
Cc: Takashi Iwai &lt;tiwai@suse.de&gt;
Cc: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
Cc: Tony Luck &lt;tony.luck@intel.com&gt;
Cc: Vlastimil Babka &lt;vbabka@suse.cz&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>dma-buf/dma-resv: Respect num_fences when initializing the shared fence list.</title>
<updated>2020-11-25T09:48:28Z</updated>
<author>
<name>Maarten Lankhorst</name>
<email>maarten.lankhorst@linux.intel.com</email>
</author>
<published>2020-11-24T11:57:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bf8975837dac156c33a4d15d46602700998cb6dd'/>
<id>urn:sha1:bf8975837dac156c33a4d15d46602700998cb6dd</id>
<content type='text'>
We hardcode the maximum number of shared fences to 4, instead of
respecting num_fences. Use a minimum of 4, but more if num_fences
is higher.

This seems to have been an oversight when first implementing the
api.

Fixes: 04a5faa8cbe5 ("reservation: update api and add some helpers")
Cc: &lt;stable@vger.kernel.org&gt; # v3.17+
Reported-by: Niranjana Vishwanathapura &lt;niranjana.vishwanathapura@intel.com&gt;
Signed-off-by: Maarten Lankhorst &lt;maarten.lankhorst@linux.intel.com&gt;
Reviewed-by: Thomas Hellström &lt;thomas.hellstrom@linux.intel.com&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20201124115707.406917-1-maarten.lankhorst@linux.intel.com
</content>
</entry>
<entry>
<title>dma-buf: system_heap: Allocate higher order pages if available</title>
<updated>2020-11-22T16:33:04Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2020-11-21T23:50:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d963ab0f15fb0797ddd65b2653f3d65c2d7a08ec'/>
<id>urn:sha1:d963ab0f15fb0797ddd65b2653f3d65c2d7a08ec</id>
<content type='text'>
While the system heap can return non-contiguous pages,
try to allocate larger order pages if possible.

This will allow slight performance gains and make implementing
page pooling easier.

Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Liam Mark &lt;lmark@codeaurora.org&gt;
Cc: Laura Abbott &lt;labbott@kernel.org&gt;
Cc: Brian Starkey &lt;Brian.Starkey@arm.com&gt;
Cc: Hridya Valsaraju &lt;hridya@google.com&gt;
Cc: Suren Baghdasaryan &lt;surenb@google.com&gt;
Cc: Sandeep Patil &lt;sspatil@google.com&gt;
Cc: Daniel Mentz &lt;danielmentz@google.com&gt;
Cc: Chris Goldsworthy &lt;cgoldswo@codeaurora.org&gt;
Cc: Ørjan Eide &lt;orjan.eide@arm.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Cc: Ezequiel Garcia &lt;ezequiel@collabora.com&gt;
Cc: Simon Ser &lt;contact@emersion.fr&gt;
Cc: James Jones &lt;jajones@nvidia.com&gt;
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey &lt;brian.starkey@arm.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-6-john.stultz@linaro.org
</content>
</entry>
<entry>
<title>dma-buf: heaps: Skip sync if not mapped</title>
<updated>2020-11-22T16:33:04Z</updated>
<author>
<name>John Stultz</name>
<email>john.stultz@linaro.org</email>
</author>
<published>2020-11-21T23:50:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4c68e499bb9d6d9ec3e18fcb2f68641abb22464a'/>
<id>urn:sha1:4c68e499bb9d6d9ec3e18fcb2f68641abb22464a</id>
<content type='text'>
This patch is basically a port of Ørjan Eide's similar patch for ION
 https://lore.kernel.org/lkml/20200414134629.54567-1-orjan.eide@arm.com/

Only sync the sg-list of dma-buf heap attachment when the attachment
is actually mapped on the device.

dma-bufs may be synced at any time. It can be reached from user space
via DMA_BUF_IOCTL_SYNC, so there are no guarantees from callers on when
syncs may be attempted, and dma_buf_end_cpu_access() and
dma_buf_begin_cpu_access() may not be paired.

Since the sg_list's dma_address isn't set up until the buffer is used
on the device, and dma_map_sg() is called on it, the dma_address will be
NULL if sync is attempted on the dma-buf before it's mapped on a device.

Before v5.0 (commit 55897af63091 ("dma-direct: merge swiotlb_dma_ops
into the dma_direct code")) this was a problem as the dma-api (at least
the swiotlb_dma_ops on arm64) would use the potentially invalid
dma_address. How that failed depended on how the device handled physical
address 0. If 0 was a valid address to physical ram, that page would get
flushed a lot, while the actual pages in the buffer would not get synced
correctly. While if 0 is an invalid physical address it may cause a
fault and trigger a crash.

In v5.0 this was incidentally fixed by commit 55897af63091 ("dma-direct:
merge swiotlb_dma_ops into the dma_direct code"), as this moved the
dma-api to use the page pointer in the sg_list, and (for Ion buffers at
least) this will always be valid if the sg_list exists at all.

But, this issue is re-introduced in v5.3 with
commit 449fa54d6815 ("dma-direct: correct the physical addr in
dma_direct_sync_sg_for_cpu/device") moves the dma-api back to the old
behaviour and picks the dma_address that may be invalid.

dma-buf core doesn't ensure that the buffer is mapped on the device, and
thus have a valid sg_list, before calling the exporter's
begin_cpu_access.

Logic and commit message originally by: Ørjan Eide &lt;orjan.eide@arm.com&gt;

Cc: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Cc: Liam Mark &lt;lmark@codeaurora.org&gt;
Cc: Laura Abbott &lt;labbott@kernel.org&gt;
Cc: Brian Starkey &lt;Brian.Starkey@arm.com&gt;
Cc: Hridya Valsaraju &lt;hridya@google.com&gt;
Cc: Suren Baghdasaryan &lt;surenb@google.com&gt;
Cc: Sandeep Patil &lt;sspatil@google.com&gt;
Cc: Daniel Mentz &lt;danielmentz@google.com&gt;
Cc: Chris Goldsworthy &lt;cgoldswo@codeaurora.org&gt;
Cc: Ørjan Eide &lt;orjan.eide@arm.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Cc: Ezequiel Garcia &lt;ezequiel@collabora.com&gt;
Cc: Simon Ser &lt;contact@emersion.fr&gt;
Cc: James Jones &lt;jajones@nvidia.com&gt;
Cc: linux-media@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey &lt;brian.starkey@arm.com&gt;
Signed-off-by: John Stultz &lt;john.stultz@linaro.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20201121235002.69945-5-john.stultz@linaro.org
</content>
</entry>
</feed>
