@@ -670,29 +670,49 @@ static unsigned int ata_devchk(struct ata_port *ap, unsigned int device)
670
670
* None.
671
671
*
672
672
* 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.
675
675
*/
676
-
677
676
unsigned int ata_dev_classify (const struct ata_taskfile * tf )
678
677
{
679
678
/* Apple's open source Darwin code hints that some devices only
680
679
* put a proper signature into the LBA mid/high registers,
681
680
* 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.
682
695
*/
683
-
684
- if (((tf -> lbam == 0 ) && (tf -> lbah == 0 )) ||
685
- ((tf -> lbam == 0x3c ) && (tf -> lbah == 0xc3 ))) {
696
+ if ((tf -> lbam == 0 ) && (tf -> lbah == 0 )) {
686
697
DPRINTK ("found ATA device by sig\n" );
687
698
return ATA_DEV_ATA ;
688
699
}
689
700
690
- if (((tf -> lbam == 0x14 ) && (tf -> lbah == 0xeb )) ||
691
- ((tf -> lbam == 0x69 ) && (tf -> lbah == 0x96 ))) {
701
+ if ((tf -> lbam == 0x14 ) && (tf -> lbah == 0xeb )) {
692
702
DPRINTK ("found ATAPI device by sig\n" );
693
703
return ATA_DEV_ATAPI ;
694
704
}
695
705
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
+
696
716
DPRINTK ("unknown device\n" );
697
717
return ATA_DEV_UNKNOWN ;
698
718
}
@@ -3426,6 +3446,12 @@ int ata_std_prereset(struct ata_link *link, unsigned long deadline)
3426
3446
(link -> flags & ATA_LFLAG_HRST_TO_RESUME ))
3427
3447
ehc -> i .action |= ATA_EH_HARDRESET ;
3428
3448
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
+
3429
3455
/* if we're about to do hardreset, nothing more to do */
3430
3456
if (ehc -> i .action & ATA_EH_HARDRESET )
3431
3457
return 0 ;
@@ -3616,6 +3642,16 @@ int sata_std_hardreset(struct ata_link *link, unsigned int *class,
3616
3642
/* wait a while before checking status, see SRST for more info */
3617
3643
msleep (150 );
3618
3644
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
+
3619
3655
rc = ata_wait_ready (ap , deadline );
3620
3656
/* link occupied, -ENODEV too is an error */
3621
3657
if (rc ) {
@@ -5966,22 +6002,26 @@ int sata_scr_valid(struct ata_link *link)
5966
6002
* @val: Place to store read value
5967
6003
*
5968
6004
* 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.
5971
6007
*
5972
6008
* LOCKING:
5973
- * None.
6009
+ * None if @link is ap->link. Kernel thread context otherwise .
5974
6010
*
5975
6011
* RETURNS:
5976
6012
* 0 on success, negative errno on failure.
5977
6013
*/
5978
6014
int sata_scr_read (struct ata_link * link , int reg , u32 * val )
5979
6015
{
5980
- struct ata_port * ap = link -> ap ;
6016
+ if (ata_is_host_link (link )) {
6017
+ struct ata_port * ap = link -> ap ;
5981
6018
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 );
5985
6025
}
5986
6026
5987
6027
/**
@@ -5991,22 +6031,26 @@ int sata_scr_read(struct ata_link *link, int reg, u32 *val)
5991
6031
* @val: value to write
5992
6032
*
5993
6033
* 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.
5996
6036
*
5997
6037
* LOCKING:
5998
- * None.
6038
+ * None if @link is ap->link. Kernel thread context otherwise .
5999
6039
*
6000
6040
* RETURNS:
6001
6041
* 0 on success, negative errno on failure.
6002
6042
*/
6003
6043
int sata_scr_write (struct ata_link * link , int reg , u32 val )
6004
6044
{
6005
- struct ata_port * ap = link -> ap ;
6045
+ if (ata_is_host_link (link )) {
6046
+ struct ata_port * ap = link -> ap ;
6006
6047
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 );
6010
6054
}
6011
6055
6012
6056
/**
@@ -6019,23 +6063,27 @@ int sata_scr_write(struct ata_link *link, int reg, u32 val)
6019
6063
* function performs flush after writing to the register.
6020
6064
*
6021
6065
* LOCKING:
6022
- * None.
6066
+ * None if @link is ap->link. Kernel thread context otherwise .
6023
6067
*
6024
6068
* RETURNS:
6025
6069
* 0 on success, negative errno on failure.
6026
6070
*/
6027
6071
int sata_scr_write_flush (struct ata_link * link , int reg , u32 val )
6028
6072
{
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 ;
6031
6076
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 ;
6037
6084
}
6038
- return - EOPNOTSUPP ;
6085
+
6086
+ return sata_pmp_scr_write (link , reg , val );
6039
6087
}
6040
6088
6041
6089
/**
@@ -6424,6 +6472,7 @@ static void ata_host_release(struct device *gendev, void *res)
6424
6472
if (ap -> scsi_host )
6425
6473
scsi_host_put (ap -> scsi_host );
6426
6474
6475
+ kfree (ap -> pmp_link );
6427
6476
kfree (ap );
6428
6477
host -> ports [i ] = NULL ;
6429
6478
}
0 commit comments