From: Balaji Selvanathan <balaji.selvanathan@oss.qualcomm.com>
To: Jonas Karlman <jonas@kwiboo.se>
Cc: Sumit Garg <sumit.garg@kernel.org>,
"u-boot-qcom@groups.io" <u-boot-qcom@groups.io>,
"u-boot@lists.denx.de" <u-boot@lists.denx.de>,
Lukasz Majewski <lukma@denx.de>,
Casey Connolly <casey.connolly@linaro.org>,
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:10 +0530 [thread overview]
Message-ID: <533e8a1c-e157-4e5c-837b-32858b44179e@oss.qualcomm.com> (raw)
In-Reply-To: <6b16c87a-ef5d-4c5d-9268-f1c0c3884b05@kwiboo.se>
On 3/24/2026 5:32 PM, Jonas Karlman wrote:
> Hi,
>
> On 3/24/2026 6:52 AM, 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.
>>
>> 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;
> Have you tried to configure SYS_MMC_MAX_BLK_COUNT=16384 for your
> platform, or otherwise set b_max in your mmc driver?
>
> That should cause similar max blocks handling at a the mmc-uclass level.
>
> Regards,
> Jonas
Hi Jonas,
Thanks for the feedback. Addressed this in v2:
https://lore.kernel.org/u-boot/20260421-emmc-v2-0-0ebd3322b676@oss.qualcomm.com/.
Thanks,
Balaji
>
>>
>> - 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 */
>>
prev parent reply other threads:[~2026-04-21 13:07 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
2026-03-24 12:02 ` Jonas Karlman
2026-04-21 13:07 ` Balaji Selvanathan [this message]
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=533e8a1c-e157-4e5c-837b-32858b44179e@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=jonas@kwiboo.se \
--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