Re: WinLink E850-96: WARNING: at block/blk-settings.c:204 blk_validate_limits

From: Arnd Bergmann
Date: Thu Mar 07 2024 - 10:04:32 EST


On Fri, Mar 1, 2024, at 22:18, Sam Protsenko wrote:
> On Fri, Mar 1, 2024 at 2:51 PM Sam Protsenko <semen.protsenko@xxxxxxxxxx> wrote:
>> On Thu, Feb 29, 2024 at 8:56 AM Arnd Bergmann <arnd@xxxxxxxx> wrote:

>
> Sorry, just noticed I commented on the wrong line. Here is the change I made:
>
> - mmc->max_seg_size = 0x1000;
> + mmc->max_seg_size = PAGE_SIZE;

I went over all MMC drivers to see what else sets a max_seg_size
smaller than a page and found these:

drivers/mmc/host/alcor.c: mmc->max_seg_size = AU6601_MAX_DMA_BLOCK_SIZE; // 0x1000
drivers/mmc/host/au1xmmc.c: mmc->max_seg_size = AU1100_MMC_DESCRIPTOR_SIZE; // 64K-1
drivers/mmc/host/dw_mmc.c: mmc->max_seg_size = 0x1000;
drivers/mmc/host/meson-gx-mmc.c: mmc->max_seg_size = mmc->max_req_size; // 1536 bytes
drivers/mmc/host/mmci_stm32_sdmmc.c: host->mmc->max_seg_size = host->variant->stm32_idmabsize_mask; // GENMASK(12, 5),
drivers/mmc/host/sunxi-mmc.c: mmc->max_seg_size = (1 << host->cfg->idma_des_size_bits); // 1 << 13, only on arm32
drivers/mmc/host/wmt-sdmmc.c: .max_seg_size = 65024,

I've tried to add the maintainers to Cc here, these likely all
need attention to work with large page sizes, in case of
meson-gx-mmc it even seems like the limit is less than a 4KB
page, so it will stop working entirely.

There are also a couple of drivers that look like they have
an off-by-one error and pass a segment size of one less than
a power-off-two number, e.g.:

drivers/mmc/host/davinci_mmc.c: mmc->max_seg_size = MAX_CCNT * rw_threshold; // (64k-1) * 32
drivers/mmc/host/atmel-mci.c: mmc->max_seg_size = mmc->max_blk_size * mmc->max_segs; // 4095*256

I think some of these are intentional, while others are
probably bugs.

Arnd