mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Apeksha Gupta <apeksha.gupta@nxp.com>
Cc: qiangqing.zhang@nxp.com, davem@davemloft.net, kuba@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-devel@linux.nxdi.nxp.com, LnxRevLi@nxp.com,
	sachin.saxena@nxp.com, hemant.agrawal@nxp.com,
	nipun.gupta@nxp.com
Subject: Re: [PATCH 2/5] net: fec: fec-uio driver
Date: Wed, 10 Nov 2021 23:06:19 +0100	[thread overview]
Message-ID: <YYxCWyLExiWgXf/L@lunn.ch> (raw)
In-Reply-To: <20211110054838.27907-3-apeksha.gupta@nxp.com>

On Wed, Nov 10, 2021 at 11:18:35AM +0530, Apeksha Gupta wrote:
> i.mx: fec-uio driver
> 
> This patch adds the userspace support. In this basic
> hardware initialization is performed in kernel via userspace
> input/output, while the majority of code is written in the
> userspace.

Where do i find this usespace code. Please include a URL to a git
repo.

> +static unsigned char macaddr[ETH_ALEN];
> +module_param_array(macaddr, byte, NULL, 0);
> +MODULE_PARM_DESC(macaddr, "FEC Ethernet MAC address");

No module parameters please. Use the standard device tree bindings.

> +static int fec_enet_uio_init(struct net_device *ndev)
> +{
> +	unsigned int total_tx_ring_size = 0, total_rx_ring_size = 0;
> +	struct fec_enet_private *fep = netdev_priv(ndev);
> +	unsigned int dsize = sizeof(struct bufdesc);
> +	unsigned short tx_ring_size, rx_ring_size;
> +	int ret, i;
> +
> +	/* Check mask of the streaming and coherent API */
> +	ret = dma_set_mask_and_coherent(&fep->pdev->dev, DMA_BIT_MASK(32));
> +	if (ret < 0) {
> +		dev_warn(&fep->pdev->dev, "No suitable DMA available\n");
> +		return ret;
> +	}
> +
> +	tx_ring_size = TX_RING_SIZE;
> +	rx_ring_size = RX_RING_SIZE;
> +
> +	for (i = 0; i <	FEC_ENET_MAX_TX_QS; i++)
> +		total_tx_ring_size += tx_ring_size;
> +	for (i = 0; i <	FEC_ENET_MAX_RX_QS; i++)
> +		total_rx_ring_size += rx_ring_size;
> +
> +	bd_size = (total_tx_ring_size + total_rx_ring_size) * dsize;

These are the buffer descriptors, not buffers themselves. I assume the
user space driver is allocating the buffer? And your userspace then
set the descriptor to point to user allocated memory? Or some other
memory in the address space, and overwrite whatever you want on the
next DMA? Or DMAing kernel memory out as frames?

> +static int
> +fec_enet_uio_probe(struct platform_device *pdev)
> +{
> +	struct fec_uio_devinfo *dev_info;
> +	const struct of_device_id *of_id;
> +	struct fec_enet_private *fep;
> +	struct net_device *ndev;
> +	u32 ecntl = ETHER_EN;
> +	static int dev_id;
> +	bool reset_again;
> +	int ret = 0;
> +
> +	/* Init network device */
> +	ndev = alloc_etherdev_mq(sizeof(struct fec_enet_private) +
> +				FEC_PRIV_SIZE, FEC_MAX_Q);

Why do you need this. This is not a netdev driver, since it does not
connect to the network stack.

> +static int
> +fec_enet_uio_remove(struct platform_device *pdev)
> +{
> +	struct net_device *ndev = platform_get_drvdata(pdev);
> +	struct fec_enet_private *fep = netdev_priv(ndev);
> +
> +	kfree(fec_dev);
> +	iounmap(fep->hwp);
> +	dma_free_coherent(&fep->pdev->dev, bd_size, cbd_base, bd_dma);

Don't you have to assume that the userspace driver has crashed and
burned, leaving the hardware in an undefined state. It could still be
receiving, into buffers we have no idea about. Don't you need to stop
the hardware, and then wait for all DMA activity to stop, and only
then can you free the buffer descriptors?

     Andrew

  reply	other threads:[~2021-11-10 22:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-10  5:48 [PATCH 0/5] drivers/net: add NXP FEC-UIO driver Apeksha Gupta
2021-11-10  5:48 ` [PATCH 1/5] dt-bindings: add binding for fec-uio Apeksha Gupta
2021-11-10  5:48 ` [PATCH 2/5] net: fec: fec-uio driver Apeksha Gupta
2021-11-10 22:06   ` Andrew Lunn [this message]
2021-11-10  5:48 ` [PATCH 3/5] ARM64: defconfig: Add config for fec-uio Apeksha Gupta
2021-11-10  5:48 ` [PATCH 4/5] MAINTAINERS: add new file Apeksha Gupta
2021-11-10  5:48 ` [PATCH 5/5] arm64: dts: imx8mm-evk-dpdk: dts for fec-uio driver Apeksha Gupta
2021-11-10 22:11   ` Andrew Lunn
2021-11-11 11:06 ` [PATCH 0/5] drivers/net: add NXP FEC-UIO driver Michael Walle

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=YYxCWyLExiWgXf/L@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=LnxRevLi@nxp.com \
    --cc=apeksha.gupta@nxp.com \
    --cc=davem@davemloft.net \
    --cc=hemant.agrawal@nxp.com \
    --cc=kuba@kernel.org \
    --cc=linux-devel@linux.nxdi.nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nipun.gupta@nxp.com \
    --cc=qiangqing.zhang@nxp.com \
    --cc=sachin.saxena@nxp.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

Powered by JetHome