The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Wentong Wu <wentong.wu@intel.com>,
	Alexander Usyskin <alexander.usyskin@intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>,
	linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] mei: vsc: Cast tx_buf to (__be32 *) when passed to cpu_to_be32_array()
Date: Wed, 7 May 2025 11:42:04 +0000	[thread overview]
Message-ID: <aBtHDKB6FbIkBS_J@kekkonen.localdomain> (raw)
In-Reply-To: <20250507090728.115910-1-hdegoede@redhat.com>

Hi Hans,

On Wed, May 07, 2025 at 11:07:28AM +0200, Hans de Goede wrote:
> Commit f88c0c72ffb0 ("mei: vsc: Use struct vsc_tp_packet as vsc-tp tx_buf
> and rx_buf type") changed the type of tx_buf from "void *" to "struct
> vsc_tp_packet *" and added a cast to (u32 *) when passing it to
> cpu_to_be32_array() and the same change was made for rx_buf.
> 
> This triggers the type-check warning in sparse:
> 
> vsc-tp.c:327:28: sparse: expected restricted __be32 [usertype] *dst
> vsc-tp.c:327:28: sparse: got unsigned int [usertype] *
> 
> vsc-tp.c:343:42: sparse: expected restricted __be32 const [usertype] *src
> vsc-tp.c:343:42: sparse: got unsigned int [usertype] *
> 
> Fix this by casting to (__be32 *) instead.
> 
> Note actually changing the type of the buffers to "be32 *" is not an option
> this buffer does actually contain a "struct vsc_tp_packet" and is used
> as such most of the time. vsc_tp_rom_xfer() re-uses the buffers as just
> dumb arrays of 32 bit words to talk to the device before the firmware has
> booted, to avoid needing to allocate a separate buffer.
> 
> Fixes: f88c0c72ffb0 ("mei: vsc: Use struct vsc_tp_packet as vsc-tp tx_buf and rx_buf type")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202505071634.kZ0I7Va6-lkp@intel.com/
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Thanks!

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> ---
>  drivers/misc/mei/vsc-tp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/mei/vsc-tp.c b/drivers/misc/mei/vsc-tp.c
> index da26a080916c..267d0de5fade 100644
> --- a/drivers/misc/mei/vsc-tp.c
> +++ b/drivers/misc/mei/vsc-tp.c
> @@ -324,7 +324,7 @@ int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf, size_t len)
>  	guard(mutex)(&tp->mutex);
>  
>  	/* rom xfer is big endian */
> -	cpu_to_be32_array((u32 *)tp->tx_buf, obuf, words);
> +	cpu_to_be32_array((__be32 *)tp->tx_buf, obuf, words);
>  
>  	ret = read_poll_timeout(gpiod_get_value_cansleep, ret,
>  				!ret, VSC_TP_ROM_XFER_POLL_DELAY_US,
> @@ -340,7 +340,7 @@ int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf, size_t len)
>  		return ret;
>  
>  	if (ibuf)
> -		be32_to_cpu_array(ibuf, (u32 *)tp->rx_buf, words);
> +		be32_to_cpu_array(ibuf, (__be32 *)tp->rx_buf, words);
>  
>  	return ret;
>  }

-- 
Regards,

Sakari Ailus

      reply	other threads:[~2025-05-07 11:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07  9:07 [PATCH] mei: vsc: Cast tx_buf to (__be32 *) when passed to cpu_to_be32_array() Hans de Goede
2025-05-07 11:42 ` Sakari Ailus [this message]

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=aBtHDKB6FbIkBS_J@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=alexander.usyskin@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=stanislaw.gruszka@linux.intel.com \
    --cc=wentong.wu@intel.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