Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mmc: sdhci: fix max req size based on spec #5571

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@
WARN_ON(host->data);

/* Sanity checks */
BUG_ON(data->blksz * data->blocks > 524288);
BUG_ON(data->blksz * data->blocks > host->mmc->max_req_size);

Check failure on line 1098 in drivers/mmc/host/sdhci.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
BUG_ON(data->blksz > host->mmc->max_blk_size);
BUG_ON(data->blocks > 65535);

Expand Down Expand Up @@ -4720,11 +4720,18 @@

/*
* Maximum number of sectors in one transfer. Limited by SDMA boundary
* size (512KiB). Note some tuning modes impose a 4MiB limit, but this
* is less anyway.
* size and by tuning modes on ADMA. On tuning mode 3 16MiB is more than
* enough to cover big data transfers.
*/
mmc->max_req_size = 524288;

if (host->flags & SDHCI_USE_ADMA) {
if (host->tuning_mode != SDHCI_TUNING_MODE_3)
mmc->max_req_size = 4194304;
else
mmc->max_req_size = 16777216;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are defines which are easier to read: SZ_4M and SZ_16M

} else {
/* On PIO/SDMA use SDMA boundary size (512KiB). */
mmc->max_req_size = 524288;
}
/*
* Maximum number of segments. Depends on if the hardware
* can do scatter/gather or not.
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/host/sdhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ struct sdhci_adma2_64_desc {
#define ADMA2_END 0x2

/*
* Maximum segments assuming a 512KiB maximum requisition size and a minimum
* Maximum segments assuming a 16MiB maximum requisition size and a minimum
* 4KiB page size. Note this also allows enough for multiple descriptors in
* case of PAGE_SIZE >= 64KiB.
*/
#define SDHCI_MAX_SEGS 128
#define SDHCI_MAX_SEGS 4096

/* Allow for a a command request and a data request at the same time */
#define SDHCI_MAX_MRQS 2
Expand Down
Loading