From patchwork Mon Oct 24 11:28:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp423722wru; Mon, 24 Oct 2022 05:25:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Q2aQ0CvpjdDbYusYoWNVBBtlFa6XUP3V3kouFdpMriQ1ftGcRtzxjNcdF8+W26BJX9S26 X-Received: by 2002:a17:902:7c12:b0:186:8111:ade2 with SMTP id x18-20020a1709027c1200b001868111ade2mr15524942pll.111.1666614337887; Mon, 24 Oct 2022 05:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666614337; cv=none; d=google.com; s=arc-20160816; b=bz7JUoUkd2XldHp0Q7NtlQ3q/wHq08VQwUpgXzsfY0Z/nkv2hlIslR0Y3aBGrTY2dy vVEEh6I3V+yT6WnYEJvoy2cWf6eUevJpGBkvGic04SYAMzB7TzueQYjs+iYUT3HUxB9/ ieDWxyyMHuQA/PCnue4pNG9hTama5NBBjJ/7SejJHSNQgP4w4Kjp+615/mNbIIxnmrsY isVHv+6BuTefPf090BSApG5EZfC5ApCHkesfVFMgm1jiV4u65VKUscwKmaMiNSL7uAZv xedHULAq+Yn5RzA4s6AUSUfPkNns0QsPNL06rpFkGSZFp3Lwp5TwLADHYWfoD/GadK07 zfYA== 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=J/JyS1HSQpiL71EJ21JKyZRHgCBN3LbOYZvaa9jGqvs=; b=vB9BWEi1Gh0weMWhBhIiS0EGsm0HQ1hQWzAJiaa65oVu9OMyR2iGDfgjyYjccn9qol pWjsKRmn4pVV9Cmx0ROg7kJXUqB/8+1LQYzIheC2YPRMQURog86RNQTKcFVABOUbyTP4 Qzo2fI0S4YSGvdBby0x2n7Opwh+ZWByprTnlPGQis1T5p6LwNMHS9g8aSP22Vhti2zM+ PnF9o4/HaxLeXRUyk2FKpZEqe2QyM5mlLh5SJV3/bwoFZAH4A+uuM8c8No6e78E2C/gX ooSVRTlf48DzRDAtTm8A2JBwn0wa/Z0bSjaljkE8QqDYXiGYQ9bhkMq0j1w1wH2GLQjA ObaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m3TAHe5m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pi16-20020a17090b1e5000b0020d47757829si10523969pjb.144.2022.10.24.05.25.25; Mon, 24 Oct 2022 05:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m3TAHe5m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233488AbiJXMYz (ORCPT + 99 others); Mon, 24 Oct 2022 08:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233371AbiJXMXM (ORCPT ); Mon, 24 Oct 2022 08:23:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6522DEF0; Mon, 24 Oct 2022 04:59:33 -0700 (PDT) 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 E47A761257; Mon, 24 Oct 2022 11:57:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02073C433D6; Mon, 24 Oct 2022 11:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612622; bh=doyM6GFH95BLQzDNCiBz6c5XV379cRQ4AYunJVs8eqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m3TAHe5m2sRQvzogrSIPmCq72dxsyc3tApwigjxHaQZlY98m445+CSQfB1nLF0ZZG kdAtYDZMRlvF5pE90/MZMN5aY2Od6fzjvhHIoCZxz3Xmo7SEZvjO42GT9zCdRr47iA BwuAD8uJDawMiYBV2uWLZ794bovFl2Rbgw3uE9N0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Norris , Guenter Roeck , Ulf Hansson Subject: [PATCH 4.19 016/229] mmc: core: Terminate infinite loop in SD-UHS voltage switch Date: Mon, 24 Oct 2022 13:28:55 +0200 Message-Id: <20221024112959.668731263@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571795684690766?= X-GMAIL-MSGID: =?utf-8?q?1747571795684690766?= From: Brian Norris commit e9233917a7e53980664efbc565888163c0a33c3f upstream. This loop intends to retry a max of 10 times, with some implicit termination based on the SD_{R,}OCR_S18A bit. Unfortunately, the termination condition depends on the value reported by the SD card (*rocr), which may or may not correctly reflect what we asked it to do. Needless to say, it's not wise to rely on the card doing what we expect; we should at least terminate the loop regardless. So, check both the input and output values, so we ensure we will terminate regardless of the SD card behavior. Note that SDIO learned a similar retry loop in commit 0797e5f1453b ("mmc: core: Fixup signal voltage switch"), but that used the 'ocr' result, and so the current pre-terminating condition looks like: rocr & ocr & R4_18V_PRESENT (i.e., it doesn't have the same bug.) This addresses a number of crash reports seen on ChromeOS that look like the following: ... // lots of repeated: ... <4>[13142.846061] mmc1: Skipping voltage switch <4>[13143.406087] mmc1: Skipping voltage switch <4>[13143.964724] mmc1: Skipping voltage switch <4>[13144.526089] mmc1: Skipping voltage switch <4>[13145.086088] mmc1: Skipping voltage switch <4>[13145.645941] mmc1: Skipping voltage switch <3>[13146.153969] INFO: task halt:30352 blocked for more than 122 seconds. ... Fixes: f2119df6b764 ("mmc: sd: add support for signal voltage switch procedure") Cc: Signed-off-by: Brian Norris Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20220914014010.2076169-1-briannorris@chromium.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/core/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -787,7 +787,8 @@ try_again: * the CCS bit is set as well. We deliberately deviate from the spec in * regards to this, which allows UHS-I to be supported for SDSC cards. */ - if (!mmc_host_is_spi(host) && rocr && (*rocr & SD_ROCR_S18A)) { + if (!mmc_host_is_spi(host) && (ocr & SD_OCR_S18R) && + rocr && (*rocr & SD_ROCR_S18A)) { err = mmc_set_uhs_voltage(host, pocr); if (err == -EAGAIN) { retries--;