Date: Sun, 3 Feb 2008 10:59:56 -0500 From: Alexander Kabaev <kabaev@gmail.com> To: gnome@freebsd.org Subject: [PATCH] HAL is broken with real SCSI CD-ROM /CD-RW devices Message-ID: <20080203105956.39617a58@kan.dnsalias.net>
next in thread | raw e-mail | index | archive | help
--Sig_/4pUFv0f.0x0.LG1qMk+ePID Content-Type: multipart/mixed; boundary="MP_/X9IJU=GTiuIPgw7cLEZnmtC" --MP_/X9IJU=GTiuIPgw7cLEZnmtC Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, hal port as it exists on today's ports CVS works very badly with my Plextor CD-RW, which hapens to be a generic SCSI-3/MMC2 device. Hal hangs the drive firmware and sometimes oven freezes the whole SCSI bus when probing for CDROM. It turns out that whoever did the initial hal port did not know that CDB length parameter passed to CAM is significant and just hardcoded it to 16. This causes 16 bytes of command to be DMA's to the drive even for SCSI 6 and 10 byte commands and that is not received warmly by at least some real SCSI targets. Attached patch (also at http://people.freebsd.org/~kan/hal-patch-scsi.diff) fixes this to renaming unused timeout parameter in hfp_cdfrom_send_ccb function to be ccb_len and passing proper command length where necessary. --=20 Alexander Kabaev --MP_/X9IJU=GTiuIPgw7cLEZnmtC Content-Type: text/x-patch; name=patch-scsi.diff Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=patch-scsi.diff --- hald/freebsd/libprobe/hfp-cdrom.h.orig 2008-02-03 10:35:35.000000000 -0= 500 +++ hald/freebsd/libprobe/hfp-cdrom.h 2008-02-03 10:39:13.000000000 -0500 @@ -149,8 +149,8 @@ HFPCDROM *hfp_cdrom_new_from_fd (int fd, const char *path, const char *par= ent); =20 boolean hfp_cdrom_send_ccb (HFPCDROM *cdrom, - char ccb[16], - int timeout, + const char *ccb, + int ccb_len, HFPCDROMDirection direction, void *data, int len, --- hald/freebsd/libprobe/hfp-cdrom.c.orig 2008-02-03 10:36:09.000000000 -0= 500 +++ hald/freebsd/libprobe/hfp-cdrom.c 2008-02-03 10:39:13.000000000 -0500 @@ -124,13 +124,14 @@ =20 boolean hfp_cdrom_send_ccb (HFPCDROM *cdrom, - char ccb[16], - int timeout, + const char *ccb, + int ccb_len, HFPCDROMDirection direction, void *data, int len, char **err) { + int timeout =3D 10; assert(cdrom !=3D NULL); assert(ccb !=3D NULL); assert(direction =3D=3D HFP_CDROM_DIRECTION_NONE @@ -227,7 +228,7 @@ data, len, sizeof(cam_ccb.csio.sense_data), - 16, + ccb_len, timeout * 1000); =20 memcpy(cam_ccb.csio.cdb_io.cdb_bytes, ccb, 16); @@ -255,7 +256,7 @@ =20 assert(cdrom !=3D NULL); =20 - return hfp_cdrom_send_ccb(cdrom, ccb, 10, HFP_CDROM_DIRECTION_NONE, NULL= , 0, NULL); + return hfp_cdrom_send_ccb(cdrom, ccb, 6, HFP_CDROM_DIRECTION_NONE, NULL,= 0, NULL); } =20 void --- hald/freebsd/probing/freebsd_dvd_rw_utils.c.orig 2008-02-03 10:35:14.00= 0000000 -0500 +++ hald/freebsd/probing/freebsd_dvd_rw_utils.c 2008-02-03 10:39:27.0000000= 00 -0500 @@ -28,6 +28,7 @@ struct ScsiCommand { HFPCDROM *cdrom; char ccb[16]; + int len; }; =20 static ScsiCommand * @@ -51,13 +52,14 @@ scsi_command_init (ScsiCommand * cmd, size_t i, int arg) { cmd->ccb[i] =3D arg; + cmd->len =3D i + 1; } =20 static int scsi_command_transport (ScsiCommand * cmd, Direction dir, void *buf, size_t sz) { - if (hfp_cdrom_send_ccb(cmd->cdrom, cmd->ccb, 10, dir, buf, sz, NULL)) + if (hfp_cdrom_send_ccb(cmd->cdrom, cmd->ccb, cmd->len, dir, buf, sz, NULL= )) return 0; else return -1; --MP_/X9IJU=GTiuIPgw7cLEZnmtC-- --Sig_/4pUFv0f.0x0.LG1qMk+ePID Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iD8DBQFHpeT8Q6z1jMm+XZYRAuAAAKC35mR1akiYzKHxdNE+I/+VAoRNsgCgnQ+z aA3iN7KqDgicsSEPA7oyahg= =S+Q2 -----END PGP SIGNATURE----- --Sig_/4pUFv0f.0x0.LG1qMk+ePID--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080203105956.39617a58>