Thread (7 messages) 7 messages, 4 authors, 2025-07-21

Re: [PATCH v2 net-next] net: Allow SF devices to be used for ZC DMA

From: Christoph Hellwig <hch@infradead.org>
Date: 2025-07-15 04:39:34
Also in: io-uring, lkml

On Mon, Jul 14, 2025 at 06:11:36PM -0700, Jakub Kicinski wrote:
quoted
+static inline struct device *netdev_get_dma_dev(const struct net_device *dev)
+{
+	struct device *dma_dev = dev->dev.parent;
+
+	if (!dma_dev)
+		return NULL;
+
+	/* Common case: dma device is parent device of netdev. */
+	if (dma_dev->dma_mask)
+		return dma_dev;
+
+	/* SF netdevs have an auxdev device as parent, the dma device being the
+	 * grandparent.
+	 */
+	dma_dev = dma_dev->parent;
+	if (dma_dev && dma_dev->dma_mask)
+		return dma_dev;
+
+	return NULL;
+}
LGTM, but we need a better place for this function. netdevice.h is
included directly by 1.5k files, and indirectly by probably another 5k.
It's not a great place to put random helpers with 2 callers. 
Maybe net/netdev_rx_queue.h and net/core/netdev_rx_queue.c?
I don't think it needs to be a static inline either.
The whole concept is also buggy.  Trying to get a dma-able device by
walking down from an upper level construct like the netdevice can't work
reliably.  You'll need to explicitly provide the dma_device using either
a method or a pointer to it instead of this guesswork.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help