From patchwork Thu Jul 28 12:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 1661619 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=OoB+zO5i; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ltq8N6GZfz9sGC for ; Thu, 28 Jul 2022 22:04:51 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oH2Ft-000896-2H; Thu, 28 Jul 2022 12:04:41 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1oH2Fq-00088W-Bl for kernel-team@lists.ubuntu.com; Thu, 28 Jul 2022 12:04:38 +0000 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 446DF3F11C for ; Thu, 28 Jul 2022 12:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1659009876; bh=x4nD3HAgDulmFBPIDbflsG3TFLfkRTEikV/THYhvVcY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OoB+zO5iUsuVYI3/2vL8eAIGDwxDpAtsuzdM9MZu+Y5T7neeSQ+3vjZAXE2ZHe65W rBMu+Aop2eIlDDXJC9JVJhoIrwdunW+zhKZ9qvBV5Mf0qE+y4Tsq1Piji1SMxH1Orc nStrv/xOaE04dVWaOeckqVndLS+zHhYA0LeCxLCnumloQTJw7wlvtRE2kVYTpPfsci 0dwsmEPAYGDMdWMuzIB988uTW4bCDtpnC2deT7ZlCBIKrxl85NxHOTKDI/0A2zeUQi MVAPDleV/pHQJW8cF0zT4+hj0+JKN2rvZLmoFTceesPXQoca4KZkbZP6dMuwZE2/OL xPv5QgqQmWnTw== Received: by mail-lf1-f70.google.com with SMTP id 25-20020ac24859000000b0048a8a367582so564688lfy.18 for ; Thu, 28 Jul 2022 05:04:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x4nD3HAgDulmFBPIDbflsG3TFLfkRTEikV/THYhvVcY=; b=XiPvBYvsuLsz2Zap/76hYMsiwBI9OgM58CZ6eHZAOoMvRNPHmJqbCrcWQwsS2oTz4e YzmrcTB3Cli2vxdMzZX87+NigSj+L5PCp44PenG7qaYzsw70ES+qkv5+mjeJDtTDuaV6 tcyIh2yRMHL3cacjL4QScxNn5gtfPoundNH4i0CT1KelHbu71GJrLInHlxiNpd4Hc+BC gF2jl586nAkfNDXBiWnsSVrHpvudZ+WRKMuQ6599LTQwAJSta4hRgRsX+YPUPZnw5PHk FCCEBAd6AUsMgRSEABQ6CVCOnXaT7IewG4eri+Cr46ABqJ2Em+fP6A/OuFmUhK3w/iVt Mwqg== X-Gm-Message-State: AJIora+gSb7sCKmknS74lMDKNF8ExUOUo8QA+h5Obech4ve7wBOw8PPc YjmF877oVfPMZfx5VmxrnhNon+G6BN31RoGrHmC0MmMB6GtFV+FHJ0a5CeV4dNdEbfldYgi/lpU 4qlZuQwZ/37+9kLd/OB36L3016ZFTMA4QPRIdKU+AFQ== X-Received: by 2002:a2e:330d:0:b0:25d:f791:cbd1 with SMTP id d13-20020a2e330d000000b0025df791cbd1mr8397306ljc.508.1659009875502; Thu, 28 Jul 2022 05:04:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vRmyh01GDnUlI3DAdWOPLDVgVD5GVzaNzrfHzy3AVjJw99vrTxs/YvL++k0nHKmUXBzwM+Zg== X-Received: by 2002:a2e:330d:0:b0:25d:f791:cbd1 with SMTP id d13-20020a2e330d000000b0025df791cbd1mr8397302ljc.508.1659009875107; Thu, 28 Jul 2022 05:04:35 -0700 (PDT) Received: from stitch.. (2-111-35-127-dynamic.dk.customer.tdc.net. [2.111.35.127]) by smtp.gmail.com with ESMTPSA id f7-20020a0565123b0700b0048a757d1303sm166849lfv.217.2022.07.28.05.04.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 05:04:34 -0700 (PDT) From: Emil Renner Berthing To: kernel-team@lists.ubuntu.com Subject: [SRU][J/starfive-5.17][PATCH 1/1] pinctrl: starfive: Serialize adding groups and functions Date: Thu, 28 Jul 2022 14:04:32 +0200 Message-Id: <20220728120432.736696-2-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220728120432.736696-1-emil.renner.berthing@canonical.com> References: <20220728120432.736696-1-emil.renner.berthing@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jianlong Huang BugLink: https://bugs.launchpad.net/bugs/1983019 The pinctrl dt_node_to_map method may be called in parallel which leads us to call pinconf_generic_add_group and pinconf_generic_add_function in parallel. This is not supported though and leads to errors, so add a mutex to serialize these calls. Signed-off-by: Jianlong Huang Signed-off-by: Emil Renner Berthing Link: https://lore.kernel.org/r/20220627085333.1774396-1-emil.renner.berthing@canonical.com Signed-off-by: Linus Walleij (cherry picked from commit e2961cd685fe548f0ffd6c7bd3ae6a491301b1e4) Signed-off-by: Emil Renner Berthing --- drivers/pinctrl/pinctrl-starfive.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pinctrl/pinctrl-starfive.c b/drivers/pinctrl/pinctrl-starfive.c index d2c9503a82c9..e563cdfcddef 100644 --- a/drivers/pinctrl/pinctrl-starfive.c +++ b/drivers/pinctrl/pinctrl-starfive.c @@ -211,6 +211,7 @@ struct starfive_pinctrl { void __iomem *base; void __iomem *padctl; struct pinctrl_dev *pctl; + struct mutex mutex; /* serialize adding groups and functions */ }; static inline unsigned int starfive_pin_to_gpio(const struct starfive_pinctrl *sfp, @@ -526,6 +527,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, nmaps = 0; ngroups = 0; + mutex_lock(&sfp->mutex); for_each_child_of_node(np, child) { int npins; int i; @@ -619,12 +621,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, *maps = map; *num_maps = nmaps; + mutex_unlock(&sfp->mutex); return 0; put_child: of_node_put(child); free_map: pinctrl_utils_free_map(pctldev, map, nmaps); + mutex_unlock(&sfp->mutex); return ret; } @@ -1325,6 +1329,7 @@ static int starfive_probe(struct platform_device *pdev) platform_set_drvdata(pdev, sfp); sfp->gc.parent = dev; raw_spin_lock_init(&sfp->lock); + mutex_init(&sfp->mutex); ret = devm_pinctrl_register_and_init(dev, &starfive_desc, sfp, &sfp->pctl); if (ret)