Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1306117rwi; Thu, 13 Oct 2022 11:47:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+rjz8J32CXVua5HI1EKApJ0F5uLkAgowMOo8Q/0cTMQ0zbY6Xf1+jvbglfdVwJOyiBFKy X-Received: by 2002:a17:90b:314b:b0:20d:a462:b996 with SMTP id ip11-20020a17090b314b00b0020da462b996mr1265846pjb.39.1665686828363; Thu, 13 Oct 2022 11:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686828; cv=none; d=google.com; s=arc-20160816; b=bx98i4D10agA3r2OIN4YRp5PtpnqCY/GH1KgtVxdQMQX3ZDBfFNCTltiBp1p4kMYH5 koLnvxm0nxuLhGVBTTrij3MCE5PnrJGkN0ilGbmL3eoBF+78rX6luscDdXXOa/JOxJ/a +FwhIuwP0nnlflPDH2EvK+sc/E/ZFuWs7sA5WigE/eanFj6rlVxxs27JvxvM2IntMDtt L/hiLe975BDKxsH+wDMH6ZrH0aB2t/F55a7o2b8gojxURwzIGqqvyWfN/syaoyOITgGL /UpkykK0sPjHuXGHr0mRN317cj4hfBB/ahAYFQy5HeKST4ZXDMopW1/8z1B9sV2HrBk0 J2lw== 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=vSusF7UnJuHJsuuhn7rfJAHkaMmD4CX9OqeBVv90ZvE=; b=0bm5cKRDFoLqP1jDRUJmFz3r8YcUoEYBh4A2hLg0MSoPeDjCNgKPcpuEM+/S3lCPjd ntX0EdVNcOTSW2xmhweaPgdvakB1tgVF4iL61nCpa7Il+iASAvSW7QtS4Rmb0E4WzhDs GHvx8Sct4iymFN+3JHqd/GibBZbmi7Z25ZHkAihhvt7Xq0/f99MO2ZPmU6MlO7RHoEdh eyQaW0BrtcxjfiCaOe8x62t7CMun5EUxGq/EgqQtbZ4xN6ZhmFA9mfDVZUqqv+KCt078 P4jVt3TArgmBu8KSeKZ437ESqZTiwMM1a2i8dJaiSpwFeEiUg1aMbiJ+QoUa9BapvjkE dYXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IbhuCf5O; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v191-20020a6389c8000000b0045b85251c12si157535pgd.260.2022.10.13.11.46.56; Thu, 13 Oct 2022 11:47:08 -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=IbhuCf5O; 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 S230019AbiJMRyg (ORCPT + 99 others); Thu, 13 Oct 2022 13:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbiJMRxx (ORCPT ); Thu, 13 Oct 2022 13:53:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87236152029; Thu, 13 Oct 2022 10:53:25 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9BC8DB82026; Thu, 13 Oct 2022 17:53:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14516C433D7; Thu, 13 Oct 2022 17:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683602; bh=beHM6p8L43oHqLXfN/3Q+tAnkkBD31uvAhb+FMk75Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IbhuCf5O48Ts04StuFvclg516afriUPHgBLa2sIrpWscDXUz9DlAp5qYT2+OU0dbM 6eyQhSnXLeOSb4qpok/ZzQf85MiIqWZ+GzjSyw4ohL18ctLNS/c+TBOK9alliLcJbj pRWsDs5tODs1yFTEHMIsGaYCuY8z5C2wafIRauxA= 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 5.4 16/38] mmc: core: Terminate infinite loop in SD-UHS voltage switch Date: Thu, 13 Oct 2022 19:52:17 +0200 Message-Id: <20221013175144.817058806@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175144.245431424@linuxfoundation.org> References: <20221013175144.245431424@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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 @@ -799,7 +799,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--;