[RFC PATCH v4 15/38] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev()

Koichiro Den posted 38 patches 3 weeks, 1 day ago
[RFC PATCH v4 15/38] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev()
Posted by Koichiro Den 3 weeks, 1 day ago
For DMA API allocations and mappings, pci-epf-vntb should provide an
appropriate struct device for the NTB core/clients.

Implement .get_dma_dev() and return the EPC parent device.

Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 9fbc27000f77..7cd976757d15 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -1747,6 +1747,15 @@ static int vntb_epf_link_disable(struct ntb_dev *ntb)
 	return 0;
 }
 
+static struct device *vntb_epf_get_dma_dev(struct ntb_dev *ndev)
+{
+	struct epf_ntb *ntb = ntb_ndev(ndev);
+
+	if (!ntb || !ntb->epf)
+		return NULL;
+	return ntb->epf->epc->dev.parent;
+}
+
 static void *vntb_epf_get_private_data(struct ntb_dev *ndev)
 {
 	struct epf_ntb *ntb = ntb_ndev(ndev);
@@ -1780,6 +1789,7 @@ static const struct ntb_dev_ops vntb_epf_ops = {
 	.db_clear_mask		= vntb_epf_db_clear_mask,
 	.db_clear		= vntb_epf_db_clear,
 	.link_disable		= vntb_epf_link_disable,
+	.get_dma_dev		= vntb_epf_get_dma_dev,
 	.get_private_data	= vntb_epf_get_private_data,
 };
 
-- 
2.51.0
Re: [RFC PATCH v4 15/38] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev()
Posted by Frank Li 3 weeks ago
On Sun, Jan 18, 2026 at 10:54:17PM +0900, Koichiro Den wrote:
> For DMA API allocations and mappings, pci-epf-vntb should provide an
> appropriate struct device for the NTB core/clients.
>
> Implement .get_dma_dev() and return the EPC parent device.

Simple said:

Implement .get_dma_dev() and return the EPC parent device for NTB
core/client's DMA allocations and mappings API.

Reviewed-by: Frank Li <Frank.Li@nxp.com>
>
> Signed-off-by: Koichiro Den <den@valinux.co.jp>
> ---
>  drivers/pci/endpoint/functions/pci-epf-vntb.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> index 9fbc27000f77..7cd976757d15 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> @@ -1747,6 +1747,15 @@ static int vntb_epf_link_disable(struct ntb_dev *ntb)
>  	return 0;
>  }
>
> +static struct device *vntb_epf_get_dma_dev(struct ntb_dev *ndev)
> +{
> +	struct epf_ntb *ntb = ntb_ndev(ndev);
> +
> +	if (!ntb || !ntb->epf)
> +		return NULL;
> +	return ntb->epf->epc->dev.parent;
> +}
> +
>  static void *vntb_epf_get_private_data(struct ntb_dev *ndev)
>  {
>  	struct epf_ntb *ntb = ntb_ndev(ndev);
> @@ -1780,6 +1789,7 @@ static const struct ntb_dev_ops vntb_epf_ops = {
>  	.db_clear_mask		= vntb_epf_db_clear_mask,
>  	.db_clear		= vntb_epf_db_clear,
>  	.link_disable		= vntb_epf_link_disable,
> +	.get_dma_dev		= vntb_epf_get_dma_dev,
>  	.get_private_data	= vntb_epf_get_private_data,
>  };
>
> --
> 2.51.0
>
Re: [RFC PATCH v4 15/38] PCI: endpoint: pci-epf-vntb: Implement .get_dma_dev()
Posted by Koichiro Den 2 weeks, 4 days ago
On Mon, Jan 19, 2026 at 03:30:16PM -0500, Frank Li wrote:
> On Sun, Jan 18, 2026 at 10:54:17PM +0900, Koichiro Den wrote:
> > For DMA API allocations and mappings, pci-epf-vntb should provide an
> > appropriate struct device for the NTB core/clients.
> >
> > Implement .get_dma_dev() and return the EPC parent device.
> 
> Simple said:
> 
> Implement .get_dma_dev() and return the EPC parent device for NTB
> core/client's DMA allocations and mappings API.

Thanks for pointing this out. That makes sense, I'll update the text as you
suggested.

Koichiro

> 
> Reviewed-by: Frank Li <Frank.Li@nxp.com>
> >
> > Signed-off-by: Koichiro Den <den@valinux.co.jp>
> > ---
> >  drivers/pci/endpoint/functions/pci-epf-vntb.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > index 9fbc27000f77..7cd976757d15 100644
> > --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
> > @@ -1747,6 +1747,15 @@ static int vntb_epf_link_disable(struct ntb_dev *ntb)
> >  	return 0;
> >  }
> >
> > +static struct device *vntb_epf_get_dma_dev(struct ntb_dev *ndev)
> > +{
> > +	struct epf_ntb *ntb = ntb_ndev(ndev);
> > +
> > +	if (!ntb || !ntb->epf)
> > +		return NULL;
> > +	return ntb->epf->epc->dev.parent;
> > +}
> > +
> >  static void *vntb_epf_get_private_data(struct ntb_dev *ndev)
> >  {
> >  	struct epf_ntb *ntb = ntb_ndev(ndev);
> > @@ -1780,6 +1789,7 @@ static const struct ntb_dev_ops vntb_epf_ops = {
> >  	.db_clear_mask		= vntb_epf_db_clear_mask,
> >  	.db_clear		= vntb_epf_db_clear,
> >  	.link_disable		= vntb_epf_link_disable,
> > +	.get_dma_dev		= vntb_epf_get_dma_dev,
> >  	.get_private_data	= vntb_epf_get_private_data,
> >  };
> >
> > --
> > 2.51.0
> >