Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp902029ybb; Fri, 20 Mar 2020 09:56:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsPT/BIcv/NNtOna1uIjfC1+Yo01KU9dZKfV48Q1IlEbYt/AxkXqsRM/euNSJJ3K9GDa91F X-Received: by 2002:a9d:8e4:: with SMTP id 91mr7909165otf.130.1584723387686; Fri, 20 Mar 2020 09:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584723387; cv=none; d=google.com; s=arc-20160816; b=A2Gf5ndJI1vT23HjaFN7C2662+f+1Q9twZaNMBWVoDr/ncHmepL95758qEaG8sDKIT ebXdX/0HtvmBjfz59rEmpr6OvNVFS1bBJgBGwDqZ2ofCdoUCZJvN1LgD8f1W2SRvaOmc yzxDKbUjofZnGXWi9O6y+VFWSs1zH80hw0i71h3spi16zyZCdjdR4aetbLkiXmFuORK3 LYxMWCFD0KS2TjXkM/wmf6oTWp9wiGQ05yeq0UF1ssHnpuf6oi7BDtlmFx1KtpRU6nSc jIojwTObShAjvSRAfEXb4jPiIt2q6FHzsXj40km+sd7yfXH8ZZUriUgsKkHBM1wQZUdz L3UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=usrqhcsME51fYUKBNI2VhtAWdq1tmoI6o2V5TV7GAqk=; b=VpDVsWYZkZ7csjWV1GUjLr9/bzsgj1G040ICsAnbgBe9lJ5Eox6BfFDDx2jiiQHSXX l5h3DecOS4Oft1PQEmoz53W4XiJ0mnby5f880YobNn55YGhEJNLDVB1KtthN99aSNlfx 6ScqPjEAtFJoapQai6NZKGy3Lzp9CQ26Xwsp4pivLevORM3auK0oMpVUPdLKtomemlGP Smg+/s2kQwjupojouzo6SkG6MDI8ZwSA5rSd3OzfuwLQ85dEAe6UMszjJBhiRrNgzBzL 8BWx8gV2Bl56EoGAQiUuGs5efR5u7zPbS78v7sRwgv3T8umSJNu2eatTIrme3Wyh59mS VI6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=oCbp72cT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z107si2860201otb.292.2020.03.20.09.56.11; Fri, 20 Mar 2020 09:56:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=oCbp72cT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbgCTQzS (ORCPT + 99 others); Fri, 20 Mar 2020 12:55:18 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:39017 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727726AbgCTQzS (ORCPT ); Fri, 20 Mar 2020 12:55:18 -0400 Received: by mail-il1-f194.google.com with SMTP id r5so1506718ilq.6 for ; Fri, 20 Mar 2020 09:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=usrqhcsME51fYUKBNI2VhtAWdq1tmoI6o2V5TV7GAqk=; b=oCbp72cTVPbZaDqUR615UdrgaJiORTpatTh0elU9NAhTpQ8DTVxGwY9RLXgTWDBwVw M/I0fwvnaMQ/bMrDS3Pqo8YWfjtDhbBXIjw3arkHzeBFachRiGxGN2sqIUTq7J+XOM9u F3IlzWQmVHL0TYbisV7O8YrsgpreQbZSgvc5EikCxaBoaINh2kofT1Rv33fejkgyfDLh AnK8fJH+UqnoRcY/X1vfVdR5dqy0xyBQRlwotcqfWxmCv5kEMFuwH65ciZGN/lc2wdIc X8PRNMFCGxImG1/OZRG9QAacg9TbaGbaPiOYByP8SxcEAzjPhQ96Cf5MmDO1g/Kb9d3B joFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=usrqhcsME51fYUKBNI2VhtAWdq1tmoI6o2V5TV7GAqk=; b=WdEwGeIMyefqAktM5maTsXpgM0kmscBCHnA9WqULT7bXV7tF3S5KsFgEbnPCo1/PHl VOOs831d0VgDmnd+YN2J68D5KwE4gKxaGzxnPqsnysmcAwIiMPdrzmBn+60eDPHxY8pz 8v5VwdYw7NE+y2kBsjLl9qvE7aUetjkl+gh0m0fWoIB4GJvhQMNE90LT1gV88dG7OPIg xDN9Po+MfxY95IZemjzhPQZD5yHjeIY2fXuPKJxAlJ6GWysYAh+KzFgJ5wfiJ0a5ch2G dFGbdMjdvPldsfmkgr5PLl5HxGpN0US2icuS4PQg8V6Zbnw0yNdqcQM2uDhdk6J8BLLj kO1g== X-Gm-Message-State: ANhLgQ3VN+RL6lfFoZyrt9SoEQTNl8EIisPE3T3oH2Ma4h/OkTGSG7e5 MDi9I4F8GxACuYRjKDPM9HvZQIRF01z1Cd5u6ZKZaQ== X-Received: by 2002:a05:6e02:10d3:: with SMTP id s19mr8977167ilj.220.1584723317219; Fri, 20 Mar 2020 09:55:17 -0700 (PDT) MIME-Version: 1.0 References: <20200320093125.23092-1-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 20 Mar 2020 17:55:06 +0100 Message-ID: Subject: Re: [PATCH] gpiolib: don't call sleeping functions with a spinlock taken To: Geert Uytterhoeven Cc: Linus Walleij , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pt., 20 mar 2020 o 11:59 Geert Uytterhoeven napisa= =C5=82(a): > > Hi Bartosz, > > On Fri, Mar 20, 2020 at 10:31 AM Bartosz Golaszewski wrot= e: > > From: Bartosz Golaszewski > > > > We must not call pinctrl_gpio_can_use_line() with the gpio_lock taken > > as it takes a mutex internally. Let's move the call before taking the > > spinlock and store the return value. > > > > This isn't perfect - there's a moment between calling > > pinctrl_gpio_can_use_line() and taking the spinlock where the situation > > can change but it isn't a regression either: previously this part wasn'= t > > protected at all and it only affects the information user-space is > > seeing. > > > > Reported-by: Geert Uytterhoeven > > Fixes: d2ac25798208 ("gpiolib: provide a dedicated function for setting= lineinfo") > > Signed-off-by: Bartosz Golaszewski > > Thanks for your patch! > > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -1154,8 +1154,19 @@ static void gpio_desc_to_lineinfo(struct gpio_de= sc *desc, > > struct gpioline_info *info) > > { > > struct gpio_chip *chip =3D desc->gdev->chip; > > + bool ok_for_pinctrl; > > unsigned long flags; > > > > + /* > > + * This function takes a mutex so we must check this before tak= ing > > + * the spinlock. > > + * > > + * FIXME: find a non-racy way to retrieve this information. May= be a > > + * lock common to both frameworks? > > + */ > > + ok_for_pinctrl =3D pinctrl_gpio_can_use_line( > > + chip->base + info->line_offset); > > Note that this is now called unconditionally, while before it was only ca= lled > if all previous steps in the ||-pipeline failed. > Is this a problem though? Doesn't seem so. Am I missing something? Bart