[PATCH v2 5/6] ASoC: xlnx: formatter: set the DMA mask from xlnx,addrwidth

From: Dhanunjanrao Katta

Date: Mon Nov 30 2026 - 02:11:10 EST


hw_params splits the ring buffer address over the LSB and MSB buffer
address registers, but the device is left on the default 32 bit mask.
The coherent buffer therefore always comes from below 4G and the MSB
register is only ever written as zero.

The address bus width is a build time option of the IP, so take it
from the device tree rather than assuming it. An instance built with a
32 bit address bus keeps the mask it has today, and one built with a
64 bit bus can place the buffer in high memory as well.

Signed-off-by: Dhanunjanrao Katta <katta.dhanunjanrao@xxxxxxx>
---
sound/soc/xilinx/xlnx_formatter_pcm.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c
index fa7419439ec7..c412ce49d634 100644
--- a/sound/soc/xilinx/xlnx_formatter_pcm.c
+++ b/sound/soc/xilinx/xlnx_formatter_pcm.c
@@ -8,8 +8,10 @@

#include <linux/bitfield.h>
#include <linux/clk.h>
+#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/module.h>
+#include <linux/property.h>
#include <linux/sizes.h>

#include <sound/asoundef.h>
@@ -594,10 +596,18 @@ static int xlnx_formatter_pcm_probe(struct platform_device *pdev)
{
int ret;
u32 val;
+ u32 addr_width;
struct xlnx_pcm_drv_data *aud_drv_data;
struct device *dev = &pdev->dev;
struct clk *axi_clk, *aud_mclk, *axis_clk;

+ if (device_property_read_u32(dev, "xlnx,addrwidth", &addr_width))
+ addr_width = 32;
+
+ ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(addr_width));
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to set the DMA mask\n");
+
axi_clk = devm_clk_get_enabled(dev, "s_axi_lite_aclk");
if (IS_ERR(axi_clk))
return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to get s_axi_lite_aclk");
--
2.34.1