[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y86ncnPW0ZDfTjye@lunn.ch>
Date: Mon, 23 Jan 2023 16:27:46 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Jiawen Wu <jiawenwu@...stnetic.com>
Cc: netdev@...r.kernel.org, mengyuanlou@...-swift.com
Subject: Re: [PATCH net-next 05/10] net: libwx: Allocate Rx and Tx resources
> +/**
> + * wx_setup_rx_resources - allocate Rx resources (Descriptors)
> + * @rx_ring: rx descriptor ring (for a specific queue) to setup
> + *
> + * Returns 0 on success, negative on failure
> + **/
> +static int wx_setup_rx_resources(struct wx_ring *rx_ring)
> +{
> + struct device *dev = rx_ring->dev;
> + int orig_node = dev_to_node(dev);
> + int numa_node = -1;
> + int size, ret;
> +
> + size = sizeof(struct wx_rx_buffer) * rx_ring->count;
> +
> + if (rx_ring->q_vector)
> + numa_node = rx_ring->q_vector->numa_node;
> +
> + rx_ring->rx_buffer_info = vmalloc_node(size, numa_node);
> + if (!rx_ring->rx_buffer_info)
> + rx_ring->rx_buffer_info = vmalloc(size);
> + if (!rx_ring->rx_buffer_info)
> + goto err;
> +
> + /* Round up to nearest 4K */
> + rx_ring->size = rx_ring->count * sizeof(union wx_rx_desc);
> + rx_ring->size = ALIGN(rx_ring->size, 4096);
> +
> + set_dev_node(dev, numa_node);
> + rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size,
> + &rx_ring->dma, GFP_KERNEL);
> + set_dev_node(dev, orig_node);
> + rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size,
> + &rx_ring->dma, GFP_KERNEL);
Is this double allocation correct?
Andrew
Powered by blists - more mailing lists