Re: [PATCH v4 07/25] dmaengine: sdxi: Allocate context control DMA pool
From: Frank Li
Date: Thu Nov 12 2026 - 17:15:46 EST
On Tue, Nov 03, 2026 at 08:49:48PM -0600, Nathan Lynch via B4 Relay wrote:
> From: Nathan Lynch <nathan.lynch@xxxxxxx>
>
> Each SDXI context has a control block (CXT_CTL) that identifies its
> descriptor ring, context status block, and write index.
>
> Define the CXT_CTL layout and create a DMA pool for them during
> function initialization.
>
> Co-developed-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Nathan Lynch <nathan.lynch@xxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> drivers/dma/sdxi/device.c | 21 ++++++++++++++++++++-
> drivers/dma/sdxi/hw.h | 11 +++++++++++
> drivers/dma/sdxi/sdxi.h | 2 ++
> 3 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/sdxi/device.c b/drivers/dma/sdxi/device.c
> index baf55f6b6826..acc955b088ba 100644
> --- a/drivers/dma/sdxi/device.c
> +++ b/drivers/dma/sdxi/device.c
> @@ -9,6 +9,7 @@
> #include <linux/delay.h>
> #include <linux/device.h>
> #include <linux/dma-mapping.h>
> +#include <linux/dmapool.h>
> #include <linux/export.h>
> #include <linux/iopoll.h>
> #include <linux/jiffies.h>
> @@ -351,6 +352,24 @@ static int sdxi_fn_activate(struct sdxi_dev *sdxi)
> return 0;
> }
>
> +static int sdxi_device_init(struct sdxi_dev *sdxi)
> +{
> + struct device *dev = sdxi->dev;
> + size_t size, align;
> + int err;
> +
> + size = align = sizeof(struct sdxi_cxt_ctl);
> + sdxi->cxt_ctl_pool = dmam_pool_create("CXT_CTL", dev, size, align, 0);
> + if (!sdxi->cxt_ctl_pool)
> + return -ENOMEM;
> +
> + err = sdxi_fn_activate(sdxi);
> + if (err)
> + return err;
> +
> + return 0;
> +}
> +
> int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops)
> {
> struct sdxi_dev *sdxi;
> @@ -372,7 +391,7 @@ int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops)
> if (err)
> return err;
>
> - return sdxi_fn_activate(sdxi);
> + return sdxi_device_init(sdxi);
> }
> EXPORT_SYMBOL_NS_GPL(sdxi_register, "SDXI");
>
> diff --git a/drivers/dma/sdxi/hw.h b/drivers/dma/sdxi/hw.h
> index 0551c2b52980..82c6b4a20cde 100644
> --- a/drivers/dma/sdxi/hw.h
> +++ b/drivers/dma/sdxi/hw.h
> @@ -47,4 +47,15 @@ struct sdxi_cxt_L1_table {
> };
> static_assert(sizeof(struct sdxi_cxt_L1_table) == 4096);
>
> +/* SDXI 1.0 Table 3-4: Context Control (CXT_CTL) */
> +struct sdxi_cxt_ctl {
> + __le64 ds_ring_ptr;
> + __le32 ds_ring_sz;
> + __u8 rsvd_0[4];
> + __le64 cxt_sts_ptr;
> + __le64 write_index_ptr;
> + __u8 rsvd_1[32];
> +} __packed __aligned(64);
> +static_assert(sizeof(struct sdxi_cxt_ctl) == 64);
> +
> #endif /* DMA_SDXI_HW_H */
> diff --git a/drivers/dma/sdxi/sdxi.h b/drivers/dma/sdxi/sdxi.h
> index 856a3838eec3..356a47ed39da 100644
> --- a/drivers/dma/sdxi/sdxi.h
> +++ b/drivers/dma/sdxi/sdxi.h
> @@ -49,6 +49,8 @@ struct sdxi_dev {
> struct sdxi_cxt_L1_table *L1_table;
> dma_addr_t L1_dma;
>
> + struct dma_pool *cxt_ctl_pool;
> +
> bool has_mailbox;
>
> const struct sdxi_bus_ops *bus_ops;
>
> --
> 2.56.0
>
>