why iowrite32_rep() doesn't work, I have to use the iowrite32() with a loop

Max Filippov jcmvbkbc at gmail.com
Sat Nov 18 10:50:34 EST 2017


On Thu, Nov 16, 2017 at 12:12 PM, ayaka <ayaka at soulik.info> wrote:
> #if 1
>          for (i = 0; i < count; i++) {
>                  u32 *cur = (u32 *)buffer;
>                  u32 pos = offset + i * 4;
>
>                  cur += i;
>                  mpp_debug(DEBUG_SET_REG, "write reg[%03d]: %08x\n",
> pos, *cur);
>                  iowrite32(*cur, mpp_dev->reg_base + pos);
> }
> #else
>          iowrite32_rep(mpp_dev->reg_base + offset, buffer, count);
> mb();
>          for (i = 0; i < count; i++) {
>                  u32 cur = 0;
>                  u32 pos = offset / 4 + i;
>
>                  cur = ioread32(mpp_dev->reg_base + pos * 4);
>                  pr_info("get reg[%03d]: %08x\n", pos, cur);
> }
> #endif

The loop with iowrite32 writes consecutive u32 words from buffer
to consecutive IO memory locations. But iowrite32_rep writes
consecutive u32 words from buffer to the same IO memory location.
So they do different things when count > 1.

-- 
Thanks.
-- Max



More information about the Kernelnewbies mailing list