All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhangfei.gao@linaro.org (zhangfei)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] net: hisilicon: new hip04 ethernet driver
Date: Sat, 22 Mar 2014 09:18:35 +0800	[thread overview]
Message-ID: <532CE4EB.6010305@linaro.org> (raw)
In-Reply-To: <4230433.d0bAGX3bJV@wuerfel>

Dear Arnd

On 03/21/2014 11:27 PM, Arnd Bergmann wrote:
> On Friday 21 March 2014 23:09:30 Zhangfei Gao wrote:
>
>> +
>> +static void __iomem *ppebase;
>
> Any reason why you still have this, rather than using a separate
> driver for it as we discussed? If you have comments that you still
> plan to address, please mention those in the introductory mail,
> so you don't get the same review comments multiple times.

Sorry for my bad understanding.
I thought you agreed to use this.
Will check your earlier comments more carefully.

>
>
>> +static void hip04_tx_reclaim(struct net_device *ndev, bool force)
>> +{
>> +	struct hip04_priv *priv = netdev_priv(ndev);
>> +	unsigned tx_head = priv->tx_head;
>> +	unsigned tx_tail = priv->tx_tail;
>> +	struct tx_desc *desc = &priv->tx_desc[priv->tx_tail];
>> +
>> +	while (tx_tail != tx_head) {
>> +		if (desc->send_addr != 0) {
>> +			if (force)
>> +				desc->send_addr = 0;
>> +			else
>> +				break;
>> +		}
>> +		if (priv->tx_phys[tx_tail]) {
>> +			dma_unmap_single(&ndev->dev, priv->tx_phys[tx_tail],
>> +				priv->tx_skb[tx_tail]->len, DMA_TO_DEVICE);
>> +			priv->tx_phys[tx_tail] = 0;
>> +		}
>> +		dev_kfree_skb_irq(priv->tx_skb[tx_tail]);
>> +		priv->tx_skb[tx_tail] = NULL;
>> +		tx_tail = TX_NEXT(tx_tail);
>> +		priv->tx_count--;
>> +	}
>> +	priv->tx_tail = tx_tail;
>> +}
>
> You call this function from start_xmit(), which may be too early, causing the
> dma_unmap_single() and dev_kfree_skb_irq() functions to be called while the
> device is still accessing the data. This is bad.

There is a protection.
Only after xmit done, desc->send_addr = 0, which is cleared by hardware.

>
> You have to ensure that you only ever clean up tx buffers that have been
> successfully transmitted. Also, you should use an interrupt to notify you
> of this in case there is no further xmit packet. Otherwise you may have
> a user space program waiting indefinitely for a single packet to get sent
> on a socket.
>
> It's ok to also call the cleanup from start_xmit, but calling it from the
> poll() function or another appropriate place is required.

There is no transmit done interrupt, so relying on every xmit to reclaim 
finished buffer.
I thought it would be enough, since there are TX_DESC_NUM descs.
It is a good idea also put reclaim in poll, then will add spin lock etc.

>
>> +	priv->id = of_alias_get_id(node, "ethernet");
>> +	if (priv->id < 0) {
>> +		dev_warn(d, "no ethernet alias\n");
>> +		ret = -EINVAL;
>> +		goto init_fail;
>> +	}
>
> Apparently you try to rely on the alias to refer to a specific piece
> of hardware, which is not correct. The alias is meant to be selectable
> to match e.g. the numbering written on the external connector, which
> is totally independent of the internal hardware.

Thanks for clarifying alisa.
The id will be used for start channel in ppe, RX_DESC_NUM * priv->id;
Is it suitable directly use id in the dts, or other name such as start-chan?

Thanks

WARNING: multiple messages have this Message-ID (diff)
From: zhangfei <zhangfei.gao@linaro.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux@arm.linux.org.uk, f.fainelli@gmail.com,
	mark.rutland@arm.com, sergei.shtylyov@cogentembedded.com,
	linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH 3/3] net: hisilicon: new hip04 ethernet driver
Date: Sat, 22 Mar 2014 09:18:35 +0800	[thread overview]
Message-ID: <532CE4EB.6010305@linaro.org> (raw)
In-Reply-To: <4230433.d0bAGX3bJV@wuerfel>

Dear Arnd

On 03/21/2014 11:27 PM, Arnd Bergmann wrote:
> On Friday 21 March 2014 23:09:30 Zhangfei Gao wrote:
>
>> +
>> +static void __iomem *ppebase;
>
> Any reason why you still have this, rather than using a separate
> driver for it as we discussed? If you have comments that you still
> plan to address, please mention those in the introductory mail,
> so you don't get the same review comments multiple times.

Sorry for my bad understanding.
I thought you agreed to use this.
Will check your earlier comments more carefully.

>
>
>> +static void hip04_tx_reclaim(struct net_device *ndev, bool force)
>> +{
>> +	struct hip04_priv *priv = netdev_priv(ndev);
>> +	unsigned tx_head = priv->tx_head;
>> +	unsigned tx_tail = priv->tx_tail;
>> +	struct tx_desc *desc = &priv->tx_desc[priv->tx_tail];
>> +
>> +	while (tx_tail != tx_head) {
>> +		if (desc->send_addr != 0) {
>> +			if (force)
>> +				desc->send_addr = 0;
>> +			else
>> +				break;
>> +		}
>> +		if (priv->tx_phys[tx_tail]) {
>> +			dma_unmap_single(&ndev->dev, priv->tx_phys[tx_tail],
>> +				priv->tx_skb[tx_tail]->len, DMA_TO_DEVICE);
>> +			priv->tx_phys[tx_tail] = 0;
>> +		}
>> +		dev_kfree_skb_irq(priv->tx_skb[tx_tail]);
>> +		priv->tx_skb[tx_tail] = NULL;
>> +		tx_tail = TX_NEXT(tx_tail);
>> +		priv->tx_count--;
>> +	}
>> +	priv->tx_tail = tx_tail;
>> +}
>
> You call this function from start_xmit(), which may be too early, causing the
> dma_unmap_single() and dev_kfree_skb_irq() functions to be called while the
> device is still accessing the data. This is bad.

There is a protection.
Only after xmit done, desc->send_addr = 0, which is cleared by hardware.

>
> You have to ensure that you only ever clean up tx buffers that have been
> successfully transmitted. Also, you should use an interrupt to notify you
> of this in case there is no further xmit packet. Otherwise you may have
> a user space program waiting indefinitely for a single packet to get sent
> on a socket.
>
> It's ok to also call the cleanup from start_xmit, but calling it from the
> poll() function or another appropriate place is required.

There is no transmit done interrupt, so relying on every xmit to reclaim 
finished buffer.
I thought it would be enough, since there are TX_DESC_NUM descs.
It is a good idea also put reclaim in poll, then will add spin lock etc.

>
>> +	priv->id = of_alias_get_id(node, "ethernet");
>> +	if (priv->id < 0) {
>> +		dev_warn(d, "no ethernet alias\n");
>> +		ret = -EINVAL;
>> +		goto init_fail;
>> +	}
>
> Apparently you try to rely on the alias to refer to a specific piece
> of hardware, which is not correct. The alias is meant to be selectable
> to match e.g. the numbering written on the external connector, which
> is totally independent of the internal hardware.

Thanks for clarifying alisa.
The id will be used for start channel in ppe, RX_DESC_NUM * priv->id;
Is it suitable directly use id in the dts, or other name such as start-chan?

Thanks

  reply	other threads:[~2014-03-22  1:18 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-21 15:09 [PATCH v2 0/3] add hisilicon hip04 ethernet driver Zhangfei Gao
2014-03-21 15:09 ` Zhangfei Gao
2014-03-21 15:09 ` [PATCH 1/3] Documentation: add Device tree bindings for Hisilicon hip04 ethernet Zhangfei Gao
2014-03-21 15:09   ` Zhangfei Gao
2014-03-21 16:42   ` Florian Fainelli
2014-03-21 16:42     ` Florian Fainelli
2014-03-21 18:22   ` Sergei Shtylyov
2014-03-21 18:22     ` Sergei Shtylyov
2014-03-21 15:09 ` [PATCH 2/3] net: hisilicon: new hip04 MDIO driver Zhangfei Gao
2014-03-21 15:09   ` Zhangfei Gao
2014-03-21 15:09 ` [PATCH 3/3] net: hisilicon: new hip04 ethernet driver Zhangfei Gao
2014-03-21 15:09   ` Zhangfei Gao
2014-03-21 15:27   ` Arnd Bergmann
2014-03-21 15:27     ` Arnd Bergmann
2014-03-22  1:18     ` zhangfei [this message]
2014-03-22  1:18       ` zhangfei
2014-03-22  8:08       ` Arnd Bergmann
2014-03-22  8:08         ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2014-04-05  4:35 [PATCH v7 0/3] add hisilicon " Zhangfei Gao
2014-04-05  4:35 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-04-05  4:35   ` Zhangfei Gao
2014-04-07 18:53   ` David Miller
2014-04-07 18:53     ` David Miller
2014-04-08  8:07     ` zhangfei
2014-04-08  8:07       ` zhangfei
2014-04-08  8:30       ` David Laight
2014-04-08  8:30         ` David Laight
2014-04-08  9:42         ` Arnd Bergmann
2014-04-08  9:42           ` Arnd Bergmann
2014-04-08 14:47         ` zhangfei
2014-04-08 14:47           ` zhangfei
2014-04-18 13:17     ` zhangfei
2014-04-18 13:17       ` zhangfei
2014-04-07 18:56   ` David Miller
2014-04-07 18:56     ` David Miller
2014-04-04 15:16 [PATCH v6 0/3] add hisilicon " Zhangfei Gao
2014-04-04 15:16 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-04-04 15:16   ` Zhangfei Gao
2014-04-01 13:27 [PATCH v5 0/3] add hisilicon " Zhangfei Gao
2014-04-01 13:27 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-04-01 13:27   ` Zhangfei Gao
2014-04-02  9:21   ` Arnd Bergmann
2014-04-02  9:21     ` Arnd Bergmann
2014-04-02  9:51     ` zhangfei
2014-04-02  9:51       ` zhangfei
2014-04-02 15:24       ` Arnd Bergmann
2014-04-02 15:24         ` Arnd Bergmann
2014-04-02 10:04     ` David Laight
2014-04-02 10:04       ` David Laight
2014-04-02 15:49       ` Arnd Bergmann
2014-04-02 15:49         ` Arnd Bergmann
2014-04-03  6:24         ` Zhangfei Gao
2014-04-03  6:24           ` Zhangfei Gao
2014-04-03  8:35           ` Arnd Bergmann
2014-04-03  8:35             ` Arnd Bergmann
2014-04-03 15:22       ` David Miller
2014-04-03 15:22         ` David Miller
2014-04-03 15:38       ` zhangfei
2014-04-03 15:38         ` zhangfei
2014-04-03 15:27     ` Russell King - ARM Linux
2014-04-03 15:27       ` Russell King - ARM Linux
2014-04-03 15:42       ` David Laight
2014-04-03 15:42         ` David Laight
2014-04-03 15:50         ` Russell King - ARM Linux
2014-04-03 15:50           ` Russell King - ARM Linux
2014-04-03 17:57       ` Arnd Bergmann
2014-04-03 17:57         ` Arnd Bergmann
2014-04-04  6:52       ` Zhangfei Gao
2014-04-04  6:52         ` Zhangfei Gao
2014-03-28 15:35 [PATCH v4 0/3] add hisilicon " Zhangfei Gao
2014-03-28 15:36 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-03-28 15:36   ` Zhangfei Gao
2014-03-24 14:14 [PATCH v3 0/3] add hisilicon " Zhangfei Gao
2014-03-24 14:14 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-03-24 14:14   ` Zhangfei Gao
2014-03-24 15:18   ` Arnd Bergmann
2014-03-24 15:18     ` Arnd Bergmann
2014-03-25  4:06     ` Zhangfei Gao
2014-03-25  4:06       ` Zhangfei Gao
2014-03-25  8:12       ` Arnd Bergmann
2014-03-25  8:12         ` Arnd Bergmann
2014-03-25 17:00         ` Florian Fainelli
2014-03-25 17:00           ` Florian Fainelli
2014-03-25 17:05           ` Arnd Bergmann
2014-03-25 17:05             ` Arnd Bergmann
2014-03-25 17:16             ` Florian Fainelli
2014-03-25 17:16               ` Florian Fainelli
2014-03-25 17:57               ` Arnd Bergmann
2014-03-25 17:57                 ` Arnd Bergmann
2014-03-26  9:55                 ` David Laight
2014-03-26  9:55                   ` David Laight
2014-03-25 17:17             ` David Laight
2014-03-25 17:17               ` David Laight
2014-03-25 17:21             ` Eric Dumazet
2014-03-25 17:21               ` Eric Dumazet
2014-03-25 17:54               ` Arnd Bergmann
2014-03-25 17:54                 ` Arnd Bergmann
2014-03-27 12:53                 ` zhangfei
2014-03-27 12:53                   ` zhangfei
2014-03-24 16:32   ` Florian Fainelli
2014-03-24 16:32     ` Florian Fainelli
2014-03-24 17:23     ` Arnd Bergmann
2014-03-24 17:23       ` Arnd Bergmann
2014-03-24 17:35       ` Florian Fainelli
2014-03-24 17:35         ` Florian Fainelli
2014-03-27  6:27     ` Zhangfei Gao
2014-03-27  6:27       ` Zhangfei Gao
2014-03-18  8:40 [PATCH 0/3] add hisilicon " Zhangfei Gao
2014-03-18  8:40 ` [PATCH 3/3] net: hisilicon: new " Zhangfei Gao
2014-03-18  8:40   ` Zhangfei Gao
2014-03-18 10:46   ` Russell King - ARM Linux
2014-03-18 10:46     ` Russell King - ARM Linux
2014-03-20  9:51     ` Zhangfei Gao
2014-03-20  9:51       ` Zhangfei Gao
2014-03-24 14:17       ` Rob Herring
2014-03-24 14:17         ` Rob Herring
2014-03-26 14:22         ` Zhangfei Gao
2014-03-26 14:22           ` Zhangfei Gao
2014-03-18 11:25   ` Arnd Bergmann
2014-03-18 11:25     ` Arnd Bergmann
2014-03-20 14:00     ` Zhangfei Gao
2014-03-20 14:00       ` Zhangfei Gao
2014-03-20 14:31       ` Arnd Bergmann
2014-03-20 14:31         ` Arnd Bergmann
2014-03-21  5:19         ` Zhangfei Gao
2014-03-21  5:19           ` Zhangfei Gao
2014-03-21  7:37           ` Arnd Bergmann
2014-03-21  7:37             ` Arnd Bergmann
2014-03-21  7:56             ` Zhangfei Gao
2014-03-21  7:56               ` Zhangfei Gao
2014-03-24  8:17         ` Zhangfei Gao
2014-03-24  8:17           ` Zhangfei Gao
2014-03-24 10:02           ` Arnd Bergmann
2014-03-24 10:02             ` Arnd Bergmann
2014-03-24 13:23             ` Zhangfei Gao
2014-03-24 13:23               ` Zhangfei Gao

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=532CE4EB.6010305@linaro.org \
    --to=zhangfei.gao@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.