From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Li Yang <leoyang.li@nxp.com>, Timur Tabi <timur@kernel.org>,
Zhao Qiang <qiang.zhao@nxp.com>
Cc: linux-arm-kernel@lists.infradead.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 6/6] soc: fsl: qe: fix sparse warnings for ucc_slow.c
Date: Mon, 16 Mar 2020 22:07:25 +0100 [thread overview]
Message-ID: <b9c5a514-18c1-e36c-1595-2b86c9bfcff1@rasmusvillemoes.dk> (raw)
In-Reply-To: <20200312222827.17409-7-leoyang.li@nxp.com>
On 12/03/2020 23.28, Li Yang wrote:
> Fixes the following sparse warnings:
>
[snip]
>
> Also removed the unneccessary clearing for kzalloc'ed structure.
Please don't mix that in the same patch, do it in a preparatory patch.
That makes reviewing much easier.
>
> /* Get PRAM base */
> uccs->us_pram_offset =
> @@ -231,24 +224,24 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
> /* clear bd buffer */
> qe_iowrite32be(0, &bd->buf);
> /* set bd status and length */
> - qe_iowrite32be(0, (u32 *)bd);
> + qe_iowrite32be(0, (u32 __iomem *)bd);
It's cleaner to do two qe_iowrite16be to &bd->status and &bd->length,
that avoids the casting altogether.
> bd++;
> }
> /* for last BD set Wrap bit */
> qe_iowrite32be(0, &bd->buf);
> - qe_iowrite32be(cpu_to_be32(T_W), (u32 *)bd);
> + qe_iowrite32be(T_W, (u32 __iomem *)bd);
Yeah, and this is why. Who can actually keep track of where that bit
ends up being set with that casting going on. Please use
qe_iowrite16be() with an appropriately modified constant to the
appropriate field instead of these games.
And if the hardware doesn't support 16 bit writes, the definition of
struct qe_bd is wrong and should have a single __be32 status_length
field, with appropriate accessors defined.
> /* Init Rx bds */
> bd = uccs->rx_bd = qe_muram_addr(uccs->rx_base_offset);
> for (i = 0; i < us_info->rx_bd_ring_len - 1; i++) {
> /* set bd status and length */
> - qe_iowrite32be(0, (u32 *)bd);
> + qe_iowrite32be(0, (u32 __iomem *)bd);
Same.
> /* clear bd buffer */
> qe_iowrite32be(0, &bd->buf);
> bd++;
> }
> /* for last BD set Wrap bit */
> - qe_iowrite32be(cpu_to_be32(R_W), (u32 *)bd);
> + qe_iowrite32be(R_W, (u32 __iomem *)bd);
Same.
> qe_iowrite32be(0, &bd->buf);
>
> /* Set GUMR (For more details see the hardware spec.). */
> @@ -273,8 +266,8 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
> qe_iowrite32be(gumr, &us_regs->gumr_h);
>
> /* gumr_l */
> - gumr = us_info->tdcr | us_info->rdcr | us_info->tenc | us_info->renc |
> - us_info->diag | us_info->mode;
> + gumr = (u32)us_info->tdcr | (u32)us_info->rdcr | (u32)us_info->tenc |
> + (u32)us_info->renc | (u32)us_info->diag | (u32)us_info->mode;
Are the tdcr, rdcr, tenc, renc fields actually set anywhere (the same
for the diag and mode, but word-grepping for those give way too many
false positives)? They seem to be a somewhat pointless split out of the
bitfields of gumr_l, and not populated anywhere?. That's not directly
related to this patch, of course, but getting rid of them first (if they
are indeed completely unused) might make the sparse cleanup a little
simpler.
Rasmus
next prev parent reply other threads:[~2020-03-16 21:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 22:28 [PATCH 0/6] Fix sparse warnings for common qe library code Li Yang
2020-03-12 22:28 ` [PATCH 1/6] soc: fsl: qe: fix sparse warnings for qe.c Li Yang
2020-03-12 22:28 ` [PATCH 2/6] soc: fsl: qe: fix sparse warning for qe_common.c Li Yang
2020-03-12 22:28 ` [PATCH 3/6] soc: fsl: qe: fix sparse warnings for ucc.c Li Yang
2020-03-12 22:28 ` [PATCH 4/6] soc: fsl: qe: fix sparse warnings for qe_ic.c Li Yang
2020-03-12 22:28 ` [PATCH 5/6] soc: fsl: qe: fix sparse warnings for ucc_fast.c Li Yang
2020-03-12 22:28 ` [PATCH 6/6] soc: fsl: qe: fix sparse warnings for ucc_slow.c Li Yang
2020-03-16 21:07 ` Rasmus Villemoes [this message]
2020-03-17 22:01 ` Li Yang
2020-03-16 21:13 ` [PATCH 0/6] Fix sparse warnings for common qe library code Rasmus Villemoes
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=b9c5a514-18c1-e36c-1595-2b86c9bfcff1@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=leoyang.li@nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=qiang.zhao@nxp.com \
--cc=timur@kernel.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
all inboxes | Powered by JetHome®