Commit 899fcf40f3177697ccfb029d0484cb8ec09a51ca
Committed by
James Bottomley
1 parent
9a10b33caf
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
[SCSI] libsas: set attached device type and target protocols for local phys
Before: $ cat /sys/class/sas_phy/phy-6\:3/device_type none $ cat /sys/class/sas_phy/phy-6\:3/target_port_protocols none After: $ cat /sys/class/sas_phy/phy-6\:3/device_type end device $ cat /sys/class/sas_phy/phy-6\:3/target_port_protocols sata Also downgrade the phy_list_lock to _irq instead of _irqsave since libsas will never call sas_get_port_device with interrupts disbled. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Showing 3 changed files with 27 additions and 4 deletions Side-by-side Diff
drivers/scsi/libsas/sas_discover.c
... | ... | @@ -69,7 +69,6 @@ |
69 | 69 | */ |
70 | 70 | static int sas_get_port_device(struct asd_sas_port *port) |
71 | 71 | { |
72 | - unsigned long flags; | |
73 | 72 | struct asd_sas_phy *phy; |
74 | 73 | struct sas_rphy *rphy; |
75 | 74 | struct domain_device *dev; |
76 | 75 | |
... | ... | @@ -78,9 +77,9 @@ |
78 | 77 | if (!dev) |
79 | 78 | return -ENOMEM; |
80 | 79 | |
81 | - spin_lock_irqsave(&port->phy_list_lock, flags); | |
80 | + spin_lock_irq(&port->phy_list_lock); | |
82 | 81 | if (list_empty(&port->phy_list)) { |
83 | - spin_unlock_irqrestore(&port->phy_list_lock, flags); | |
82 | + spin_unlock_irq(&port->phy_list_lock); | |
84 | 83 | sas_put_device(dev); |
85 | 84 | return -ENODEV; |
86 | 85 | } |
... | ... | @@ -89,7 +88,7 @@ |
89 | 88 | memcpy(dev->frame_rcvd, phy->frame_rcvd, min(sizeof(dev->frame_rcvd), |
90 | 89 | (size_t)phy->frame_rcvd_size)); |
91 | 90 | spin_unlock(&phy->frame_rcvd_lock); |
92 | - spin_unlock_irqrestore(&port->phy_list_lock, flags); | |
91 | + spin_unlock_irq(&port->phy_list_lock); | |
93 | 92 | |
94 | 93 | if (dev->frame_rcvd[0] == 0x34 && port->oob_mode == SATA_OOB_MODE) { |
95 | 94 | struct dev_to_host_fis *fis = |
... | ... | @@ -134,6 +133,11 @@ |
134 | 133 | sas_put_device(dev); |
135 | 134 | return -ENODEV; |
136 | 135 | } |
136 | + | |
137 | + spin_lock_irq(&port->phy_list_lock); | |
138 | + list_for_each_entry(phy, &port->phy_list, port_phy_el) | |
139 | + sas_phy_set_target(phy, dev); | |
140 | + spin_unlock_irq(&port->phy_list_lock); | |
137 | 141 | rphy->identify.phy_identifier = phy->phy->identify.phy_identifier; |
138 | 142 | memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE); |
139 | 143 | sas_fill_in_rphy(dev, rphy); |
drivers/scsi/libsas/sas_internal.h
... | ... | @@ -30,6 +30,7 @@ |
30 | 30 | #include <scsi/scsi_host.h> |
31 | 31 | #include <scsi/scsi_transport_sas.h> |
32 | 32 | #include <scsi/libsas.h> |
33 | +#include <scsi/sas_ata.h> | |
33 | 34 | |
34 | 35 | #define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__) |
35 | 36 | |
... | ... | @@ -144,6 +145,22 @@ |
144 | 145 | default: |
145 | 146 | rphy->identify.device_type = SAS_PHY_UNUSED; |
146 | 147 | break; |
148 | + } | |
149 | +} | |
150 | + | |
151 | +static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_device *dev) | |
152 | +{ | |
153 | + struct sas_phy *phy = p->phy; | |
154 | + | |
155 | + if (dev) { | |
156 | + if (dev_is_sata(dev)) | |
157 | + phy->identify.device_type = SAS_END_DEVICE; | |
158 | + else | |
159 | + phy->identify.device_type = dev->dev_type; | |
160 | + phy->identify.target_port_protocols = dev->tproto; | |
161 | + } else { | |
162 | + phy->identify.device_type = SAS_PHY_UNUSED; | |
163 | + phy->identify.target_port_protocols = 0; | |
147 | 164 | } |
148 | 165 | } |
149 | 166 |
drivers/scsi/libsas/sas_port.c
... | ... | @@ -104,6 +104,7 @@ |
104 | 104 | |
105 | 105 | /* add the phy to the port */ |
106 | 106 | list_add_tail(&phy->port_phy_el, &port->phy_list); |
107 | + sas_phy_set_target(phy, port->port_dev); | |
107 | 108 | phy->port = port; |
108 | 109 | port->num_phys++; |
109 | 110 | port->phy_mask |= (1U << phy->id); |
... | ... | @@ -182,6 +183,7 @@ |
182 | 183 | spin_lock(&port->phy_list_lock); |
183 | 184 | |
184 | 185 | list_del_init(&phy->port_phy_el); |
186 | + sas_phy_set_target(phy, NULL); | |
185 | 187 | phy->port = NULL; |
186 | 188 | port->num_phys--; |
187 | 189 | port->phy_mask &= ~(1U << phy->id); |