From patchwork Wed Aug 7 06:03:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755661 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 1F811198E65 for ; Wed, 7 Aug 2024 06:04:43 +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=1723010684; cv=none; b=E8xjb6zLjMhqVFmcc2jFqfediO/LQto/kzf5Wwpfhf1u3t2CsY9RyaA4suqKPGDGuLDvY/tbLpAAoDiOt7wd3ZGF9fqv5Mp2S7BlnDWjirvRG4z52/6eHEW3OpHsGXj9C0Qn7EUN75eJVilbznp6eZ7QO+McZ5hHpiMWyCljQKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010684; c=relaxed/simple; bh=ZEgObMbnv6e4XAH8wAQxCGBp478qeQKb/VSh+uWR0MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yxvr6HJfryVzsv/tf/LwJGGpl0styFFl4O/USP++qpEL3/Kg9IcTRZc5ZvfVQRZQs3mEbT/xhGuHfu/xrps3JNygiW31XjhMafwz0Kg2NNTwcv7PRiroxP2MMzpMF+/3jWBOfOTZp4S2uInasfgMxyTOKYMycGH4Fsn1p78KD6U= 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=WSiYlgW4; 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="WSiYlgW4" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010683; x=1754546683; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZEgObMbnv6e4XAH8wAQxCGBp478qeQKb/VSh+uWR0MQ=; b=WSiYlgW4VzUI8sTglMOx5x004/sUNoLKUzqfJzGQoUSEUHoZrtmyrU8X 0CcXRCK4Nt6OYxSZBKYd5RzmUMC73Go3HThApiDIBQUt/U3DJ55Ux+8ft 54mS5eTEefsUVNoH4mW2vEJHQ76D8hU7RF5TNDVp8QykI7LaYh6CxRNzv BER2kT2O1VRvUZT0eYGLSI1eY9Q0cQ4KH9ngeKQ2nD8Ymy2wCYcdNfowM CEWW54ZnhDVCmLOCoB3ikOJ0wZAsB4Vvu4CqAKRK4Yck+Iy1bAiJNWYQG 2Mr2oJzsiu5Rx4Gmxyn3Fd2PVHitvnRzhooS7UfHtu+B8Zufd/T47mtuF w==; X-CSE-ConnectionGUID: fUy9D/I3Qmy3k05cgD9gMA== X-CSE-MsgGUID: X3TBfgBARm2/laObiv/sGg== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039286" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:04:43 +0800 IronPort-SDR: 66b30080_3QvT3gzbXca0QqL2udo9YUPuKglR1TCfFakmu8Q9xnivA/F nPQlRm7NO1L0DzdmjRu1WwADIemdOyDxOYBDKng== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:05 -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; 06 Aug 2024 23:04:42 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 01/10] mmc: sd: SDUC Support Recognition Date: Wed, 7 Aug 2024 09:03:00 +0300 Message-Id: <20240807060309.2403023-2-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 Wed Aug 7 06:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755662 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 BAB02198E85 for ; Wed, 7 Aug 2024 06:04:46 +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=1723010688; cv=none; b=nbl9RefMoNkQtv9tcNVXNqSsoqdLzh7JB87WSkUk4WLkMx09SKu5gYal7adSXjHc1S1eIsFMyXSbCBS7w+F6V/vvcmvsYo7lJPIPlrrx7WWOur9PnZ7fGuOzoRETQiD5PId/ArqGLc+rVTU9oBgIh3BuwxL8p198oFLlo3k5Ksk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010688; c=relaxed/simple; bh=KQ34oRMswWKaUD5gQuHBgpKk5zj/IZmCJxdHEcJMn6o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G45KqeeNfLnZgeQ8p1k3+wD09lEPplo3ih9Z6Pol/rKG3HL1ostOZGgEuDk84kCn8MAiI1saRGxQIhYDvvOP77nS/8l78ktOg9lmrgmCR+RBli33NYPh9JhuYqgnSNrpyDmv3fjzSsFSyv2w+BctSJdfmpSiVX3pqxXOJQ1fhY4= 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=KgNzgFYi; 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="KgNzgFYi" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010686; x=1754546686; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KQ34oRMswWKaUD5gQuHBgpKk5zj/IZmCJxdHEcJMn6o=; b=KgNzgFYi0ygDBG5TRNnFIkczAJDLT+5RZLK9kK1s8R63IR1XNG6zSB52 VnI+LXGyyTHMvB5+4qUamtjsHh3KFt2yfM6k87p7GeB2WMmKDK2JQg6t+ mRk4nj28ASptA2d1HlR4ueGJVeGjPuVrgNhUK9VvdYUZx1trZNEuyrwQI emZDGkpiuKbPBAn2JZ1QGi50BI3CCIF5FNKg/HbLcyEP5VLoafHv1xxzi RbG3B7cmMIhoDxMA5FIWD+yQrLhw+oRc+hd12VEmKJaghhxl+fq4srdeF mXLp/RbSAAMSfwrwICB4KrIWDJJ8AVvryt6Fv3Zi7dLpnNFD6JDLAxQvZ g==; X-CSE-ConnectionGUID: 4OPcZMjyQQyorC99f955sA== X-CSE-MsgGUID: DOrojtcoRiq8NW/JAxSYuw== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039291" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:04:46 +0800 IronPort-SDR: 66b30084_4LH6qeLgnjUr1UKTy5WZt6GmcMDkL3zmkHAukX/krFLFGho BhK2x3j7HRNmIMd2969T64RFNCiC+YjoqE031Ww== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:08 -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; 06 Aug 2024 23:04:46 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 02/10] mmc: sd: Add SD CSD version 3.0 Date: Wed, 7 Aug 2024 09:03:01 +0300 Message-Id: <20240807060309.2403023-3-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 Wed Aug 7 06:03:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755663 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 77EAD198E85 for ; Wed, 7 Aug 2024 06:04:50 +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=1723010692; cv=none; b=BmgTZTfVgTOwAZLihf6QSxBqpy5j1zP1RzHp1zcLI4uGLto+FjTKOlibo7Msdi4vTEHfw6kxQlYsPfsvcWZ7ge9iEEkrxU6q4lqauO3mNgwzpiHNJTV3R0FU9Zcdb7tojF2BwvcaBColXLxAPr/wxPewGrxOuSuFogKCqSbg4sA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010692; c=relaxed/simple; bh=nJNXYdnwmHYmdGbpumUlSgWKZYS31MO/Iex+/scdqws=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dqmZfuuyO56e7C7F2eXDsMHh+KtObQ78RUFWjMK4xZ4gdIAXGobaPd5dz2NxP13K20imH4bRy1UiCDRjxKh07qlVbsUFvPykHAId+LCnODlDx9ET4bpa2mU3ye1X53L1rZ8ogo653imJL1r4i0zL+a7b4jDQZqNBIRlBWkUdrhY= 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=Wh+OlKh3; 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="Wh+OlKh3" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010690; x=1754546690; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nJNXYdnwmHYmdGbpumUlSgWKZYS31MO/Iex+/scdqws=; b=Wh+OlKh3Uj+o/M8H2L5yUZvFpoXLBj9RcX9QJJtPJwpcMcpRb4LaTp45 doKPW8WHwzcF4bCVBh89O1rfOb4V/YNsCM5KRAZhdcpLxvZ4KqOzs2tIu VxgF7J/fRBDClO9QEVYbIAgyTnlPh2NKBMvTAo8XaKMtNMRef5q7nCt7n IudoPV8ekpuBnNatGbrb8ixwoq7H4VwvWLhf/QqVs2YkBIv8TxdkTCnn+ owIhbvMX1EqViTisEJDsLWVN0uv4vhno+62WNP64dTjpzYJKrOHVElPOP VwK3ZMQB3mSnlumYVPv1niqrppzqNdcqdizBbj8y0o8XEA/faCDefF2m4 w==; X-CSE-ConnectionGUID: 5yT+521pRWO9OiCeKjGrdg== X-CSE-MsgGUID: BFlG8zlKTyGVcA76lvYbBg== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039297" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:04:50 +0800 IronPort-SDR: 66b30088_UNPtFJWS4XWi36TdFYsA0dyyC2eHWb8LwR1mgptQbAa+oo+ 0ZxsoyLktHHE1GWmwx3TfkSZTFm7Qpp0ukXEo4w== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:12 -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; 06 Aug 2024 23:04:49 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 03/10] mmc: sd: Add Extension memory addressing Date: Wed, 7 Aug 2024 09:03:02 +0300 Message-Id: <20240807060309.2403023-4-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 | 15 +++++++++++++++ drivers/mmc/core/sd_ops.h | 1 + include/linux/mmc/sd.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index 7f6963dac873..8b69129d7b61 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -199,6 +199,21 @@ 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, sector_t addr) +{ + struct mmc_command cmd = { + .opcode = SD_ADDR_EXT, + .arg = (u32)((addr >> 32) & 0x3F), + .flags = MMC_RSP_R1 | MMC_CMD_AC, + }; + + if (!mmc_card_is_sduc(host)) + return 0; + + return mmc_wait_for_cmd(host, &cmd, 0); +} +EXPORT_SYMBOL_GPL(mmc_send_ext_addr); + 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..462efd43acfa 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, sector_t 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 Wed Aug 7 06:03:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755664 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 98A8E198E85 for ; Wed, 7 Aug 2024 06:04:53 +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=1723010695; cv=none; b=IoOX3LRKjQQQCBOf0rWef7Z6aGQ35RF0BQ34YvAgQuW5474gW5gLQBTWMke7pmSyNtbTvyac5vfzTBaQ/TREr21/D9UfCBnxQBhWm9+DkGXMKvp8iT7q5KK8VYUb7ONY0AEEsRH9oSlYGpawjU2JPaMyyn6/0VQc55zz0x7jJqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010695; c=relaxed/simple; bh=MHFndB2QnUNxORquhxbFIL559YwED7RczyN5weD7NGA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ta+FPX1ekuzPw1zC+wt49W9dSNPmkUVblvdXnwUIgiRJOgo5wKI0B7ZI/1Ll4N5kjDHo4vXr9pr6UVLE2/Y/CndazUbEphza36WXCFYP0zrxlsdjL3ne9tF8qbSFQKDa5l0y9SEJkFGhtIv8yPEoLsdaGUUDu6Cm3YtBpvypY2c= 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=OfcbR8Jp; 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="OfcbR8Jp" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010693; x=1754546693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MHFndB2QnUNxORquhxbFIL559YwED7RczyN5weD7NGA=; b=OfcbR8JpiTYdmfYMqIxZJQPajWdees1Y1meIMvrP7/3iXIhqR5Ss2pEZ LH92a//4o4a1J8USPir9D66LSSEfxXMFEKEQA7GcLEOde3DxG704EbgKB u29GZ3pTShq0K2cg6olPU9iGSYJItIlrCTqn64+Z3UxyfqholF+sHB0iH FdN4V7/5A1LNmGdGxCNcuoH4bgKb1Zx2I5r+r7gvC0EgPyoUGTKt4az0S 3GjvhYgtETp8m8wqKjY43dP+e9s18zo/lzTn7Q5zG2Hv28Dbj7XsnVvoj Br8i/3c5iBfrj6CY/xgEbfhAUTpcXZepZunr9A8pSTBQbdpFqDZSk0v21 g==; X-CSE-ConnectionGUID: 5+xjMRaoSK6PQMzp2s5PCw== X-CSE-MsgGUID: rZJX4PSaQHa6+05pwvOMNg== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039305" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:04:53 +0800 IronPort-SDR: 66b3008b_9PK0d7kqjssOuJNcDLbMPNT1413bdOpEPUiQRBRO5Iacij9 ghNgzgg3DAfWVmJYegOov5OgZ7LBi35QNGZiCRA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:15 -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; 06 Aug 2024 23:04:53 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 04/10] mmc: core: Add open-ended Ext memory addressing Date: Wed, 7 Aug 2024 09:03:03 +0300 Message-Id: <20240807060309.2403023-5-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 367509b5b646..392621232ad8 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,9 @@ 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)) { + mmc_blk_wait_for_idle(mq, card->host); + mmc_send_ext_addr(card->host, blk_rq_pos(req)); } } From patchwork Wed Aug 7 06:03:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755665 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 D21E3198A05 for ; Wed, 7 Aug 2024 06:04:56 +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=1723010698; cv=none; b=oslIQuI/R4VVwuDtkGliBJW6EbVAY19dDakrsL4v/AMkHaxhmYbdpmTIzAREwVfE3kR1nZz/6Hho6NFPQT0h4lNQzMDIUbneTiLhBz6D9HFcRf0O7/5CL2T+Ih2eyXLiLx9pNqUj1d+eLkiqlkHwhGl2t7927gROGfC5CF8hDYI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010698; c=relaxed/simple; bh=2kwH4Vt8a7i9oZ37i7o0f8oMETvYf0/kaB14dJeKXg8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HhWP7UfF6mL0uEUt836saFr9pN/6z5ykevUqn9wQR9DxO7yIjjx/dqk+zBybey6CwyfSssurOKdctsIf5wXBHKGOFJzwEDZxj7YKj+NNvYRjPyBEd0nbyep1mFQFOi8RZxnWEow5wFKoPPX+BmNZga+Qj40drIRydmnCvsJr3v4= 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=FZJYO60+; 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="FZJYO60+" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010697; x=1754546697; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2kwH4Vt8a7i9oZ37i7o0f8oMETvYf0/kaB14dJeKXg8=; b=FZJYO60+QvCcNYqkCF3pXrVUGCLTMUcgyi9r6xEgnPnpYe+m/LiFifFI ACEasvMMBrP3OXBaxtRxNBeOIamB/kMx/rwlfR8VILSOrrJbD0gEQeVti faL8OOykTVi1fUJXgmMEGg3IdtVgSU77gD/Vzgits/qg9oEKwrACrujeA Exc/SsDnOaFNbxgwJoex9Rgt0c9xhUXskoiSykjTBieHTut7d/T99lE7E jivWPcHVFog72HcCRfR/7jf9z5EfImOtGxOShbm3jbefNQosl/4AIxUtt i7R8CHCcYfjXUaBgY7/YQ2M1982aWk4GU4AaHjDpzydvmXxQC15Pr96O5 Q==; X-CSE-ConnectionGUID: 6xd+K1UdTbSHVRJVWf63PQ== X-CSE-MsgGUID: 3+zVYMBhQFOQwc2DtdriFQ== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039310" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:04:56 +0800 IronPort-SDR: 66b3008e_bjEecZVCckZquI9CorkoMh4rw3MkNExaD6VgxhifVe/IusC OtZbS9t6gGGog3Pu71AvjxH6jDEh3CCNfLcluZQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:18 -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; 06 Aug 2024 23:04:56 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 05/10] mmc: host: Always use manual-cmd23 in SDUC Date: Wed, 7 Aug 2024 09:03:04 +0300 Message-Id: <20240807060309.2403023-6-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 Wed Aug 7 06:03:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755666 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 2AA75198E90 for ; Wed, 7 Aug 2024 06:05:00 +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=1723010701; cv=none; b=gu035J1tU1z5b4juHbzstC8XLgJ6MJnBXp1o4u7b1LPW5o2zvAOXGIA344Da0HQeZQWG8162cNPch/DwDGWRxhHv5nfQC6zPzsG2CNtGj2bh7R5b5atzAvtxWAAEt7n/bOHaBjFQJ3VV8oc/K5eboR24dtB++AfdGIuAlT8GkWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010701; c=relaxed/simple; bh=oG+rXt7cEqPZX9VNLCZ/g6/9uNIBC2w1APBThzfqA4o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s8s6nbUTe8OXQ9ER3jf69ZrEmcG7RgCKZjg4hkZ4t2ntEQt+By9rbQDghW200Yl5v86lemjt3KAYaBLITIUirnD8+iUP1520PxByDB7E7STTo2OqTYge+VTOW/OKFYrrL6pvAXH/xRjMAbJfc26o2WEFzus2tKOrpaBFXLb61CI= 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=TsCX61y0; 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="TsCX61y0" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010700; x=1754546700; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oG+rXt7cEqPZX9VNLCZ/g6/9uNIBC2w1APBThzfqA4o=; b=TsCX61y0ORFe7yh8/kAxtYQX/9SjYuSu9MPsgL+0yjQUpg34vV3GCfw/ I2F3rW9xt07xnf+qdHjb6jpvvzjAJ1jRx4eiF95nwskf9YubqHCR/gfTI OyEqJ/zNpnnuEgLl0S06DdS2Dod42xCmN/UIHK65BSTORHldVGvpyZCht XEER4cbSi6+IjqzoaMBVWDmCdSomIPxvk/y/lV9GxJ72mXbj+V+RfPdQX Wun6cnqOkqj9hbI+9Uw/gQ7Nqxnn7l7Qn+jUpfznmAKQhlJ/rU2f/YJLL inThh2GOQuHI+Lzdh5u19jrFwDyWLPsNluUipX53UOi0gpyiojTwK2qqE A==; X-CSE-ConnectionGUID: AoBsIqHWTIKThOs+YBgb8g== X-CSE-MsgGUID: b7GcAWbWQpiHSimoLR+HdQ== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039316" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:05:00 +0800 IronPort-SDR: 66b30091_vl6OnTE1aUyKb0FJzS04iKloNyQAol6mzxPEGBbz8bzFZt2 eYYQvyfOCtb1mXUbwFJ7T7RBxLwCW5/7ZK8MB+w== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:22 -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; 06 Aug 2024 23:04:59 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 06/10] mmc: core: Add close-ended Ext memory addressing Date: Wed, 7 Aug 2024 09:03:05 +0300 Message-Id: <20240807060309.2403023-7-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 392621232ad8..abf1e8a124a5 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 = (u32)((blk_rq_pos(req) >> 32) & 0x3F); + brq->ext.flags = MMC_RSP_R1 | MMC_CMD_AC; + brq->mrq.ext = &brq->ext; + } } else if (mmc_card_is_sduc(card->host)) { mmc_blk_wait_for_idle(mq, card->host); mmc_send_ext_addr(card->host, 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 Wed Aug 7 06:03:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755667 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 6C561198E78 for ; Wed, 7 Aug 2024 06:05:03 +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=1723010704; cv=none; b=XEPuQ40rPWh1o9nUrTAmMLXxfy+w3a08GDrPg/YeTTD7iEmwm+CZthKiwJmxadiMesX1FmB+S5WBhAMX2u1Iq69SRMnalm7szJJKZFwaWZvUfozIRSHSdoJf9ycwKTzvd6BJzmKtbkTsy2TLWAvwV8j25HVeZCj9Zie1YcmnyyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010704; c=relaxed/simple; bh=BoKIbjjurzqYFYYKFBYg+GzXOxVAHzR514QYDJtnOfY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pGnSgejrAQXkX6KH57b7BaT2sbusBTR9INkoZ8mmrkdSZ1PUPOLRJpHs7XRFtWL3BHjY+z5U5/Ln9kqLujXa7UvBt84ol4aHN/lLuCiyWWk3rBD1hHyc21o52Yx+9GWSK2iwTqsLxe1J0je3wrAIgFTpS6hSUDfee3/DEPZKADA= 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=ZeTLzhlp; 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="ZeTLzhlp" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010703; x=1754546703; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BoKIbjjurzqYFYYKFBYg+GzXOxVAHzR514QYDJtnOfY=; b=ZeTLzhlpdgWZ0vfkWry9kllFziN6KFozHn3oEvB0ruM9Lez5uRnRfrY1 ezLBgKMTPrurhJiEcnMkksc0EnJbns5vD2iueo1C01/ZNXlCMi68HlYpg HC+TUy822wBPN5rxzoCrGVgCbS13Bg64qTaQqmrqj4qBp9SmSy66/Lwf+ Pn2JifCZ/uN5zsSPg3cYaIavmitoDF+iyQLm9JNvS1rmOEJ31JsBGrOrS mL82h7xPdIdxR2IaLa7dNa8a4Cyjdnh2VB+3bEml/0NhmgI1Q+zZx42dd Qadci1LgcgzQ8JQUc5KWeA4hfagTsZK65/ItHWNpmkLRC1WVnuFHCWgN0 w==; X-CSE-ConnectionGUID: q1RL4oZGQTCiFnC1s7fOYw== X-CSE-MsgGUID: qAmVPpXVQ92tAtuU1t3CTA== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039320" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:05:03 +0800 IronPort-SDR: 66b30095_ptqlXW6Rjhm5rQWCuZb86/tUcAK32JoyQOWYkdpYKD1Rc01 xp9WWUi0/oeHQfNNMhT8r+mffR34o2+PJVCAASA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:25 -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; 06 Aug 2024 23:05:03 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 07/10] mmc: host: Add close-ended Ext memory addressing Date: Wed, 7 Aug 2024 09:03:06 +0300 Message-Id: <20240807060309.2403023-8-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 Wed Aug 7 06:03:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755668 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 A2289198E86 for ; Wed, 7 Aug 2024 06:05:06 +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=1723010708; cv=none; b=OTTcSLGZuZPG9Dy7pNGoaKPLDEizr15T6VRgCZXAA/S0tB8wg5o2IG/k40X3D54sVUIVfqTJi1Npe/1zg/9QLN2+AIB1L3qgck2G/DyyW9zrtKj564KD2p7mOQXvRTxvRLh7mmWSmnFYGWW9aTLYT5JHEpchT0ryHPGhPx3tF3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010708; c=relaxed/simple; bh=Wcj/mjpTmCbjL+Xssf02Wc9rFe9DuiBgVw5VCokqUaM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RLGB24+yOOObBRyHwX3dxxo9U46gJmnD16HthdOuL1F/yTA5Bwmv7IWDWcUQEYTxOiaY2AIw7bGNJJ84CC1CiC3ggChWb8CZvYZobdV1vsO6AkRfr2WxhaquNxVPduu+H1XzZtR2YFvdaL9YZMvrG6aDY2GkTVxxcSY9IpDaJZI= 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=NOEAb1cm; 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="NOEAb1cm" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010706; x=1754546706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Wcj/mjpTmCbjL+Xssf02Wc9rFe9DuiBgVw5VCokqUaM=; b=NOEAb1cmE2Q84+sLWTKdJQoBFmlrF7/tU/p6f1sg4fe6K2fO43EiokoT KM8Xxa95GvJO2OM9kDJGsStFCwl2+C7RqqPpA7LexA7oIbc0sg1Xfhgxn ED2YsjTlMOmoaFDq+v6LVCdfTfikBtOtfQH1qn7PIXiuuhSeIwasZ9hgU z06FbJkI7Qx8CIsdAkuFnJN3U0UcA1Lxf1Iqy4fz8rKTE0ltkPNsYvg0N +0eRPr1Tu0c3mVSV+6K+6VMKa3NIc6/f7JU+40lw7PaOLPJXgnsp/wM7V AgT3+ArLCdQ0xVezz7O+8nlOdZ2N21gkfLunlyVfys6ZPzSLvC3uphCzQ Q==; X-CSE-ConnectionGUID: t1dMmJ3/SwWKMPwsxWm/sA== X-CSE-MsgGUID: MU7aajEhSM2zBUr3XR2JKg== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039327" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:05:06 +0800 IronPort-SDR: 66b30098_JnMCyhjUz2ySKUo1lKRg9mVE12O6QZYLQkvl9cPiVPuF51K ImJYkNOIELkAhwvqh7yxrAjabmfkcRGt4EpxE0g== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:28 -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; 06 Aug 2024 23:05:06 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 08/10] mmc: core: Allow mmc erase to carry large addresses Date: Wed, 7 Aug 2024 09:03:07 +0300 Message-Id: <20240807060309.2403023-9-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 abf1e8a124a5..55b9fc34fdd4 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 Wed Aug 7 06:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755669 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 05BA8198E86 for ; Wed, 7 Aug 2024 06:05:09 +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=1723010711; cv=none; b=og0zOYYjZZHlA1K8AkmZXhyxeOGORmrEVYah3Sp5zsyz5lVuXxMn2NDA1pB8Xfn7mmUSfIRDElOrmUDVfq/+YbQKjaKgGk5SAAn5LsAct96xU/21qi+8IGuEsTtRiYyaTYY5GB80PLYGb54ulgFMyIqa2WhmLx+ePefmkok1swo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010711; c=relaxed/simple; bh=oS2WvIIaNV5PmJ0CQTKdBv1ZzMtV6p3ggJdzvkjwHyU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U6gkvukeoLznvDugz44e4ghXCuWm8CCO/Bj+IN5uh3Wav9JsdmTyMMWUQ6Ipb42qABkNZlDWAygxT8oY09Ofzmr6hc7l0YI9Jpz2OVm7uGR4GQkvXxeh47nPTVzwfamOp0KZtmegWHhujS5THmYLAdQ8Zo8QiT+cQDMN6TiAkD8= 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=jQIWrYkV; 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="jQIWrYkV" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010710; x=1754546710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oS2WvIIaNV5PmJ0CQTKdBv1ZzMtV6p3ggJdzvkjwHyU=; b=jQIWrYkVLc+Wg2RpXeizRURR/ItDxG+16DnPtZHut7mWbJITDUwP2g2v UBlf/djsK+vidSEapMpHgahPs3PujNW4o0N3G/zz3zhqj2xwQxGOevnSI uYZFL6RfIwQGfTCRuEz+2NWtMQ3MK5EhRHgRUSPgER3tBB8EWuV6o/xDE LnEhDveuR1hSu/7Ka0+dQh4fvVzb9QclHcW2KA2GuXqVcR6xHLdrTBYmZ Rx3uxiCef/iOjIsXbBghL6u+5HtAoVgelfFpKJJxm6oIB6CoIiumWTgqT ETE6UpZRvUNVKBE2AOJ1NUvkgHQ9o+8lDLs2UmoxvgWC1avCXcPFoUNn7 g==; X-CSE-ConnectionGUID: 3nBwnIMYSQmbKPjGcKbBzg== X-CSE-MsgGUID: 7tSxm0wORiKpYi2aA7LPwQ== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039336" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:05:10 +0800 IronPort-SDR: 66b3009b_uMiOXCy/D/GadthD9frVvBmMcGiMxvqZBgym8qlGW5rrk6z JQzPUAgWkX0wwz9KYFtDjMd7//GYfiqq1dtS7yw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:31 -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; 06 Aug 2024 23:05:09 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 09/10] mmc: core: Add Ext memory addressing for erase Date: Wed, 7 Aug 2024 09:03:08 +0300 Message-Id: <20240807060309.2403023-10-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 8ea28a04e438..7f724f6a1332 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1660,8 +1660,12 @@ 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)) + mmc_send_ext_addr(card->host, from); + err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group start error %d, " @@ -1675,8 +1679,12 @@ 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)) + mmc_send_ext_addr(card->host, to); + err = mmc_wait_for_cmd(card->host, &cmd, 0); if (err) { pr_err("mmc_erase: group end error %d, status %#x\n", From patchwork Wed Aug 7 06:03:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avri Altman X-Patchwork-Id: 13755670 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 36A48198E86 for ; Wed, 7 Aug 2024 06:05:13 +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=1723010715; cv=none; b=M1/nrQPnHHsVaush7gGc3W3DjuGmGsUKBU8rTLfAuWa9Y0aV3cKx7W5WGOjdHRDgRPjII99RbfZxJw6Mv3UF042liULlIwRHhRNZ4QepuyiKuN3tnrRWBiXVeEMelY0VcT/+tbN35iAl3XOPiDiXE5l6A+lKVJEqGOE4ezzrLTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723010715; c=relaxed/simple; bh=k4mDYAkeb/fiZjjyfKZZvjDoyB3+P9fEVHfV+YOvaOw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JOD7SgHOgkdkPzX0707F7ZfNlxoToJKunCHdxvn88oPdRP5UzvweZ2wGFGsr96ENqLEh1HletmQXxvz6PhJJPo2anjJxxXqH5nNB1BUXPg5wa0C8BlyzT0ZClW750HFsPw2um32/3Nc+XfwO8HH15giIW6/ZiLa2XsjmFdhA4UE= 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=rRltALGE; 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="rRltALGE" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1723010713; x=1754546713; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k4mDYAkeb/fiZjjyfKZZvjDoyB3+P9fEVHfV+YOvaOw=; b=rRltALGE8lqTIxOXpCLZJ5a1nLy17lvTcQOKd9pjihva2xVSOuEc/0Q+ 0w6KY5YwLifTyxmAnVEtKOHb3qs0IyUMulXSqFdD1D5HN6nmD0fo3UyKt nXdH8+ZJB07Z28qEkIlNlZRnHoXK3N/t6Tvyv+iQL6UBy6UoXmMUHjlSR dKD2Eu3seNYu8glt0iHDG1bP5JyY7MCGX7Ej3EDQDksSuJfHh9IYivs9a n3g8oV/jx8X1xdllriaHWo9UOo0CVicGIOMhRKdcoNKkHgtmr71JXYJrf sID81snkv0cOA0HRXZjmeoNLHcES4sUm/8h+7P+TC7M3Op6CRjWzlEbD1 w==; X-CSE-ConnectionGUID: zlx8++V2SvuQK86Emutq+g== X-CSE-MsgGUID: H3CaxLQlQ0Obyup/+zlSLw== X-IronPort-AV: E=Sophos;i="6.09,269,1716220800"; d="scan'208";a="23039345" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 07 Aug 2024 14:05:13 +0800 IronPort-SDR: 66b3009e_25zw/x2N+bQ5ijwE2aJt6bQhqD2AAjwYAFuAILmqdgPdK2D IjxiOT7ybIX7t6vygDEWMJ3JqnNUWzc/QPmhDBg== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 06 Aug 2024 22:05:35 -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; 06 Aug 2024 23:05:12 -0700 From: Avri Altman To: Ulf Hansson , linux-mmc@vger.kernel.org Cc: Ricky WU , Avri Altman Subject: [PATCH v2 10/10] mmc: core: Adjust ACMD22 to SDUC Date: Wed, 7 Aug 2024 09:03:09 +0300 Message-Id: <20240807060309.2403023-11-avri.altman@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240807060309.2403023-1-avri.altman@wdc.com> References: <20240807060309.2403023-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 55b9fc34fdd4..cb268af26982 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);