summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-cd.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2007-11-19 18:05:48 +0000
committersos <sos@FreeBSD.org>2007-11-19 18:05:48 +0000
commit24ced90f97f7dc7365541adcf3e3e8610e935957 (patch)
tree491ed6ea353a84da21e00c0036f398cb187a6bce /sys/dev/ata/atapi-cd.c
parent4833340b9c0071527738ef27c1ac7180cd04a59d (diff)
downloadFreeBSD-src-24ced90f97f7dc7365541adcf3e3e8610e935957.zip
FreeBSD-src-24ced90f97f7dc7365541adcf3e3e8610e935957.tar.gz
Fix the problem with certain ATAPI commands on AHCI devices.
Revert the probe in atapi-cd.c to the old usage now its fixed on AHCI. THis change also fixes using virtual CD's om fx parallels. Still leaves the GEOM problem of telling media vs device access apart in the access function.
Diffstat (limited to 'sys/dev/ata/atapi-cd.c')
-rw-r--r--sys/dev/ata/atapi-cd.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index 4c6b55d..22caf9b 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -689,25 +689,32 @@ acd_geom_access(struct g_provider *pp, int dr, int dw, int de)
{
device_t dev = pp->geom->softc;
struct acd_softc *cdp = device_get_ivars(dev);
+ struct ata_request *request;
+ int8_t ccb[16] = { ATAPI_TEST_UNIT_READY, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int timeout = 60, track;
- /* check for media present, waiting for loading medium just in case */
+ if (!(request = ata_alloc_request()))
+ return ENOMEM;
+
+ /* wait if drive is not finished loading the medium */
while (timeout--) {
- if (!acd_mode_sense(dev, ATAPI_CDROM_CAP_PAGE,
- (caddr_t)&cdp->cap, sizeof(cdp->cap)) &&
- cdp->cap.page_code == ATAPI_CDROM_CAP_PAGE) {
- if ((cdp->cap.medium_type == MST_FMT_NONE) ||
- (cdp->cap.medium_type == MST_NO_DISC) ||
- (cdp->cap.medium_type == MST_DOOR_OPEN) ||
- (cdp->cap.medium_type == MST_FMT_ERROR))
- return EIO;
- else
- break;
- }
- pause("acdld", hz / 2);
+ bzero(request, sizeof(struct ata_request));
+ request->dev = dev;
+ bcopy(ccb, request->u.atapi.ccb, 16);
+ request->flags = ATA_R_ATAPI;
+ request->timeout = 5;
+ ata_queue_request(request);
+ if (!request->error &&
+ (request->u.atapi.sense.key == 2 ||
+ request->u.atapi.sense.key == 7) &&
+ request->u.atapi.sense.asc == 4 &&
+ request->u.atapi.sense.ascq == 1)
+ pause("acdld", hz / 2);
+ else
+ break;
}
- if (timeout <= 0)
- return EIO;
+ ata_free_request(request);
if (pp->acr == 0) {
acd_prevent_allow(dev, 1);
OpenPOWER on IntegriCloud