Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2021 07:22:11 GMT
From:      Michal Meloun <mmel@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: dfb736022285 - main - dwmmc: Calculate the maximum transaction length correctly.
Message-ID:  <202110080722.1987MB71006597@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by mmel:

URL: https://cgit.FreeBSD.org/src/commit/?id=dfb7360222856e7e4f5e0e5564281a25af63319c

commit dfb7360222856e7e4f5e0e5564281a25af63319c
Author:     Michal Meloun <mmel@FreeBSD.org>
AuthorDate: 2021-10-07 18:42:56 +0000
Commit:     Michal Meloun <mmel@FreeBSD.org>
CommitDate: 2021-10-08 07:21:03 +0000

    dwmmc: Calculate the maximum transaction length correctly.
    
    We should reserve two descriptors (not MMC_SECTORS) for potentially
    unaligned (so bounced) buffer fragments, one for the starting fragment
    and one for the ending fragment.
    
    Submitted by:   kjopek@gmail.com
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D30387
---
 sys/dev/mmc/host/dwmmc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sys/dev/mmc/host/dwmmc.c b/sys/dev/mmc/host/dwmmc.c
index 77c8e42a6150..2080a973564f 100644
--- a/sys/dev/mmc/host/dwmmc.c
+++ b/sys/dev/mmc/host/dwmmc.c
@@ -145,6 +145,11 @@ struct idmac_desc {
  * second half of page
  */
 #define	IDMAC_MAX_SIZE	2048
+/*
+ * Busdma may bounce buffers, so we must reserve 2 descriptors
+ * (on start and on end) for bounced fragments.
+ */
+#define DWMMC_MAX_DATA	(IDMAC_MAX_SIZE * (IDMAC_DESC_SEGS - 2)) / MMC_SECTOR_SIZE
 
 static void dwmmc_next_operation(struct dwmmc_softc *);
 static int dwmmc_setup_bus(struct dwmmc_softc *, int);
@@ -1358,13 +1363,7 @@ dwmmc_read_ivar(device_t bus, device_t child, int which, uintptr_t *result)
 		*(int *)result = sc->host.caps;
 		break;
 	case MMCBR_IVAR_MAX_DATA:
-		/*
-		 * Busdma may bounce buffers, so we must reserve 2 descriptors
-		 * (on start and on end) for bounced fragments.
-		 *
-		 */
-		*(int *)result = (IDMAC_MAX_SIZE * IDMAC_DESC_SEGS) /
-		    MMC_SECTOR_SIZE - 3;
+		*(int *)result = DWMMC_MAX_DATA;
 		break;
 	case MMCBR_IVAR_TIMING:
 		*(int *)result = sc->host.ios.timing;
@@ -1444,7 +1443,7 @@ dwmmc_get_tran_settings(device_t dev, struct ccb_trans_settings_mmc *cts)
 	cts->host_f_min = sc->host.f_min;
 	cts->host_f_max = sc->host.f_max;
 	cts->host_caps = sc->host.caps;
-	cts->host_max_data = (IDMAC_MAX_SIZE * IDMAC_DESC_SEGS) / MMC_SECTOR_SIZE;
+	cts->host_max_data = DWMMC_MAX_DATA;
 	memcpy(&cts->ios, &sc->host.ios, sizeof(struct mmc_ios));
 
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110080722.1987MB71006597>