Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6013772pxb; Mon, 14 Feb 2022 13:08:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzn91KsWel9ORYo0cLkcNe7o3B6CWelxn58OU3BtSPMtRctt8WJfN8iHqWaSsVJtPzYwhUs X-Received: by 2002:a05:6a00:1747:: with SMTP id j7mr791719pfc.32.1644872933419; Mon, 14 Feb 2022 13:08:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644872933; cv=none; d=google.com; s=arc-20160816; b=P9h16TVl/mYxchWz0oqJd4qylftH/GmuQ8ZKiUnPzvZvKz1qnJJUwTE7PQEs/TWjdl tjNhi48J1MWhHE4i2mFnPThLLft6G63SzilFiV4zJpH2KNuK4C/2GvfmVflda6xA0z8i vvYHBjjHA9uaDO2r2Gw4AfOiUORR2TaxCT+jhyoJLtfu/r8M+j0oZIMPEgJCoGU7/wGX rfulKNoTofa1TZrpxQUfXDyvvyfdPsg/HFZh8Mjrw2jxhuPGqhWaHD2JOafdpQMmkBp6 WdP16aznwVsgsAasMnVmifDBUMbra/J3+46+FwVlSXDmqdtMPlN9rVN1vIvZRAoi/wbV HmDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8iEnHeGfxFfgKOx6/4p+1SIBFJid8eL35ftRYx0B9F0=; b=ZtxjlwvK6CrwVR4sRQxNcpzfSTXvbrx7Tcmv6cHQHd9sqepMBZXnc+HkwRAqFJLUD5 DeR9WDYJXBtccwE+xbbB7YZzUxxfR6auGbdPJRdLGa5FpoYZROGXSahLPOVNNFabxYfv dmwdkxL85eexp7Ak88Z3dweUUSw2jq6sSRUzQ5/tvRgXqu1xSnKnj2/dlt6aO+qL1k+C oRgEvI3BXLZ/gE0O1eI8r6Bfl0DZhqjfoxG5QVFwRT2QYIbD6PNjYcxBnGmVa3DGMdLO zrBXxu2A9uyFCvLSqkkkVKjd7abzlLMvPK6xVqNKTk5eEF0wV77fR8x/LnC+bjSuGBzp Pknw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GBxtVcjV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z1si32955811pfe.46.2022.02.14.13.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 13:08:53 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GBxtVcjV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 353972069A9; Mon, 14 Feb 2022 12:29:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343634AbiBNJxU (ORCPT + 99 others); Mon, 14 Feb 2022 04:53:20 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245544AbiBNJuN (ORCPT ); Mon, 14 Feb 2022 04:50:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 734C625E98; Mon, 14 Feb 2022 01:41:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 540F161190; Mon, 14 Feb 2022 09:41:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 34C1EC340EF; Mon, 14 Feb 2022 09:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831675; bh=OwigAV6fhT7YdraeaXtXy7WEvpHp92vEVh3hKPQ1iP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBxtVcjVrhJrMDsrvzmtPquw2cHK3ho3g3q2N7Uh3Qyr/HF/MGzo2/qfltD9C9ZD0 BiqbjDzDdN/frL2NNTJOxYdfR3HrjSQytLUbiNVS4QKUYfxaACkoLuFX8iW/2NPbjO Th+4YB+OXOxkHM2fCFrjMGQ7tTusGXqPiAV6dNGw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Mikko=20Salom=C3=A4ki?= , Geert Uytterhoeven , Andy Shevchenko , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 5.10 059/116] gpio: aggregator: Fix calling into sleeping GPIO controllers Date: Mon, 14 Feb 2022 10:25:58 +0100 Message-Id: <20220214092500.781219665@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ Upstream commit 2cba05451a6d0c703bb74f1a250691404f27c4f1 ] If the parent GPIO controller is a sleeping controller (e.g. a GPIO controller connected to I2C), getting or setting a GPIO triggers a might_sleep() warning. This happens because the GPIO Aggregator takes the can_sleep flag into account only for its internal locking, not for calling into the parent GPIO controller. Fix this by using the gpiod_[gs]et*_cansleep() APIs when calling into a sleeping GPIO controller. Reported-by: Mikko Salomäki Fixes: 828546e24280f721 ("gpio: Add GPIO Aggregator") Signed-off-by: Geert Uytterhoeven Reviewed-by: Andy Shevchenko Signed-off-by: Bartosz Golaszewski Signed-off-by: Sasha Levin --- drivers/gpio/gpio-aggregator.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index dfd8a4876a27a..d5f25246404d9 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -330,7 +330,8 @@ static int gpio_fwd_get(struct gpio_chip *chip, unsigned int offset) { struct gpiochip_fwd *fwd = gpiochip_get_data(chip); - return gpiod_get_value(fwd->descs[offset]); + return chip->can_sleep ? gpiod_get_value_cansleep(fwd->descs[offset]) + : gpiod_get_value(fwd->descs[offset]); } static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, @@ -349,7 +350,10 @@ static int gpio_fwd_get_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, for_each_set_bit(i, mask, fwd->chip.ngpio) descs[j++] = fwd->descs[i]; - error = gpiod_get_array_value(j, descs, NULL, values); + if (fwd->chip.can_sleep) + error = gpiod_get_array_value_cansleep(j, descs, NULL, values); + else + error = gpiod_get_array_value(j, descs, NULL, values); if (error) return error; @@ -384,7 +388,10 @@ static void gpio_fwd_set(struct gpio_chip *chip, unsigned int offset, int value) { struct gpiochip_fwd *fwd = gpiochip_get_data(chip); - gpiod_set_value(fwd->descs[offset], value); + if (chip->can_sleep) + gpiod_set_value_cansleep(fwd->descs[offset], value); + else + gpiod_set_value(fwd->descs[offset], value); } static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, @@ -403,7 +410,10 @@ static void gpio_fwd_set_multiple(struct gpiochip_fwd *fwd, unsigned long *mask, descs[j++] = fwd->descs[i]; } - gpiod_set_array_value(j, descs, NULL, values); + if (fwd->chip.can_sleep) + gpiod_set_array_value_cansleep(j, descs, NULL, values); + else + gpiod_set_array_value(j, descs, NULL, values); } static void gpio_fwd_set_multiple_locked(struct gpio_chip *chip, -- 2.34.1