From patchwork Sun Jul 28 08:11:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 814935 Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E780C13B for ; Sun, 28 Jul 2024 08:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154466; cv=none; b=SLYBZTb3s0CeKFkG+7LhTlQAMgTXwCerH7qgDBoWLkWXN3vc8tfxzFfi3zf31C2wEw9xXYwaIlj7vzO9O/fF3B0KXKmiRyQocSJ779Sj11yLoN+OdhllMqLMhrb3jrKj7ofqAJJ9iHlHJyEcqh7yBuisSoI/QbIAjnXQ1uIRuFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154466; c=relaxed/simple; bh=ZEgObMbnv6e4XAH8wAQxCGBp478qeQKb/VSh+uWR0MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H0zNkALctJHhUgavq5b7vh3vCZdB1eAReah1wdWd2FRD7ByvwienmPNTD/ci+PKRFfOlBasTCuwZvJcCgNkadgGH8vF1NtmGEjX2pOiB+Gx6mzBpkJ9om040DFeBkl24Z/K68V45Wm1hwzZJlcl73UoKpYvy7QE6Xuylj9kGlpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=nQerns0S; arc=none smtp.client-ip=216.71.154.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="nQerns0S" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154464; x=1753690464; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZEgObMbnv6e4XAH8wAQxCGBp478qeQKb/VSh+uWR0MQ=; b=nQerns0S44T72rat8bGIlhvOadBhl13rUfENuGaTDJjjI/QKk8JiwPoB o3ZtD7MowOsDMPHv2RqfRmVlrle++vyCsSbM+XKroNAY49zTdUVkLISVq UEh9bXDnWjJssFvYJRvFrQs1JekUzYem5RNwF62OOUYSbyQ5WoXYc7GUF xe1SatghSb4hFF6QmPAaDiXlvzYStrHcjeP5c8M2oBUu3c2c9lAPZvntZ n48JvGeSGtum+JVGa9iLpE7P9VaeU0S8AlXd3QyHX5zrargqO+OBrbACJ NJ9nIOkIwPFKlv/fk0m5dilYC4d9qCJYSJvTzagDIBeivQE+T4MotbrK/ g==; X-CSE-ConnectionGUID: Cy5lsA0pQqaossaF7n+ZjQ== X-CSE-MsgGUID: HO5Nx/4IRQqg9PTRz+ShmA== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22256097" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:18 +0800 IronPort-SDR: 66a5f104_ybCAqaAP/PgDqF0/viYR1PcjsFEKlg86UwfaALsixQEETv7 VRDVgu7H5p8MVgV9KaIja1fcpnaJI6rLvlABZ8g== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:33 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:17 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 01/10] mmc: sd: SDUC Support Recognition Date: Sun, 28 Jul 2024 11:11:45 +0300 Message-Id: <20240728081154.1782120-2-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ACMD21 was extended to support the host-card handshake during initialization. The card expects that the HCS & HO2T bits to be set in the command argument, and sets the applicable bits in the R3 returned response. On the contrary, if a SDUC card is inserted to a non-supporting host, it will never respond to this ACMD21 until eventually, the host will timed out and give up. Signed-off-by: Avri Altman --- drivers/mmc/core/sd_ops.c | 19 +++++++++++++++---- include/linux/mmc/host.h | 6 ++++++ include/linux/mmc/sd.h | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 8b9b34286ef3..7f6963dac873 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -168,12 +168,16 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) .cmd = &cmd }; int err; + u32 sduc_arg = SD_OCR_CCS | SD_OCR_2T; cmd.opcode = SD_APP_OP_COND; + cmd.arg = ocr; + if (mmc_host_is_spi(host)) - cmd.arg = ocr & (1 << 30); /* SPI only defines one bit */ + cmd.arg &= (1 << 30); /* SPI only defines one bit */ else - cmd.arg = ocr; + cmd.arg |= sduc_arg; + cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R3 | MMC_CMD_BCR; err = __mmc_poll_for_busy(host, SD_APP_OP_COND_PERIOD_US, @@ -182,8 +186,15 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) if (err) return err; - if (rocr && !mmc_host_is_spi(host)) - *rocr = cmd.resp[0]; + if (!mmc_host_is_spi(host)) { + if (rocr) + *rocr = cmd.resp[0]; + + if ((cmd.resp[0] & sduc_arg) == sduc_arg) + host->caps2 |= MMC_CAP2_SD_SDUC; + else + host->caps2 &= ~MMC_CAP2_SD_SDUC; + } return 0; } diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 88c6a76042ee..a9c36a3e1a10 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -427,6 +427,7 @@ struct mmc_host { #define MMC_CAP2_CRYPTO 0 #endif #define MMC_CAP2_ALT_GPT_TEGRA (1 << 28) /* Host with eMMC that has GPT entry at a non-standard location */ +#define MMC_CAP2_SD_SDUC (1 << 29) /* SD over 2TB */ int fixed_drv_type; /* fixed driver type for non-removable media */ @@ -638,6 +639,11 @@ static inline int mmc_card_uhs(struct mmc_card *card) card->host->ios.timing <= MMC_TIMING_UHS_DDR50; } +static inline int mmc_card_is_sduc(struct mmc_host *host) +{ + return host->caps2 & MMC_CAP2_SD_SDUC; +} + void mmc_retune_timer_stop(struct mmc_host *host); static inline void mmc_retune_needed(struct mmc_host *host) diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h index 6727576a8755..865cc0ca8543 100644 --- a/include/linux/mmc/sd.h +++ b/include/linux/mmc/sd.h @@ -36,6 +36,7 @@ /* OCR bit definitions */ #define SD_OCR_S18R (1 << 24) /* 1.8V switching request */ #define SD_ROCR_S18A SD_OCR_S18R /* 1.8V switching accepted by card */ +#define SD_OCR_2T (1 << 27) /* HO2T/CO2T - SDUC support */ #define SD_OCR_XPC (1 << 28) /* SDXC power control */ #define SD_OCR_CCS (1 << 30) /* Card Capacity Status */ From patchwork Sun Jul 28 08:11:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 815541 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E84DE15E88 for ; Sun, 28 Jul 2024 08:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.143.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154417; cv=none; b=gSkn9rS8xQxoplGXvHUl8C6Y9FWLWwl7ovf4IHXDivNzUNgQDkx0dzHhpT2an0/aC491aduhDawcoq2ZVlQrX8RK4aE+CSdWGkMcCeKHw63s6Ys2I/uD0xfgukz97+nZBDfqov8bl+JIx9KyDbi1G5Md9NhJdsJANSuXxNRuLRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154417; c=relaxed/simple; bh=KQ34oRMswWKaUD5gQuHBgpKk5zj/IZmCJxdHEcJMn6o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JF6h3cAd3xu3pk7zmc0t9dw294gPh/hZDeVltsobU/nCUOFdcR7Eh0hkKWoKMfAP9oaEiWVxVAPyO8K5l0se6jxTR+v1cwAZFkpLyJV685yV5W6n7El8RgFOiX5mnAgGX/llwyjPR3uxmiVePXEp4ykoAMlz8ulWiHYaKtg8R+Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=QSjf0jwx; arc=none smtp.client-ip=68.232.143.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="QSjf0jwx" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154415; x=1753690415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KQ34oRMswWKaUD5gQuHBgpKk5zj/IZmCJxdHEcJMn6o=; b=QSjf0jwx+o444NwJOOH4iOw96IALky37qlW7NYwu6RyR5a7PaeacTWJA u5GifOttGvkzp8/13kKtAbMLDwQ4QklwOmdCnYjFrOHW+qUnjjsRHvxsP p1Re2Q4r9N0wahDfFkiOJzVrhujTWJY1v/EsY8r3xB8blobDsWfzV1O5l hSlRyKGzztvRUpHmjCzIGa265CGlhBdbVvLzUd0ImaGheGhcTa/UNhvAv +NSfwGPJPRjgRXisG73rVXc7HOoHdRQW3h5weGLBm12dsg7AIq1ka2U71 0tfViozFB9mM6aUpi6RAw3lUKoy0a7Cc8ehfDBksccns4qJBvdJ0yMiUf Q==; X-CSE-ConnectionGUID: XZmjY/j0QnmEWSCLl0Orew== X-CSE-MsgGUID: VqDRD7VSREGq+zFXecnkVg== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="23160000" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:27 +0800 IronPort-SDR: 66a5f10d_PVCGO2obxV4yzF1PJRZhT8aOAgcQ1x8mKPcXbLw3KnVRY7q F6UhcT/0/yn6iVBmSBAG+kzgArCv8OSPrOOLHpA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:42 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:26 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 02/10] mmc: sd: Add SD CSD version 3.0 Date: Sun, 28 Jul 2024 11:11:46 +0300 Message-Id: <20240728081154.1782120-3-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Ultra Capacity SD cards (SDUC) was already introduced in SD7.0. Those cards support capacity larger than 2TB and up to including 128TB. Properly parse the csd register as the c_size field got expanded to 28 bits. Signed-off-by: Avri Altman --- drivers/mmc/core/bus.c | 4 +++- drivers/mmc/core/card.h | 3 +++ drivers/mmc/core/sd.c | 16 +++++++++++----- include/linux/mmc/card.h | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 0ddaee0eae54..30763b342bd3 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -321,7 +321,9 @@ int mmc_add_card(struct mmc_card *card) case MMC_TYPE_SD: type = "SD"; if (mmc_card_blockaddr(card)) { - if (mmc_card_ext_capacity(card)) + if (mmc_card_ult_capacity(card)) + type = "SDUC"; + else if (mmc_card_ext_capacity(card)) type = "SDXC"; else type = "SDHC"; diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index b7754a1b8d97..64dcb463a4f4 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -23,6 +23,7 @@ #define MMC_CARD_SDXC (1<<3) /* card is SDXC */ #define MMC_CARD_REMOVED (1<<4) /* card has been removed */ #define MMC_STATE_SUSPENDED (1<<5) /* card is suspended */ +#define MMC_CARD_SDUC (1<<6) /* card is SDUC */ #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) @@ -30,11 +31,13 @@ #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED)) #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED) +#define mmc_card_ult_capacity(c) ((c)->state & MMC_CARD_SDUC) #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) +#define mmc_card_set_ult_capacity(c) ((c)->state |= MMC_CARD_SDUC) #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED) #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED) diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 1c8148cdda50..28193a9b31c9 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -157,6 +157,7 @@ static int mmc_decode_csd(struct mmc_card *card) mmc_card_set_readonly(card); break; case 1: + case 2: /* * This is a block-addressed SDHC or SDXC card. Most * interesting fields are unused and have fixed @@ -172,14 +173,19 @@ static int mmc_decode_csd(struct mmc_card *card) e = UNSTUFF_BITS(resp, 96, 3); csd->max_dtr = tran_exp[e] * tran_mant[m]; csd->cmdclass = UNSTUFF_BITS(resp, 84, 12); - csd->c_size = UNSTUFF_BITS(resp, 48, 22); - /* SDXC cards have a minimum C_SIZE of 0x00FFFF */ - if (csd->c_size >= 0xFFFF) + if (csd_struct == 1) + m = UNSTUFF_BITS(resp, 48, 22); + else + m = UNSTUFF_BITS(resp, 48, 28); + csd->c_size = m; + + if (csd->c_size >= 0x400000 && mmc_card_is_sduc(card->host)) + mmc_card_set_ult_capacity(card); + else if (csd->c_size >= 0xFFFF) mmc_card_set_ext_capacity(card); - m = UNSTUFF_BITS(resp, 48, 22); - csd->capacity = (1 + m) << 10; + csd->capacity = (1 + (typeof(sector_t))m) << 10; csd->read_blkbits = 9; csd->read_partial = 0; diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index f34407cc2788..f39bce322365 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -35,7 +35,7 @@ struct mmc_csd { unsigned int wp_grp_size; unsigned int read_blkbits; unsigned int write_blkbits; - unsigned int capacity; + sector_t capacity; unsigned int read_partial:1, read_misalign:1, write_partial:1, From patchwork Sun Jul 28 08:11:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 814938 Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18F4DBA34 for ; Sun, 28 Jul 2024 08:13:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=68.232.143.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154420; cv=none; b=Ois9KrbTu7i6in+n8x3ieAyj2YUSWeoF7XeinglH0kNxHwo6GUxrvc8/U+r/tR4Z0VzWQDnV2VadHtBhH3CzDCozZfGB+yY0wSUknpGEQDls0oJwsDWes+x2oolU+MWKHc9gWZAqRUku7LTUIpyIs29ywMBHM6RNxRw6yFSRezI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154420; c=relaxed/simple; bh=X0/a+BX4U/emCOb0S9LS+gkDCOcQajRM/sLCLXaTzMw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kdQd60ByGogKYJ4y9qGiFvnG+ehSBPikcbsx2JRM3zM5dGjpiBwKwzCzvmguFS05NY36RU4AWsDkcVmJellmmIKCf06CA2VUscuuskixbnktFj8E0qr2CnRDBQMO6vkSVzSit0i04ehcKbjYxPoZ4A87WOtsx2TtR//5pGZWJFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=Rt0Bh8fw; arc=none smtp.client-ip=68.232.143.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Rt0Bh8fw" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154418; x=1753690418; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X0/a+BX4U/emCOb0S9LS+gkDCOcQajRM/sLCLXaTzMw=; b=Rt0Bh8fw5gxhpp4Z9ifNBUwDgCQkU+26KFkF84J0G02zzRe6ImlIR039 PBAcFr3Neyi9xYomrfJsdNx7lyZ+KEpADJdQs1jCfv55Il4HC8TQeSkjg 5mgvl+RrptSPiC6PDFDZJW77UlNTTkDuJMYBsKiNyiFlPluGnA7M0wc+K pKt4TUANKR7oH1uE2LZFekD5TxdYTAR+WMMsjmELLqkRLsupGBWIpJb1z D+O2z5GdPvJ+c91gOVXAqtXj9dupZrZER6YK/z8BIG6VnC77DCmWTxjHv 9bNWKR4cCs24hN366a+hLDWa16APeSeFDd6VRS84ZdowKylttH8nDkSfJ w==; X-CSE-ConnectionGUID: mjXM694HQxeZfhIfCgoZog== X-CSE-MsgGUID: c4t9wfUGTlGLEercYQ3mlA== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="23160001" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:30 +0800 IronPort-SDR: 66a5f111_0OAUMtfLf72/y4xYV9tV20J+aQb0yzLRK+0c8zg2w+EFVEs WuUpu3+usIXb/KNdn15UGByOt5otnPFi23KSsQg== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:45 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:29 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 03/10] mmc: sd: Add Extension memory addressing Date: Sun, 28 Jul 2024 11:11:47 +0300 Message-Id: <20240728081154.1782120-4-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 SDUC memory addressing spans beyond 2TB and up to 128TB. Therefore, 38 bits are required to access the entire memory space of all sectors. Those extra 6 bits are to be carried by CMD22 prior of sending read/write/erase commands: CMD17, CMD18, CMD24, CMD25, CMD32, and CMD33. CMD22 will carry the higher order 6 bits, and must precedes any of the above commands even if it targets sector < 2TB. No error related to address or length is indicated in CMD22 but rather in the read/write command itself. Signed-off-by: Avri Altman --- drivers/mmc/core/sd_ops.c | 14 ++++++++++++++ drivers/mmc/core/sd_ops.h | 1 + include/linux/mmc/sd.h | 3 +++ 3 files changed, 18 insertions(+) diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 7f6963dac873..25b299d91cfc 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -199,6 +199,20 @@ int mmc_send_app_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) return 0; } +int mmc_send_ext_addr(struct mmc_host *host, u8 ext_addr) +{ + struct mmc_command cmd = {}; + + if (!mmc_card_is_sduc(host)) + return 0; + + cmd.opcode = SD_ADDR_EXT; + cmd.arg = ext_addr & 0x3F; + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + + return mmc_wait_for_cmd(host, &cmd, 0); +} + static int __mmc_send_if_cond(struct mmc_host *host, u32 ocr, u8 pcie_bits, u32 *resp) { diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h index 7667fc223b74..0db081f2355c 100644 --- a/drivers/mmc/core/sd_ops.h +++ b/drivers/mmc/core/sd_ops.h @@ -21,6 +21,7 @@ int mmc_send_relative_addr(struct mmc_host *host, unsigned int *rca); int mmc_app_send_scr(struct mmc_card *card); int mmc_app_sd_status(struct mmc_card *card, void *ssr); int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card); +int mmc_send_ext_addr(struct mmc_host *host, u8 ext_addr); #endif diff --git a/include/linux/mmc/sd.h b/include/linux/mmc/sd.h index 865cc0ca8543..af5fc70e09a2 100644 --- a/include/linux/mmc/sd.h +++ b/include/linux/mmc/sd.h @@ -15,6 +15,9 @@ #define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */ #define SD_SWITCH_VOLTAGE 11 /* ac R1 */ +/* Class 2 */ +#define SD_ADDR_EXT 22 /* ac [5:0] R1 */ + /* class 10 */ #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ From patchwork Sun Jul 28 08:11:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 815537 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81E70BA20 for ; Sun, 28 Jul 2024 08:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154486; cv=none; b=XOPRr9ruhIwNO80TaI1wK7yBCgOSPBYwX9q5RSBXuZ/o7zfM+IOMMtY05tJTT4hSBnjxvgMhs8oApISFxI5EnJpvKayVHZ+a0XgMW44aLZwAvc+Zkfs1lMrhro7fkILMjiOzzXT9ybcQ4aVVgiZqlDcfwOAxXypx3m7JG9a7fUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154486; c=relaxed/simple; bh=S8xVwTDSTeCW0c+Tn4lgqG+XzOS+QoWYH54V9w9WVPE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O8dPeFl6Fsd3F6Z2WaebDB6MJCsdBp3no8KNj606/oHVZX4KfBHVOdjdo0KNyVogtJPZUTLuRgknLD/zQ3CUHeIDIqLj44+thVN5Vh9BSwTvsTXp/PiP361IB1FMuzZ3IKh2EgbW98rLNA1AiGPxhq0OZ1XrDAEjF6uq1lzZ0ts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=C/g3sVbn; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="C/g3sVbn" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154484; x=1753690484; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S8xVwTDSTeCW0c+Tn4lgqG+XzOS+QoWYH54V9w9WVPE=; b=C/g3sVbnB83TXpr3GRgMZY21iIpBwXHwUBUrDFu+87eVPr+ErIDzF+V+ 11P1yG378s16+fgjgk9Hh/VIZ25JKYihcQDLFi5quP4a983nswZ9JFGHQ OGSm6ayiH/7iYfSyzD31k1Bay+0TcCDlrf8c8MysYRwQnK72thbYQGwGE vHVuOf8tgpG590uJoyin5XKm0iDdT/YuJEpTfk8H5/BumSgOU3qh20alM NW1AnTVNW8/GayyIE2THSsSJATCb50mKq5koYr8n9j1X9fwBgM/Urlo8d ASJ+//RR6i7vmXBkMnS18HS3Sbbp6+nYO71l67wBlOkznUk8GHJefrQk6 w==; X-CSE-ConnectionGUID: 2/Ce7q+cRWKL+gSJYItd6w== X-CSE-MsgGUID: E63lat4ETfizHo5PsJudfw== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909116" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:35 +0800 IronPort-SDR: 66a5f116_DYq9VzEpchK5O4hMTib0pc2o9b9LqiSMzn2tD2EIW2sKbO0 Q3VhXE164iJB6nfzDKF4q+cajmNpJQ3bgauBD/g== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:50 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:34 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 04/10] mmc: core: Add open-ended Ext memory addressing Date: Sun, 28 Jul 2024 11:11:48 +0300 Message-Id: <20240728081154.1782120-5-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For open-ended read/write - just send CMD22 before issuing the command. While at it, make sure that the rw command arg is properly casting the lower 32 bits, as it can be larger now. Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 8 +++++++- drivers/mmc/core/sd_ops.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 367509b5b646..eb41d2803c9b 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -180,6 +180,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, static void mmc_blk_hsq_req_done(struct mmc_request *mrq); static int mmc_spi_err_check(struct mmc_card *card); static int mmc_blk_busy_cb(void *cb_data, bool *busy); +static int mmc_blk_wait_for_idle(struct mmc_queue *mq, struct mmc_host *host); static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { @@ -1664,7 +1665,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, brq->mrq.cmd = &brq->cmd; - brq->cmd.arg = blk_rq_pos(req); + brq->cmd.arg = blk_rq_pos(req) & 0xFFFFFFFF; if (!mmc_card_blockaddr(card)) brq->cmd.arg <<= 9; brq->cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; @@ -1712,6 +1713,11 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, (do_data_tag ? (1 << 29) : 0); brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; brq->mrq.sbc = &brq->sbc; + } else if (mmc_card_is_sduc(card->host)) { + u8 ext_addr = FIELD_GET(SDUC_ADDR_EXT_MASK, blk_rq_pos(req)); + + mmc_blk_wait_for_idle(mq, card->host); + mmc_send_ext_addr(card->host, ext_addr); } } diff --git a/drivers/mmc/core/sd_ops.h b/drivers/mmc/core/sd_ops.h index 0db081f2355c..1f80941b6779 100644 --- a/drivers/mmc/core/sd_ops.h +++ b/drivers/mmc/core/sd_ops.h @@ -9,6 +9,9 @@ #define _MMC_SD_OPS_H #include +#include + +#define SDUC_ADDR_EXT_MASK GENMASK(37, 32) struct mmc_card; struct mmc_host; From patchwork Sun Jul 28 08:11:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 815536 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E33FCA62 for ; Sun, 28 Jul 2024 08:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154488; cv=none; b=oUByICGXITeKUCGBKVGQ+RRHDIiVhyokOAuUR9egcWsgsjE6jH68tSYbqjk7mCJF6TaLX5PKGrbsKNlG8P9AE+dPdaism7ed5COGzhFkcQfMf66kva1GryY1T96mSFE3RyRMV0eVc9Bsjeh6MJsREbbVUtg5c59+6jRT4QAPvd4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154488; c=relaxed/simple; bh=2kwH4Vt8a7i9oZ37i7o0f8oMETvYf0/kaB14dJeKXg8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bYshojgWL4o8knZJaH6gqLYT9qFC6iaYBp/pjlOcgYVSV2w/tkdkC2AbQaOupo2W/Unb5sTJw4TdNiPI2DEJJL+tUewGIJfHoZ30xrKiINsqWuVhQwJqqizkAIXQzO6DvE4qZBno29BMnPQPBhQl0XfSCJruOc35GnpbyzkReTI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=X/aj7QbG; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="X/aj7QbG" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154486; x=1753690486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2kwH4Vt8a7i9oZ37i7o0f8oMETvYf0/kaB14dJeKXg8=; b=X/aj7QbGLTZXQAVbvW7pd0Wua64Ory3KPqn41F/wK4BTvnSTVriW9/ut Ne/Q9tWXeGeefdSAiJSsrUQuViEp2XEYfIuDvw2g1tUZifcpos2Nkum7H 0hbcecD9KbmXAK3PlUs9W+yzlP31A6FqWGGrZlSR/qR9EtOIkEeChAF/q eUtFqqE32QHPuIs0I6oYAEsmSoi8H46qSQOxksHK/bbZuIyR11DlTEnhi buL3SDCzpam311NfPSTjSmJiZiz66ee1gQtMLzpI757/62k8b5DYsp4TM fMQBODNo2PNS4GhyNrTY6yKvd5gQDf1odmSvuZiw8UpppHHh6DaIJ0z3t A==; X-CSE-ConnectionGUID: R8uIL85lQQOD6Voauc4StQ== X-CSE-MsgGUID: Hifiw68ISZmbkBLlziAsrw== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909119" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:39 +0800 IronPort-SDR: 66a5f11a_ms7IgA7rpN4atuw4Q2KW3nuVmeVXfzahlx/MqrLPF5gLi4f Hh1kJ1pnJD8s377/oSUKzzJhyTRprx2wd61Cqaw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:54 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:38 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 05/10] mmc: host: Always use manual-cmd23 in SDUC Date: Sun, 28 Jul 2024 11:11:49 +0300 Message-Id: <20240728081154.1782120-6-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In Multi-Block read/write, CMD23 must precede CMD22. Therefore always use manual cmd23 so that we'll be able to control the sequence of commands. Also, add an applicable mmc_command member for both mmc_blk_request and mmc_request to accommodate the address extension command. Signed-off-by: Avri Altman --- drivers/mmc/core/queue.h | 1 + drivers/mmc/host/sdhci.c | 4 ++-- include/linux/mmc/core.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 9ade3bcbb714..d903fd8a45b5 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -40,6 +40,7 @@ struct mmc_blk_ioc_data; struct mmc_blk_request { struct mmc_request mrq; struct mmc_command sbc; + struct mmc_command ext; struct mmc_command cmd; struct mmc_command stop; struct mmc_data data; diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4b91c9e96635..f62b489c9e9c 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1399,13 +1399,13 @@ static inline bool sdhci_auto_cmd12(struct sdhci_host *host, static inline bool sdhci_auto_cmd23(struct sdhci_host *host, struct mmc_request *mrq) { - return mrq->sbc && (host->flags & SDHCI_AUTO_CMD23); + return mrq->sbc && (host->flags & SDHCI_AUTO_CMD23) && !mrq->ext; } static inline bool sdhci_manual_cmd23(struct sdhci_host *host, struct mmc_request *mrq) { - return mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23); + return mrq->sbc && (mrq->ext || !(host->flags & SDHCI_AUTO_CMD23)); } static inline void sdhci_auto_cmd_select(struct sdhci_host *host, diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 2c7928a50907..5560e70cb8d4 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h @@ -142,6 +142,7 @@ struct mmc_data { struct mmc_host; struct mmc_request { struct mmc_command *sbc; /* SET_BLOCK_COUNT for multiblock */ + struct mmc_command *ext; /* SD_ADDR_EXT for SDUC */ struct mmc_command *cmd; struct mmc_data *data; struct mmc_command *stop; From patchwork Sun Jul 28 08:11:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 814934 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D33C13B for ; Sun, 28 Jul 2024 08:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154488; cv=none; b=ThYuiAYz5MhT+wxVetcEektB6gfIt8rIX1z0+dAHHkiFGVIGoZxfipl/usLRKgmQhic/i8DVpEWHjVr7CTXMAubXUZjB3JNTl32gp1IAZqaf/BJRsKpWIifT8RmRsZJBm14Vi4kzopJt+bD1r+6LDEzLVcXSXPm0thAX+Hf3feQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154488; c=relaxed/simple; bh=8vklSCxbwQmBqkwyEQxE9z9GSmPMa5EQCOmr4nxL940=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NDzbiC4leLTWjMns/J43cSTao0S1Wa+E12Mp1RaCh5RRqTqUkX1H5DRyA4uwbQNRXqWujftY64Rgh6psgr66amLupo8dme44sGatoDEcFVHzdbvGYwJ0avs8ig3ul9TaJF7Ow/ouFPqmCx21vnWRciKTB7a1jNDV0epXiPYaAV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=lHDN45SM; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="lHDN45SM" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154486; x=1753690486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8vklSCxbwQmBqkwyEQxE9z9GSmPMa5EQCOmr4nxL940=; b=lHDN45SMZ7svN/5VuqVxHf4iYwG1QrBAerOf0tKoOAYVEmZcAtI09ac6 OfQaezzEX+e8ftkOV6kfpixR9zFy44vxYXi3nY01AePLx+WVSNiivn5vD trFCFEuHpWYSSDuUbCdQp70T/5c1ACmRKebORanARASN0r7IvKDHzsbLQ 5InR0P5lskINMFlrDotHwwWfPYcF9aLVGs5VTUpC+Y2bBO8JUL4HIv4f1 DZy9Oy1sCjKSCR7esLFx27J3F0On8BWTN0r+NeQi0avr2f3Caiwq1nMWb 7hCNpQeVGkMnYj/l7Iel7zrCdcCzQb7sRclwqupGynHV0jrmeZNBDubnY g==; X-CSE-ConnectionGUID: aDzcQy0wRbGVCsSBndx1JA== X-CSE-MsgGUID: iezgi68TQaymxu3XxeBczw== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909124" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:43 +0800 IronPort-SDR: 66a5f11d_ootoeREntYTuuuR+KmdUSvTBi07m9lbfK9HxpAUdLDJuN/T 2CGaYuPtLwRBujRuZiL7eOG/hooJmSdKtu2CS/A== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:19:58 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:42 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 06/10] mmc: core: Add close-ended Ext memory addressing Date: Sun, 28 Jul 2024 11:11:50 +0300 Message-Id: <20240728081154.1782120-7-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In a multi-block data transfer, CMD23 shall precede CMD22. Prepare CMD22 in advance as an additional extension of the mrq, to be handle by the host once CMD23 is done. Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 7 +++++++ drivers/mmc/core/core.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index eb41d2803c9b..fd3ee4d5db31 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1713,6 +1713,13 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, (do_data_tag ? (1 << 29) : 0); brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; brq->mrq.sbc = &brq->sbc; + + if (mmc_card_is_sduc(card->host)) { + brq->ext.opcode = SD_ADDR_EXT; + brq->ext.arg = FIELD_GET(SDUC_ADDR_EXT_MASK, blk_rq_pos(req)); + brq->ext.flags = MMC_RSP_R1 | MMC_CMD_AC; + brq->mrq.ext = &brq->ext; + } } else if (mmc_card_is_sduc(card->host)) { u8 ext_addr = FIELD_GET(SDUC_ADDR_EXT_MASK, blk_rq_pos(req)); diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index d6c819dd68ed..754e628b061b 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -184,6 +184,14 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) mrq->sbc->resp[2], mrq->sbc->resp[3]); } + if (mrq->ext) { + pr_debug("%s: req done : %d: %08x %08x %08x %08x\n", + mmc_hostname(host), mrq->ext->opcode, + mrq->ext->error, + mrq->ext->resp[0], mrq->ext->resp[1], + mrq->ext->resp[2], mrq->ext->resp[3]); + } + pr_debug("%s: req done (CMD%u): %d: %08x %08x %08x %08x\n", mmc_hostname(host), cmd->opcode, err, cmd->resp[0], cmd->resp[1], @@ -270,6 +278,12 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq, mrq->sbc->arg, mrq->sbc->flags); } + if (mrq->ext) { + pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n", + mmc_hostname(host), mrq->ext->opcode, + mrq->ext->arg, mrq->ext->flags); + } + if (mrq->cmd) { pr_debug("%s: starting %sCMD%u arg %08x flags %08x\n", mmc_hostname(host), cqe ? "CQE direct " : "", @@ -309,6 +323,10 @@ static int mmc_mrq_prep(struct mmc_host *host, struct mmc_request *mrq) mrq->sbc->error = 0; mrq->sbc->mrq = mrq; } + if (mrq->ext) { + mrq->ext->error = 0; + mrq->ext->mrq = mrq; + } if (mrq->data) { if (mrq->data->blksz > host->max_blk_size || mrq->data->blocks > host->max_blk_count || From patchwork Sun Jul 28 08:11:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 815540 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 556D8BA20 for ; Sun, 28 Jul 2024 08:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154434; cv=none; b=dPQBAxa1DkF4IqqTJUNucuCHFJC928j2B1wqZtc+LVQvid1zbB0SfkcDxt4f/T51r5zNamCjEl8C9ey6CEbhNP8EufRT4qwp1E48nxn1qCj0NCJuvIpcYYGwexI2PBwaN2FYU8VOMJ3wMZWDG8RI57mK6eYu+jeJVAcmr0Ysclc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154434; c=relaxed/simple; bh=BoKIbjjurzqYFYYKFBYg+GzXOxVAHzR514QYDJtnOfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Oj5Dn+wIO9eso4OeC+gA3aSU0C1yAmnfOkiihIcODpK2++gjv4pWgK07/amVfvqvLxE7u3rDB2+vsWVJVuo7SqDxLBLo8hIANokD0QX7tAw60+EJ6lwZk812ILQPFCb5kFGP6wRmmOvg3YIaGlHGMllFvZ41nZPTqH/Z4F36NhQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=nUSI2TTD; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="nUSI2TTD" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154432; x=1753690432; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BoKIbjjurzqYFYYKFBYg+GzXOxVAHzR514QYDJtnOfY=; b=nUSI2TTDeETKfiGtIXlHzsgZcCuQyF6IMkNZJMiv1GzrXnBvKsrFN+c/ hxezsee7k4Znw9JpoaRBkqR0p5ztTBmutqGLXh5TunVwD93O+dkyv1tpn LXrVgAVvDq/355GXXBSn7wABzNTUy6i7f1GUtX7mKd6+9jyglfR9DWGgX Hq4HyV6mC05G5oqDjYbuWcfOJUeS15k6PyLvufzO9E9SmWZFbUuta0piP C482B1M2hn2FwvKq61mLURTeV1kI8Lt6DHZXweZJQvEOu1ACDL9SF2z4E BYMnh7AkDYZRbO5dL9Q4DWJ6Y80SgY726oU4s0Jl8SMeFzQYiBen3OO9n A==; X-CSE-ConnectionGUID: gelN8qUTTO+eKnpK+jcrDQ== X-CSE-MsgGUID: Z1EUmgtqQTGfPmSIuo/T3w== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909126" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:51 +0800 IronPort-SDR: 66a5f125_UnVa6ZV0c42B3xhNdwztVQ9e2HFtrBIcpvcLn2wgmx/nsM5 sE4sJQP6ZEF5i9iI9Ln4OBQ+W5M2pv74GoZlD+w== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:20:06 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:50 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 07/10] mmc: host: Add close-ended Ext memory addressing Date: Sun, 28 Jul 2024 11:11:51 +0300 Message-Id: <20240728081154.1782120-8-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In a close-ended multi-block data transfer, CMD23 shall precede CMD22. Handle that logic once the sbc is done. Host drivers that handle their own sbc logic, e.g. bcm2835 etc. are out of scope of this change. Signed-off-by: Avri Altman --- drivers/mmc/host/sdhci.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index f62b489c9e9c..75a91d0ed16a 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1791,9 +1791,36 @@ static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd) } } +static struct mmc_command *sdhci_get_sbc_ext(struct sdhci_host *host, + struct mmc_command *cmd) +{ + if (mmc_card_is_sduc(host->mmc)) { + /* Finished CMD22, now send actual command */ + if (cmd == cmd->mrq->ext) + return cmd->mrq->cmd; + } + + /* Finished CMD23 */ + if (cmd == cmd->mrq->sbc) { + if (mmc_card_is_sduc(host->mmc)) { + /* send CMD22 after CMD23 */ + if (WARN_ON(!cmd->mrq->ext)) + return NULL; + else + return cmd->mrq->ext; + } else { + /* Finished CMD23, now send actual command */ + return cmd->mrq->cmd; + } + } + + return NULL; +} + static void sdhci_finish_command(struct sdhci_host *host) { struct mmc_command *cmd = host->cmd; + struct mmc_command *sbc_ext = NULL; host->cmd = NULL; @@ -1828,14 +1855,13 @@ static void sdhci_finish_command(struct sdhci_host *host) } } - /* Finished CMD23, now send actual command. */ - if (cmd == cmd->mrq->sbc) { - if (!sdhci_send_command(host, cmd->mrq->cmd)) { + sbc_ext = sdhci_get_sbc_ext(host, cmd); + if (sbc_ext) { + if (!sdhci_send_command(host, sbc_ext)) { WARN_ON(host->deferred_cmd); host->deferred_cmd = cmd->mrq->cmd; } } else { - /* Processed actual command. */ if (host->data && host->data_early) sdhci_finish_data(host); From patchwork Sun Jul 28 08:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 814937 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62805BA20 for ; Sun, 28 Jul 2024 08:13:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154437; cv=none; b=LsQzSRR+SLS1zDWJ47aNuGiq9VtK+H0GhlRyZVQF7zynKTkhUz4SCpc7hJrv1usuXauu30hBQn8SURDf9EnhGYR1Ddj2A4aLs8R1x5jz7969AxRjPAC8VniqfcX8GtQJHkwXPzaOG34zfP7MgAeu4V5clIMN+nEiKmkUke4uQcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154437; c=relaxed/simple; bh=38eSsADIMpm1RQl8XDaizDtP6b5FDWVAALmVL2xxC/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fv8l/CjhPEWfO6KUa44Oz52b9tiCcCktyMbAMd5yvzFGFMVxE6VEgt1bEOwcwswwmGKc/AdZhwIuUMNfo4nnVWDLTOh8qgV/kr11j4nm5uwxa4oFH3XKTp0EaifcPNh3jgVyvoFetjUeAuLI4ii4Yw3HrC2lYtAL+7IWAn1U/HY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=eHgKf4Er; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="eHgKf4Er" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154435; x=1753690435; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=38eSsADIMpm1RQl8XDaizDtP6b5FDWVAALmVL2xxC/M=; b=eHgKf4ErcYqco+kgHtqRmH/rvJrB/qoNe9QnKc4orx4bH3zL1P+Iz1he WMPcNFUTEU71p2LVobNcSXi/RbKnUKVhv8fyvpY1iSgJroGWTgIVHszEI 944UmBDWk8dDrjB/L8kxLzQoTDLl8irSyF8h91hPuytnuDIMDkuzkxrgY zdHt5HGlKLxVlqafR8InWzkRnlBu2y0LeJKijqSHbK39A/cuJ/OrHd3N3 j+92ohmEGzyJLa6pY1/vFtEJv/kiPvWt/nmzih1l0fxL1HuUI7ldFfmFU uTeUWVu6OmALDrY7bJYpJ/dPLoAtk/lU4r4liB6LkzyGiWXsznBKavBxB Q==; X-CSE-ConnectionGUID: SuvV5aFHRS+jTC+7yMHBfg== X-CSE-MsgGUID: bmbOz4E3TmKz6Tq8lBbziQ== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909128" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:55 +0800 IronPort-SDR: 66a5f129_qqq9Y+QtopotvGdAh0Fovh9JA6Yx6X/9AA0CVGB/ec8smXs dyALzoJbeEfd7VmLe1I5L620vadOQ36yofWoiJQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:20:10 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:53 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 08/10] mmc: core: Allow mmc erase to carry large addresses Date: Sun, 28 Jul 2024 11:11:52 +0300 Message-Id: <20240728081154.1782120-9-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Preparing for SDUC, Allow the erase address to be larger beyond a 32 bit address. Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 6 ++++-- drivers/mmc/core/core.c | 18 ++++++++++-------- drivers/mmc/core/core.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index fd3ee4d5db31..db171f496117 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1154,7 +1154,8 @@ static void mmc_blk_issue_erase_rq(struct mmc_queue *mq, struct request *req, { struct mmc_blk_data *md = mq->blkdata; struct mmc_card *card = md->queue.card; - unsigned int from, nr; + unsigned int nr; + sector_t from; int err = 0; blk_status_t status = BLK_STS_OK; @@ -1209,7 +1210,8 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq, { struct mmc_blk_data *md = mq->blkdata; struct mmc_card *card = md->queue.card; - unsigned int from, nr, arg; + unsigned int nr, arg; + sector_t from; int err = 0, type = MMC_BLK_SECDISCARD; blk_status_t status = BLK_STS_OK; diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 754e628b061b..8ea28a04e438 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1616,8 +1616,8 @@ static unsigned int mmc_erase_timeout(struct mmc_card *card, return mmc_mmc_erase_timeout(card, arg, qty); } -static int mmc_do_erase(struct mmc_card *card, unsigned int from, - unsigned int to, unsigned int arg) +static int mmc_do_erase(struct mmc_card *card, sector_t from, + sector_t to, unsigned int arg) { struct mmc_command cmd = {}; unsigned int qty = 0, busy_timeout = 0; @@ -1718,18 +1718,19 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from, } static unsigned int mmc_align_erase_size(struct mmc_card *card, - unsigned int *from, - unsigned int *to, + sector_t *from, + sector_t *to, unsigned int nr) { - unsigned int from_new = *from, nr_new = nr, rem; + sector_t from_new = *from; + unsigned int nr_new = nr, rem; /* * When the 'card->erase_size' is power of 2, we can use round_up/down() * to align the erase size efficiently. */ if (is_power_of_2(card->erase_size)) { - unsigned int temp = from_new; + sector_t temp = from_new; from_new = round_up(temp, card->erase_size); rem = from_new - temp; @@ -1774,10 +1775,11 @@ static unsigned int mmc_align_erase_size(struct mmc_card *card, * * Caller must claim host before calling this function. */ -int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, +int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg) { - unsigned int rem, to = from + nr; + unsigned int rem; + sector_t to = from + nr; int err; if (!(card->csd.cmdclass & CCC_ERASE)) diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 37091a6589ed..faae4b6404ad 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -116,7 +116,7 @@ bool mmc_is_req_done(struct mmc_host *host, struct mmc_request *mrq); int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq); -int mmc_erase(struct mmc_card *card, unsigned int from, unsigned int nr, +int mmc_erase(struct mmc_card *card, sector_t from, unsigned int nr, unsigned int arg); int mmc_can_erase(struct mmc_card *card); int mmc_can_trim(struct mmc_card *card); From patchwork Sun Jul 28 08:11:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 815539 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D05C4BA20 for ; Sun, 28 Jul 2024 08:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154440; cv=none; b=QQ+Er3ntfb/6D7nsfU4ENhkefDcQnfR+jcURmgHJIzSx15YOUqN333FhQ8BmPvpJRFyDWD9CktvMHXC1XWWNCEMZEwHCnNOhLDiDmvHbXSbDu4+jGBFFNfS+b7hY4QIjxzS3sjiTWQ6dRqMwfrQezn/RvimcT/EeMknWq4o22Y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154440; c=relaxed/simple; bh=bYI8Wmcgv5vMy7rPbYOKjMoL9KGmWTDIgYatyUMjIRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BCAYT9VVoehKtZFaVtOypct+M/ujnujvXLHkPLBqprfvWWsLVSHT7/wDzC94ptCrsLQhj9GCilUwcxhkjf2boePG1XubbwPWQjZuflSuZyfDfb8xUDL4LLB9i3MLGt6VU785DpXoAPTV3V7wc3n4gfKlNAW1hCK0qeyyJPvIh9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=kevmg83o; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="kevmg83o" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154438; x=1753690438; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bYI8Wmcgv5vMy7rPbYOKjMoL9KGmWTDIgYatyUMjIRw=; b=kevmg83oTdwaaCp0fNRzmq4Y2RRbI79F38Noj+qOL9tklAE/ttENm/SE Us719xpxbyTZfq6RiJ9VbYlXIpPJqvANuSgrkfIfgYdmZVDnj179p4nC3 04ftaxx5MG9j5jMO4pchq2NwqjLj4J5CdVH5YMRYw/Ilk9/QN+Gdf7KG9 vwc2AfPZBJW8lbvuU0JVHaeivN8p2N1dwHhWuDQFxroCkT6s5WObwsGv5 mIdsmQm/WfWlv5SSYywXNYgN1xqceBafdakxR8acvphmyQNkDOva3Zzm6 9aOEHsxXVBy6/JQIZmOuXkCYPjNPmGazeWUhEOHsCLZ2tJ4j7U4Ht48Ih w==; X-CSE-ConnectionGUID: iJXYVL4MSpSYSfQqI/c9Pw== X-CSE-MsgGUID: iAx6fwDdQPirEoxoWCBO7g== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909131" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:13:58 +0800 IronPort-SDR: 66a5f12d_m4p5WKXY9UzqTX5IRBOHKoRyEsT4+CKc5FIQ2wHlhoS9xgZ qDyR3Vf33h1qscRwEPYm3WtAyBmM32mrV0zVz3w== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:20:13 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:13:57 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 09/10] mmc: core: Add Ext memory addressing for erase Date: Sun, 28 Jul 2024 11:11:53 +0300 Message-Id: <20240728081154.1782120-10-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 CMD22 shall precede CMD32 and CMD33 to configure 38-bit erase start address and 38 bit erase stop address. Signed-off-by: Avri Altman --- drivers/mmc/core/core.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8ea28a04e438..e0984b7c5f08 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1660,8 +1660,15 @@ static int mmc_do_erase(struct mmc_card *card, sector_t from, cmd.opcode = SD_ERASE_WR_BLK_START; else cmd.opcode = MMC_ERASE_GROUP_START; - cmd.arg = from; + cmd.arg = from & 0xFFFFFFFF; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; + + if (mmc_card_is_sduc(card->host)) { + u8 ext_addr = FIELD_GET(SDUC_ADDR_EXT_MASK, from); + + mmc_send_ext_addr(card->host, ext_addr); + } + err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group start error %d, " @@ -1675,8 +1682,15 @@ static int mmc_do_erase(struct mmc_card *card, sector_t from, cmd.opcode = SD_ERASE_WR_BLK_END; else cmd.opcode = MMC_ERASE_GROUP_END; - cmd.arg = to; + cmd.arg = to & 0xFFFFFFFF; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; + + if (mmc_card_is_sduc(card->host)) { + u8 ext_addr = FIELD_GET(SDUC_ADDR_EXT_MASK, to); + + mmc_send_ext_addr(card->host, ext_addr); + } + err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group end error %d, status %#x\n", From patchwork Sun Jul 28 08:11:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 814936 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FD9ABA20 for ; Sun, 28 Jul 2024 08:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154444; cv=none; b=cMWfb7LiaST9c0wz+VVGKNEfKCBMuAtvdzx5OH2/Ek0sbMPKlbMN9lp8z86MKoyphS73Q/ilUJQhcliDQs4eM+REswiMHiO9b0VL0owmcz+rsolbS0MwCqE6/Bxc6Lw80i1gG/zBAwCsRHoN6wcD/zFE5n65zbyw+OzmHLlEXq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722154444; c=relaxed/simple; bh=+w4oSb3yz6ee+7ajXZSShcLSd9D1+IKCm4KjM0VdI5E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XaDQtgTTleej81xVBANHf4phjMphwH5bLntZ/Gvx74dgrRnwPnUj7UooChY+/UfwoPtc8Ex2orx27kI7+kSfm4TWvseqhiGQjPqZOj2UMM35Rtc8YXuqKD6GyCyfWc73RNt1sIAVXgjkjvNHFWQGrxZPWk/DoFmiDtp7KDSeFR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=mwzNDlDK; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="mwzNDlDK" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1722154442; x=1753690442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+w4oSb3yz6ee+7ajXZSShcLSd9D1+IKCm4KjM0VdI5E=; b=mwzNDlDKmYMZaL0ABOxpd520C/96oVJ37fjo9+eleXwayizY5luc30x7 XkZGU2FOAaYOBEyR0eBrKe6nsTdwih9tXrv6nXr58vF/VBOG8mYggk6gh kijWh0ZRu/Si4cXmrOK+sRSDt6KQ8o0TqJlSpWvYakrOzoCtLJdrmAeUM rQcLKbvaajd+Qf3yYTgRg43dd1x/HR/QpXlEA+9k9HWEakgvfiKhutmqZ MhQUrBq1lPeJuXnrVewWPTwBEOwgoHAxfpSqZUxI+2lTDm/LlfgTysb77 H/N3ZDjNXgj5zDIyyukmsKuFz9ibeYAEnEb8pQ48hEshOBKX6zdAbrqrI Q==; X-CSE-ConnectionGUID: 2ZSkAENCS9uCwkEEiRa1bQ== X-CSE-MsgGUID: vrnXyI2uRBOhRAGu5qr3qg== X-IronPort-AV: E=Sophos;i="6.09,243,1716220800"; d="scan'208";a="22909135" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2024 16:14:02 +0800 IronPort-SDR: 66a5f130_mEtiD63Q9LBa4IWxIl5ImALQ+qivT2cDeeCOaqFgAqu72Qa ZxdevP2gF32LMpjgVUYRqisr5IutAFfjDn9/yIA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 00:20:17 -0700 WDCIronportException: Internal Received: from avri-office.ad.shared (HELO avri-office.sdcorp.global.sandisk.com) ([10.45.31.142]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 28 Jul 2024 01:14:00 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH 10/10] mmc: core: Adjust ACMD22 to SDUC Date: Sun, 28 Jul 2024 11:11:54 +0300 Message-Id: <20240728081154.1782120-11-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240728081154.1782120-1-avri.altman@wdc.com> References: <20240728081154.1782120-1-avri.altman@wdc.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ACMD22 is used to verify the previously write operation. Normally, it returns the number of written sectors as u32. SDUC, however, returns it as u64. This is a superfluous requirement, as the previously write operation could not be more than the block layer limits, just make room for a u64 and ignore the 2nd dword. Moreover, SD cards expect to be allowed the full 500msec busy period post write operations. This is true for standard capacity SD, and even more so for high volume SD cards, specifically SDUC. If CMD13 return an error bit, the recovery flow is entered regardless of the busy period. Thus, better enforce the busy period for SDUC, otherwise it might return a bogus bytes written. Signed-off-by: Avri Altman --- drivers/mmc/core/block.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index db171f496117..59fdc6f964f1 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -948,13 +948,20 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) int err; u32 result; __be32 *blocks; - + u8 resp_sz; struct mmc_request mrq = {}; struct mmc_command cmd = {}; struct mmc_data data = {}; - struct scatterlist sg; + /* + * SD cards, specifically high volume cards, expect to be allowed with the + * full 500msec busy period post write. Otherwise, they may not indicate + * correctly the number of bytes written. + */ + if (mmc_card_is_sduc(card->host)) + mmc_delay(500); + err = mmc_app_cmd(card->host, card); if (err) return err; @@ -963,7 +970,16 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) cmd.arg = 0; cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_ADTC; - data.blksz = 4; + /* + * Normally, ACMD22 returns the number of written sectors as u32. + * SDUC, however, returns it as u64. This is a superfluous + * requirement, as the previously write operation could not be more + * than the block layer limits, just make room for a u64 and ignore + * the 2nd dword. + */ + resp_sz = mmc_card_is_sduc(card->host) ? 8 : 4; + + data.blksz = resp_sz; data.blocks = 1; data.flags = MMC_DATA_READ; data.sg = &sg; @@ -973,11 +989,11 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) mrq.cmd = &cmd; mrq.data = &data; - blocks = kmalloc(4, GFP_KERNEL); + blocks = kmalloc(resp_sz, GFP_KERNEL); if (!blocks) return -ENOMEM; - sg_init_one(&sg, blocks, 4); + sg_init_one(&sg, blocks, resp_sz); mmc_wait_for_req(card->host, &mrq);