@@ -670,29 +670,49 @@ static unsigned int ata_devchk(struct ata_port *ap, unsigned int device)
670670 * None.
671671 *
672672 * RETURNS:
673- * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, or %ATA_DEV_UNKNOWN
674- * the event of failure.
673+ * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP or
674+ * %ATA_DEV_UNKNOWN the event of failure.
675675 */
676-
677676unsigned int ata_dev_classify (const struct ata_taskfile * tf )
678677{
679678 /* Apple's open source Darwin code hints that some devices only
680679 * put a proper signature into the LBA mid/high registers,
681680 * So, we only check those. It's sufficient for uniqueness.
681+ *
682+ * ATA/ATAPI-7 (d1532v1r1: Feb. 19, 2003) specified separate
683+ * signatures for ATA and ATAPI devices attached on SerialATA,
684+ * 0x3c/0xc3 and 0x69/0x96 respectively. However, SerialATA
685+ * spec has never mentioned about using different signatures
686+ * for ATA/ATAPI devices. Then, Serial ATA II: Port
687+ * Multiplier specification began to use 0x69/0x96 to identify
688+ * port multpliers and 0x3c/0xc3 to identify SEMB device.
689+ * ATA/ATAPI-7 dropped descriptions about 0x3c/0xc3 and
690+ * 0x69/0x96 shortly and described them as reserved for
691+ * SerialATA.
692+ *
693+ * We follow the current spec and consider that 0x69/0x96
694+ * identifies a port multiplier and 0x3c/0xc3 a SEMB device.
682695 */
683-
684- if (((tf -> lbam == 0 ) && (tf -> lbah == 0 )) ||
685- ((tf -> lbam == 0x3c ) && (tf -> lbah == 0xc3 ))) {
696+ if ((tf -> lbam == 0 ) && (tf -> lbah == 0 )) {
686697 DPRINTK ("found ATA device by sig\n" );
687698 return ATA_DEV_ATA ;
688699 }
689700
690- if (((tf -> lbam == 0x14 ) && (tf -> lbah == 0xeb )) ||
691- ((tf -> lbam == 0x69 ) && (tf -> lbah == 0x96 ))) {
701+ if ((tf -> lbam == 0x14 ) && (tf -> lbah == 0xeb )) {
692702 DPRINTK ("found ATAPI device by sig\n" );
693703 return ATA_DEV_ATAPI ;
694704 }
695705
706+ if ((tf -> lbam == 0x69 ) && (tf -> lbah == 0x96 )) {
707+ DPRINTK ("found PMP device by sig\n" );
708+ return ATA_DEV_PMP ;
709+ }
710+
711+ if ((tf -> lbam == 0x3c ) && (tf -> lbah == 0xc3 )) {
712+ printk ("ata: SEMB device ignored\n" );
713+ return ATA_DEV_SEMB_UNSUP ; /* not yet */
714+ }
715+
696716 DPRINTK ("unknown device\n" );
697717 return ATA_DEV_UNKNOWN ;
698718}
@@ -3426,6 +3446,12 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
34263446 (link -> flags & ATA_LFLAG_HRST_TO_RESUME ))
34273447 ehc -> i .action |= ATA_EH_HARDRESET ;
34283448
3449+ /* Some PMPs don't work with only SRST, force hardreset if PMP
3450+ * is supported.
3451+ */
3452+ if (ap -> flags & ATA_FLAG_PMP )
3453+ ehc -> i .action |= ATA_EH_HARDRESET ;
3454+
34293455 /* if we're about to do hardreset, nothing more to do */
34303456 if (ehc -> i .action & ATA_EH_HARDRESET )
34313457 return 0 ;
@@ -3616,6 +3642,16 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class,
36163642 /* wait a while before checking status, see SRST for more info */
36173643 msleep (150 );
36183644
3645+ /* If PMP is supported, we have to do follow-up SRST. Note
3646+ * that some PMPs don't send D2H Reg FIS after hardreset at
3647+ * all if the first port is empty. Wait for it just for a
3648+ * second and request follow-up SRST.
3649+ */
3650+ if (ap -> flags & ATA_FLAG_PMP ) {
3651+ ata_wait_ready (ap , jiffies + HZ );
3652+ return - EAGAIN ;
3653+ }
3654+
36193655 rc = ata_wait_ready (ap , deadline );
36203656 /* link occupied, -ENODEV too is an error */
36213657 if (rc ) {
@@ -5966,22 +6002,26 @@ int sata_scr_valid(struct ata_link *link)
59666002 * @val: Place to store read value
59676003 *
59686004 * Read SCR register @reg of @link into *@val. This function is
5969- * guaranteed to succeed if the cable type of the port is SATA
5970- * and the port implements ->scr_read.
6005+ * guaranteed to succeed if @link is ap->link, the cable type of
6006+ * the port is SATA and the port implements ->scr_read.
59716007 *
59726008 * LOCKING:
5973- * None.
6009+ * None if @link is ap->link. Kernel thread context otherwise .
59746010 *
59756011 * RETURNS:
59766012 * 0 on success, negative errno on failure.
59776013 */
59786014int sata_scr_read (struct ata_link * link , int reg , u32 * val )
59796015{
5980- struct ata_port * ap = link -> ap ;
6016+ if (ata_is_host_link (link )) {
6017+ struct ata_port * ap = link -> ap ;
59816018
5982- if (sata_scr_valid (link ))
5983- return ap -> ops -> scr_read (ap , reg , val );
5984- return - EOPNOTSUPP ;
6019+ if (sata_scr_valid (link ))
6020+ return ap -> ops -> scr_read (ap , reg , val );
6021+ return - EOPNOTSUPP ;
6022+ }
6023+
6024+ return sata_pmp_scr_read (link , reg , val );
59856025}
59866026
59876027/**
@@ -5991,22 +6031,26 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val)
59916031 * @val: value to write
59926032 *
59936033 * Write @val to SCR register @reg of @link. This function is
5994- * guaranteed to succeed if the cable type of the port is SATA
5995- * and the port implements ->scr_read.
6034+ * guaranteed to succeed if @link is ap->link, the cable type of
6035+ * the port is SATA and the port implements ->scr_read.
59966036 *
59976037 * LOCKING:
5998- * None.
6038+ * None if @link is ap->link. Kernel thread context otherwise .
59996039 *
60006040 * RETURNS:
60016041 * 0 on success, negative errno on failure.
60026042 */
60036043int sata_scr_write (struct ata_link * link , int reg , u32 val )
60046044{
6005- struct ata_port * ap = link -> ap ;
6045+ if (ata_is_host_link (link )) {
6046+ struct ata_port * ap = link -> ap ;
60066047
6007- if (sata_scr_valid (link ))
6008- return ap -> ops -> scr_write (ap , reg , val );
6009- return - EOPNOTSUPP ;
6048+ if (sata_scr_valid (link ))
6049+ return ap -> ops -> scr_write (ap , reg , val );
6050+ return - EOPNOTSUPP ;
6051+ }
6052+
6053+ return sata_pmp_scr_write (link , reg , val );
60106054}
60116055
60126056/**
@@ -6019,23 +6063,27 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val)
60196063 * function performs flush after writing to the register.
60206064 *
60216065 * LOCKING:
6022- * None.
6066+ * None if @link is ap->link. Kernel thread context otherwise .
60236067 *
60246068 * RETURNS:
60256069 * 0 on success, negative errno on failure.
60266070 */
60276071int sata_scr_write_flush (struct ata_link * link , int reg , u32 val )
60286072{
6029- struct ata_port * ap = link -> ap ;
6030- int rc ;
6073+ if (ata_is_host_link (link )) {
6074+ struct ata_port * ap = link -> ap ;
6075+ int rc ;
60316076
6032- if (sata_scr_valid (link )) {
6033- rc = ap -> ops -> scr_write (ap , reg , val );
6034- if (rc == 0 )
6035- rc = ap -> ops -> scr_read (ap , reg , & val );
6036- return rc ;
6077+ if (sata_scr_valid (link )) {
6078+ rc = ap -> ops -> scr_write (ap , reg , val );
6079+ if (rc == 0 )
6080+ rc = ap -> ops -> scr_read (ap , reg , & val );
6081+ return rc ;
6082+ }
6083+ return - EOPNOTSUPP ;
60376084 }
6038- return - EOPNOTSUPP ;
6085+
6086+ return sata_pmp_scr_write (link , reg , val );
60396087}
60406088
60416089/**
@@ -6424,6 +6472,7 @@ static void ata_host_release(struct device *gendev, void *res)
64246472 if (ap -> scsi_host )
64256473 scsi_host_put (ap -> scsi_host );
64266474
6475+ kfree (ap -> pmp_link );
64276476 kfree (ap );
64286477 host -> ports [i ] = NULL ;
64296478 }
0 commit comments