From patchwork Tue Sep 25 19:24:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 974686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="UOV90hfZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42KWFR704lz9s55 for ; Wed, 26 Sep 2018 05:23:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbeIZBcY (ORCPT ); Tue, 25 Sep 2018 21:32:24 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46039 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbeIZBcY (ORCPT ); Tue, 25 Sep 2018 21:32:24 -0400 Received: by mail-lj1-f193.google.com with SMTP id x16-v6so16440670ljd.12; Tue, 25 Sep 2018 12:23:21 -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=d/NOn73sulnzViPWgFPRhgBzoeN51MibPB5UyJoKcPY=; b=UOV90hfZLCFsTO3Up7K/UJOSyHotObGZMon2CPvbVVy52adQs+VxG/VbYjY3NDqWTo 7tcK/Afp0isU/nFOdgwLl+J4nxejQA2T36DFpUW7Py/EJQEoaMASGvmYyjs45P5F1lwL ml+AUsFR1H7cAmEXfJesQkcA6u3cqAPDj+ys7+us6Q/Xl5JmNCGFsNaus89eqXuy+Tzn wq8G1y6iI4ONxXPjipvLMPQbWxF6yarBrqYeOa8tIZGGvwYUKFsVWaiHRQiPVVw5eQej NXAKcqJPWKeYQbuflLt/ERfdEABLv6PxzREFWV3Xia0Ey0OMytQMgvBrrS3hexspFFYX 0wqw== 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=d/NOn73sulnzViPWgFPRhgBzoeN51MibPB5UyJoKcPY=; b=jVHp+DxzTmetqvefDXj/hiuizkYAAtALsjkcUjhrBuNL2KGSxOnnnEmah4ynuEXZF1 asd7AxC4o/ArcGxLERKXcd3/2n9Z77a41fwtwk1s5RGSgXMqGLnU/3xPoPtnA7a3Sy/T k/av8pUcOjkZiEUxn22ud+j0XITMvZA7at5uUSJZLRQrIGpObEO9F5hSyOgMHZBD0Iq1 1onM11cfVUaga9Q+Vo49NXdVvw9ooUoQTbFd2GhgBRRnh+vTdvnfqVnBWqsHB1OqROAp S4IWaWWAbLdzrrOENsIIFhfRjaDiPUbmmf4uAkFvRHfGvayoY3v+w2OFNf0xBbTFX8// /sSQ== X-Gm-Message-State: ABuFfog54WIlrQiKkmkJdhJHIGMBARy1yHo1FlZvP2SCNz/XuATZdF4G iopOjHSM6HiIqnkDLtebc7CajISJ6NE= X-Google-Smtp-Source: ACcGV62yspT7xgZeOqLL6nDBJExDQ1gg6y4g/yTC1hNsgiYWAVRC256uyLQkZPEjCU7jDERwpoDyTg== X-Received: by 2002:a2e:9694:: with SMTP id q20-v6mr2055898lji.35.1537903400434; Tue, 25 Sep 2018 12:23:20 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id n23-v6sm553160ljh.77.2018.09.25.12.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 12:23:19 -0700 (PDT) From: Janusz Krzysztofik To: Linus Walleij Cc: Ulf Hansson , Janusz Krzysztofik , linux-mmc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Szyprowski , Krzysztof Kozlowski , Linux Samsung SOC Subject: [PATCH] mmc: pwrseq_simple: Fix incorrect handling of GPIO bitmap Date: Tue, 25 Sep 2018 21:24:33 +0200 Message-Id: <20180925192433.1377-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 updated code of mmc_pwrseq_simple_set_gpios_value() incorrectly uses 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, boot hanging caused by incorrectly handled MMC device has been observed. As a side effect of that incorrect interpreation of the 'value' argument, wrong assumption is taken about the 'values' bitmap size never exceding the number of bits of the 'value' argument type. Fix it. Reported-by: Marek Szyprowski Signed-off-by: Janusz Krzysztofik --- Hi, I hope I've finally identified the root cause of the boot hang reported by Marek Szyprowski. I've reviewed the code of other divers updated for the modified GPIO API and found no more issues of that kind. Marek, can you please test this fix on top of next-20180920 with the fix "gpiolib: Fix missing updates of bitmap index" also applied? I've assumed this fix, if tested successfully, will be merged via GPIO tree, hence I've selected Linus as the main recipient of this message. 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); } }