From patchwork Thu Jul 28 12:41:06 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: 1661635 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=aqBAqqTw; 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 4LtqyR23wJz9sFk for ; Thu, 28 Jul 2022 22:41:19 +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 1oH2pF-0003P2-4L; Thu, 28 Jul 2022 12:41:13 +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 1oH2pD-0003OL-3D for kernel-team@lists.ubuntu.com; Thu, 28 Jul 2022 12:41:11 +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 A04A43F11C for ; Thu, 28 Jul 2022 12:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1659012070; bh=9DnSiLzwxRx6QYhXHpQwNkuwjyPgzanPqhMmes03hs0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aqBAqqTwMvh/UlryFRdQV8Ze6wQ+H0eeSG+148UGIoV3clYnWM1cFv6n6PjyXTatL YHLsLrGJICuBl5FlusgIeb8GM0OMckWhPEJeSygNB3/XjDzsFbfoRqnLxtPGdVdTA/ u8zNTEKmFceBrQJrCYD8drZ8KES751Q502LRgEhB6PIySxIUJmJtLloz50uskPjjMN D9bnisHYw6HgM2mhLJZCPF7MP5/ZkULXF+S6Y1wE8HIHi2XyIhGoahKs1gRec1OcEv EHHZsfSfCGILsVAeiv78S1Y7rR9HomNpIYEgY3LJbd+9mXMODUwcFMGfH8++7kf/bC 1Gr9Lu+yeRHYQ== Received: by mail-lf1-f70.google.com with SMTP id k25-20020a195619000000b00489e6a6527eso598446lfb.8 for ; Thu, 28 Jul 2022 05:41:10 -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=9DnSiLzwxRx6QYhXHpQwNkuwjyPgzanPqhMmes03hs0=; b=Wcm8DF1gY6OyaSXZNXnoxV88zwuWwFAWRDATrpERYRiAc7fafsGbBdG7a3VugbCkfY TChitEu1a0SgBCBipjJqWLZNi63Cs5PUbdX3QKV4A13OGX5vAZLL388kz/egm3vkWiYX wTwuLZyhodQTCCF6yoAA0WAkDqXLxuA9rHOZ/xo0/o5JHvctZICaFFv1At5V+u9IrmmQ wuKHOKfQx5ViSoa7T5DrZNwnnmA5rKZyGmM2In8xBR0Y4wyiqkg5CAABpVMUHhRpFE0M qdj9mAR16Tj6zBivpED9Vl7PzcIbGp5EDpFn6yoID6Jq07wci7sQ2lHpj7lP4X+CGdqE 3flw== X-Gm-Message-State: AJIora82WBrb9cEli7QrWTyD6LhgaX3N8gxkpXuSzoyuiZEujPO97bd1 tNkxt3jCWCul5jpJ75y8u+fj4ppl1wLpcEz7nQe07nMLz2VHW32NPVhTNYh6JDv+S258a27wDvl 4AtiULw9nz00lgljIns3d9PR7PT+ZphzcCy5jx2gGkQ== X-Received: by 2002:a05:6512:1690:b0:48a:c5b6:17cc with SMTP id bu16-20020a056512169000b0048ac5b617ccmr1124160lfb.375.1659012069725; Thu, 28 Jul 2022 05:41:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tEXU11ht6xLNwqHG0XyOX03x7Cd+AmeaawYk3FvSTtyx6pfLUDT/syvmv7LRgmzTp2ky3awg== X-Received: by 2002:a05:6512:1690:b0:48a:c5b6:17cc with SMTP id bu16-20020a056512169000b0048ac5b617ccmr1124155lfb.375.1659012069524; Thu, 28 Jul 2022 05:41:09 -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 k1-20020ac257c1000000b0048a73208cbbsm177345lfo.280.2022.07.28.05.41.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 05:41:09 -0700 (PDT) From: Emil Renner Berthing To: kernel-team@lists.ubuntu.com Subject: [SRU][J/starfive-5.17][PATCH v2 1/1] pinctrl: starfive: Serialize adding groups and functions Date: Thu, 28 Jul 2022 14:41:06 +0200 Message-Id: <20220728124106.739685-2-emil.renner.berthing@canonical.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220728124106.739685-1-emil.renner.berthing@canonical.com> References: <20220728124106.739685-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 linux-next) 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)