<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/sound/core/memalloc.c, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2024-12-20T08:54:12+00:00</updated>
<entry>
<title>ALSA: memalloc: prefer dma_mapping_error() over explicit address checking</title>
<updated>2024-12-20T08:54:12+00:00</updated>
<author>
<name>Fedor Pchelkin</name>
<email>pchelkin@ispras.ru</email>
</author>
<published>2024-12-19T20:33:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fa0308134d26dbbeb209a1581eea46df663866b6'/>
<id>urn:sha1:fa0308134d26dbbeb209a1581eea46df663866b6</id>
<content type='text'>
With CONFIG_DMA_API_DEBUG enabled, the following warning is observed:

DMA-API: snd_hda_intel 0000:03:00.1: device driver failed to check map error[device address=0x00000000ffff0000] [size=20480 bytes] [mapped as single]
WARNING: CPU: 28 PID: 2255 at kernel/dma/debug.c:1036 check_unmap+0x1408/0x2430
CPU: 28 UID: 42 PID: 2255 Comm: wireplumber Tainted: G  W L  6.12.0-10-133577cad6bf48e5a7848c4338124081393bfe8a+ #759
debug_dma_unmap_page+0xe9/0xf0
snd_dma_wc_free+0x85/0x130 [snd_pcm]
snd_pcm_lib_free_pages+0x1e3/0x440 [snd_pcm]
snd_pcm_common_ioctl+0x1c9a/0x2960 [snd_pcm]
snd_pcm_ioctl+0x6a/0xc0 [snd_pcm]
...

Check for returned DMA addresses using specialized dma_mapping_error()
helper which is generally recommended for this purpose by
Documentation/core-api/dma-api.rst.

Fixes: c880a5146642 ("ALSA: memalloc: Use proper DMA mapping API for x86 WC buffer allocations")
Reported-by: Mikhail Gavrilov &lt;mikhail.v.gavrilov@gmail.com&gt;
Closes: https://lore.kernel.org/r/CABXGCsNB3RsMGvCucOy3byTEOxoc-Ys+zB_HQ=Opb_GhX1ioDA@mail.gmail.com/
Tested-by: Mikhail Gavrilov &lt;mikhail.v.gavrilov@gmail.com&gt;
Signed-off-by: Fedor Pchelkin &lt;pchelkin@ispras.ru&gt;
Link: https://patch.msgid.link/20241219203345.195898-1-pchelkin@ispras.ru
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Use proper DMA mapping API for x86 S/G buffer allocations</title>
<updated>2024-09-12T16:02:18+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-09-12T15:52:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0b9f2bd00fc3677e38ae5e46ff79b8d48d9cb02e'/>
<id>urn:sha1:0b9f2bd00fc3677e38ae5e46ff79b8d48d9cb02e</id>
<content type='text'>
The fallback S/G buffer allocation for x86 used the addresses deduced
from the page allocations blindly.  It broke the allocations on IOMMU
and made us to work around with a hackish DMA ops check.

For cleaning up those messes, this patch switches to the proper DMA
mapping API usages with the standard sg-table instead.

By introducing the sg-table, the address table isn't needed, but for
keeping the original allocation sizes for freeing, replace it with the
array keeping the number of pages.

The get_addr callback is changed to use the existing one for
non-contiguous buffers.  (Also it's the reason sg_table is put at the
beginning of struct snd_dma_sg_fallback.)

And finally, the hackish workaround that checks the DMA ops is
dropped now.

Link: https://patch.msgid.link/20240912155227.4078-3-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Use proper DMA mapping API for x86 WC buffer allocations</title>
<updated>2024-09-12T16:02:03+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-09-12T15:52:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c880a5146642e9d35f88aaa353ae98ffd4fc3f99'/>
<id>urn:sha1:c880a5146642e9d35f88aaa353ae98ffd4fc3f99</id>
<content type='text'>
The x86 WC page allocation assumes incorrectly the DMA address
directly taken from the page.  Also it checks the DMA ops
inappropriately for switching to the own method.

This patch rewrites the stuff to use the proper DMA mapping API
instead.

Link: https://patch.msgid.link/20240912155227.4078-2-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Drop Xen PV workaround again</title>
<updated>2024-09-11T06:31:19+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-09-10T11:30:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9408ace468c317d60159c011b863b2982dae5e05'/>
<id>urn:sha1:9408ace468c317d60159c011b863b2982dae5e05</id>
<content type='text'>
Since recently in the commit e469e2045f1b ("ALSA: memalloc: Let IOMMU
handle S/G primarily"), the SG buffer allocation code was modified to
use the standard DMA code primarily and the fallback is applied only
limitedly.  This made the Xen PV specific workarounds we took in the
commit 53466ebdec61 ("ALSA: memalloc: Workaround for Xen PV") rather
superfluous.

It was a hackish workaround for the regression at that time, and it
seems that it's causing another issues (reportedly memory
corruptions).  So it's better to clean it up, after all.

Link: https://lore.kernel.org/20240906184209.25423-1-ariadne@ariadne.space
Cc: Ariadne Conill &lt;ariadne@ariadne.space&gt;
Link: https://patch.msgid.link/20240910113100.32542-1-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Move snd_malloc_ops definition into memalloc.c again</title>
<updated>2024-09-10T11:32:36+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-09-10T11:31:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5ced8b914ed46edff0d265fb6f397bc851f5fd85'/>
<id>urn:sha1:5ced8b914ed46edff0d265fb6f397bc851f5fd85</id>
<content type='text'>
The definition of struct snd_malloc_ops was moved out to
memalloc_local.h since there was another code for S/G buffer
allocation referring to the struct.  But since the code change to use
non-contiguous allocators, it's solely referred in memalloc.c, hence
it makes little sense to have a separate header file.

Let's move it back to memalloc.c.

Link: https://patch.msgid.link/20240910113141.32618-1-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Let IOMMU handle S/G primarily</title>
<updated>2024-08-01T10:45:49+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-08-01T06:48:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e469e2045f1b78418f39a2461a9fdf73c2789a1a'/>
<id>urn:sha1:e469e2045f1b78418f39a2461a9fdf73c2789a1a</id>
<content type='text'>
The recent changes in IOMMU made the non-contiguous page allocations
as default, hence we can simply use the standard DMA allocation for
the S/G pages as well.  In this patch, we simplify the code by trying
the standard DMA allocation at first, instead of
dma_alloc_noncontiguous().

For the case without IOMMU, we still need to manage the S/G pages
manually, so we keep the same fallback routines like before.

The fallback types (SNDRV_DMA_TYPE_DEV_SG_FALLBACK &amp; co) are dropped /
folded into SNDRV_DMA_TYPE_DEV_SG and co now.  The allocation via the
standard DMA call overrides the type accordingly, hence we don't have
to have extra fallback types any longer.  OTOH, SNDRV_DMA_TYPE_DEV_SG
is no longer an alias but became its own type back again.

Note that this patch requires another prerequisite fix for memmalloc
helper to use the DMA API for WC pages on x86.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=219087
Link: https://patch.msgid.link/20240801064808.31205-2-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Use DMA API for x86 WC page allocations, too</title>
<updated>2024-08-01T10:45:41+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2024-08-01T06:48:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9c27301342a53fdf349e4c630d75c7c12bbbc580'/>
<id>urn:sha1:9c27301342a53fdf349e4c630d75c7c12bbbc580</id>
<content type='text'>
The memalloc helper used a house-made code for allocation of WC pages
on x86, since the standard DMA API doesn't cover it well.  Meanwhile,
the manually allocated pages won't work together with IOMMU, resulting
in faults, so we should switch to the DMA API in that case, instead.

This patch tries to switch back to DMA API for WC pages on x86, but
with some additional tweaks that are missing.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=219087
Link: https://patch.msgid.link/20240801064808.31205-1-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: Workaround for Xen PV</title>
<updated>2023-01-27T08:16:24+00:00</updated>
<author>
<name>Takashi Iwai</name>
<email>tiwai@suse.de</email>
</author>
<published>2023-01-25T15:31:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=53466ebdec614f915c691809b0861acecb941e30'/>
<id>urn:sha1:53466ebdec614f915c691809b0861acecb941e30</id>
<content type='text'>
We change recently the memalloc helper to use
dma_alloc_noncontiguous() and the fallback to get_pages().  Although
lots of issues with IOMMU (or non-IOMMU) have been addressed, but
there seems still a regression on Xen PV.  Interestingly, the only
proper way to work is use dma_alloc_coherent().  The use of
dma_alloc_coherent() for SG buffer was dropped as it's problematic on
IOMMU systems.  OTOH, Xen PV has a different way, and it's fine to use
the dma_alloc_coherent().

This patch is a workaround for Xen PV.  It consists of the following
changes:
- For Xen PV, use only the fallback allocation without
  dma_alloc_noncontiguous()
- In the fallback allocation, use dma_alloc_coherent();
  the DMA address from dma_alloc_coherent() is returned in get_addr
  ops
- The DMA addresses are stored in an array; the first entry stores the
  number of allocated pages in lower bits, which are referred at
  releasing pages again

Reported-by: Marek Marczykowski-Górecki &lt;marmarek@invisiblethingslab.com&gt;
Tested-by: Marek Marczykowski-Górecki &lt;marmarek@invisiblethingslab.com&gt;
Fixes: a8d302a0b770 ("ALSA: memalloc: Revive x86-specific WC page allocations again")
Fixes: 9736a325137b ("ALSA: memalloc: Don't fall back for SG-buffer with IOMMU")
Link: https://lore.kernel.org/r/87tu256lqs.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20230125153104.5527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai &lt;tiwai@suse.de&gt;
</content>
</entry>
<entry>
<title>ALSA: memalloc: don't use GFP_COMP for non-coherent dma allocations</title>
<updated>2022-12-21T07:45:17+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2022-12-20T08:05:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=db918321275d648294a3fb2bdefeb99e33f00467'/>
<id>urn:sha1:db918321275d648294a3fb2bdefeb99e33f00467</id>
<content type='text'>
While not quite as bogus as for the dma-coherent allocations that were
fixed earlier, GFP_COMP for these allocations has no benefits for
the dma-direct case, and can't be supported at all by dma dma-iommu
backend which splits up allocations into smaller orders.  Due to an
oversight in ffcb75458460 that flag stopped being cleared for all
dma allocations, but only got rejected for coherent ones.

Start fixing this by not requesting __GFP_COMP in the sound code, which
is the only place that did this.

Fixes: ffcb75458460 ("dma-mapping: reject __GFP_COMP in dma_alloc_attrs")
Reported-by: Mikhail Gavrilov &lt;mikhail.v.gavrilov@gmail.com&gt;
Reported-by: Kai Vehmanen &lt;kai.vehmanen@linux.intel.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: Takashi Iwai &lt;tiwai@suse.de&gt;
Tested-by: Mikhail Gavrilov &lt;mikhail.v.gavrilov@gmail.com&gt;
Tested-by: Kai Vehmanen &lt;kai.vehmanen@linux.intel.com&gt;
</content>
</entry>
<entry>
<title>Merge tag 'sound-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound</title>
<updated>2022-12-13T19:27:26+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2022-12-13T19:27:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=102f9d3d455870844c47b82322c2dfc0a35eb745'/>
<id>urn:sha1:102f9d3d455870844c47b82322c2dfc0a35eb745</id>
<content type='text'>
Pull sound updates from Takashi Iwai:
 "This looks like a relatively calm development cycle; there have been
  only few changes in ALSA and ASoC core sides while we get lots of
  device-specific fixes and updates as usual. Most of commits are about
  ASoC, including Intel SOF/AVS and many device tree updates.

  Below are some highlights:

  Core:
   - Improvement in memalloc helper for fallback allocations
   - More cleanups of ASoC DAPM code

  ASoC:
   - Factoring out of mapping hw_params onto SoundWire configuration
   - The ever ongoing overhauls of the Intel DSP code continue,
     including support for loading libraries and probes with IPC4 on
     SOF.
   - Support for more sample formats on JZ4740
   - Lots of device tree conversions and fixups
   - Support for Allwinner D1, a range of AMD and Intel systems,
     Mediatek systems with multiple DMICs, Nuvoton NAU8318, NXP
     fsl_rpmsg and i.MX93, Qualcomm AudioReach Enable, MFC and SAL,
     RealTek RT1318 and Rockchip RK3588

  ALSA:
   - Addition of PCM kselftest; still minimalistic but can be extended
     in future
   - Fixes for corner-case XRUNs with USB-audio implicit feedback mode
   - Usual device-specific quirk updates for USB- and HD-audio
   - FireWire DICE updates

  This also contains a few cross-tree updates:
   - Some OMAP board file updates for removal of relevant OMAP platforms
   - A new I2C API update for I2C probe API adaption
   - A DRM update for the further hdmi-codec updates"

* tag 'sound-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (417 commits)
  ALSA: mts64: fix possible null-ptr-defer in snd_mts64_interrupt
  ALSA: patch_realtek: Fix Dell Inspiron Plus 16
  ALSA: hda/cirrus: Add extra 10 ms delay to allow PLL settle and lock.
  ASoC: dt-bindings: Correct Alexandre Belloni email
  ASoC: dt-bindings: maxim,max98504: Convert to DT schema
  ASoC: dt-bindings: maxim,max98357a: Convert to DT schema
  ASoC: dt-bindings: Reference common DAI properties
  ASoC: dt-bindings: Extend name-prefix.yaml into common DAI properties
  ASoC: rt715: Make read-only arrays capture_reg_H and capture_reg_L static const
  ASoC: uniphier: aio-core: Make some read-only arrays static const
  ASoC: wcd938x: Make read-only array minCode_param static const
  ASoC: qcom: lpass-sc7280: Add maybe_unused tag for system PM ops
  ASoC : SOF: amd: Add support for IPC and DSP dumps
  ASoC: SOF: amd: Use poll function instead to read ACP_SHA_DSP_FW_QUALIFIER
  ALSA: usb-audio: Workaround for XRUN at prepare
  ALSA: pcm: Handle XRUN at trigger START
  ALSA: pcm: Set missing stop_operating flag at undoing trigger start
  drm: tda99x: Don't advertise non-existent capture support
  ASoC: hdmi-codec: Allow playback and capture to be disabled
  kselftest/alsa: Add more coverage of sample rates and channel counts
  ...
</content>
</entry>
</feed>
