devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhangfei <zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	David.Laight-JxhZ9S5GRejQT0dZR+AlfA@public.gmane.org,
	eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	haifeng.yan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	jchxue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 3/3] net: hisilicon: add hix5hd2 mac driver
Date: Tue, 27 May 2014 11:57:52 +0800	[thread overview]
Message-ID: <53840D40.3000600@linaro.org> (raw)
In-Reply-To: <201405261651.15998.arnd-r2nGTMty4D4@public.gmane.org>

Hi Arnd,

Thanks for the kind suggestions.

On 05/26/2014 10:51 PM, Arnd Bergmann wrote:
> On Monday 19 May 2014, Zhangfei Gao wrote:
>
> I only noticed one real issue with the driver:
>
>> +struct hix5hd2_desc {
>> +	__le32 buff_addr;
>> +	__le32 buff_len:11;
>> +	__le32 reserve2:5;
>> +	__le32 data_len:11;
>> +	__le32 reserve1:2;
>> +	__le32 fl:2;
>> +	__le32 descvid:1;
>> +} __aligned(32);
>> +
>
> You should generall not use bitfields in hardware data structures, as that is
> not endian safe and will prevent running a big-endian kernel on this machine.
> Better convert this to a set of __le32 fields and explicit shifts and masks.

Got it, will update.

More knowledge about big-endian kernel is appreciated, in which case we 
should consider such kernel.
Can we only consider this driver is only running on arm, which is 
little-endian.

>
> Two smaller things you should think about, I'm not entirely sure about these:
>
>> +static int hix5hd2_rx(struct net_device *dev, int limit)
>> +{
>> +	struct hix5hd2_priv *priv = netdev_priv(dev);
>> +	struct sk_buff *skb;
>> +	struct hix5hd2_desc *desc;
>> +	dma_addr_t dma_addr;
>> +	u32 start, end, num, pos, i, len;
>> +
>> +	/* software read pointer */
>> +	start = dma_cnt(readl_relaxed(priv->base + RX_BQ_RD_ADDR));
>> +	/* logic write pointer */
>> +	end = dma_cnt(readl_relaxed(priv->base + RX_BQ_WR_ADDR));
>
> I think one of these needs to be readl() instead of readl_relaxed(),
> to ensure the data is correctly ordered with regard to the pointer
> access.
readl_relaxed can ensure the sequence.

>
>> +	if (pos != start)
>> +		writel(dma_byte(pos), priv->base + TX_RQ_RD_ADDR);
>
> While this looks like it could be writel_relaxed().
>
En, I think all three cases can use xxx_relaxed.
These accesses are just update pointer used by internal logic and get 
pointer updated by internal logic.

Thanks

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-05-27  3:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 12:57 [PATCH 0/3] add hix5hd2 mac driver Zhangfei Gao
2014-05-19 12:57 ` [PATCH 1/3] hix5hd2-clock: add complex clk Zhangfei Gao
2014-05-19 13:11   ` David Laight
2014-05-20 12:02     ` zhangfei
2014-05-19 12:57 ` [PATCH 2/3] Documentation: add Device tree bindings for Hisilicon hix5hd2 ethernet Zhangfei Gao
     [not found]   ` <1400504227-12047-3-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2014-05-19 16:26     ` Sergei Shtylyov
     [not found]       ` <537A30AA.8080107-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2014-05-20  2:12         ` zhangfei
2014-05-19 12:57 ` [PATCH 3/3] net: hisilicon: add hix5hd2 mac driver Zhangfei Gao
2014-05-25 12:25   ` zhangfei
2014-05-26 14:51   ` Arnd Bergmann
     [not found]     ` <201405261651.15998.arnd-r2nGTMty4D4@public.gmane.org>
2014-05-27  3:57       ` zhangfei [this message]
2014-05-27 13:25         ` Arnd Bergmann
2014-05-28  5:17           ` zhangfei

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=53840D40.3000600@linaro.org \
    --to=zhangfei.gao-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=David.Laight-JxhZ9S5GRejQT0dZR+AlfA@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=haifeng.yan-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=jchxue-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.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 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).