Re: [PATCH v4 03/25] dmaengine: sdxi: Add PCI initialization

From: Jonathan Cameron

Date: Tue Nov 24 2026 - 20:01:37 EST


On Tue, 03 Nov 2026 20:49:44 -0600
Nathan Lynch via B4 Relay <devnull+nathan.lynch.amd.com@xxxxxxxxxx> wrote:

> From: Nathan Lynch <nathan.lynch@xxxxxxx>
>
> Add enough code to bind a SDXI device via the class code and map its
> control registers and doorbell region.
>
> Keep PCI resource setup in pci.c and register devices with the SDXI core
> through bus operations.
>
> Co-developed-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
> Signed-off-by: Nathan Lynch <nathan.lynch@xxxxxxx>

Just a few quick comments inline.

> diff --git a/drivers/dma/sdxi/device.c b/drivers/dma/sdxi/device.c
> new file mode 100644
> index 000000000000..0974a83bb45c
> --- /dev/null
> +++ b/drivers/dma/sdxi/device.c
> @@ -0,0 +1,33 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * SDXI hardware device driver
> + *
> + * Copyright Advanced Micro Devices, Inc.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/export.h>
> +#include <linux/slab.h>
> +
> +#include "sdxi.h"
> +
> +int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops)
> +{
> + struct sdxi_dev *sdxi;
> +
> + sdxi = devm_kzalloc(dev, sizeof(*sdxi), GFP_KERNEL);

Perhaps switch now to devm_kzalloc_obj() and avoid the churn
if it being updated once applied. The mass change is there
in rc3.

> + if (!sdxi)
> + return -ENOMEM;
> +
> + sdxi->dev = dev;
> + sdxi->bus_ops = ops;
> + dev_set_drvdata(dev, sdxi);
> +
> + return sdxi->bus_ops->init(sdxi);
> +}
> +EXPORT_SYMBOL_NS_GPL(sdxi_register, "SDXI");
> +
> +MODULE_AUTHOR("Wei Huang");
> +MODULE_AUTHOR("Nathan Lynch");
> +MODULE_DESCRIPTION("SDXI core");
> +MODULE_LICENSE("GPL");


> diff --git a/drivers/dma/sdxi/pci.c b/drivers/dma/sdxi/pci.c
> new file mode 100644
> index 000000000000..0778cde31f14
> --- /dev/null
> +++ b/drivers/dma/sdxi/pci.c

> +
> +static const struct sdxi_bus_ops sdxi_pci_ops = {
> + .init = sdxi_pci_init,
> +};
> +
> +static int sdxi_pci_probe(struct pci_dev *pdev,
> + const struct pci_device_id *id)
> +{
> + return sdxi_register(&pdev->dev, &sdxi_pci_ops);

This seems oddly miss balanced. Perhaps it's better to introduce
an empty sdxi_unregister() ready for when it's needed later?


> +}
> +
> +static void sdxi_pci_remove(struct pci_dev *pdev)
> +{
> + pci_disable_sriov(pdev);
> +}

> +
> +MODULE_IMPORT_NS("SDXI");
> +MODULE_AUTHOR("Wei Huang");
> +MODULE_AUTHOR("Nathan Lynch");
> +MODULE_DESCRIPTION("SDXI PCIe interface driver");
> +MODULE_LICENSE("GPL");
> +module_pci_driver(sdxi_driver);

This is normally placed near the struct pci_driver. So before all
the MODULE_ macros. I found a few examples of this style, but that
one is much more common and makes sense given this is just generating
boiler plate functions to register etc that structure.

> diff --git a/drivers/dma/sdxi/sdxi.h b/drivers/dma/sdxi/sdxi.h
> new file mode 100644
> index 000000000000..d4c61ca2f875
> --- /dev/null
> +++ b/drivers/dma/sdxi/sdxi.h
> @@ -0,0 +1,38 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * SDXI device driver header
> + *
> + * Copyright Advanced Micro Devices, Inc.
> + */
> +
> +#ifndef DMA_SDXI_H
> +#define DMA_SDXI_H
> +
> +#include <linux/compiler_types.h>
> +#include <linux/types.h>
> +
> +struct sdxi_dev;
> +
> +/**
> + * struct sdxi_bus_ops - Bus-specific methods for SDXI devices.
> + */
> +struct sdxi_bus_ops {
> + /**
> + * @init: Map control registers and doorbell region, allocate
> + * IRQ ranges. Invoked before bus-agnostic SDXI
> + * function initialization.

Trivial but comment wrap should be closer to 80 chars.

> + int (*init)(struct sdxi_dev *sdxi);
> +};
> +
> +struct sdxi_dev {
> + struct device *dev;
> + void __iomem *ctrl_regs; /* virt addr of ctrl registers */
> + void __iomem *dbs; /* virt addr of doorbells */
> +
> + const struct sdxi_bus_ops *bus_ops;
> +};
> +
> +int sdxi_register(struct device *dev, const struct sdxi_bus_ops *ops);
> +
> +#endif /* DMA_SDXI_H */
>