From: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
To: Casey Connolly <casey.connolly@linaro.org>,
Sumit Garg <sumit.garg@kernel.org>,
u-boot-qcom@groups.io, u-boot@lists.denx.de
Cc: Lukasz Majewski <lukma@denx.de>,
Neil Armstrong <neil.armstrong@linaro.org>,
Tom Rini <trini@konsulko.com>,
Aswin Murugan <aswin.murugan@oss.qualcomm.com>,
Stephan Gerhold <stephan.gerhold@linaro.org>,
Varadarajan Narayanan <quic_varada@quicinc.com>,
Peng Fan <peng.fan@nxp.com>,
Jaehoon Chung <jh80.chung@samsung.com>,
Tanmay Kathpalia <tanmay.kathpalia@altera.com>,
Simon Glass <sjg@chromium.org>,
Jean-Jacques Hiblot <jjhiblot@ti.com>,
Varadarajan Narayanan <varadarajan.narayanan@oss.qualcomm.com>
Subject: Re: [PATCH 3/3] fs: fat: Limit transfer size to prevent SDHCI controller timeout
Date: Tue, 21 Apr 2026 18:37:59 +0530 [thread overview]
Message-ID: <8a98b441-b765-494c-ab53-c6cb2dd663f1@oss.qualcomm.com> (raw)
In-Reply-To: <a8c8f3f7-15ca-49b2-872e-aded2a424ff0@linaro.org>
On 3/24/2026 5:26 PM, Casey Connolly wrote:
> Hi Balaji,
>
> On 24/03/2026 06:52, Balaji Selvanathan wrote:
>> Some SDHCI controllers have limitations on maximum transfer sizes
>> and can timeout on large block operations.
>>
>> Break large read and write operations into chunks of 16384 blocks
>> to stay within controller limits. This prevents timeout errors during
>> large file transfers on FAT filesystems while maintaining
>> compatibility with all platforms.
> Shouldn't this be split into two transfers at the MMC layer? Perhaps
> with a quirk flag?
>
> In fact this seems to be already totally supported, just change
> CONFIG_SYS_MMC_MAX_BLK_COUNT to 16384 (see mmc_get_b_max() in mmc_bread()).
Hi Casey,
Thanks for the feedback. Addressed this in v2:
https://lore.kernel.org/u-boot/20260421-emmc-v2-0-0ebd3322b676@oss.qualcomm.com/
Regards,
Balaji
>
> Kind regards,
>
>> This patch builds on top of the work from:
>> https://lore.kernel.org/u-boot/20260224035000.1617869-1-varadarajan.narayanan@oss.qualcomm.com/
>>
>> Signed-off-by: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
>> ---
>> fs/fat/fat.c | 29 ++++++++++++++++++++---------
>> 1 file changed, 20 insertions(+), 9 deletions(-)
>>
>> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>> index 85b511f75af..6ec241af584 100644
>> --- a/fs/fat/fat.c
>> +++ b/fs/fat/fat.c
>> @@ -30,6 +30,9 @@
>> /* maximum number of clusters for FAT12 */
>> #define MAX_FAT12 0xFF4
>>
>> +/* maximum blocks per read/write to avoid SDHCI timeout */
>> +#define MAX_BLOCKS_PER_TRANSFER 16384
>> +
>> /*
>> * Convert a string to lowercase. Converts at most 'len' characters,
>> * 'len' may be larger than the length of 'str' if 'str' is NULL
>> @@ -136,18 +139,26 @@ static int disk_rw(__u32 sect, __u32 nr_sect, void *buf, bool read)
>> if (rem > blksz) {
>> n = rem / blksz;
>>
>> - if (read)
>> - ret = blk_dread(cur_dev, start + s, n, buf);
>> - else
>> - ret = blk_dwrite(cur_dev, start + s, n, buf);
>> + /* Break large reads/writes into chunks */
>> + while (n > 0) {
>> + __u32 transfer_count = (n > MAX_BLOCKS_PER_TRANSFER) ? MAX_BLOCKS_PER_TRANSFER : n;
>>
>> - if (ret != n) {
>> - ret = -1;
>> - goto exit;
>> + if (read)
>> + ret = blk_dread(cur_dev, start + s, transfer_count, buf);
>> + else
>> + ret = blk_dwrite(cur_dev, start + s, transfer_count, buf);
>> +
>> + if (ret != transfer_count) {
>> + ret = -1;
>> + goto exit;
>> + }
>> +
>> + buf += transfer_count * blksz;
>> + s += transfer_count;
>> + n -= transfer_count;
>> }
>> - buf += n * blksz;
>> +
>> rem = rem % blksz;
>> - s += n;
>> }
>>
>> /* Do part 3, read a block and copy the trailing sectors */
>>
next prev parent reply other threads:[~2026-04-21 13:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 5:52 [PATCH 0/3] Enable eMMC and SD card support for QCS615 Balaji Selvanathan
2026-03-24 5:52 ` [PATCH 1/3] clk: qcom: qcs615: Add SDCC1 and SDCC2 clock support Balaji Selvanathan
2026-03-24 10:06 ` Varadarajan Narayanan
2026-04-13 9:35 ` Sumit Garg
2026-03-24 5:52 ` [PATCH 2/3] drivers: mmc: uclass: Set removable flag based on device tree property Balaji Selvanathan
2026-03-24 10:14 ` Varadarajan Narayanan
2026-04-13 9:45 ` Sumit Garg
2026-04-21 13:05 ` Balaji Selvanathan
2026-03-24 5:52 ` [PATCH 3/3] fs: fat: Limit transfer size to prevent SDHCI controller timeout Balaji Selvanathan
2026-03-24 11:56 ` Casey Connolly
2026-04-21 13:07 ` Balaji Selvanathan [this message]
2026-03-24 12:02 ` Jonas Karlman
2026-04-21 13:07 ` Balaji Selvanathan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a98b441-b765-494c-ab53-c6cb2dd663f1@oss.qualcomm.com \
--to=balaji.selvanathan@oss.qualcomm.com \
--cc=aswin.murugan@oss.qualcomm.com \
--cc=casey.connolly@linaro.org \
--cc=jh80.chung@samsung.com \
--cc=jjhiblot@ti.com \
--cc=lukma@denx.de \
--cc=neil.armstrong@linaro.org \
--cc=peng.fan@nxp.com \
--cc=quic_varada@quicinc.com \
--cc=sjg@chromium.org \
--cc=stephan.gerhold@linaro.org \
--cc=sumit.garg@kernel.org \
--cc=tanmay.kathpalia@altera.com \
--cc=trini@konsulko.com \
--cc=u-boot-qcom@groups.io \
--cc=u-boot@lists.denx.de \
--cc=varadarajan.narayanan@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox