From patchwork Fri Oct 12 19:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10639133 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B7AC15E2 for ; Fri, 12 Oct 2018 19:08:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A5882C52F for ; Fri, 12 Oct 2018 19:08:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D3F92C533; Fri, 12 Oct 2018 19:08:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AF10B2C52F for ; Fri, 12 Oct 2018 19:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8Ojr7INqL5rg+S9CPWMOFyhCwNRqENM1s91bBO3xdH4=; b=gUHeW/bP5z7WC9aQKEpGD3ai+C n1Mgp4hzSsPtGqS/4ITE59nnC5ZG2vLSjkvVY2Q+Na6JBPfAW7whTc6swCGkIjzUMx60ylPw910KI rul7rMSXQFYHOhZqr0QQ/Bp0J17yi02WRwNSkt6FV/nAinmv520AXHCBvNdljxzI8Y/Pmpwp5v8I1 pauSzztFq2YZM7MiAxuy3uJ6wox9Mkttr5qsIOiG62vePbuEzDrBYG4mLaOlxPzI46yNWAtTXEw/d VO93+0/xC6uBuuqO38gS1hnccoUY8kezSYbpSrxmOiUHYEH3OdQZ8f8mw8ATFPbgewdTxf040WLPv G+iK5jgQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB2nR-0005vt-Vz; Fri, 12 Oct 2018 19:08:26 +0000 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB2mx-0005gw-Sj; Fri, 12 Oct 2018 19:07:57 +0000 Received: by mail-lj1-x242.google.com with SMTP id o14-v6so12280326ljj.2; Fri, 12 Oct 2018 12:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GaRB0w55q1HTP3osbZnN3wKaaRwWOUx826TTBAkNzwU=; b=I9iDldZetEfJHGROPZ+tW9BimkrelJAhW2cHPlZw0ObA9z6+EqaL/3Z/W5MtVixpmv QLeREBzalrBiJ/ocb3exNtHtxFLh5BKC3nXuU5y8z/h8li3yqE6aAoEmRVBvjjTDQZwi UkQNC/FbFiSAqbWQwiSrEybQVtfAIXHbpqNC9NZyVnITv6o2iWredhlNQl4sK6/C+fxD xtsH0hTldnipI37f/H0OXYqd34KQwuljizQ4d/rkvKpEpM/dWCYnDhYkk1h62X9llNZN 0w127upK8b4WiGidTl/RNvoSnvCk+d76D3jVQOEH4AbtlGh8S6z9KHxJr/oK/2NKg0lm CQ7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GaRB0w55q1HTP3osbZnN3wKaaRwWOUx826TTBAkNzwU=; b=R09aWhUwxfy3M0hlwH9E0omQGPPi9tmuziK5LERslfSckPmTGKIbMJ/0lLstzhOYxV D4T/BUNc8tlgogeoqcVIb5iPVs9NFc6k4uJziQro9djYdZJjqzs6oEhBK0I4JdGTU4ia pC00gMNKmBIywEf82CKqMEhkvGfz0NeA+Shch9GSjXjdN3Cfokc+bsKUirOqB1/lzGWi btasJFWBkgVaTkLY5CcxLKNjzz0ueo6OI1H6a5NlVWJfr3UaSptUAYc7UzZ8OT6na+EE BQ5i1R+VDFQ/pRJ+jYa1OO9zo/uv6q0cojmefTqgTMgKPUP4qa+keLxnLt62Nhh/LjEt IMmQ== X-Gm-Message-State: ABuFfojJoeGhL0cs7gD1CvI7wbdGeCu3ysIoA8r10lSXbCbvS8Ac4EPZ u3hmr1zTEd5TyhRiliYpGpc= X-Google-Smtp-Source: ACcGV61Hia86VhFYxKDts9k6Wnmv04yPnPWiJN9xlB54jc33RbO5iV0TJwty2as6vtMuljhJpMTixQ== X-Received: by 2002:a2e:9f17:: with SMTP id u23-v6mr4729689ljk.53.1539371263199; Fri, 12 Oct 2018 12:07:43 -0700 (PDT) Received: from localhost.localdomain ([31.0.86.150]) by smtp.gmail.com with ESMTPSA id h8-v6sm412359lfc.47.2018.10.12.12.07.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 12:07:42 -0700 (PDT) From: Janusz Krzysztofik To: Ulf Hansson Subject: [RFT PATCH] mmc: pwrseq_simple: Fix incorrect handling of GPIO bitmap Date: Fri, 12 Oct 2018 21:09:01 +0200 Message-Id: <20181012190901.1243-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180925192433.1377-1-jmkrzyszt@gmail.com> References: <20180925192433.1377-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_120756_000759_FAF862A9 X-CRM114-Status: GOOD ( 17.61 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Tony Lindgren , Linus Walleij , Marek Szyprowski , Linux Samsung SOC , Kevin Hilman , Janusz Krzysztofik , Krzysztof Kozlowski , linux-rockchip@lists.infradead.org, Kukjin Kim , NXP Linux Team , Javier Martinez Canillas , Pengutronix Kernel Team , Enric Balletbo i Serra , Sascha Hauer , linux-gpio@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Beno=C3=AEt_Cousson?= , Carlo Caione , Shawn Guo , Fabio Estevam MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit b9762bebc633 ("gpiolib: Pass bitmaps, not integer arrays, to get/set array") changed the way GPIO values are passed to gpiod_get/set_array_value() and friends. The new code introduced into mmc_pwrseq_simple_set_gpios_value() incorrectly interpretes the 'value' argument as a bitmap of GPIO values and assigns it directly to the 'values' bitmap variable passed to gpiod_set_array_value_cansleep() instead of filling that bitmap with bits equal to the 'value' argument. As a result, only member 0 of the array is handled correctly. Moreover, wrong assumption is taken about the 'values' bitmap size not exceding the number of bits of the 'value' argument type. Fix it. Signed-off-by: Janusz Krzysztofik Tested-by: Marek Szyprowski --- Hi, I think that patch has been missed while we were resolving issues related to GPIO fast bitmap processing. Since all issues other than the one addreessed by this patch have been been hopefully identified and fixed, GPIO tree seems now to be in good shape in regard to that. However, I believe pwrseq_simple is still broken. Hence, I'm resubmitting this patch to Ulf for inclusion in MMC tree, Cc: many other people who are kindly requested to test it if possible. I've identified the following DT files representing devices which may be affected (have more than one GPIO assigned to pwrseq_simple): - arch/arm/boot/dts/imx6qdl-sr-som-brcm.dtsi - arch/arm/boot/dts/exynos5250-snow-common.dtsi - arch/arm/boot/dts/imx6sl-warp.dts - arch/arm/boot/dts/omap3-igep0030.dts - arch/arm/boot/dts/omap3-igep0020.dts - arch/arm/boot/dts/rk3036-kylin.dts - arch/arm64/boot/dts/rockchip/rk3368-r88.dts - arch/arm64/boot/dts/amlogic/meson-gxbb-vega-s95.dtsi Please start with checking if pwrseq_simple from linux-next works for you and if not, please test if this patch fixes the issue. Thanks, Janusz drivers/mmc/core/pwrseq_simple.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/pwrseq_simple.c b/drivers/mmc/core/pwrseq_simple.c index 7f882a2bb872..ece34c734693 100644 --- a/drivers/mmc/core/pwrseq_simple.c +++ b/drivers/mmc/core/pwrseq_simple.c @@ -40,13 +40,22 @@ static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, struct gpio_descs *reset_gpios = pwrseq->reset_gpios; if (!IS_ERR(reset_gpios)) { - DECLARE_BITMAP(values, BITS_PER_TYPE(value)); + unsigned long *values; int nvalues = reset_gpios->ndescs; - values[0] = value; + values = bitmap_alloc(nvalues, GFP_KERNEL); + if (!values) + return; + + if (value) + bitmap_fill(values, nvalues); + else + bitmap_zero(values, nvalues); gpiod_set_array_value_cansleep(nvalues, reset_gpios->desc, reset_gpios->info, values); + + kfree(values); } }