Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 03 Sep 2019 14:06:43 -0000
From:      Ilya Bakulin <kibab@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346097 - in head: sbin/camcontrol sys/cam/mmc sys/dev/mmc
Message-ID:  <201904101949.x3AJnZ1R024092@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kibab
Date: Wed Apr 10 19:49:35 2019
New Revision: 346097
URL: https://svnweb.freebsd.org/changeset/base/346097

Log:
  Add new fields to mmc_data in preparation to SDIO CMD53 block mode support
  
  SDIO command CMD53 (IO_RW_EXTENDED) allows data transfers using blocks of 1-2048 bytes,
  with a maximum of 511 blocks per request.
  Extend mmc_data structure to properly describe such requests,
  and initialize the new fields in kernel and userland consumers.
  
  No actual driver changes happen yet, these will follow in the separate changes.
  
  Reviewed by:	bz
  Approved by:	imp (mentor)
  Differential Revision:	https://reviews.freebsd.org/D19779

Modified:
  head/sbin/camcontrol/camcontrol.c
  head/sys/cam/mmc/mmc_da.c
  head/sys/dev/mmc/mmcreg.h

Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c	Wed Apr 10 19:27:14 2019	(r346096)
+++ head/sbin/camcontrol/camcontrol.c	Wed Apr 10 19:49:35 2019	(r346097)
@@ -7788,6 +7788,7 @@ mmcsdcmd(struct cam_device *device, int argc, char **a
 		flags |= CAM_DIR_IN;
 		mmc_data = malloc(mmc_data_len);
 		memset(mmc_data, 0, mmc_data_len);
+		memset(&mmc_d, 0, sizeof(mmc_d));
 		mmc_d.len = mmc_data_len;
 		mmc_d.data = mmc_data;
 		mmc_d.flags = MMC_DATA_READ;

Modified: head/sys/cam/mmc/mmc_da.c
==============================================================================
--- head/sys/cam/mmc/mmc_da.c	Wed Apr 10 19:27:14 2019	(r346096)
+++ head/sys/cam/mmc/mmc_da.c	Wed Apr 10 19:49:35 2019	(r346097)
@@ -791,6 +791,11 @@ sddaregister(struct cam_periph *periph, void *arg)
 	softc->state = SDDA_STATE_INIT;
 	softc->mmcdata =
 		(struct mmc_data *)malloc(sizeof(struct mmc_data), M_DEVBUF, M_NOWAIT|M_ZERO);
+	if (softc->mmcdata == NULL) {
+		printf("sddaregister: Unable to probe new device. "
+		    "Unable to allocate mmcdata\n");
+		return (CAM_REQ_CMP_ERR);
+	}
 	periph->softc = softc;
 	softc->periph = periph;
 
@@ -889,6 +894,7 @@ mmc_send_ext_csd(struct cam_periph *periph, union ccb 
 	struct mmc_data d;
 
 	KASSERT(buf_len == 512, ("Buffer for ext csd must be 512 bytes"));
+	memset(&d, 0, sizeof(d));
 	d.data = rawextcsd;
 	d.len = buf_len;
 	d.flags = MMC_DATA_READ;
@@ -1013,6 +1019,7 @@ mmc_sd_switch(struct cam_periph *periph, union ccb *cc
 	int err;
 
 	memset(res, 0, 64);
+	memset(&mmc_d, 0, sizeof(mmc_d));
 	mmc_d.len = 64;
 	mmc_d.data = res;
 	mmc_d.flags = MMC_DATA_READ;
@@ -1804,6 +1811,7 @@ sddastart(struct cam_periph *periph, union ccb *start_
 
 		mmcio->cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
 		mmcio->cmd.data = softc->mmcdata;
+		memset(mmcio->cmd.data, 0, sizeof(struct mmc_data));
 		mmcio->cmd.data->data = bp->bio_data;
 		mmcio->cmd.data->len = 512 * count;
 		mmcio->cmd.data->flags = (bp->bio_cmd == BIO_READ ? MMC_DATA_READ : MMC_DATA_WRITE);

Modified: head/sys/dev/mmc/mmcreg.h
==============================================================================
--- head/sys/dev/mmc/mmcreg.h	Wed Apr 10 19:27:14 2019	(r346096)
+++ head/sys/dev/mmc/mmcreg.h	Wed Apr 10 19:49:35 2019	(r346097)
@@ -197,7 +197,10 @@ struct mmc_data {
 #define	MMC_DATA_READ	(1UL << 1)
 #define	MMC_DATA_STREAM	(1UL << 2)
 #define	MMC_DATA_MULTI	(1UL << 3)
+#define MMC_DATA_BLOCK_SIZE (1UL << 4)
 	struct mmc_request *mrq;
+	size_t block_size;      /* block size for CMD53 */
+	size_t block_count;     /* block count for CMD53 */
 };
 
 struct mmc_request {





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