Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2341878ybz; Thu, 23 Apr 2020 16:22:07 -0700 (PDT) X-Google-Smtp-Source: APiQypLMq/ZEdRQ2eDQXWy/t7lx5Q+b/4rY4VDHycTygxlha/spU9xF3UBaj3veyEx43CWQmLc2E X-Received: by 2002:a17:906:27d1:: with SMTP id k17mr4629382ejc.134.1587684126838; Thu, 23 Apr 2020 16:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587684126; cv=none; d=google.com; s=arc-20160816; b=QO4HQyowQS2tdLgmXdlxUxBY7JenBTQzv05Ot5OMJbVzhnybFDYSBFLahy7mzWbo/M QqCdLU4P3i0DGMVC5CiBJGZ/WVdlem6Du8fAOe5OtZsN6BxU8BTIZIF53gsywTatcROb NlOmP0qTUQHOHBR0Mp9pjk4uCLXKlGo1cyhzf8u9e0ilhJddnWKtjBqb+TfeBcRy1YCT AeWO7HlOJ8A/C0e/AMSzanilH1XUSAoBqjrfG0XtgCYNUudaN3Z8aiWriUIfkHgH6dON +bKq/sPBzErojNDKhTAZiPfIrE/w5PHTnu9KJkGG9w2ieWtqVV+yLQxlmT1cUlYiX03A jPIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=xsnbNTGVS47Sp5hx3NQ1+I4SUzPE3p6IR/EHX+bsikE=; b=ixQqIhipro8vOrb58bM7ApLtpe3i6HylX9iErIQvVunL1n4SybLIzt6lRehogL0wPQ xIE7ypsKg2radIf/vDqa5kckrWMd8oqaowxrbPD2gjyP4exVE6stm30Cp8a4Vtuc33FI tvzYT66IIGmC/iHj+MOGV1hGApnOPmc00CvXfKz6xhGcZdvkE0fgRx6qsCbQpNI/BaHW 02LYn1wT8rEjuLqmX1nlFi4QzZ/dLbLvYxbAz6ROL59GZ187TXt36bST5TffFzgBca4j dQIBkprtBbCYqbB5Z9+RNOc6gWT2GHgBqDNDSOiQIqSBemu3UFzXyxacnBKFTglhnhXJ vOdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si1989745edk.195.2020.04.23.16.21.44; Thu, 23 Apr 2020 16:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgDWXU1 (ORCPT + 99 others); Thu, 23 Apr 2020 19:20:27 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:48642 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728220AbgDWXGd (ORCPT ); Thu, 23 Apr 2020 19:06:33 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvM-0004bO-0O; Fri, 24 Apr 2020 00:06:28 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvK-00E6jf-Lr; Fri, 24 Apr 2020 00:06:26 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Mika Westerberg" , "Linus Walleij" Date: Fri, 24 Apr 2020 00:04:56 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 069/245] pinctrl: baytrail: Serialize all register access In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mika Westerberg commit 39ce8150a079e3ae6ed9abf26d7918a558ef7c19 upstream. There is a hardware issue in Intel Baytrail where concurrent GPIO register access might result reads of 0xffffffff and writes might get dropped completely. Prevent this from happening by taking the serializing lock in all places where it is possible that more than one thread might be accessing the hardware concurrently. Signed-off-by: Mika Westerberg Signed-off-by: Linus Walleij [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- drivers/pinctrl/pinctrl-baytrail.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) --- a/drivers/pinctrl/pinctrl-baytrail.c +++ b/drivers/pinctrl/pinctrl-baytrail.c @@ -194,6 +194,9 @@ static int byt_gpio_request(struct gpio_ struct byt_gpio *vg = to_byt_gpio(chip); void __iomem *reg = byt_gpio_reg(chip, offset, BYT_CONF0_REG); u32 value, gpio_mux; + unsigned long flags; + + spin_lock_irqsave(&vg->lock, flags); /* * In most cases, func pin mux 000 means GPIO function. @@ -207,18 +210,16 @@ static int byt_gpio_request(struct gpio_ value = readl(reg) & BYT_PIN_MUX; gpio_mux = byt_get_gpio_mux(vg, offset); if (WARN_ON(gpio_mux != value)) { - unsigned long flags; - - spin_lock_irqsave(&vg->lock, flags); value = readl(reg) & ~BYT_PIN_MUX; value |= gpio_mux; writel(value, reg); - spin_unlock_irqrestore(&vg->lock, flags); dev_warn(&vg->pdev->dev, "pin %u forcibly re-configured as GPIO\n", offset); } + spin_unlock_irqrestore(&vg->lock, flags); + pm_runtime_get(&vg->pdev->dev); return 0; @@ -266,7 +267,15 @@ static int byt_irq_type(struct irq_data static int byt_gpio_get(struct gpio_chip *chip, unsigned offset) { void __iomem *reg = byt_gpio_reg(chip, offset, BYT_VAL_REG); - return readl(reg) & BYT_LEVEL; + struct byt_gpio *vg = to_byt_gpio(chip); + unsigned long flags; + u32 val; + + spin_lock_irqsave(&vg->lock, flags); + val = readl(reg); + spin_unlock_irqrestore(&vg->lock, flags); + + return val & BYT_LEVEL; } static void byt_gpio_set(struct gpio_chip *chip, unsigned offset, int value) @@ -435,8 +444,10 @@ static void byt_irq_ack(struct irq_data unsigned offset = irqd_to_hwirq(d); void __iomem *reg; + spin_lock(&vg->lock); reg = byt_gpio_reg(&vg->chip, offset, BYT_INT_STAT_REG); writel(BIT(offset % 32), reg); + spin_unlock(&vg->lock); } static void byt_irq_unmask(struct irq_data *d)