2023-05-16 10:26:06

by kernel test robot

[permalink] [raw]
Subject: drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
commit: 0c18184de990e63f708b090bcb9fc6c0fbc427cd platform/x86: apple-gmux: support MMIO gmux on T2 Macs
date: 9 weeks ago
config: i386-randconfig-s001-20230515
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0c18184de990e63f708b090bcb9fc6c0fbc427cd
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 0c18184de990e63f708b090bcb9fc6c0fbc427cd
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/x86/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
drivers/platform/x86/apple-gmux.c:224:48: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:224:48: sparse: expected void const [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:224:48: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:227:53: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:227:53: sparse: expected void const [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:227:53: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:241:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:241:55: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:241:55: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:243:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:243:39: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:243:39: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:245:32: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:245:32: sparse: expected void const [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:245:32: sparse: got unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:256:32: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:256:32: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:256:32: sparse: got unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:258:53: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:258:53: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:258:53: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:260:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:260:39: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:260:39: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:272:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:272:55: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:272:55: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:274:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:274:39: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:274:39: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:276:15: sparse: expected void const [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:276:15: sparse: got unsigned char [usertype] *[noderef] iomem_base
>> drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32
>> drivers/platform/x86/apple-gmux.c:286:19: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] @@ got restricted __be32 [usertype] @@
drivers/platform/x86/apple-gmux.c:286:19: sparse: expected unsigned int [usertype]
drivers/platform/x86/apple-gmux.c:286:19: sparse: got restricted __be32 [usertype]
drivers/platform/x86/apple-gmux.c:286:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:286:46: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:286:46: sparse: got unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:287:53: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:287:53: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:287:53: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:289:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got unsigned char [usertype] * @@
drivers/platform/x86/apple-gmux.c:289:39: sparse: expected void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:289:39: sparse: got unsigned char [usertype] *
drivers/platform/x86/apple-gmux.c:739:39: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected unsigned char [usertype] *[noderef] iomem_base @@ got void [noderef] __iomem * @@
drivers/platform/x86/apple-gmux.c:739:39: sparse: expected unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:739:39: sparse: got void [noderef] __iomem *
drivers/platform/x86/apple-gmux.c:889:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:889:34: sparse: expected void volatile [noderef] __iomem *addr
drivers/platform/x86/apple-gmux.c:889:34: sparse: got unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:916:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] iomem_base @@
drivers/platform/x86/apple-gmux.c:916:34: sparse: expected void volatile [noderef] __iomem *addr
drivers/platform/x86/apple-gmux.c:916:34: sparse: got unsigned char [usertype] *[noderef] iomem_base
drivers/platform/x86/apple-gmux.c:224:26: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:227:31: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:241:33: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:243:17: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:245:23: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:256:23: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:258:31: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:260:17: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:272:33: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:274:17: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:286:37: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:287:31: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:289:17: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c: note: in included file:
include/linux/apple-gmux.h:69:41: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [usertype] *[noderef] __iomem iomem_base @@ got void [noderef] __iomem * @@
include/linux/apple-gmux.h:69:41: sparse: expected unsigned char [usertype] *[noderef] __iomem iomem_base
include/linux/apple-gmux.h:69:41: sparse: got void [noderef] __iomem *
include/linux/apple-gmux.h:80:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got unsigned char [usertype] * @@
include/linux/apple-gmux.h:80:34: sparse: expected void const [noderef] __iomem *
include/linux/apple-gmux.h:80:34: sparse: got unsigned char [usertype] *
include/linux/apple-gmux.h:81:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got unsigned char [usertype] *[noderef] __iomem iomem_base @@
include/linux/apple-gmux.h:81:17: sparse: expected void volatile [noderef] __iomem *addr
include/linux/apple-gmux.h:81:17: sparse: got unsigned char [usertype] *[noderef] __iomem iomem_base
include/linux/apple-gmux.h:72:14: sparse: sparse: dereference of noderef expression
include/linux/apple-gmux.h:80:23: sparse: sparse: dereference of noderef expression
include/linux/apple-gmux.h:81:17: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:740:22: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:888:13: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:889:25: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:915:13: sparse: sparse: dereference of noderef expression
drivers/platform/x86/apple-gmux.c:916:25: sparse: sparse: dereference of noderef expression

vim +276 drivers/platform/x86/apple-gmux.c

265
266 static u32 gmux_mmio_read32(struct apple_gmux_data *gmux_data, int port)
267 {
268 u32 val;
269
270 mutex_lock(&gmux_data->index_lock);
271 gmux_mmio_wait(gmux_data);
272 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
273 iowrite8(GMUX_MMIO_READ | sizeof(val),
274 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
275 gmux_mmio_wait(gmux_data);
> 276 val = be32_to_cpu(ioread32(gmux_data->iomem_base));
277 mutex_unlock(&gmux_data->index_lock);
278
279 return val;
280 }
281
282 static void gmux_mmio_write32(struct apple_gmux_data *gmux_data, int port,
283 u32 val)
284 {
285 mutex_lock(&gmux_data->index_lock);
> 286 iowrite32(cpu_to_be32(val), gmux_data->iomem_base);
287 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
288 iowrite8(GMUX_MMIO_WRITE | sizeof(val),
289 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
290 gmux_mmio_wait(gmux_data);
291 mutex_unlock(&gmux_data->index_lock);
292 }
293

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (12.95 kB)
config (153.43 kB)
Download all attachments

2023-05-16 10:31:44

by Hans de Goede

[permalink] [raw]
Subject: Re: drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32

Hi,

On 5/16/23 12:16, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
> commit: 0c18184de990e63f708b090bcb9fc6c0fbc427cd platform/x86: apple-gmux: support MMIO gmux on T2 Macs
> date: 9 weeks ago
> config: i386-randconfig-s001-20230515
> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> reproduce:
> # apt-get install sparse
> # sparse version: v0.6.4-39-gce1a6720-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0c18184de990e63f708b090bcb9fc6c0fbc427cd
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 0c18184de990e63f708b090bcb9fc6c0fbc427cd
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/x86/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <[email protected]>
> | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

<snip>

> vim +276 drivers/platform/x86/apple-gmux.c
>
> 265
> 266 static u32 gmux_mmio_read32(struct apple_gmux_data *gmux_data, int port)
> 267 {
> 268 u32 val;
> 269
> 270 mutex_lock(&gmux_data->index_lock);
> 271 gmux_mmio_wait(gmux_data);
> 272 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
> 273 iowrite8(GMUX_MMIO_READ | sizeof(val),
> 274 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
> 275 gmux_mmio_wait(gmux_data);
> > 276 val = be32_to_cpu(ioread32(gmux_data->iomem_base));

Ok, so sparse does not like this line.

> 277 mutex_unlock(&gmux_data->index_lock);
> 278
> 279 return val;
> 280 }
> 281
> 282 static void gmux_mmio_write32(struct apple_gmux_data *gmux_data, int port,
> 283 u32 val)
> 284 {
> 285 mutex_lock(&gmux_data->index_lock);
> > 286 iowrite32(cpu_to_be32(val), gmux_data->iomem_base);

Nor this line. But this is what we want (convert to/from be32 to CPU
when reading/writing).

There is iowrite32be() but that always unconditionally swabs
the byte order independent of the CPU byte-order.

Now this is an x86 driver so always swapping is fine, still
I wonder if there is a better option here then using
iowrite32be() and ioread32be() ?

Regards,

Hans




> 287 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
> 288 iowrite8(GMUX_MMIO_WRITE | sizeof(val),
> 289 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
> 290 gmux_mmio_wait(gmux_data);
> 291 mutex_unlock(&gmux_data->index_lock);
> 292 }
> 293
>


2023-05-16 11:54:56

by Orlando Chamberlain

[permalink] [raw]
Subject: Re: drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32

Hi,

> On 16 May 2023, at 8:27 pm, Hans de Goede <[email protected]> wrote:
>
> Hi,
>
>> On 5/16/23 12:16, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
>> commit: 0c18184de990e63f708b090bcb9fc6c0fbc427cd platform/x86: apple-gmux: support MMIO gmux on T2 Macs
>> date: 9 weeks ago
>> config: i386-randconfig-s001-20230515
>> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
>> reproduce:
>> # apt-get install sparse
>> # sparse version: v0.6.4-39-gce1a6720-dirty
>> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0c18184de990e63f708b090bcb9fc6c0fbc427cd
>> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>> git fetch --no-tags linus master
>> git checkout 0c18184de990e63f708b090bcb9fc6c0fbc427cd
>> # save the config file
>> mkdir build_dir && cp config build_dir/.config
>> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
>> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/x86/
>>
>> If you fix the issue, kindly add following tag where applicable
>> | Reported-by: kernel test robot <[email protected]>
>> | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> <snip>
>
>> vim +276 drivers/platform/x86/apple-gmux.c
>>
>> 265
>> 266 static u32 gmux_mmio_read32(struct apple_gmux_data *gmux_data, int port)
>> 267 {
>> 268 u32 val;
>> 269
>> 270 mutex_lock(&gmux_data->index_lock);
>> 271 gmux_mmio_wait(gmux_data);
>> 272 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
>> 273 iowrite8(GMUX_MMIO_READ | sizeof(val),
>> 274 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
>> 275 gmux_mmio_wait(gmux_data);
>>> 276 val = be32_to_cpu(ioread32(gmux_data->iomem_base));
>
> Ok, so sparse does not like this line.
>
>> 277 mutex_unlock(&gmux_data->index_lock);
>> 278
>> 279 return val;
>> 280 }
>> 281
>> 282 static void gmux_mmio_write32(struct apple_gmux_data *gmux_data, int port,
>> 283 u32 val)
>> 284 {
>> 285 mutex_lock(&gmux_data->index_lock);
>>> 286 iowrite32(cpu_to_be32(val), gmux_data->iomem_base);
>
> Nor this line. But this is what we want (convert to/from be32 to CPU
> when reading/writing).
>
> There is iowrite32be() but that always unconditionally swabs
> the byte order independent of the CPU byte-order.
>
> Now this is an x86 driver so always swapping is fine, still
> I wonder if there is a better option here then using
> iowrite32be() and ioread32be() ?

Thanks for finding those functions. I can't think of anything better unless there's a simple way to change sparse's rules so that it will be happy with code like this.

Regards,
Orlando

>
> Regards,
>
> Hans
>
>
>
>
>> 287 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
>> 288 iowrite8(GMUX_MMIO_WRITE | sizeof(val),
>> 289 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
>> 290 gmux_mmio_wait(gmux_data);
>> 291 mutex_unlock(&gmux_data->index_lock);
>> 292 }
>> 293
>>
>

2023-05-16 19:03:03

by Hans de Goede

[permalink] [raw]
Subject: Re: drivers/platform/x86/apple-gmux.c:276:15: sparse: sparse: cast to restricted __be32

Hi,

On 5/16/23 13:31, Orlando Chamberlain wrote:
> Hi,
>
>> On 16 May 2023, at 8:27 pm, Hans de Goede <[email protected]> wrote:
>>
>> Hi,
>>
>>> On 5/16/23 12:16, kernel test robot wrote:
>>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>>> head: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
>>> commit: 0c18184de990e63f708b090bcb9fc6c0fbc427cd platform/x86: apple-gmux: support MMIO gmux on T2 Macs
>>> date: 9 weeks ago
>>> config: i386-randconfig-s001-20230515
>>> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
>>> reproduce:
>>> # apt-get install sparse
>>> # sparse version: v0.6.4-39-gce1a6720-dirty
>>> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0c18184de990e63f708b090bcb9fc6c0fbc427cd
>>> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>> git fetch --no-tags linus master
>>> git checkout 0c18184de990e63f708b090bcb9fc6c0fbc427cd
>>> # save the config file
>>> mkdir build_dir && cp config build_dir/.config
>>> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 olddefconfig
>>> make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/platform/x86/
>>>
>>> If you fix the issue, kindly add following tag where applicable
>>> | Reported-by: kernel test robot <[email protected]>
>>> | Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>>
>> <snip>
>>
>>> vim +276 drivers/platform/x86/apple-gmux.c
>>>
>>> 265
>>> 266 static u32 gmux_mmio_read32(struct apple_gmux_data *gmux_data, int port)
>>> 267 {
>>> 268 u32 val;
>>> 269
>>> 270 mutex_lock(&gmux_data->index_lock);
>>> 271 gmux_mmio_wait(gmux_data);
>>> 272 iowrite8((port & 0xff), gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
>>> 273 iowrite8(GMUX_MMIO_READ | sizeof(val),
>>> 274 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
>>> 275 gmux_mmio_wait(gmux_data);
>>>> 276 val = be32_to_cpu(ioread32(gmux_data->iomem_base));
>>
>> Ok, so sparse does not like this line.
>>
>>> 277 mutex_unlock(&gmux_data->index_lock);
>>> 278
>>> 279 return val;
>>> 280 }
>>> 281
>>> 282 static void gmux_mmio_write32(struct apple_gmux_data *gmux_data, int port,
>>> 283 u32 val)
>>> 284 {
>>> 285 mutex_lock(&gmux_data->index_lock);
>>>> 286 iowrite32(cpu_to_be32(val), gmux_data->iomem_base);
>>
>> Nor this line. But this is what we want (convert to/from be32 to CPU
>> when reading/writing).
>>
>> There is iowrite32be() but that always unconditionally swabs
>> the byte order independent of the CPU byte-order.
>>
>> Now this is an x86 driver so always swapping is fine, still
>> I wonder if there is a better option here then using
>> iowrite32be() and ioread32be() ?
>
> Thanks for finding those functions. I can't think of anything better unless there's a simple way to change sparse's rules so that it will be happy with code like this.

Ok, can you please submit a pathc to switch to iowrite32be() and
ioread32be() then (when you have time to work on this) ?

Regards,

Hans






>>> 287 iowrite8(port & 0xff, gmux_data->iomem_base + GMUX_MMIO_PORT_SELECT);
>>> 288 iowrite8(GMUX_MMIO_WRITE | sizeof(val),
>>> 289 gmux_data->iomem_base + GMUX_MMIO_COMMAND_SEND);
>>> 290 gmux_mmio_wait(gmux_data);
>>> 291 mutex_unlock(&gmux_data->index_lock);
>>> 292 }
>>> 293
>>>
>>
>