aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ata/libata-core.c6
-rw-r--r--include/linux/libata.h53
2 files changed, 51 insertions, 8 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index dcae590cc9b4..af9c0ab600dc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6064,13 +6064,14 @@ void ata_dev_init(struct ata_device *dev)
6064 * ata_link_init - Initialize an ata_link structure 6064 * ata_link_init - Initialize an ata_link structure
6065 * @ap: ATA port link is attached to 6065 * @ap: ATA port link is attached to
6066 * @link: Link structure to initialize 6066 * @link: Link structure to initialize
6067 * @pmp: Port multiplier port number
6067 * 6068 *
6068 * Initialize @link. 6069 * Initialize @link.
6069 * 6070 *
6070 * LOCKING: 6071 * LOCKING:
6071 * Kernel thread context (may sleep) 6072 * Kernel thread context (may sleep)
6072 */ 6073 */
6073static void ata_link_init(struct ata_port *ap, struct ata_link *link) 6074static void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
6074{ 6075{
6075 int i; 6076 int i;
6076 6077
@@ -6078,6 +6079,7 @@ static void ata_link_init(struct ata_port *ap, struct ata_link *link)
6078 memset(link, 0, offsetof(struct ata_link, device[0])); 6079 memset(link, 0, offsetof(struct ata_link, device[0]));
6079 6080
6080 link->ap = ap; 6081 link->ap = ap;
6082 link->pmp = pmp;
6081 link->active_tag = ATA_TAG_POISON; 6083 link->active_tag = ATA_TAG_POISON;
6082 link->hw_sata_spd_limit = UINT_MAX; 6084 link->hw_sata_spd_limit = UINT_MAX;
6083 6085
@@ -6173,7 +6175,7 @@ struct ata_port *ata_port_alloc(struct ata_host *host)
6173 6175
6174 ap->cbl = ATA_CBL_NONE; 6176 ap->cbl = ATA_CBL_NONE;
6175 6177
6176 ata_link_init(ap, &ap->link); 6178 ata_link_init(ap, &ap->link, 0);
6177 6179
6178#ifdef ATA_IRQ_TRAP 6180#ifdef ATA_IRQ_TRAP
6179 ap->stats.unhandled_irq = 1; 6181 ap->stats.unhandled_irq = 1;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index bfa155789993..7a1793bd2371 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -515,6 +515,7 @@ struct ata_acpi_gtm {
515 515
516struct ata_link { 516struct ata_link {
517 struct ata_port *ap; 517 struct ata_port *ap;
518 int pmp; /* port multiplier port # */
518 519
519 unsigned int active_tag; /* active tag on this link */ 520 unsigned int active_tag; /* active tag on this link */
520 u32 sactive; /* active NCQ commands */ 521 u32 sactive; /* active NCQ commands */
@@ -563,6 +564,9 @@ struct ata_port {
563 564
564 struct ata_link link; /* host default link */ 565 struct ata_link link; /* host default link */
565 566
567 int nr_pmp_links; /* nr of available PMP links */
568 struct ata_link *pmp_link; /* array of PMP links */
569
566 struct ata_port_stats stats; 570 struct ata_port_stats stats;
567 struct ata_host *host; 571 struct ata_host *host;
568 struct device *dev; 572 struct device *dev;
@@ -926,11 +930,17 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
926#define ata_port_printk(ap, lv, fmt, args...) \ 930#define ata_port_printk(ap, lv, fmt, args...) \
927 printk(lv"ata%u: "fmt, (ap)->print_id , ##args) 931 printk(lv"ata%u: "fmt, (ap)->print_id , ##args)
928 932
929#define ata_link_printk(link, lv, fmt, args...) \ 933#define ata_link_printk(link, lv, fmt, args...) do { \
930 printk(lv"ata%u: "fmt, (link)->ap->print_id , ##args) 934 if ((link)->ap->nr_pmp_links) \
935 printk(lv"ata%u.%02u: "fmt, (link)->ap->print_id, \
936 (link)->pmp , ##args); \
937 else \
938 printk(lv"ata%u: "fmt, (link)->ap->print_id , ##args); \
939 } while(0)
931 940
932#define ata_dev_printk(dev, lv, fmt, args...) \ 941#define ata_dev_printk(dev, lv, fmt, args...) \
933 printk(lv"ata%u.%02u: "fmt, (dev)->link->ap->print_id, (dev)->devno , ##args) 942 printk(lv"ata%u.%02u: "fmt, (dev)->link->ap->print_id, \
943 (dev)->link->pmp + (dev)->devno , ##args)
934 944
935/* 945/*
936 * ata_eh_info helpers 946 * ata_eh_info helpers
@@ -1039,15 +1049,46 @@ static inline unsigned int ata_dev_absent(const struct ata_device *dev)
1039/* 1049/*
1040 * link helpers 1050 * link helpers
1041 */ 1051 */
1052static inline int ata_is_host_link(const struct ata_link *link)
1053{
1054 return link == &link->ap->link;
1055}
1056
1042static inline int ata_link_max_devices(const struct ata_link *link) 1057static inline int ata_link_max_devices(const struct ata_link *link)
1043{ 1058{
1044 if (link->ap->flags & ATA_FLAG_SLAVE_POSS) 1059 if (ata_is_host_link(link) && link->ap->flags & ATA_FLAG_SLAVE_POSS)
1045 return 2; 1060 return 2;
1046 return 1; 1061 return 1;
1047} 1062}
1048 1063
1049#define ata_port_for_each_link(lk, ap) \ 1064static inline struct ata_link *ata_port_first_link(struct ata_port *ap)
1050 for ((lk) = &(ap)->link; (lk); (lk) = NULL) 1065{
1066 if (ap->nr_pmp_links)
1067 return ap->pmp_link;
1068 return &ap->link;
1069}
1070
1071static inline struct ata_link *ata_port_next_link(struct ata_link *link)
1072{
1073 struct ata_port *ap = link->ap;
1074
1075 if (link == &ap->link) {
1076 if (!ap->nr_pmp_links)
1077 return NULL;
1078 return ap->pmp_link;
1079 }
1080
1081 if (++link - ap->pmp_link < ap->nr_pmp_links)
1082 return link;
1083 return NULL;
1084}
1085
1086#define __ata_port_for_each_link(lk, ap) \
1087 for ((lk) = &(ap)->link; (lk); (lk) = ata_port_next_link(lk))
1088
1089#define ata_port_for_each_link(link, ap) \
1090 for ((link) = ata_port_first_link(ap); (link); \
1091 (link) = ata_port_next_link(link))
1051 1092
1052#define ata_link_for_each_dev(dev, link) \ 1093#define ata_link_for_each_dev(dev, link) \
1053 for ((dev) = (link)->device; \ 1094 for ((dev) = (link)->device; \