Re: [PATCH v4] i2c: sh_mobile: implement atomic transfers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Wolfram,

On Fri, Oct 2, 2020 at 5:44 PM Wolfram Sang <wsa@xxxxxxxxxxxxx> wrote:
> On Mon, Sep 28, 2020 at 05:59:50PM +0200, Ulrich Hecht wrote:
> > Implements atomic transfers to fix reboot/shutdown on r8a7790 Lager and
> > similar boards.
> >
> > Signed-off-by: Ulrich Hecht <uli+renesas@xxxxxxxx>

> > @@ -581,10 +585,12 @@ static void start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,

> > +             if (pd->atomic_xfer) {
> > +                     unsigned long j = jiffies + pd->adap.timeout;
> > +
> > +                     time_left = time_before_eq(jiffies, j);
> > +                     while (time_left &&
> > +                            !(pd->sr & (ICSR_TACK | SW_DONE))) {
> > +                             unsigned char sr = iic_rd(pd, ICSR);
> > +
> > +                             if (sr & (ICSR_AL   | ICSR_TACK |
> > +                                       ICSR_WAIT | ICSR_DTE)) {
> > +                                     sh_mobile_i2c_isr(0, pd);
> > +                                     udelay(150);
> > +                             } else {
> > +                                     cpu_relax();
> > +                             }
>
> Is it 100% safe to call cpu_relax() that late? Aren't interrupts
> disabled? What is waking the CPU again? And where does the value 150us
> come from?

cpu_relax() does not sleep, usually it's merely a compiler directive.

On arm32/v7 (and most other platforms):

    #define cpu_relax()                     barrier()

    #define barrier() __asm__ __volatile__("": : :"memory")

On arm64:

    static inline void cpu_relax(void)
    {
            asm volatile("yield" ::: "memory");
    }

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux