<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/kernel/dma, branch v5.14.9</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.14.9</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.14.9'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-09-30T08:13:04Z</updated>
<entry>
<title>dma-debug: prevent an error message from causing runtime problems</title>
<updated>2021-09-30T08:13:04Z</updated>
<author>
<name>Hamza Mahfooz</name>
<email>someguy@effective-light.com</email>
</author>
<published>2021-09-10T23:53:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=de4afec2d2946c92c62a15ab341c70b287289e6a'/>
<id>urn:sha1:de4afec2d2946c92c62a15ab341c70b287289e6a</id>
<content type='text'>
[ Upstream commit 510e1a724ab1bf38150be2c1acabb303f98d0047 ]

For some drivers, that use the DMA API. This error message can be reached
several millions of times per second, causing spam to the kernel's printk
buffer and bringing the CPU usage up to 100% (so, it should be rate
limited). However, since there is at least one driver that is in the
mainline and suffers from the error condition, it is more useful to
err_printk() here instead of just rate limiting the error message (in hopes
that it will make it easier for other drivers that suffer from this issue
to be spotted).

Link: https://lkml.kernel.org/r/fd67fbac-64bf-f0ea-01e1-5938ccfab9d0@arm.com
Reported-by: Jeremy Linton &lt;jeremy.linton@arm.com&gt;
Signed-off-by: Hamza Mahfooz &lt;someguy@effective-light.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>dma-debug: fix debugfs initialization order</title>
<updated>2021-09-18T11:43:28Z</updated>
<author>
<name>Anthony Iliopoulos</name>
<email>ailiop@suse.com</email>
</author>
<published>2021-07-22T14:10:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7c0c5add1387dba745f12e61ced39d5a585e2ec0'/>
<id>urn:sha1:7c0c5add1387dba745f12e61ced39d5a585e2ec0</id>
<content type='text'>
[ Upstream commit 173735c346c412d9f084825ecb04f24ada0e2986 ]

Due to link order, dma_debug_init is called before debugfs has a chance
to initialize (via debugfs_init which also happens in the core initcall
stage), so the directories for dma-debug are never created.

Decouple dma_debug_fs_init from dma_debug_init and defer its init until
core_initcall_sync (after debugfs has been initialized) while letting
dma-debug initialization occur as soon as possible to catch any early
mappings, as suggested in [1].

[1] https://lore.kernel.org/linux-iommu/YIgGa6yF%2Fadg8OSN@kroah.com/

Fixes: 15b28bbcd567 ("dma-debug: move initialization to common code")
Signed-off-by: Anthony Iliopoulos &lt;ailiop@suse.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>dma-mapping: handle vmalloc addresses in dma_common_{mmap,get_sgtable}</title>
<updated>2021-07-16T09:30:26Z</updated>
<author>
<name>Roman Skakun</name>
<email>Roman_Skakun@epam.com</email>
</author>
<published>2021-07-16T08:39:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=40ac971eab89330d6153e7721e88acd2d98833f9'/>
<id>urn:sha1:40ac971eab89330d6153e7721e88acd2d98833f9</id>
<content type='text'>
xen-swiotlb can use vmalloc backed addresses for dma coherent allocations
and uses the common helpers.  Properly handle them to unbreak Xen on
ARM platforms.

Fixes: 1b65c4e5a9af ("swiotlb-xen: use xen_alloc/free_coherent_pages")
Signed-off-by: Roman Skakun &lt;roman_skakun@epam.com&gt;
Reviewed-by: Andrii Anisov &lt;andrii_anisov@epam.com&gt;
[hch: split the patch, renamed the helpers]
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>Merge tag 'dma-mapping-5.14' of git://git.infradead.org/users/hch/dma-mapping</title>
<updated>2021-07-02T20:31:08Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-07-02T20:31:08Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e72b069609aa76cc1de35f5d434dbfaa5392ae9a'/>
<id>urn:sha1:e72b069609aa76cc1de35f5d434dbfaa5392ae9a</id>
<content type='text'>
Pull dma-mapping updates from Christoph Hellwig:

 - a trivivial whitespace fix (Zhen Lei)

 - report -EEXIST errors in add_dma_entry (Hamza Mahfooz)

* tag 'dma-mapping-5.14' of git://git.infradead.org/users/hch/dma-mapping:
  dma-debug: report -EEXIST errors in add_dma_entry
  dma-mapping: remove a trailing space
</content>
</entry>
<entry>
<title>Merge branch 'stable/for-linus-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb</title>
<updated>2021-06-23T16:04:07Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-06-23T16:04:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8fd2ed1c01dd96396c39dfa203c54705c6b6e03b'/>
<id>urn:sha1:8fd2ed1c01dd96396c39dfa203c54705c6b6e03b</id>
<content type='text'>
Pull swiotlb fix from Konrad Rzeszutek Wilk:
 "A fix for the regression for the DMA operations where the offset was
  ignored and corruptions would appear.

  Going forward there will be a cleanups to make the offset and
  alignment logic more clearer and better test-cases to help with this"

* 'stable/for-linus-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb:
  swiotlb: manipulate orig_addr when tlb_addr has offset
</content>
</entry>
<entry>
<title>dma-debug: report -EEXIST errors in add_dma_entry</title>
<updated>2021-06-22T06:15:47Z</updated>
<author>
<name>Hamza Mahfooz</name>
<email>someguy@effective-light.com</email>
</author>
<published>2021-05-18T12:54:43Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2b4bbc6231d789f58676d2ccc42177df163e1c4a'/>
<id>urn:sha1:2b4bbc6231d789f58676d2ccc42177df163e1c4a</id>
<content type='text'>
Since, overlapping mappings are not supported by the DMA API we should
report an error if active_cacheline_insert returns -EEXIST.

Suggested-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Signed-off-by: Hamza Mahfooz &lt;someguy@effective-light.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>dma-mapping: remove a trailing space</title>
<updated>2021-06-22T06:15:46Z</updated>
<author>
<name>Zhen Lei</name>
<email>thunder.leizhen@huawei.com</email>
</author>
<published>2021-06-08T07:52:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bab1622350699dc209db4f50d9ab99e6f6465334'/>
<id>urn:sha1:bab1622350699dc209db4f50d9ab99e6f6465334</id>
<content type='text'>
Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>swiotlb: manipulate orig_addr when tlb_addr has offset</title>
<updated>2021-06-21T12:59:02Z</updated>
<author>
<name>Bumyong Lee</name>
<email>bumyong.lee@samsung.com</email>
</author>
<published>2021-05-10T09:10:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5f89468e2f060031cd89fd4287298e0eaf246bf6'/>
<id>urn:sha1:5f89468e2f060031cd89fd4287298e0eaf246bf6</id>
<content type='text'>
in case of driver wants to sync part of ranges with offset,
swiotlb_tbl_sync_single() copies from orig_addr base to tlb_addr with
offset and ends up with data mismatch.

It was removed from
"swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single",
but said logic has to be added back in.

From Linus's email:
"That commit which the removed the offset calculation entirely, because the old

        (unsigned long)tlb_addr &amp; (IO_TLB_SIZE - 1)

was wrong, but instead of removing it, I think it should have just
fixed it to be

        (tlb_addr - mem-&gt;start) &amp; (IO_TLB_SIZE - 1);

instead. That way the slot offset always matches the slot index calculation."

(Unfortunatly that broke NVMe).

The use-case that drivers are hitting is as follow:

1. Get dma_addr_t from dma_map_single()

dma_addr_t tlb_addr = dma_map_single(dev, vaddr, vsize, DMA_TO_DEVICE);

    |&lt;---------------vsize-------------&gt;|
    +-----------------------------------+
    |                                   | original buffer
    +-----------------------------------+
  vaddr

 swiotlb_align_offset
     |&lt;-----&gt;|&lt;---------------vsize-------------&gt;|
     +-------+-----------------------------------+
     |       |                                   | swiotlb buffer
     +-------+-----------------------------------+
          tlb_addr

2. Do something
3. Sync dma_addr_t through dma_sync_single_for_device(..)

dma_sync_single_for_device(dev, tlb_addr + offset, size, DMA_TO_DEVICE);

  Error case.
    Copy data to original buffer but it is from base addr (instead of
  base addr + offset) in original buffer:

 swiotlb_align_offset
     |&lt;-----&gt;|&lt;- offset -&gt;|&lt;- size -&gt;|
     +-------+-----------------------------------+
     |       |            |##########|           | swiotlb buffer
     +-------+-----------------------------------+
          tlb_addr

    |&lt;- size -&gt;|
    +-----------------------------------+
    |##########|                        | original buffer
    +-----------------------------------+
  vaddr

The fix is to copy the data to the original buffer and take into
account the offset, like so:

 swiotlb_align_offset
     |&lt;-----&gt;|&lt;- offset -&gt;|&lt;- size -&gt;|
     +-------+-----------------------------------+
     |       |            |##########|           | swiotlb buffer
     +-------+-----------------------------------+
          tlb_addr

    |&lt;- offset -&gt;|&lt;- size -&gt;|
    +-----------------------------------+
    |            |##########|           | original buffer
    +-----------------------------------+
  vaddr

[One fix which was Linus's that made more sense to as it created a
symmetry would break NVMe. The reason for that is the:
 unsigned int offset = (tlb_addr - mem-&gt;start) &amp; (IO_TLB_SIZE - 1);

would come up with the proper offset, but it would lose the
alignment (which this patch contains).]

Fixes: 16fc3cef33a0 ("swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single")
Signed-off-by: Bumyong Lee &lt;bumyong.lee@samsung.com&gt;
Signed-off-by: Chanho Park &lt;chanho61.park@samsung.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reported-by: Dominique MARTINET &lt;dominique.martinet@atmark-techno.com&gt;
Reported-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Tested-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
CC: stable@vger.kernel.org
Signed-off-by: Konrad Rzeszutek Wilk &lt;konrad.wilk@oracle.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'stable/for-linus-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb</title>
<updated>2021-05-04T17:58:49Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-05-04T17:58:49Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=74d6790cdaaf3825afe53e668b32e662ad5e2e12'/>
<id>urn:sha1:74d6790cdaaf3825afe53e668b32e662ad5e2e12</id>
<content type='text'>
Pull swiotlb updates from Konrad Rzeszutek Wilk:
 "Christoph Hellwig has taken a cleaver and trimmed off the not-needed
  code and nicely folded duplicate code in the generic framework.

  This lays the groundwork for more work to add extra DMA-backend-ish in
  the future. Along with that some bug-fixes to make this a nice working
  package"

* 'stable/for-linus-5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb:
  swiotlb: don't override user specified size in swiotlb_adjust_size
  swiotlb: Fix the type of index
  swiotlb: Make SWIOTLB_NO_FORCE perform no allocation
  ARM: Qualify enabling of swiotlb_init()
  swiotlb: remove swiotlb_nr_tbl
  swiotlb: dynamically allocate io_tlb_default_mem
  swiotlb: move global variables into a new io_tlb_mem structure
  xen-swiotlb: remove the unused size argument from xen_swiotlb_fixup
  xen-swiotlb: split xen_swiotlb_init
  swiotlb: lift the double initialization protection from xen-swiotlb
  xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs
  xen-swiotlb: remove xen_set_nslabs
  xen-swiotlb: use io_tlb_end in xen_swiotlb_dma_supported
  xen-swiotlb: use is_swiotlb_buffer in is_xen_swiotlb_buffer
  swiotlb: split swiotlb_tbl_sync_single
  swiotlb: move orig addr and size validation into swiotlb_bounce
  swiotlb: remove the alloc_size parameter to swiotlb_tbl_unmap_single
  powerpc/svm: stop using io_tlb_start
</content>
</entry>
<entry>
<title>Merge tag 'dma-mapping-5.13' of git://git.infradead.org/users/hch/dma-mapping</title>
<updated>2021-05-04T17:52:09Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-05-04T17:52:09Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=954b7207059cc4004f2e18f49c335304b1c6d64a'/>
<id>urn:sha1:954b7207059cc4004f2e18f49c335304b1c6d64a</id>
<content type='text'>
Pull dma-mapping updates from Christoph Hellwig:

 - add a new dma_alloc_noncontiguous API (me, Ricardo Ribalda)

 - fix a copyright notice (Hao Fang)

 - add an unlikely annotation to dma_mapping_error (Heiner Kallweit)

 - remove a pointless empty line (Wang Qing)

 - add support for multi-pages map/unmap bencharking (Xiang Chen)

* tag 'dma-mapping-5.13' of git://git.infradead.org/users/hch/dma-mapping:
  dma-mapping: add unlikely hint to error path in dma_mapping_error
  dma-mapping: benchmark: Add support for multi-pages map/unmap
  dma-mapping: benchmark: use the correct HiSilicon copyright
  dma-mapping: remove a pointless empty line in dma_alloc_coherent
  media: uvcvideo: Use dma_alloc_noncontiguous API
  dma-iommu: implement -&gt;alloc_noncontiguous
  dma-iommu: refactor iommu_dma_alloc_remap
  dma-mapping: add a dma_alloc_noncontiguous API
  dma-mapping: refactor dma_{alloc,free}_pages
  dma-mapping: add a dma_mmap_pages helper
</content>
</entry>
</feed>
