Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4162568imm; Tue, 25 Sep 2018 12:25:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61swQcHqzY9+nk9/uz4Y7lV5AsCd2+VggbvWtOTfcqKxtmMsj59dC3mesivLPn4Ety2Ec8V X-Received: by 2002:a62:6f87:: with SMTP id k129-v6mr2583144pfc.26.1537903520342; Tue, 25 Sep 2018 12:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537903520; cv=none; d=google.com; s=arc-20160816; b=aF6TYtYYs6amMZkNE9HZCb/rSCu+n/lDR0xK+QVrXjKYCbd68ooY0BhKsP8RuLxGK6 3wkrMDfaCounE6BjAYpCkqwzLV28N2qXqKFrqloXLomVQDO4B9MGgw7+sqw9jn2wv0O3 a6GRXzpjHww74k54AcUd9/Ar2QxIkCc/Ey+xytLHq4gGp5RN3oeTdgLJ5j4V01BxQels u8+mmiGYuN6yuzEoYwEthvmYVARnucZOzPBJ1xlTRdQlBuJeehU1eBXIEU6jQSc+Y5+B 4Zd0Ldp0RP/8sI8WklVaMFJq2HldlQfs3SQeSgCTX/tMYiB60xdxYvflp4GoLoCWbwbJ n5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=d/NOn73sulnzViPWgFPRhgBzoeN51MibPB5UyJoKcPY=; b=E6DT+oLdzi50MZORhigtMliBRyNLFwQwVlyttb3ofAg00z1QKx8PTlCJKUybEd9c+R cWtUC8ueddYXtF6zHbvB8aFB6DtX0WzbFCs17k2W3pWeZQZatZN0dmenaMTzATG/e5wz q058IMgr3gnmrDCh7/xink8JQzp3p5U8OLF6uu3nexO3FqR1QDFKRaRhZRt4UFHBO1yo xzUEPM3TQmKijiEnej3DFq5LjYUS8+SGuc3E41heDUduRUKMOSsIIjakRgSbRjo+Mihg jlnuHG3xiHDSgv2IGhSU15fD3iHw57l6YzIiesTHEqo4ofrnD2h0GzT22iyKQBS9NjI1 TkaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UOV90hfZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r20-v6si3082920pls.485.2018.09.25.12.24.55; Tue, 25 Sep 2018 12:25:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UOV90hfZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727604AbeIZBcY (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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); } } -- 2.16.4