Author: mav
Date: Sun Feb 14 19:44:48 2010
New Revision: 203890
URL: http://svn.freebsd.org/changeset/base/203890

Log:
  MFC r203376, r203384:
  - Give ATA/SATA SIMs info about ATAPI packet size, supported by device.
  - Make ATA XPT to reject longer SCSI CDBs then supported by device, or
  any SCSI CDBs, if device doesn't support ATAPI.

Modified:
  stable/8/sbin/camcontrol/camcontrol.c
  stable/8/sys/cam/ata/ata_xpt.c
  stable/8/sys/cam/cam_ccb.h
  stable/8/sys/cam/cam_xpt.c
  stable/8/sys/dev/ahci/ahci.c
  stable/8/sys/dev/ahci/ahci.h
  stable/8/sys/dev/ata/ata-all.c
  stable/8/sys/dev/ata/ata-all.h
  stable/8/sys/dev/siis/siis.c
  stable/8/sys/dev/siis/siis.h
Directory Properties:
  stable/8/   (props changed)
  stable/8/Makefile.inc1   (props changed)
  stable/8/ObsoleteFiles.inc   (props changed)
  stable/8/UPDATING   (props changed)
  stable/8/bin/   (props changed)
  stable/8/bin/chmod/   (props changed)
  stable/8/bin/cp/   (props changed)
  stable/8/bin/csh/   (props changed)
  stable/8/bin/getfacl/   (props changed)
  stable/8/bin/ls/   (props changed)
  stable/8/bin/mv/   (props changed)
  stable/8/bin/pax/   (props changed)
  stable/8/bin/pkill/   (props changed)
  stable/8/bin/ps/   (props changed)
  stable/8/bin/setfacl/   (props changed)
  stable/8/bin/sh/   (props changed)
  stable/8/cddl/compat/opensolaris/   (props changed)
  stable/8/cddl/contrib/opensolaris/   (props changed)
  stable/8/cddl/contrib/opensolaris/cmd/zdb/   (props changed)
  stable/8/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  stable/8/cddl/contrib/opensolaris/lib/libzfs/   (props changed)
  stable/8/cddl/lib/libnvpair/   (props changed)
  stable/8/contrib/bind9/   (props changed)
  stable/8/contrib/bsnmp/   (props changed)
  stable/8/contrib/bzip2/   (props changed)
  stable/8/contrib/cpio/   (props changed)
  stable/8/contrib/csup/   (props changed)
  stable/8/contrib/ee/   (props changed)
  stable/8/contrib/expat/   (props changed)
  stable/8/contrib/file/   (props changed)
  stable/8/contrib/gcc/   (props changed)
  stable/8/contrib/gdb/   (props changed)
  stable/8/contrib/gdtoa/   (props changed)
  stable/8/contrib/groff/   (props changed)
  stable/8/contrib/less/   (props changed)
  stable/8/contrib/libpcap/   (props changed)
  stable/8/contrib/ncurses/   (props changed)
  stable/8/contrib/netcat/   (props changed)
  stable/8/contrib/ntp/   (props changed)
  stable/8/contrib/one-true-awk/   (props changed)
  stable/8/contrib/openbsm/   (props changed)
  stable/8/contrib/openpam/   (props changed)
  stable/8/contrib/pf/   (props changed)
  stable/8/contrib/sendmail/   (props changed)
  stable/8/contrib/tcpdump/   (props changed)
  stable/8/contrib/tcsh/   (props changed)
  stable/8/contrib/top/   (props changed)
  stable/8/contrib/top/install-sh   (props changed)
  stable/8/contrib/traceroute/   (props changed)
  stable/8/contrib/wpa/   (props changed)
  stable/8/crypto/heimdal/   (props changed)
  stable/8/crypto/openssh/   (props changed)
  stable/8/crypto/openssl/   (props changed)
  stable/8/etc/   (props changed)
  stable/8/games/factor/   (props changed)
  stable/8/games/fortune/   (props changed)
  stable/8/games/fortune/datfiles/   (props changed)
  stable/8/gnu/usr.bin/groff/   (props changed)
  stable/8/gnu/usr.bin/patch/   (props changed)
  stable/8/include/   (props changed)
  stable/8/kerberos5/lib/libgssapi_krb5/   (props changed)
  stable/8/kerberos5/lib/libgssapi_spnego/   (props changed)
  stable/8/kerberos5/usr.bin/kdestroy/   (props changed)
  stable/8/kerberos5/usr.bin/kpasswd/   (props changed)
  stable/8/lib/bind/   (props changed)
  stable/8/lib/csu/   (props changed)
  stable/8/lib/libarchive/   (props changed)
  stable/8/lib/libbluetooth/   (props changed)
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libdevinfo/   (props changed)
  stable/8/lib/libdisk/   (props changed)
  stable/8/lib/libelf/   (props changed)
  stable/8/lib/libexpat/   (props changed)
  stable/8/lib/libfetch/   (props changed)
  stable/8/lib/libgpib/   (props changed)
  stable/8/lib/libgssapi/   (props changed)
  stable/8/lib/libjail/   (props changed)
  stable/8/lib/libkvm/   (props changed)
  stable/8/lib/libpmc/   (props changed)
  stable/8/lib/libradius/   (props changed)
  stable/8/lib/librpcsec_gss/   (props changed)
  stable/8/lib/libstand/   (props changed)
  stable/8/lib/libtacplus/   (props changed)
  stable/8/lib/libthr/   (props changed)
  stable/8/lib/libusb/   (props changed)
  stable/8/lib/libusb/usb.h   (props changed)
  stable/8/lib/libutil/   (props changed)
  stable/8/libexec/rtld-elf/   (props changed)
  stable/8/release/   (props changed)
  stable/8/sbin/   (props changed)
  stable/8/sbin/atacontrol/   (props changed)
  stable/8/sbin/bsdlabel/   (props changed)
  stable/8/sbin/camcontrol/   (props changed)
  stable/8/sbin/ddb/   (props changed)
  stable/8/sbin/dhclient/   (props changed)
  stable/8/sbin/dumpfs/   (props changed)
  stable/8/sbin/fsck/   (props changed)
  stable/8/sbin/fsck_ffs/   (props changed)
  stable/8/sbin/geom/   (props changed)
  stable/8/sbin/geom/class/stripe/   (props changed)
  stable/8/sbin/ggate/   (props changed)
  stable/8/sbin/growfs/   (props changed)
  stable/8/sbin/ifconfig/   (props changed)
  stable/8/sbin/ipfw/   (props changed)
  stable/8/sbin/mdconfig/   (props changed)
  stable/8/sbin/mksnap_ffs/   (props changed)
  stable/8/sbin/mount/   (props changed)
  stable/8/sbin/mount_cd9660/   (props changed)
  stable/8/sbin/mount_msdosfs/   (props changed)
  stable/8/sbin/mount_nfs/   (props changed)
  stable/8/sbin/natd/   (props changed)
  stable/8/sbin/newfs/   (props changed)
  stable/8/sbin/routed/   (props changed)
  stable/8/sbin/sysctl/   (props changed)
  stable/8/sbin/umount/   (props changed)
  stable/8/secure/usr.bin/bdes/   (props changed)
  stable/8/share/examples/   (props changed)
  stable/8/share/man/man3/   (props changed)
  stable/8/share/man/man4/   (props changed)
  stable/8/share/man/man5/   (props changed)
  stable/8/share/man/man7/   (props changed)
  stable/8/share/man/man8/   (props changed)
  stable/8/share/man/man9/   (props changed)
  stable/8/share/misc/   (props changed)
  stable/8/share/mk/   (props changed)
  stable/8/share/timedef/   (props changed)
  stable/8/share/zoneinfo/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/netinet/   (props changed)
  stable/8/tools/kerneldoc/subsys/   (props changed)
  stable/8/tools/regression/acltools/   (props changed)
  stable/8/tools/regression/bin/sh/   (props changed)
  stable/8/tools/regression/fifo/   (props changed)
  stable/8/tools/regression/geom/   (props changed)
  stable/8/tools/regression/lib/libc/   (props changed)
  stable/8/tools/regression/lib/msun/test-conj.t   (props changed)
  stable/8/tools/regression/poll/   (props changed)
  stable/8/tools/regression/priv/   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pgrep-_g.t   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pgrep-_s.t   (props changed)
  stable/8/tools/regression/usr.bin/pkill/pkill-_g.t   (props changed)
  stable/8/tools/tools/ath/   (props changed)
  stable/8/tools/tools/ath/common/dumpregs.h   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5210.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5211.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5212.c   (props changed)
  stable/8/tools/tools/ath/common/dumpregs_5416.c   (props changed)
  stable/8/tools/tools/termcap/termcap.pl   (props changed)
  stable/8/tools/tools/vimage/   (props changed)
  stable/8/usr.bin/awk/   (props changed)
  stable/8/usr.bin/calendar/   (props changed)
  stable/8/usr.bin/catman/   (props changed)
  stable/8/usr.bin/comm/   (props changed)
  stable/8/usr.bin/csup/   (props changed)
  stable/8/usr.bin/fetch/   (props changed)
  stable/8/usr.bin/find/   (props changed)
  stable/8/usr.bin/finger/   (props changed)
  stable/8/usr.bin/fstat/   (props changed)
  stable/8/usr.bin/gcore/   (props changed)
  stable/8/usr.bin/gzip/   (props changed)
  stable/8/usr.bin/kdump/   (props changed)
  stable/8/usr.bin/locale/   (props changed)
  stable/8/usr.bin/look/   (props changed)
  stable/8/usr.bin/makewhatis/   (props changed)
  stable/8/usr.bin/netstat/   (props changed)
  stable/8/usr.bin/perror/   (props changed)
  stable/8/usr.bin/procstat/   (props changed)
  stable/8/usr.bin/systat/   (props changed)
  stable/8/usr.bin/tftp/   (props changed)
  stable/8/usr.bin/truss/   (props changed)
  stable/8/usr.bin/unifdef/   (props changed)
  stable/8/usr.bin/uniq/   (props changed)
  stable/8/usr.bin/vmstat/   (props changed)
  stable/8/usr.bin/w/   (props changed)
  stable/8/usr.bin/whois/   (props changed)
  stable/8/usr.sbin/   (props changed)
  stable/8/usr.sbin/Makefile   (props changed)
  stable/8/usr.sbin/acpi/   (props changed)
  stable/8/usr.sbin/arp/   (props changed)
  stable/8/usr.sbin/bsnmpd/   (props changed)
  stable/8/usr.sbin/burncd/   (props changed)
  stable/8/usr.sbin/cdcontrol/   (props changed)
  stable/8/usr.sbin/cpucontrol/   (props changed)
  stable/8/usr.sbin/crashinfo/   (props changed)
  stable/8/usr.sbin/cron/   (props changed)
  stable/8/usr.sbin/diskinfo/   (props changed)
  stable/8/usr.sbin/dumpcis/cardinfo.h   (props changed)
  stable/8/usr.sbin/dumpcis/cis.h   (props changed)
  stable/8/usr.sbin/faithd/   (props changed)
  stable/8/usr.sbin/freebsd-update/   (props changed)
  stable/8/usr.sbin/inetd/   (props changed)
  stable/8/usr.sbin/iostat/   (props changed)
  stable/8/usr.sbin/jail/   (props changed)
  stable/8/usr.sbin/jls/   (props changed)
  stable/8/usr.sbin/lpr/   (props changed)
  stable/8/usr.sbin/makefs/ffs/ffs_bswap.c   (props changed)
  stable/8/usr.sbin/makefs/ffs/ffs_subr.c   (props changed)
  stable/8/usr.sbin/makefs/ffs/ufs_bswap.h   (props changed)
  stable/8/usr.sbin/makefs/getid.c   (props changed)
  stable/8/usr.sbin/mergemaster/   (props changed)
  stable/8/usr.sbin/mfiutil/mfiutil.8   (props changed)
  stable/8/usr.sbin/ndp/   (props changed)
  stable/8/usr.sbin/newsyslog/   (props changed)
  stable/8/usr.sbin/ntp/   (props changed)
  stable/8/usr.sbin/pmcstat/   (props changed)
  stable/8/usr.sbin/powerd/   (props changed)
  stable/8/usr.sbin/ppp/   (props changed)
  stable/8/usr.sbin/pstat/   (props changed)
  stable/8/usr.sbin/rpc.umntall/   (props changed)
  stable/8/usr.sbin/rtsold/   (props changed)
  stable/8/usr.sbin/service/   (props changed)
  stable/8/usr.sbin/sysinstall/   (props changed)
  stable/8/usr.sbin/syslogd/   (props changed)
  stable/8/usr.sbin/traceroute/   (props changed)
  stable/8/usr.sbin/traceroute6/   (props changed)
  stable/8/usr.sbin/usbconfig/   (props changed)
  stable/8/usr.sbin/wpa/   (props changed)
  stable/8/usr.sbin/ypserv/   (props changed)
  stable/8/usr.sbin/zic/   (props changed)

Modified: stable/8/sbin/camcontrol/camcontrol.c
==============================================================================
--- stable/8/sbin/camcontrol/camcontrol.c       Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sbin/camcontrol/camcontrol.c       Sun Feb 14 19:44:48 2010        
(r203890)
@@ -1010,8 +1010,10 @@ camxferrate(struct cam_device *device)
                printf(" (");
                if (ata->valid & CTS_ATA_VALID_MODE)
                        printf("%s, ", ata_mode2string(ata->mode));
+               if ((ata->valid & CTS_ATA_VALID_ATAPI) && ata->atapi != 0)
+                       printf("ATAPI %dbytes, ", ata->atapi);
                if (ata->valid & CTS_ATA_VALID_BYTECOUNT)
-                       printf("PIO size %dbytes", ata->bytecount);
+                       printf("PIO %dbytes", ata->bytecount);
                printf(")");
        } else if (ccb->cts.transport == XPORT_SATA) {
                struct ccb_trans_settings_sata *sata =
@@ -1022,8 +1024,10 @@ camxferrate(struct cam_device *device)
                        printf("SATA %d.x, ", sata->revision);
                if (sata->valid & CTS_SATA_VALID_MODE)
                        printf("%s, ", ata_mode2string(sata->mode));
+               if ((sata->valid & CTS_SATA_VALID_ATAPI) && sata->atapi != 0)
+                       printf("ATAPI %dbytes, ", sata->atapi);
                if (sata->valid & CTS_SATA_VALID_BYTECOUNT)
-                       printf("PIO size %dbytes", sata->bytecount);
+                       printf("PIO %dbytes", sata->bytecount);
                printf(")");
        }
 
@@ -2800,6 +2804,10 @@ cts_print(struct cam_device *device, str
                        fprintf(stdout, "%sATA mode: %s\n", pathstr,
                                ata_mode2string(ata->mode));
                }
+               if ((ata->valid & CTS_ATA_VALID_ATAPI) != 0) {
+                       fprintf(stdout, "%sATAPI packet length: %d\n", pathstr,
+                               ata->atapi);
+               }
                if ((ata->valid & CTS_ATA_VALID_BYTECOUNT) != 0) {
                        fprintf(stdout, "%sPIO transaction length: %d\n",
                                pathstr, ata->bytecount);
@@ -2817,6 +2825,10 @@ cts_print(struct cam_device *device, str
                        fprintf(stdout, "%sATA mode: %s\n", pathstr,
                                ata_mode2string(sata->mode));
                }
+               if ((sata->valid & CTS_SATA_VALID_ATAPI) != 0) {
+                       fprintf(stdout, "%sATAPI packet length: %d\n", pathstr,
+                               sata->atapi);
+               }
                if ((sata->valid & CTS_SATA_VALID_BYTECOUNT) != 0) {
                        fprintf(stdout, "%sPIO transaction length: %d\n",
                                pathstr, sata->bytecount);

Modified: stable/8/sys/cam/ata/ata_xpt.c
==============================================================================
--- stable/8/sys/cam/ata/ata_xpt.c      Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/cam/ata/ata_xpt.c      Sun Feb 14 19:44:48 2010        
(r203890)
@@ -1334,7 +1334,20 @@ ata_device_transport(struct cam_path *pa
        cts.protocol = path->device->protocol;
        cts.protocol_version = path->device->protocol_version;
        cts.proto_specific.valid = 0;
-       cts.xport_specific.valid = 0;
+       if (ident_buf) {
+               if (path->device->transport == XPORT_ATA) {
+                       cts.xport_specific.ata.atapi = 
+                           ((ident_buf->config & ATA_PROTO_MASK) == 
ATA_PROTO_ATAPI_16) ? 16 :
+                           ((ident_buf->config & ATA_PROTO_MASK) == 
ATA_PROTO_ATAPI_12) ? 12 : 0;
+                       cts.xport_specific.ata.valid = CTS_ATA_VALID_ATAPI;
+               } else {
+                       cts.xport_specific.sata.atapi = 
+                           ((ident_buf->config & ATA_PROTO_MASK) == 
ATA_PROTO_ATAPI_16) ? 16 :
+                           ((ident_buf->config & ATA_PROTO_MASK) == 
ATA_PROTO_ATAPI_12) ? 12 : 0;
+                       cts.xport_specific.sata.valid = CTS_SATA_VALID_ATAPI;
+               }
+       } else
+               cts.xport_specific.valid = 0;
        xpt_action((union ccb *)&cts);
 }
 
@@ -1366,6 +1379,27 @@ ata_action(union ccb *start_ccb)
                (*(sim->sim_action))(sim, start_ccb);
                break;
        }
+       case XPT_SCSI_IO:
+       {
+               struct cam_ed *device;
+               u_int   maxlen = 0;
+
+               device = start_ccb->ccb_h.path->device;
+               if (device->protocol == PROTO_SCSI &&
+                   (device->flags & CAM_DEV_IDENTIFY_DATA_VALID)) {
+                       uint16_t p =
+                           device->ident_data.config & ATA_PROTO_MASK;
+
+                       maxlen = (p == ATA_PROTO_ATAPI_16) ? 16 :
+                           (p == ATA_PROTO_ATAPI_12) ? 12 : 0;
+               }
+               if (start_ccb->csio.cdb_len > maxlen) {
+                       start_ccb->ccb_h.status = CAM_REQ_INVALID;
+                       xpt_done(start_ccb);
+                       break;
+               }
+               /* FALLTHROUGH */
+       }
        default:
                xpt_action_default(start_ccb);
                break;

Modified: stable/8/sys/cam/cam_ccb.h
==============================================================================
--- stable/8/sys/cam/cam_ccb.h  Sun Feb 14 19:38:27 2010        (r203889)
+++ stable/8/sys/cam/cam_ccb.h  Sun Feb 14 19:44:48 2010        (r203890)
@@ -823,8 +823,10 @@ struct ccb_trans_settings_ata {
        u_int           valid;          /* Which fields to honor */
 #define        CTS_ATA_VALID_MODE              0x01
 #define        CTS_ATA_VALID_BYTECOUNT         0x02
+#define        CTS_ATA_VALID_ATAPI             0x20
        int             mode;           /* Mode */
        u_int           bytecount;      /* Length of PIO transaction */
+       u_int           atapi;          /* Length of ATAPI CDB */
 };
 
 struct ccb_trans_settings_sata {
@@ -834,11 +836,13 @@ struct ccb_trans_settings_sata {
 #define        CTS_SATA_VALID_REVISION         0x04
 #define        CTS_SATA_VALID_PM               0x08
 #define        CTS_SATA_VALID_TAGS             0x10
+#define        CTS_SATA_VALID_ATAPI            0x20
        int             mode;           /* Legacy PATA mode */
        u_int           bytecount;      /* Length of PIO transaction */
        int             revision;       /* SATA revision */
        u_int           pm_present;     /* PM is present (XPT->SIM) */
        u_int           tags;           /* Number of allowed tags */
+       u_int           atapi;          /* Length of ATAPI CDB */
 };
 
 /* Get/Set transfer rate/width/disconnection/tag queueing settings */

Modified: stable/8/sys/cam/cam_xpt.c
==============================================================================
--- stable/8/sys/cam/cam_xpt.c  Sun Feb 14 19:38:27 2010        (r203889)
+++ stable/8/sys/cam/cam_xpt.c  Sun Feb 14 19:44:48 2010        (r203890)
@@ -1201,8 +1201,10 @@ xpt_announce_periph(struct cam_periph *p
                printf(" (");
                if (ata->valid & CTS_ATA_VALID_MODE)
                        printf("%s, ", ata_mode2string(ata->mode));
+               if ((ata->valid & CTS_ATA_VALID_ATAPI) && ata->atapi != 0)
+                       printf("ATAPI %dbytes, ", ata->atapi);
                if (ata->valid & CTS_ATA_VALID_BYTECOUNT)
-                       printf("PIO size %dbytes", ata->bytecount);
+                       printf("PIO %dbytes", ata->bytecount);
                printf(")");
        }
        if (cts.ccb_h.status == CAM_REQ_CMP && cts.transport == XPORT_SATA) {
@@ -1214,8 +1216,10 @@ xpt_announce_periph(struct cam_periph *p
                        printf("SATA %d.x, ", sata->revision);
                if (sata->valid & CTS_SATA_VALID_MODE)
                        printf("%s, ", ata_mode2string(sata->mode));
+               if ((sata->valid & CTS_ATA_VALID_ATAPI) && sata->atapi != 0)
+                       printf("ATAPI %dbytes, ", sata->atapi);
                if (sata->valid & CTS_SATA_VALID_BYTECOUNT)
-                       printf("PIO size %dbytes", sata->bytecount);
+                       printf("PIO %dbytes", sata->bytecount);
                printf(")");
        }
        if (path->device->inq_flags & SID_CmdQue

Modified: stable/8/sys/dev/ahci/ahci.c
==============================================================================
--- stable/8/sys/dev/ahci/ahci.c        Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/ahci/ahci.c        Sun Feb 14 19:44:48 2010        
(r203890)
@@ -2213,6 +2213,8 @@ ahciaction(struct cam_sim *sim, union cc
                        d->tags = min(ch->numslots, 
cts->xport_specific.sata.tags);
                if (cts->xport_specific.sata.valid & CTS_SATA_VALID_PM)
                        ch->pm_present = cts->xport_specific.sata.pm_present;
+               if (cts->xport_specific.sata.valid & CTS_SATA_VALID_ATAPI)
+                       d->atapi = cts->xport_specific.sata.atapi;
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);
                break;
@@ -2256,6 +2258,8 @@ ahciaction(struct cam_sim *sim, union cc
                cts->xport_specific.sata.valid |= CTS_SATA_VALID_PM;
                cts->xport_specific.sata.tags = d->tags;
                cts->xport_specific.sata.valid |= CTS_SATA_VALID_TAGS;
+               cts->xport_specific.sata.atapi = d->atapi;
+               cts->xport_specific.sata.valid |= CTS_SATA_VALID_ATAPI;
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);
                break;

Modified: stable/8/sys/dev/ahci/ahci.h
==============================================================================
--- stable/8/sys/dev/ahci/ahci.h        Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/ahci/ahci.h        Sun Feb 14 19:44:48 2010        
(r203890)
@@ -358,6 +358,7 @@ struct ahci_device {
        int                     revision;
        int                     mode;
        u_int                   bytecount;
+       u_int                   atapi;
        u_int                   tags;
 };
 

Modified: stable/8/sys/dev/ata/ata-all.c
==============================================================================
--- stable/8/sys/dev/ata/ata-all.c      Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/ata/ata-all.c      Sun Feb 14 19:44:48 2010        
(r203890)
@@ -1348,6 +1348,8 @@ ata_cam_begin_transaction(device_t dev, 
                    ccb->csio.cdb_io.cdb_ptr : ccb->csio.cdb_io.cdb_bytes,
                    request->u.atapi.ccb, ccb->csio.cdb_len);
                request->flags |= ATA_R_ATAPI;
+               if (ch->curr[ccb->ccb_h.target_id].atapi == 16)
+                       request->flags |= ATA_R_ATAPI16;
                if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE &&
                    ch->curr[ccb->ccb_h.target_id].mode >= ATA_DMA)
                        request->flags |= ATA_R_DMA;
@@ -1358,7 +1360,6 @@ ata_cam_begin_transaction(device_t dev, 
        }
        request->transfersize = min(request->bytecount,
            ch->curr[ccb->ccb_h.target_id].bytecount);
-//     request->callback = ad_done;
        request->retries = 0;
        request->timeout = (ccb->ccb_h.timeout + 999) / 1000;
        callout_init_mtx(&request->callout, &ch->state_mtx, 
CALLOUT_RETURNUNLOCKED);
@@ -1491,7 +1492,7 @@ ataaction(struct cam_sim *sim, union ccb
                if (ch->flags & ATA_SATA) {
                        if (cts->xport_specific.sata.valid & 
CTS_SATA_VALID_REVISION)
                                d->revision = cts->xport_specific.sata.revision;
-                       if (cts->xport_specific.ata.valid & 
CTS_SATA_VALID_MODE) {
+                       if (cts->xport_specific.sata.valid & 
CTS_SATA_VALID_MODE) {
                                if (cts->type == CTS_TYPE_CURRENT_SETTINGS) {
                                        d->mode = ATA_SETMODE(ch->dev,
                                            ccb->ccb_h.target_id,
@@ -1499,8 +1500,10 @@ ataaction(struct cam_sim *sim, union ccb
                                } else
                                        d->mode = cts->xport_specific.sata.mode;
                        }
-                       if (cts->xport_specific.ata.valid & 
CTS_SATA_VALID_BYTECOUNT)
+                       if (cts->xport_specific.sata.valid & 
CTS_SATA_VALID_BYTECOUNT)
                                d->bytecount = min(8192, 
cts->xport_specific.sata.bytecount);
+                       if (cts->xport_specific.sata.valid & 
CTS_SATA_VALID_ATAPI)
+                               d->atapi = cts->xport_specific.sata.atapi;
                } else {
                        if (cts->xport_specific.ata.valid & CTS_ATA_VALID_MODE) 
{
                                if (cts->type == CTS_TYPE_CURRENT_SETTINGS) {
@@ -1512,6 +1515,8 @@ ataaction(struct cam_sim *sim, union ccb
                        }
                        if (cts->xport_specific.ata.valid & 
CTS_ATA_VALID_BYTECOUNT)
                                d->bytecount = 
cts->xport_specific.ata.bytecount;
+                       if (cts->xport_specific.ata.valid & CTS_ATA_VALID_ATAPI)
+                               d->atapi = cts->xport_specific.ata.atapi;
                }
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);
@@ -1541,6 +1546,8 @@ ataaction(struct cam_sim *sim, union ccb
                        } else
                                cts->xport_specific.sata.revision = d->revision;
                        cts->xport_specific.sata.valid |= 
CTS_SATA_VALID_REVISION;
+                       cts->xport_specific.sata.atapi = d->atapi;
+                       cts->xport_specific.sata.valid |= CTS_SATA_VALID_ATAPI;
                } else {
                        cts->transport = XPORT_ATA;
                        cts->transport_version = XPORT_VERSION_UNSPECIFIED;
@@ -1548,6 +1555,8 @@ ataaction(struct cam_sim *sim, union ccb
                        cts->xport_specific.ata.valid |= CTS_ATA_VALID_MODE;
                        cts->xport_specific.ata.bytecount = d->bytecount;
                        cts->xport_specific.ata.valid |= 
CTS_ATA_VALID_BYTECOUNT;
+                       cts->xport_specific.ata.atapi = d->atapi;
+                       cts->xport_specific.ata.valid |= CTS_ATA_VALID_ATAPI;
                }
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);

Modified: stable/8/sys/dev/ata/ata-all.h
==============================================================================
--- stable/8/sys/dev/ata/ata-all.h      Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/ata/ata-all.h      Sun Feb 14 19:44:48 2010        
(r203890)
@@ -539,6 +539,7 @@ struct ata_cam_device {
        u_int                   revision;
        int                     mode;
        u_int                   bytecount;
+       u_int                   atapi;
 };
 #endif
 

Modified: stable/8/sys/dev/siis/siis.c
==============================================================================
--- stable/8/sys/dev/siis/siis.c        Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/siis/siis.c        Sun Feb 14 19:44:48 2010        
(r203890)
@@ -1671,6 +1671,8 @@ siisaction(struct cam_sim *sim, union cc
                        else
                                ATA_OUTL(ch->r_mem, SIIS_P_CTLCLR, 
SIIS_P_CTL_PME);
                }
+               if (cts->xport_specific.sata.valid & CTS_SATA_VALID_TAGS)
+                       d->atapi = cts->xport_specific.sata.atapi;
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);
                break;
@@ -1714,6 +1716,8 @@ siisaction(struct cam_sim *sim, union cc
                cts->xport_specific.sata.valid |= CTS_SATA_VALID_PM;
                cts->xport_specific.sata.tags = d->tags;
                cts->xport_specific.sata.valid |= CTS_SATA_VALID_TAGS;
+               cts->xport_specific.sata.atapi = d->atapi;
+               cts->xport_specific.sata.valid |= CTS_SATA_VALID_ATAPI;
                ccb->ccb_h.status = CAM_REQ_CMP;
                xpt_done(ccb);
                break;

Modified: stable/8/sys/dev/siis/siis.h
==============================================================================
--- stable/8/sys/dev/siis/siis.h        Sun Feb 14 19:38:27 2010        
(r203889)
+++ stable/8/sys/dev/siis/siis.h        Sun Feb 14 19:44:48 2010        
(r203890)
@@ -356,6 +356,7 @@ struct siis_device {
        int                     revision;
        int                     mode;
        u_int                   bytecount;
+       u_int                   atapi;
        u_int                   tags;
 };
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to