svn commit: r328165 - in head: sbin/camcontrol sys/cam sys/cam/mmc
Scott Long
scottl at FreeBSD.org
Fri Jan 19 15:32:29 UTC 2018
Author: scottl
Date: Fri Jan 19 15:32:27 2018
New Revision: 328165
URL: https://svnweb.freebsd.org/changeset/base/328165
Log:
Revert ABI breakage to CAM that came in with MMC/SD support in r320844.
Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO
call instead. Convert camcontrol to the new scheme.
Reviewed by: imp. kibab
Sponsored by: Netflix
Differential Revision: D13868
Modified:
head/sbin/camcontrol/camcontrol.c
head/sys/cam/cam_ccb.h
head/sys/cam/cam_xpt.c
head/sys/cam/mmc/mmc_xpt.c
Modified: head/sbin/camcontrol/camcontrol.c
==============================================================================
--- head/sbin/camcontrol/camcontrol.c Fri Jan 19 14:50:53 2018 (r328164)
+++ head/sbin/camcontrol/camcontrol.c Fri Jan 19 15:32:27 2018 (r328165)
@@ -715,14 +715,50 @@ print_dev_semb(struct device_match_result *dev_result,
static int
print_dev_mmcsd(struct device_match_result *dev_result, char *tmpstr)
{
+ union ccb *ccb;
+ struct ccb_dev_advinfo *advi;
+ struct cam_device *dev;
+ struct mmc_params mmc_ident_data;
- if (strlen(dev_result->mmc_ident_data.model) > 0) {
- sprintf(tmpstr, "<%s>", dev_result->mmc_ident_data.model);
+ dev = cam_open_btl(dev_result->path_id, dev_result->target_id,
+ dev_result->target_lun, O_RDWR, NULL);
+ if (dev == NULL) {
+ warnx("%s", cam_errbuf);
+ return (1);
+ }
+
+ ccb = cam_getccb(dev);
+ if (ccb == NULL) {
+ warnx("couldn't allocate CCB");
+ cam_close_device(dev);
+ return (1);
+ }
+
+ advi = &ccb->cdai;
+ advi->ccb_h.flags = CAM_DIR_IN;
+ advi->ccb_h.func_code = XPT_DEV_ADVINFO;
+ advi->flags = CDAI_FLAG_NONE;
+ advi->buftype = CDAI_TYPE_MMC_PARAMS;
+ advi->bufsiz = sizeof(struct mmc_params);
+ advi->buf = (uint8_t *)&mmc_ident_data;
+
+ if (cam_send_ccb(dev, ccb) < 0) {
+ warn("error sending CAMIOCOMMAND ioctl");
+ cam_freeccb(ccb);
+ cam_close_device(dev);
+ return (1);
+ }
+
+ if (strlen(mmc_ident_data.model) > 0) {
+ sprintf(tmpstr, "<%s>", mmc_ident_data.model);
} else {
sprintf(tmpstr, "<%s card>",
- dev_result->mmc_ident_data.card_features &
+ mmc_ident_data.card_features &
CARD_FEATURE_SDIO ? "SDIO" : "unknown");
}
+
+ cam_freeccb(ccb);
+ cam_close_device(dev);
return (0);
}
Modified: head/sys/cam/cam_ccb.h
==============================================================================
--- head/sys/cam/cam_ccb.h Fri Jan 19 14:50:53 2018 (r328164)
+++ head/sys/cam/cam_ccb.h Fri Jan 19 15:32:27 2018 (r328165)
@@ -506,7 +506,6 @@ struct device_match_result {
struct scsi_inquiry_data inq_data;
struct ata_params ident_data;
dev_result_flags flags;
- struct mmc_params mmc_ident_data;
};
struct bus_match_result {
@@ -1278,6 +1277,7 @@ struct ccb_dev_advinfo {
#define CDAI_TYPE_EXT_INQ 5
#define CDAI_TYPE_NVME_CNTRL 6 /* NVMe Identify Controller data */
#define CDAI_TYPE_NVME_NS 7 /* NVMe Identify Namespace data */
+#define CDAI_TYPE_MMC_PARAMS 8 /* MMC/SD ident */
off_t bufsiz; /* IN: Size of external buffer */
#define CAM_SCSI_DEVID_MAXLEN 65536 /* length in buffer is an uint16_t */
off_t provsiz; /* OUT: Size required/used */
Modified: head/sys/cam/cam_xpt.c
==============================================================================
--- head/sys/cam/cam_xpt.c Fri Jan 19 14:50:53 2018 (r328164)
+++ head/sys/cam/cam_xpt.c Fri Jan 19 15:32:27 2018 (r328165)
@@ -1909,9 +1909,6 @@ xptedtdevicefunc(struct cam_ed *device, void *arg)
bcopy(&device->ident_data,
&cdm->matches[j].result.device_result.ident_data,
sizeof(struct ata_params));
- bcopy(&device->mmc_ident_data,
- &cdm->matches[j].result.device_result.mmc_ident_data,
- sizeof(struct mmc_params));
/* Let the user know whether this device is unconfigured */
if (device->flags & CAM_DEV_UNCONFIGURED)
Modified: head/sys/cam/mmc/mmc_xpt.c
==============================================================================
--- head/sys/cam/mmc/mmc_xpt.c Fri Jan 19 14:50:53 2018 (r328164)
+++ head/sys/cam/mmc/mmc_xpt.c Fri Jan 19 15:32:27 2018 (r328165)
@@ -367,6 +367,13 @@ mmc_dev_advinfo(union ccb *start_ccb)
case CDAI_TYPE_PHYS_PATH: /* pass(4) wants this */
cdai->provsiz = 0;
break;
+ case CDAI_TYPE_MMC_PARAMS:
+ cdai->provsiz = device->mmc_ident_data;
+ if (device->mmc_ident_data == NULL)
+ break;
+ amt = MIN(cdai->provsiz, cdai->bufsiz);
+ memcpy(cdai->buff, device->mmc_ident_data, amt);
+ break;
default:
panic("Unknown buftype");
return;
More information about the svn-src-all
mailing list