netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mina Almasry <almasrymina@google.com>
To: Dragos Tatulea <dtatulea@nvidia.com>
Cc: asml.silence@gmail.com, Saeed Mahameed <saeedm@nvidia.com>,
	 Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	 Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	 cratiu@nvidia.com, parav@nvidia.com,
	Christoph Hellwig <hch@infradead.org>,
	 netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [RFC net-next v3 4/7] net/mlx5e: add op for getting netdev DMA device
Date: Mon, 18 Aug 2025 11:18:10 -0700	[thread overview]
Message-ID: <CAHS8izNWStDWNfNro3oX1v5mwyzK_xmA0YfffqSeB0JZwArK7w@mail.gmail.com> (raw)
In-Reply-To: <jvbtvbmgqspgfc7q2bprtdtigrhdsrjqf3un2wvxnbydngyc7r@y2sgbxgqkdyi>

On Mon, Aug 18, 2025 at 10:40 AM Dragos Tatulea <dtatulea@nvidia.com> wrote:
>
> On Fri, Aug 15, 2025 at 10:37:15AM -0700, Mina Almasry wrote:
> > On Fri, Aug 15, 2025 at 4:07 AM Dragos Tatulea <dtatulea@nvidia.com> wrote:
> > >
> > > For zero-copy (devmem, io_uring), the netdev DMA device used
> > > is the parent device of the net device. However that is not
> > > always accurate for mlx5 devices:
> > > - SFs: The parent device is an auxdev.
> > > - Multi-PF netdevs: The DMA device should be determined by
> > >   the queue.
> > >
> > > This change implements the DMA device queue API that returns the DMA
> > > device appropriately for all cases.
> > >
> > > Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
> > > ---
> > >  .../net/ethernet/mellanox/mlx5/core/en_main.c | 24 +++++++++++++++++++
> > >  1 file changed, 24 insertions(+)
> > >
> > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > index 21bb88c5d3dc..0e48065a46eb 100644
> > > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> > > @@ -5625,12 +5625,36 @@ static int mlx5e_queue_start(struct net_device *dev, void *newq,
> > >         return 0;
> > >  }
> > >
> > > +static struct device *mlx5e_queue_get_dma_dev(struct net_device *dev,
> > > +                                             int queue_index)
> > > +{
> > > +       struct mlx5e_priv *priv = netdev_priv(dev);
> > > +       struct mlx5e_channels *channels;
> > > +       struct device *pdev = NULL;
> > > +       struct mlx5e_channel *ch;
> > > +
> > > +       channels = &priv->channels;
> > > +
> > > +       mutex_lock(&priv->state_lock);
> > > +
> > > +       if (queue_index >= channels->num)
> > > +               goto out;
> > > +
> > > +       ch = channels->c[queue_index];
> > > +       pdev = ch->pdev;
> >
> > This code assumes priv is initialized, and probably that the device is
> > up/running/registered. At first I thought that was fine, but now that
> > I look at the code more closely, netdev_nl_bind_rx_doit checks if the
> > device is present but doesn't seem to check that the device is
> > registered.
> >
> > I wonder if we should have a generic check in netdev_nl_bind_rx_doit
> > for NETDEV_REGISTERED, and if not, does this code handle unregistered
> > netdev correctly (like netdev_priv and priv->channels are valid even
> > for unregistered mlx5 devices)?
> >
> netdev_get_by_index_lock() returns non-NULL only when the device is in
> state NETDEV_REGISTERED or NETREG_UNINITIALIZED. So I think  that this
> check should suffice.
>

Ack, thanks for checking. For the patch:

Reviewed-by: Mina Almasry <almasrymina@google.com>



-- 
Thanks,
Mina

  reply	other threads:[~2025-08-18 18:18 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-15 11:03 [RFC net-next v3 0/7] devmem/io_uring: allow more flexibility for ZC DMA devices Dragos Tatulea
2025-08-15 11:03 ` [RFC net-next v3 1/7] queue_api: add support for fetching per queue DMA dev Dragos Tatulea
2025-08-15 17:16   ` Jakub Kicinski
2025-08-19 14:41     ` Dragos Tatulea
2025-08-19 15:30       ` Jakub Kicinski
2025-08-15 18:11   ` Mina Almasry
2025-08-16  8:55     ` Dragos Tatulea
2025-08-19 15:56   ` Pavel Begunkov
2025-08-15 11:03 ` [RFC net-next v3 3/7] net: devmem: get netdev DMA device via new API Dragos Tatulea
2025-08-15 17:30   ` Mina Almasry
2025-08-15 11:03 ` [RFC net-next v3 4/7] net/mlx5e: add op for getting netdev DMA device Dragos Tatulea
2025-08-15 17:37   ` Mina Almasry
2025-08-18 17:40     ` Dragos Tatulea
2025-08-18 18:18       ` Mina Almasry [this message]
2025-08-15 11:03 ` [RFC net-next v3 5/7] net: devmem: pull out dma_dev out of net_devmem_bind_dmabuf Dragos Tatulea
2025-08-18 18:22   ` Mina Almasry
2025-08-15 11:03 ` [RFC net-next v3 6/7] net: devmem: pre-read requested rx queues during bind Dragos Tatulea
2025-08-15 17:20   ` Jakub Kicinski
2025-08-15 18:05   ` Mina Almasry
2025-08-16  8:59     ` Dragos Tatulea
2025-08-18 18:24       ` Mina Almasry
2025-08-15 11:03 ` [RFC net-next v3 7/7] net: devmem: allow binding on rx queues with same MA devices Dragos Tatulea
2025-08-15 17:24   ` Jakub Kicinski
2025-08-16  9:05     ` Dragos Tatulea
2025-08-15 15:31 ` [RFC net-next v3 0/7] devmem/io_uring: allow more flexibility for ZC DMA devices Stanislav Fomichev
2025-08-15 15:48   ` Dragos Tatulea

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHS8izNWStDWNfNro3oX1v5mwyzK_xmA0YfffqSeB0JZwArK7w@mail.gmail.com \
    --to=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=asml.silence@gmail.com \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=hch@infradead.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=parav@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).