[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <mfvy2vvs2272mq5qsstpluiir4ww4sdp22mj34viizr4dgwjt5@qhy2cr4rrjm3>
Date: Wed, 21 Jan 2026 10:44:07 +0900
From: Koichiro Den <den@...inux.co.jp>
To: Frank Li <Frank.li@....com>
Cc: dave.jiang@...el.com, cassel@...nel.org, mani@...nel.org,
kwilczynski@...nel.org, kishon@...nel.org, bhelgaas@...gle.com, geert+renesas@...der.be,
robh@...nel.org, vkoul@...nel.org, jdmason@...zu.us, allenbh@...il.com,
jingoohan1@...il.com, lpieralisi@...nel.org, linux-pci@...r.kernel.org,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
devicetree@...r.kernel.org, dmaengine@...r.kernel.org, iommu@...ts.linux.dev,
ntb@...ts.linux.dev, netdev@...r.kernel.org, linux-kselftest@...r.kernel.org,
arnd@...db.de, gregkh@...uxfoundation.org, joro@...tes.org, will@...nel.org,
robin.murphy@....com, magnus.damm@...il.com, krzk+dt@...nel.org, conor+dt@...nel.org,
corbet@....net, skhan@...uxfoundation.org, andriy.shevchenko@...ux.intel.com,
jbrunet@...libre.com, utkarsh02t@...il.com
Subject: Re: [RFC PATCH v4 11/38] NTB: core: Add .get_dma_dev() to ntb_dev_ops
On Mon, Jan 19, 2026 at 03:09:18PM -0500, Frank Li wrote:
> On Sun, Jan 18, 2026 at 10:54:13PM +0900, Koichiro Den wrote:
> > Not all NTB implementations are able to naturally do DMA mapping through
> > the NTB PCI device itself (e.g. due to IOMMU topology or non-PCI backing
> > devices).
> >
> > Add an optional .get_dma_dev() callback and helper so clients can use
> > the appropriate struct device for DMA API allocations and mappings.
> >
> > Signed-off-by: Koichiro Den <den@...inux.co.jp>
> > ---
> > include/linux/ntb.h | 18 ++++++++++++++++++
> > 1 file changed, 18 insertions(+)
> >
> > diff --git a/include/linux/ntb.h b/include/linux/ntb.h
> > index aa888219732a..7ac8cb13e90d 100644
> > --- a/include/linux/ntb.h
> > +++ b/include/linux/ntb.h
> > @@ -262,6 +262,7 @@ struct ntb_mw_subrange {
> > * @msg_clear_mask: See ntb_msg_clear_mask().
> > * @msg_read: See ntb_msg_read().
> > * @peer_msg_write: See ntb_peer_msg_write().
> > + * @get_dma_dev: See ntb_get_dma_dev().
> > * @get_private_data: See ntb_get_private_data().
> > */
> > struct ntb_dev_ops {
> > @@ -339,6 +340,7 @@ struct ntb_dev_ops {
> > int (*msg_clear_mask)(struct ntb_dev *ntb, u64 mask_bits);
> > u32 (*msg_read)(struct ntb_dev *ntb, int *pidx, int midx);
> > int (*peer_msg_write)(struct ntb_dev *ntb, int pidx, int midx, u32 msg);
> > + struct device *(*get_dma_dev)(struct ntb_dev *ntb);
> > void *(*get_private_data)(struct ntb_dev *ntb);
> > };
> >
> > @@ -405,6 +407,7 @@ static inline int ntb_dev_ops_is_valid(const struct ntb_dev_ops *ops)
> > !ops->peer_msg_write == !ops->msg_count &&
> >
> > /* Miscellaneous optional callbacks */
> > + /* ops->get_dma_dev && */
> > /* ops->get_private_data && */
> > 1;
> > }
> > @@ -1614,6 +1617,21 @@ static inline int ntb_peer_msg_write(struct ntb_dev *ntb, int pidx, int midx,
> > return ntb->ops->peer_msg_write(ntb, pidx, midx, msg);
> > }
> >
> > +/**
> > + * ntb_get_dma_dev() - get the device suitable for DMA mapping
> > + * @ntb: NTB device context.
> > + *
> > + * Retrieve a struct device which is suitable for DMA mapping.
> > + *
> > + * Return: Pointer to struct device.
> > + */
> > +static inline struct device __maybe_unused *ntb_get_dma_dev(struct ntb_dev *ntb)
>
> I remember if there are inline, needn't __maybe_unused.
My bad, I'll drop it.
Thanks,
Koichiro
>
> Reviewed-by: Frank Li <Frank.Li@....com>
> > +{
> > + if (!ntb->ops->get_dma_dev)
> > + return ntb->dev.parent;
> > + return ntb->ops->get_dma_dev(ntb);
> > +}
> > +
> > /**
> > * ntb_get_private_data() - get private data specific to the hardware driver
> > * @ntb: NTB device context.
> > --
> > 2.51.0
> >
Powered by blists - more mailing lists