From patchwork Mon Aug 15 07:33:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 597436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92762C25B0E for ; Mon, 15 Aug 2022 07:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240876AbiHOHdi (ORCPT ); Mon, 15 Aug 2022 03:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbiHOHdh (ORCPT ); Mon, 15 Aug 2022 03:33:37 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B7FF183AD for ; Mon, 15 Aug 2022 00:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660548817; x=1692084817; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1AK1S1BOIw9Q6ZTrhHzTTh8pHFE1UB2y0y7l7SC8mWI=; b=XX/v7rSac+DOLjHQSKv3DqTFpc3WFrlg9X9eEd7AApWo2SXS8WChEJHF OqeuX+dsyl3ZAA9wSv3k2wjikqZ6z+wB4sl0d6CjOMw+zPCTZ9uVYB0CZ 7nRiRPaInoN2iLgGaj6Eh9Nz+9bXoCkhhg3MLA5wKDr60xUeL91YCet21 Bs1+HOo0YsfyYdNjq5iayMhwgt8mWHA2rDfYHg5e9yw77Nz2WZG93f/qj lS3jtfJk0bpUc7vYjIUDKRvV9VVI6NzDOQNN1dolvMOhOGxdWCtgpRW1k LQcYLLoQ/FlwcdqFRdowvGm33I2BaDQ59fl4OqPNwI6oZf+SE5FyDU7PH w==; X-IronPort-AV: E=McAfee;i="6400,9594,10439"; a="290663301" X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="290663301" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2022 00:33:37 -0700 X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="603108074" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.50.166]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2022 00:33:35 -0700 From: Adrian Hunter To: Ulf Hansson Cc: linux-mmc , Seunghui Lee , DooHyun Hwang Subject: [PATCH 1/2] mmc: sd: Fix 1.8V workaround branch Date: Mon, 15 Aug 2022 10:33:20 +0300 Message-Id: <20220815073321.63382-2-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815073321.63382-1-adrian.hunter@intel.com> References: <20220815073321.63382-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org When introduced, upon success, the 1.8V fixup workaround in mmc_sd_init_card() would branch to practically the end of the function, to a label named "done". Unfortunately, perhaps due to the label name, over time new code has been added that really should have come after "done" not before it. Move the label to the correct place and rename it "cont". Fixes: 045d705dc1fb ("mmc: core: Enable the MMC host software queue for the SD card") Signed-off-by: Adrian Hunter Reviewed-by: Seunghui Lee --- drivers/mmc/core/sd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index cee4c0b59f43..bc84d7dfc8e1 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -1498,7 +1498,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, mmc_remove_card(card); goto retry; } - goto done; + goto cont; } } @@ -1534,7 +1534,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, mmc_set_bus_width(host, MMC_BUS_WIDTH_4); } } - +cont: if (!oldcard) { /* Read/parse the extension registers. */ err = sd_read_ext_regs(card); @@ -1566,7 +1566,7 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, err = -EINVAL; goto free_card; } -done: + host->card = card; return 0; From patchwork Mon Aug 15 07:33:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 598370 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD3A5C00140 for ; Mon, 15 Aug 2022 07:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240765AbiHOHdl (ORCPT ); Mon, 15 Aug 2022 03:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbiHOHdj (ORCPT ); Mon, 15 Aug 2022 03:33:39 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27831183AD for ; Mon, 15 Aug 2022 00:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660548819; x=1692084819; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZOsqDs1y2TB8CObDHbvMu/N5FecGKSYTKMtllmsB2H4=; b=SUWhJqXOHE4Cw8wRYK/jvUqvfIzsb10zNnPZVvO6UwHusUtsFQGEmpor CjnB9S76aWoIAXYbRFq9eBGFoIoGJ4kDKePA33F5V8jJgYKJXDwTIEiiB Zz+yxMstBhzN6XGzslDbKfmFf+fQOLk789zM0eYlobbUZDs1xpKMlFfRf 8Iyfj+lvWVokdshl2y/xghjy1Lf2l+aSwAQZ+5IDexZFd3c0eLzUjousw twAQY2OFVGQz7UYWNzcUxPwZjEoO900FGFui0dGchbmnf/vU55M2jksRu m70nNFVtz9mxkRrEXBIkg1nbHiAVu4L4M2awyClahLP7aFORbt3DuRgLi w==; X-IronPort-AV: E=McAfee;i="6400,9594,10439"; a="290663306" X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="290663306" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2022 00:33:39 -0700 X-IronPort-AV: E=Sophos;i="5.93,237,1654585200"; d="scan'208";a="603108088" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.50.166]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Aug 2022 00:33:37 -0700 From: Adrian Hunter To: Ulf Hansson Cc: linux-mmc , Seunghui Lee , DooHyun Hwang Subject: [PATCH 2/2] mmc: sd: Fix inconsistent sd3_bus_mode with failed voltage switch Date: Mon, 15 Aug 2022 10:33:21 +0300 Message-Id: <20220815073321.63382-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220815073321.63382-1-adrian.hunter@intel.com> References: <20220815073321.63382-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org If re-initialization results is a different signal voltage, because the voltage switch failed previously but not this time (or vice versa), then sd3_bus_mode will be inconsistent with the card because the SD_SWITCH command is done only upon first initialization. Fix by always reading SD_SWITCH information during re-initialization which also means it does not need to be re-read later for the 1.8V fixup workaround. Note, brief testing showed SD_SWITCH took about 1.8ms to 2ms which added about 1% to 1.5% to the re-initialization time, so not particularly significant. Reported-by: Seunghui Lee Signed-off-by: Adrian Hunter --- drivers/mmc/core/sd.c | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index bc84d7dfc8e1..06aa62ce0ed1 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -949,15 +949,16 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, /* Erase init depends on CSD and SSR */ mmc_init_erase(card); - - /* - * Fetch switch information from card. - */ - err = mmc_read_switch(card); - if (err) - return err; } + /* + * Fetch switch information from card. Note, sd3_bus_mode can change if + * voltage switch outcome changes, so do this always. + */ + err = mmc_read_switch(card); + if (err) + return err; + /* * For SPI, enable CRC as appropriate. * This CRC enable is located AFTER the reading of the @@ -1480,26 +1481,15 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, if (!v18_fixup_failed && !mmc_host_is_spi(host) && mmc_host_uhs(host) && mmc_sd_card_using_v18(card) && host->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_180) { - /* - * Re-read switch information in case it has changed since - * oldcard was initialized. - */ - if (oldcard) { - err = mmc_read_switch(card); - if (err) - goto free_card; - } - if (mmc_sd_card_using_v18(card)) { - if (mmc_host_set_uhs_voltage(host) || - mmc_sd_init_uhs_card(card)) { - v18_fixup_failed = true; - mmc_power_cycle(host, ocr); - if (!oldcard) - mmc_remove_card(card); - goto retry; - } - goto cont; + if (mmc_host_set_uhs_voltage(host) || + mmc_sd_init_uhs_card(card)) { + v18_fixup_failed = true; + mmc_power_cycle(host, ocr); + if (!oldcard) + mmc_remove_card(card); + goto retry; } + goto cont; } /* Initialization sequence for UHS-I cards */