Re: [Qemu-devel] [PATCH v8 22/35] RISC-V: Use atomic_cmpxchg to update PLIC bitmaps

2018-04-27 Thread Michael Clark
On Fri, Apr 27, 2018 at 12:14 PM, Richard Henderson < richard.hender...@linaro.org> wrote: > On 04/25/2018 01:45 PM, Michael Clark wrote: > > +uint32_t old, new; > > +do { > > +old = atomic_read(>pending[word]); > > +new = (old & ~(1 << (irq & 31))) | (-!!pending & (1 <<

Re: [Qemu-devel] [PATCH v8 22/35] RISC-V: Use atomic_cmpxchg to update PLIC bitmaps

2018-04-26 Thread Richard Henderson
On 04/25/2018 01:45 PM, Michael Clark wrote: > +uint32_t old, new; > +do { > +old = atomic_read(>pending[word]); > +new = (old & ~(1 << (irq & 31))) | (-!!pending & (1 << (irq & 31))); > +} while (atomic_cmpxchg(>pending[word], old, new) != old); I prefer uint32_t

[Qemu-devel] [PATCH v8 22/35] RISC-V: Use atomic_cmpxchg to update PLIC bitmaps

2018-04-25 Thread Michael Clark
The PLIC previously used a mutex to protect against concurrent access to the claimed and pending bitfields. Instead of using a mutex, we update the bitfields using atomic_cmpxchg. Rename sifive_plic_num_irqs_pending to sifive_plic_irqs_pending and add an early out if any interrupts are pending as