From mboxrd@z Thu Jan 1 00:00:00 1970 From: dianders@chromium.org (Doug Anderson) Date: Mon, 20 Oct 2014 16:57:17 -0700 Subject: [PATCH 4/4] pinctrl: rockchip: Protect read-modify-write with the spinlock In-Reply-To: <1413847670-12245-4-git-send-email-dianders@chromium.org> References: <1413847670-12245-1-git-send-email-dianders@chromium.org> <1413847670-12245-4-git-send-email-dianders@chromium.org> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi, On Mon, Oct 20, 2014 at 4:27 PM, Doug Anderson wrote: > @@ -1464,15 +1474,20 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) > if (ret < 0) > return ret; > > + spin_lock_irqsave(&bank->slock, flags); > + > data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); > data &= ~mask; > writel_relaxed(data, bank->reg_base + GPIO_SWPORT_DDR); > > + spin_unlock_irqrestore(&bank->slock, flags); > + > if (type & IRQ_TYPE_EDGE_BOTH) > __irq_set_handler_locked(d->irq, handle_edge_irq); > else > __irq_set_handler_locked(d->irq, handle_level_irq); > > + spin_lock_irqsave(&bank->slock, flags); > irq_gc_lock(gc); > > level = readl_relaxed(gc->reg_base + GPIO_INTTYPE_LEVEL); > @@ -1522,6 +1537,7 @@ static int rockchip_irq_set_type(struct irq_data *d, unsigned int type) > writel_relaxed(polarity, gc->reg_base + GPIO_INT_POLARITY); > > irq_gc_unlock(gc); > + spin_unlock_irqrestore(&bank->slock, flags); I just reviewed this again myself and I realized that there was an error path case that I missed. I'll plan to spin tomorrow and include any extra feedback people have. I'll also note that I'd love any extra scrutiny people have on this patch. I'm submitting it totally based on code inspection and am nowhere near an expert on this driver. I mostly just looked for all of the read/modify/wites using writel and added the lock... -Doug