libsas error handling + discovery v7
Subsystems (5)
v7 cover libsas error handling + discovery v7
Changes since v6: http://marc.info/?l=linux-scsi&m=132711081125550&w=2
1/ "isci: kill iphy->isci_port lookups": refreshed to fix a build error on
32-bit. I think it is time for these changes to get some soak time in -next.
2/ "libsas: improve debug statements": changed 'routing char' for
table-to-table capable expanders to 'U' per Doug.
3/ "libsas: let libata recover links that fail to transmit initial
sig-fis": no functional changes, content rebased due to note 2.
4/ "libsas: async ata scanning": fixed to close potential crash if eh is
already active when libsas tries to probe a new device.
5/ new "libsas: fix lifetime of SAS_HA_FROZEN": slub debug caught a
regression due to SAS_HA_FROZEN preventing eh_scmds from being completed normally.
6/ new "libsas: revert ata srst": originally added to take advantage of
the srst generation capabilities of isci, but since isci has opted not to use it we no longer need to carry it upstream.
[PATCH 0/1] isci: kill iphy->isci_port lookups
[PATCH 0/2] libsas: improve debug statements
[PATCH 0/3] libsas: let libata recover links that fail to transmit initial sig-fis [PATCH 0/4] libsas: async ata scanning
[PATCH 0/5] libsas: fix lifetime of SAS_HA_FROZEN
[PATCH 0/6] libsas: revert ata srst
Incremental diff (libsas-eh-reworks-v6..libsas-eh-reworks-v7):
drivers/scsi/isci/port.c +1 -1
@@ -1710,7 +1710,7 @@ void isci_port_deformed(struct asd_sas_phy *phy)if (i >=SCI_MAX_PHYS )dev_dbg (&ihost->pdev->dev,"%s: port: %ld\n" , - __func__, iport - &ihost->ports[0 ]); + __func__, (long ) (iport - &ihost->ports[0 ])); }void isci_port_formed (struct asd_sas_phy *phy)
drivers/scsi/libsas/sas_ata.c +16 -40
92 lines not on this page · raw message
drivers/scsi/libsas/sas_expander.c +23 -15
@@ -166,6 +166,23 @@ static inline void *alloc_smp_resp(int size)return kzalloc (size,GFP_KERNEL ); } +static char sas_route_char (struct domain_device *dev,struct ex_phy *phy) +{ +switch (phy->routing_attr) { +case TABLE_ROUTING : +if (dev->ex_dev.t2t_supp) +return 'U' ; +else +return 'T' ; +case DIRECT_ROUTING : +return 'D' ; +case SUBTRACTIVE_ROUTING : +return 'S' ; +default : +return '?' ; + } +} +static enum sas_dev_type to_dev_type (struct discover_resp *dr) {/* This is detecting a failure to transmit initial dev to host
@@ -287,10 +304,8 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)SAS_DPRINTK ("ex %016llx phy%02d:%c:%X attached: %016llx (%s)\n" ,SAS_ADDR (dev->sas_addr), phy->phy_id, - phy->routing_attr ==TABLE_ROUTING ?'T' : - phy->routing_attr ==DIRECT_ROUTING ?'D' : - phy->routing_attr ==SUBTRACTIVE_ROUTING ?'S' :'?' , - phy->linkrate,SAS_ADDR (phy->attached_sas_addr), type); +sas_route_char (dev, phy), phy->linkrate, +SAS_ADDR (phy->attached_sas_addr), type); }/* check if we have an existing attached ata device on this expander phy */
@@ -1192,32 +1207,25 @@ static void sas_print_parent_topology_bug(struct domain_device *child, struct ex_phy *parent_phy, struct ex_phy *child_phy) { -static const char ra_char[] = { - [DIRECT_ROUTING ] ='D' , - [SUBTRACTIVE_ROUTING ] ='S' , - [TABLE_ROUTING ] ='T' , - };static const char *ex_type[] = { [EDGE_DEV ] ="edge" , [FANOUT_DEV ] ="fanout" , };struct domain_device *parent = child->parent; -sas_printk ("%s ex %016llx (T2T supp:%d) phy 0x%x <--> %s ex %016llx " -"(T2T supp:%d) phy 0x%x has %c:%c routing link!\n" , +sas_printk ("%s ex %016llx phy 0x%x <--> %s ex %016llx " +"phy 0x%x has %c:%c routing link!\n" , ex_type[parent->dev_type],SAS_ADDR (parent->sas_addr), - parent->ex_dev.t2t_supp, parent_phy->phy_id, ex_type[child->dev_type],SAS_ADDR (child->sas_addr), - child->ex_dev.t2t_supp, child_phy->phy_id, - ra_char[parent_phy->routing_attr], - ra_char[child_phy->routing_attr]); +sas_route_char (parent, parent_phy), +sas_route_char (child, child_phy)); } static int sas_check_eeds(struct domain_device *child,
drivers/scsi/libsas/sas_scsi_host.c +7 -6
@@ -521,8 +521,7 @@ try_bus_reset:return FAILED ; } -static int sas_eh_handle_sas_errors (struct Scsi_Host *shost, -struct list_head *work_q) +static void sas_eh_handle_sas_errors (struct Scsi_Host *shost,struct list_head *work_q) {struct scsi_cmnd *cmd, *n;enum task_disposition res =TASK_IS_DONE ;
@@ -658,7 +657,7 @@ static int sas_eh_handle_sas_errors(struct Scsi_Host *shost, out:list_splice_tail (&done, work_q);list_splice_tail_init (&ha->eh_ata_q, work_q); -return list_empty (work_q); +return ; clear_q:SAS_DPRINTK ("--- Exit %s -- clear_q\n" , __func__);
@@ -682,10 +681,13 @@ void sas_scsi_recover_host(struct Scsi_Host *shost) __func__, shost->host_busy, shost->host_failed);/* * Deal with commands that still have SAS tasks (i.e. they didn't -* complete via the normal sas_task completion mechanism) +* complete via the normal sas_task completion mechanism), +* SAS_HA_FROZEN gives eh dominion over all sas_task completion. */ set_bit (SAS_HA_FROZEN , &ha->state); -if (sas_eh_handle_sas_errors (shost, &eh_work_q)) +sas_eh_handle_sas_errors (shost, &eh_work_q); +clear_bit (SAS_HA_FROZEN , &ha->state); +if (list_empty (&eh_work_q)) goto out;/*
@@ -699,7 +701,6 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)scsi_eh_ready_devs (shost, &eh_work_q, &ha->eh_done_q); out: -clear_bit (SAS_HA_FROZEN , &ha->state);if (ha->lldd_max_execute_num >1 )wake_up_process (ha->core.queue_thread);
include/scsi/libsas.h +0 -1
@@ -619,7 +619,6 @@ struct sas_domain_function_template {int (*lldd_clear_aca)(struct domain_device *,u8 *lun);int (*lldd_clear_task_set)(struct domain_device *,u8 *lun);int (*lldd_I_T_nexus_reset)(struct domain_device *); -int (*lldd_ata_soft_reset)(struct domain_device *);int (*lldd_ata_check_ready)(struct domain_device *);void (*lldd_ata_set_dmamode)(struct domain_device *);int (*lldd_lu_reset)(struct domain_device *,u8 *lun);
PATCH v7 1/6 isci: kill iphy->isci_port lookups
This field is a holdover from the OS abstraction conversion. The stable phy to port lookups are done via iphy->ownining_port under scic_lock. After this conversion to use port->lldd_port the only volatile lookup is the initial lookup in isci_port_formed(). After that point any lookup via a successfully notified domain_device is guaranteed to be valid until the domain_device is destroyed.
Delete ->start_complete as it is only set once and is set as a consequence of the port going link up, by definition of getting a port formed event the port is "ready".
While we are correcting port lookups also move the asd_sas_port table out from under the isci_port. This is to preclude any temptation to use container_of() to convert an asd_sas_port to an isci_port, the association is dynamic and under libsas control.
--- drivers/scsi/isci/host.h | 19 -------- drivers/scsi/isci/init.c | 7 --- drivers/scsi/isci/phy.c | 18 +++++--- drivers/scsi/isci/phy.h | 1 drivers/scsi/isci/port.c | 84 +++++++++++++++++++++++++++---------- drivers/scsi/isci/port.h | 2 - drivers/scsi/isci/remote_device.c | 29 ++++--------- 7 files changed, 83 insertions(+), 77 deletions(-)
drivers/scsi/isci/host.h +1 -18
@@ -187,6 +187,7 @@ struct isci_host {int id;/* unique within a given pci device */ struct isci_phy phys[SCI_MAX_PHYS ];struct isci_port ports[SCI_MAX_PORTS +1 ];/* includes dummy port */ +struct asd_sas_port sas_ports[SCI_MAX_PORTS ];struct sas_ha_struct sas_ha;spinlock_t state_lock;
@@ -393,24 +394,6 @@ static inline int sci_remote_device_node_count(struct isci_remote_device *idev)#define sci_controller_clear_invalid_phy (controller, phy) \ ((controller)->invalid_phy_mask &= ~(1 << (phy)->phy_index)) -static inline struct device *sciphy_to_dev (struct isci_phy *iphy) -{ - -if (!iphy || !iphy->isci_port || !iphy->isci_port->isci_host) -return NULL ; - -return &iphy->isci_port->isci_host->pdev->dev; -} - -static inline struct device *sciport_to_dev (struct isci_port *iport) -{ - -if (!iport || !iport->isci_host) -return NULL ; - -return &iport->isci_host->pdev->dev; -} -static inline struct device *scirdev_to_dev (struct isci_remote_device *idev) {if (!idev || !idev->isci_port || !idev->isci_port->isci_host)
drivers/scsi/isci/init.c +1 -6
@@ -233,18 +233,13 @@ static int isci_register_sas_ha(struct isci_host *isci_host)if (!sas_ports)return -ENOMEM ; -/*----------------- Libsas Initialization Stuff---------------------- -* Set various fields in the sas_ha struct: -*/ - sas_ha->sas_ha_name =DRV_NAME ; sas_ha->lldd_module =THIS_MODULE ; sas_ha->sas_addr = &isci_host->phys[0 ].sas_addr[0 ]; -/* set the array of phy and port structs. */ for (i =0 ; i <SCI_MAX_PHYS ; i++) { sas_phys[i] = &isci_host->phys[i].sas_phy; - sas_ports[i] = &isci_host->ports[i].sas_port; + sas_ports[i] = &isci_host->sas_ports[i]; } sas_ha->sas_phy = sas_phys;
drivers/scsi/isci/phy.c +12 -6
@@ -67,6 +67,14 @@ enum sas_linkrate sci_phy_linkrate(struct isci_phy *iphy)return iphy->max_negotiated_speed; } +static struct device *sciphy_to_dev (struct isci_phy *iphy) +{ +struct isci_phy *table = iphy - iphy->phy_index; +struct isci_host *ihost =container_of (table,typeof (*ihost), phys[0 ]); + +return &ihost->pdev->dev; +} +static enum sci_status sci_phy_transport_layer_initialization (struct isci_phy *iphy,struct scu_transport_layer_registers __iomem *reg)
@@ -1249,7 +1257,6 @@ void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index) sas_addr =cpu_to_be64 (sci_sas_addr);memcpy (iphy->sas_addr, &sas_addr,sizeof (sas_addr)); - iphy->isci_port =NULL ; iphy->sas_phy.enabled =0 ; iphy->sas_phy.id = index; iphy->sas_phy.sas_addr = &iphy->sas_addr[0 ];
@@ -1283,13 +1290,13 @@ int isci_phy_control(struct asd_sas_phy *sas_phy, {int ret =0 ;struct isci_phy *iphy = sas_phy->lldd_phy; -struct isci_port *iport = iphy->isci_port; +struct asd_sas_port *port = sas_phy->port;struct isci_host *ihost = sas_phy->ha->lldd_ha;unsigned long flags;dev_dbg (&ihost->pdev->dev,"%s: phy %p; func %d; buf %p; isci phy %p, port %p\n" , - __func__, sas_phy, func, buf, iphy, iport); + __func__, sas_phy, func, buf, iphy, port);switch (func) {case PHY_FUNC_DISABLE :
@@ -1306,11 +1313,10 @@ int isci_phy_control(struct asd_sas_phy *sas_phy,break ;case PHY_FUNC_HARD_RESET : -if (!iport) +if (!port)return -ENODEV ; -/* Perform the port reset. */ - ret =isci_port_perform_hard_reset (ihost, iport, iphy); + ret =isci_port_perform_hard_reset (ihost, port->lldd_port, iphy);break ;case PHY_FUNC_GET_EVENTS : {
drivers/scsi/isci/phy.h +0 -1
@@ -103,7 +103,6 @@ struct isci_phy {struct scu_transport_layer_registers __iomem *transport_layer_registers;struct scu_link_layer_registers __iomem *link_layer_registers;struct asd_sas_phy sas_phy; -struct isci_port *isci_port;u8 sas_addr[SAS_ADDR_SIZE ];union {struct sas_identify_frame iaf;
drivers/scsi/isci/port.c +61 -23
130 lines not on this page · raw message
drivers/scsi/isci/port.h +0 -2
@@ -92,11 +92,9 @@ enum isci_status {struct isci_port {enum isci_status status;struct isci_host *isci_host; -struct asd_sas_port sas_port;struct list_head remote_dev_list;spinlock_t state_lock;struct list_head domain_dev_list; -struct completion start_complete;struct completion hard_reset_complete;enum sci_status hard_reset_status;struct sci_base_state_machine sm;
drivers/scsi/isci/remote_device.c +8 -21
@@ -1377,31 +1377,18 @@ void isci_remote_device_gone(struct domain_device *dev)* * status, zero indicates success. */ -int isci_remote_device_found (struct domain_device *domain_dev) +int isci_remote_device_found (struct domain_device *dev) { -struct isci_host *isci_host =dev_to_ihost (domain_dev); -struct isci_port *isci_port; -struct isci_phy *isci_phy; -struct asd_sas_port *sas_port; -struct asd_sas_phy *sas_phy; +struct isci_host *isci_host =dev_to_ihost (dev); +struct isci_port *isci_port = dev->port->lldd_port;struct isci_remote_device *isci_device;enum sci_status status;dev_dbg (&isci_host->pdev->dev, -"%s: domain_device = %p\n" , __func__, domain_dev); +"%s: domain_device = %p\n" , __func__, dev); -wait_for_start (isci_host); - - sas_port = domain_dev->port; - sas_phy = list_first_entry(&sas_port->phy_list, struct asd_sas_phy, - port_phy_el); - isci_phy =to_iphy (sas_phy); - isci_port = isci_phy->isci_port; - -/* we are being called for a device on this port, -* so it has to come up eventually -*/ -wait_for_completion (&isci_port->start_complete); +if (!isci_port) +return -ENODEV ;if ((isci_stopping ==isci_port_get_state (isci_port)) || (isci_stopped ==isci_port_get_state (isci_port)))
@@ -1415,7 +1402,7 @@ int isci_remote_device_found(struct domain_device *domain_dev)INIT_LIST_HEAD (&isci_device->node);spin_lock_irq (&isci_host->scic_lock); - isci_device->domain_dev = domain_dev; + isci_device->domain_dev = dev; isci_device->isci_port = isci_port;list_add_tail (&isci_device->node, &isci_port->remote_dev_list);
@@ -1428,7 +1415,7 @@ int isci_remote_device_found(struct domain_device *domain_dev)if (status ==SCI_SUCCESS ) {/* device came up, advertise it to the world */ - domain_dev->lldd_dev = isci_device; + dev->lldd_dev = isci_device; }else isci_put_device (isci_device);spin_unlock_irq (&isci_host->scic_lock);
PATCH v7 2/6 libsas: improve debug statements
In reply to Dan WilliamsIt's difficult to determine which domain_device is triggering error recovery, so convert messages like:
sas: ex 5001b4da000e703f phy08:T attached: 5001b4da000e7028
sas: ex 5001b4da000e703f phy09:T attached: 5001b4da000e7029
...
ata7: sas eh calling libata port error handler
ata8: sas eh calling libata port error handler
...into:
sas: ex 5001517e85cfefff phy05:T:9 attached: 5001517e85cfefe5 (stp)
sas: ex 5001517e3b0af0bf phy11:T:8 attached: 5001517e3b0af0ab (stp)
...
sas: ata7: end_device-21:1: dev error handler
sas: ata8: end_device-20:0:5: dev error handler
which shows attached link rate, device type, and associates a domain_device with its ata_port id to correlate messages emitted from libata-eh.
As Doug notes, we can also take the opportunity to clarify expander phy routing capabilities.
--- drivers/scsi/libsas/sas_ata.c | 43 ++++++++++++++++----- drivers/scsi/libsas/sas_expander.c | 74 +++++++++++++++++++++++++----------- 2 files changed, 85 insertions(+), 32 deletions(-)
drivers/scsi/libsas/sas_ata.c +33 -10
@@ -317,6 +317,28 @@ static int local_ata_check_ready(struct ata_link *link) } } +static int sas_ata_printk (const char *level,const struct domain_device *ddev, +const char *fmt, ...) +{ +struct ata_port *ap = ddev->sata_dev.ap; +struct device *dev = &ddev->rphy->dev; +struct va_format vaf; +va_list args; +int r; + +va_start (args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + + r =printk ("%ssas: ata%u: %s: %pV" , + level, ap->print_id,dev_name (dev), &vaf); + +va_end (args); + +return r; +} +static int sas_ata_hard_reset (struct ata_link *link,unsigned int *class,unsigned long deadline) {
@@ -333,7 +355,7 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, res = i->dft->lldd_I_T_nexus_reset (dev);if (res !=TMF_RESP_FUNC_COMPLETE ) -SAS_DPRINTK ("%s: Unable to reset ata device?\n" , __func__); +sas_ata_printk (KERN_DEBUG , dev,"Unable to reset ata device?\n" ); phy =sas_get_local_phy (dev);if (scsi_is_sas_phy_local (phy))
@@ -344,7 +366,7 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class, ret =ata_wait_after_reset (link, deadline, check_ready);if (ret && ret != -EAGAIN ) -ata_link_err (link,"COMRESET failed (errno=%d)\n" , ret); +sas_ata_printk (KERN_ERR , dev,"reset failed (errno=%d)\n" , ret);/* XXX: if the class changes during the reset the upper layer * should be informed, if the device has gone away we assume
@@ -665,7 +687,7 @@ static void async_sas_ata_eh(void *data, async_cookie_t cookie)* remove once all commands are completed */ kref_get (&dev->kref); -ata_port_printk (ap,KERN_DEBUG ,"sas eh calling libata port error handler" ); +sas_ata_printk (KERN_DEBUG , dev,"dev error handler\n" );ata_scsi_port_error_handler (ha->core.shost, ap);sas_put_device (dev);
@@ -708,26 +730,27 @@ void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q, struct list_head *done_q) {struct scsi_cmnd *cmd, *n; -struct ata_port *ap; +struct domain_device *eh_dev; do { LIST_HEAD(sata_q); - - ap = NULL; + eh_dev = NULL; list_for_each_entry_safe(cmd, n, work_q, eh_entry) { struct domain_device *ddev = cmd_to_domain_dev(cmd); if (!dev_is_sata(ddev) || TO_SAS_TASK(cmd)) continue; - if (ap && ap != ddev->sata_dev.ap) + if (eh_dev && eh_dev != ddev) continue; - ap = ddev->sata_dev.ap; + eh_dev = ddev; list_move(&cmd->eh_entry, &sata_q); } if (!list_empty(&sata_q)) { - ata_port_printk(ap, KERN_DEBUG, "sas eh calling libata cmd error handler\n"); + struct ata_port *ap = eh_dev->sata_dev.ap; + + sas_ata_printk(KERN_DEBUG, eh_dev, "cmd error handler\n"); ata_scsi_cmd_error_handler(shost, ap, &sata_q); /* * ata's error handler may leave the cmd on the list
@@ -743,7 +766,7 @@ void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q,while (!list_empty (&sata_q))list_del_init (sata_q.next); } - }while (ap); + }while (eh_dev); }void sas_ata_schedule_reset (struct domain_device *dev)
drivers/scsi/libsas/sas_expander.c +52 -22
120 lines not on this page · raw message
PATCH v7 3/6 libsas: let libata recover links that fail to transmit initial sig-fis
In reply to Dan Williamslibsas fails to discover all sata devices in the domain. If a device fails negotiation and does not transmit a signature fis the link needs recovery. libata already understands how to manage slow to come up links, so treat these conditions as ata device attach events for the purposes of creating an ata_port. This allows libata to manage retrying link bring up.
Rediscovery is modified to be careful about checking changes in dev_type. It looks like libsas leaks old devices if the sas address changes, but that's a fix for another patch.
--- drivers/scsi/libsas/sas_ata.c | 71 +++++++++++++- drivers/scsi/libsas/sas_discover.c | 1 drivers/scsi/libsas/sas_expander.c | 178 ++++++++++++++++++++---------------- drivers/scsi/libsas/sas_internal.h | 6 + include/scsi/sas.h | 4 - include/scsi/sas_ata.h | 8 +- 6 files changed, 179 insertions(+), 89 deletions(-)
drivers/scsi/libsas/sas_ata.c +66 -5
@@ -278,26 +278,84 @@ static struct sas_internal *dev_to_sas_internal(struct domain_device *dev)return to_sas_internal (dev->port->ha->core.shost->transportt); } +static void sas_get_ata_command_set (struct domain_device *dev); + +int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) +{ +if (phy->attached_tproto &SAS_PROTOCOL_STP ) + dev->tproto = phy->attached_tproto; +if (phy->attached_sata_dev) + dev->tproto |=SATA_DEV ; + +if (phy->attached_dev_type ==SATA_PENDING ) + dev->dev_type =SATA_PENDING ; +else { +int res; + + dev->dev_type =SATA_DEV ; + res =sas_get_report_phy_sata (dev->parent, phy->phy_id, + &dev->sata_dev.rps_resp); +if (res) { +SAS_DPRINTK ("report phy sata to %016llx:0x%x returned " +"0x%x\n" ,SAS_ADDR (dev->parent->sas_addr), + phy->phy_id, res); +return res; + } +memcpy (dev->frame_rcvd, &dev->sata_dev.rps_resp.rps.fis, +sizeof (struct dev_to_host_fis )); +/* TODO switch to ata_dev_classify() */ +sas_get_ata_command_set (dev); + } +return 0 ; +} + +static int sas_ata_clear_pending (struct domain_device *dev,struct ex_phy *phy) +{ +int res; + +/* we weren't pending, so successfully end the reset sequence now */ +if (dev->dev_type !=SATA_PENDING ) +return 1 ; + +/* hmmm, if this succeeds do we need to repost the domain_device to the +* lldd so it can pick up new parameters? +*/ + res =sas_get_ata_info (dev, phy); +if (res) +return 0 ;/* retry */ +else +return 1 ; +} +static int smp_ata_check_ready (struct ata_link *link) {int res; -u8 addr[8 ];struct ata_port *ap = link->ap;struct domain_device *dev = ap->private_data;struct domain_device *ex_dev = dev->parent;struct sas_phy *phy =sas_get_local_phy (dev); +struct ex_phy *ex_phy = &ex_dev->ex_dev.ex_phy[phy->number]; - res =sas_get_phy_attached_sas_addr (ex_dev, phy->number, addr); + res =sas_ex_phy_discover (ex_dev, phy->number);sas_put_local_phy (phy); +/* break the wait early if the expander is unreachable, * otherwise keep polling */ if (res == -ECOMM )return res; -if (res !=SMP_RESP_FUNC_ACC ||SAS_ADDR (addr) ==0 ) +if (res !=SMP_RESP_FUNC_ACC )return 0 ; -else -return 1 ; + +switch (ex_phy->attached_dev_type) { +case SATA_PENDING : +return 0 ; +case SAS_END_DEV : +if (ex_phy->attached_sata_dev) +return sas_ata_clear_pending (dev, ex_phy); +default : +return -ENODEV ; + } }static int local_ata_check_ready (struct ata_link *link)
@@ -584,6 +642,9 @@ static void sas_get_ata_command_set(struct domain_device *dev)struct dev_to_host_fis *fis = (struct dev_to_host_fis *) dev->frame_rcvd; +if (dev->dev_type ==SATA_PENDING ) +return ; + if ((fis->sector_count == 1 && /* ATA */ fis->lbal == 1 && fis->lbam == 0 &&
drivers/scsi/libsas/sas_discover.c +1 -0
@@ -48,6 +48,7 @@ void sas_init_dev(struct domain_device *dev)case SATA_DEV :case SATA_PM :case SATA_PM_PORT : +case SATA_PENDING :INIT_LIST_HEAD (&dev->sata_dev.children);break ;default :
drivers/scsi/libsas/sas_expander.c +99 -79
289 lines not on this page · raw message
drivers/scsi/libsas/sas_internal.h +4 -2
@@ -91,8 +91,9 @@ int sas_smp_get_phy_events(struct sas_phy *phy);void sas_device_set_phy (struct domain_device *dev,struct sas_port *port);struct domain_device *sas_find_dev_by_rphy (struct sas_rphy *rphy);struct domain_device *sas_ex_to_ata (struct domain_device *ex_dev,int phy_id); -int sas_get_phy_attached_sas_addr (struct domain_device *dev,int phy_id, -u8 *attached_sas_addr); +int sas_ex_phy_discover (struct domain_device *dev,int single); +int sas_get_report_phy_sata (struct domain_device *dev,int phy_id, +struct smp_resp *rps_resp);int sas_try_ata_reset (struct asd_sas_phy *phy);void sas_hae_reset (struct work_struct *work);
@@ -122,6 +123,7 @@ static inline void sas_fill_in_rphy(struct domain_device *dev,case SATA_DEV :/* FIXME: need sata device type */ case SAS_END_DEV : +case SATA_PENDING : rphy->identify.device_type =SAS_END_DEVICE ;break ;case EDGE_DEV :
include/scsi/sas.h +2 -2
@@ -89,8 +89,7 @@ enum sas_oob_mode {SAS_OOB_MODE }; -/* See sas_discover.c if you plan on changing these. -*/ +/* See sas_discover.c if you plan on changing these */ enum sas_dev_type {NO_DEVICE =0 ,/* protocol */ SAS_END_DEV =1 ,/* protocol */
@@ -100,6 +99,7 @@ enum sas_dev_type {SATA_DEV =5 ,SATA_PM =7 ,SATA_PM_PORT =8 , + SATA_PENDING = 9, }; enum sas_protocol {
include/scsi/sas_ata.h +7 -1
@@ -33,9 +33,10 @@static inline int dev_is_sata (struct domain_device *dev) {return dev->dev_type ==SATA_DEV || dev->dev_type ==SATA_PM || - dev->dev_type ==SATA_PM_PORT ; + dev->dev_type ==SATA_PM_PORT || dev->dev_type ==SATA_PENDING ; } +int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy);int sas_ata_init_host_and_port (struct domain_device *found_dev,struct scsi_target *starget);
@@ -82,6 +83,11 @@ static inline void sas_ata_schedule_reset(struct domain_device *dev)static inline void sas_ata_wait_eh (struct domain_device *dev) { } + +static inline int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) +{ +return 0 ; +}#endif #endif /* _SAS_ATA_H_ */
PATCH v7 4/6 libsas: async ata scanning
In reply to Dan Williamslibsas ata error handling is already async but this does not help the scan case. Move initial link recovery out from under host->scan_mutex, and delay synchronization with eh until after all port probe/recovery work has been queued.
Device ordering is maintained with scan order by still calling sas_rphy_add() in order of domain discovery.
Since we now scan the domain list when invoking libata-eh we need to be careful to check for fully initialized ata ports.
--- drivers/ata/libata-core.c | 34 +++++++++------- drivers/ata/libata-scsi.c | 13 ++++++ drivers/ata/libata.h | 1 drivers/scsi/aic94xx/aic94xx_init.c | 1 drivers/scsi/isci/init.c | 1 drivers/scsi/libsas/sas_ata.c | 74 ++++++++++++++++++++++++++++++----- drivers/scsi/libsas/sas_discover.c | 22 +++++----- drivers/scsi/libsas/sas_internal.h | 9 ++++ drivers/scsi/libsas/sas_scsi_host.c | 18 --------- drivers/scsi/mvsas/mv_init.c | 1 drivers/scsi/pm8001/pm8001_init.c | 1 include/linux/libata.h | 1 include/scsi/libsas.h | 1 include/scsi/sas_ata.h | 12 +++--- 14 files changed, 123 insertions(+), 66 deletions(-)
drivers/ata/libata-core.c +18 -16
@@ -5874,29 +5874,31 @@ void ata_host_init(struct ata_host *host, struct device *dev, host->ops = ops; } -int ata_port_probe (struct ata_port *ap) +void __ata_port_probe (struct ata_port *ap) { -int rc =0 ; +struct ata_eh_info *ehi = &ap->link.eh_info; +unsigned long flags; -/* probe */ -if (ap->ops->error_handler) { -struct ata_eh_info *ehi = &ap->link.eh_info; -unsigned long flags; +/* kick EH for boot probing */ +spin_lock_irqsave (ap->lock, flags); -/* kick EH for boot probing */ -spin_lock_irqsave (ap->lock, flags); + ehi->probe_mask |=ATA_ALL_DEVICES ; + ehi->action |=ATA_EH_RESET ; + ehi->flags |=ATA_EHI_NO_AUTOPSY |ATA_EHI_QUIET ; - ehi->probe_mask |=ATA_ALL_DEVICES ; - ehi->action |=ATA_EH_RESET ; - ehi->flags |=ATA_EHI_NO_AUTOPSY |ATA_EHI_QUIET ; + ap->pflags &= ~ATA_PFLAG_INITIALIZING ; + ap->pflags |=ATA_PFLAG_LOADING ; +ata_port_schedule_eh (ap); - ap->pflags &= ~ATA_PFLAG_INITIALIZING ; - ap->pflags |=ATA_PFLAG_LOADING ; -ata_port_schedule_eh (ap); +spin_unlock_irqrestore (ap->lock, flags); +} -spin_unlock_irqrestore (ap->lock, flags); +int ata_port_probe (struct ata_port *ap) +{ +int rc =0 ; -/* wait for EH to finish */ +if (ap->ops->error_handler) { +__ata_port_probe (ap);ata_port_wait_eh (ap); }else {DPRINTK ("ata%u: bus probe begin\n" , ap->print_id);
drivers/ata/libata-scsi.c +13 -0
@@ -3837,6 +3837,19 @@ void ata_sas_port_stop(struct ata_port *ap) }EXPORT_SYMBOL_GPL (ata_sas_port_stop); +int ata_sas_async_port_init (struct ata_port *ap) +{ +int rc = ap->ops->port_start (ap); + +if (!rc) { + ap->print_id = ata_print_id++; +__ata_port_probe (ap); + } + +return rc; +} +EXPORT_SYMBOL_GPL (ata_sas_async_port_init); +/** * ata_sas_port_init - Initialize a SATA device * @ap: SATA port to initialize
drivers/ata/libata.h +1 -0
@@ -104,6 +104,7 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);extern struct ata_port *ata_port_alloc (struct ata_host *host);extern const char *sata_spd_string (unsigned int spd);extern int ata_port_probe (struct ata_port *ap); +extern void __ata_port_probe (struct ata_port *ap);/* libata-acpi.c */ #ifdef CONFIG_ATA_ACPI
drivers/scsi/aic94xx/aic94xx_init.c +0 -1
@@ -81,7 +81,6 @@ static struct scsi_host_template aic94xx_sht = { .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler, .eh_bus_reset_handler = sas_eh_bus_reset_handler, - .slave_alloc = sas_slave_alloc, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, };
drivers/scsi/isci/init.c +0 -1
@@ -157,7 +157,6 @@ static struct scsi_host_template isci_sht = { .sg_tablesize = SG_ALL, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, - .slave_alloc = sas_slave_alloc, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = isci_host_attrs,
drivers/scsi/libsas/sas_ata.c +63 -11
111 lines not on this page · raw message
drivers/scsi/libsas/sas_discover.c +11 -11
@@ -207,22 +207,22 @@ static void sas_probe_devices(struct work_struct *work)clear_bit (DISCE_PROBE , &port->disc.pending); -list_for_each_entry_safe (dev, n, &port->disco_list, disco_list_node) { -int err; - +/* devices must be domain members before link recovery and probe */ +list_for_each_entry (dev, &port->disco_list, disco_list_node) {spin_lock_irq (&port->dev_list_lock);list_add_tail (&dev->dev_list_node, &port->dev_list);spin_unlock_irq (&port->dev_list_lock); + } - err =sas_rphy_add (dev->rphy); +sas_probe_sata (port); -if (err) { -SAS_DPRINTK ("%s: for %s device %16llx returned %d\n" , - __func__, dev->parent ?"exp-attached" : -"direct-attached" , -SAS_ADDR (dev->sas_addr), err); -sas_unregister_dev (port, dev); - }else +list_for_each_entry_safe (dev, n, &port->disco_list, disco_list_node) { +int err; + + err =sas_rphy_add (dev->rphy); +if (err) +sas_fail_probe (dev, __func__, err); +else list_del_init (&dev->disco_list_node); } }
drivers/scsi/libsas/sas_internal.h +9 -0
@@ -113,6 +113,15 @@ static inline int sas_smp_host_handler(struct Scsi_Host *shost, }#endif +static inline void sas_fail_probe (struct domain_device *dev,const char *func,int err) +{ +SAS_DPRINTK ("%s: for %s device %16llx returned %d\n" , + func, dev->parent ?"exp-attached" : +"direct-attached" , +SAS_ADDR (dev->sas_addr), err); +sas_unregister_dev (dev->port, dev); +} +static inline void sas_fill_in_rphy (struct domain_device *dev,struct sas_rphy *rphy) {
drivers/scsi/libsas/sas_scsi_host.c +0 -18
@@ -762,17 +762,10 @@ int sas_target_alloc(struct scsi_target *starget) {struct sas_rphy *rphy =dev_to_rphy (starget->dev.parent);struct domain_device *found_dev =sas_find_dev_by_rphy (rphy); -int res;if (!found_dev)return -ENODEV ; -if (dev_is_sata (found_dev)) { - res =sas_ata_init_host_and_port (found_dev, starget); -if (res) -return res; - } -kref_get (&found_dev->kref); starget->hostdata = found_dev;return 0 ;
@@ -1012,16 +1005,6 @@ void sas_task_abort(struct sas_task *task) } } -int sas_slave_alloc (struct scsi_device *scsi_dev) -{ -struct domain_device *dev =sdev_to_domain_dev (scsi_dev); - -if (dev_is_sata (dev)) -return ata_sas_port_init (dev->sata_dev.ap); - -return 0 ; -} -void sas_target_destroy (struct scsi_target *starget) {struct domain_device *found_dev = starget->hostdata;
@@ -1082,6 +1065,5 @@ EXPORT_SYMBOL_GPL(sas_task_abort);EXPORT_SYMBOL_GPL (sas_phy_reset);EXPORT_SYMBOL_GPL (sas_eh_device_reset_handler);EXPORT_SYMBOL_GPL (sas_eh_bus_reset_handler); -EXPORT_SYMBOL_GPL (sas_slave_alloc);EXPORT_SYMBOL_GPL (sas_target_destroy);EXPORT_SYMBOL_GPL (sas_ioctl);
drivers/scsi/mvsas/mv_init.c +0 -1
@@ -73,7 +73,6 @@ static struct scsi_host_template mvs_sht = { .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler, .eh_bus_reset_handler = sas_eh_bus_reset_handler, - .slave_alloc = sas_slave_alloc, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = mvst_host_attrs,
drivers/scsi/pm8001/pm8001_init.c +0 -1
@@ -75,7 +75,6 @@ static struct scsi_host_template pm8001_sht = { .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler, .eh_bus_reset_handler = sas_eh_bus_reset_handler, - .slave_alloc = sas_slave_alloc, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .shost_attrs = pm8001_host_attrs,
include/linux/libata.h +1 -0
@@ -996,6 +996,7 @@ extern int ata_sas_scsi_ioctl(struct ata_port *ap, struct scsi_device *dev,extern void ata_sas_port_destroy (struct ata_port *);extern struct ata_port *ata_sas_port_alloc (struct ata_host *,struct ata_port_info *,struct Scsi_Host *); +extern int ata_sas_async_port_init (struct ata_port *);extern int ata_sas_port_init (struct ata_port *);extern int ata_sas_port_start (struct ata_port *ap);extern void ata_sas_port_stop (struct ata_port *ap);
include/scsi/libsas.h +0 -1
@@ -646,7 +646,6 @@ int sas_phy_reset(struct sas_phy *phy, int hard_reset);int sas_queue_up (struct sas_task *task);extern int sas_queuecommand (struct Scsi_Host * ,struct scsi_cmnd *);extern int sas_target_alloc (struct scsi_target *); -extern int sas_slave_alloc (struct scsi_device *);extern int sas_slave_configure (struct scsi_device *);extern int sas_change_queue_depth (struct scsi_device *,int new_depth,int reason);
include/scsi/sas_ata.h +7 -5
@@ -37,15 +37,14 @@ static inline int dev_is_sata(struct domain_device *dev) }int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy); -int sas_ata_init_host_and_port (struct domain_device *found_dev, -struct scsi_target *starget); - +int sas_ata_init_host_and_port (struct domain_device *found_dev);void sas_ata_task_abort (struct sas_task *task);void sas_ata_strategy_handler (struct Scsi_Host *shost);void sas_ata_eh (struct Scsi_Host *shost,struct list_head *work_q,struct list_head *done_q);void sas_ata_schedule_reset (struct domain_device *dev);void sas_ata_wait_eh (struct domain_device *dev); +void sas_probe_sata (struct asd_sas_port *port);#else
@@ -53,8 +52,7 @@ static inline int dev_is_sata(struct domain_device *dev) {return 0 ; } -static inline int sas_ata_init_host_and_port (struct domain_device *found_dev, -struct scsi_target *starget) +static inline int sas_ata_init_host_and_port (struct domain_device *found_dev) {return 0 ; }
@@ -79,6 +77,10 @@ static inline void sas_ata_wait_eh(struct domain_device *dev) { } +static inline void sas_probe_sata (struct asd_sas_port *port) +{ +} +static inline int sas_get_ata_info (struct domain_device *dev,struct ex_phy *phy) {return 0 ;
PATCH v7 5/6 libsas: fix lifetime of SAS_HA_FROZEN
In reply to Dan WilliamsUntil all sas_tasks are known to no longer be in-flight this flag gates late completions from colliding with error handling. However, it must be cleared prior to the submission of scsi_send_eh_cmnd() requests, otherwise those commands will never be completed correctly.
This was spotted by slub debug:
=============================================================================
BUG sas_task: Objects remaining on kmem_cache_close()
-----------------------------------------------------------------------------
INFO: Slab 0xffffea001f0eba00 objects=34 used=1 fp=0xffff8807c3aecb00 flags=0x8000000000004080
Pid: 22919, comm: modprobe Not tainted 3.2.0-isci+ #2
Call Trace: [<ffffffff810fcdcd>] slab_err+0xb0/0xd2 [<ffffffff810e1c50>] ? free_percpu+0x31/0x117 [<ffffffff81100122>] ? kzalloc+0x14/0x16 [<ffffffff81100122>] ? kzalloc+0x14/0x16 [<ffffffff81100486>] kmem_cache_destroy+0x11d/0x270 [<ffffffffa0112bdc>] sas_class_exit+0x10/0x12 [libsas] [<ffffffff81078fba>] sys_delete_module+0x1c4/0x23c [<ffffffff814797ba>] ? sysret_check+0x2e/0x69 [<ffffffff8126479e>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff81479782>] system_call_fastpath+0x16/0x1b INFO: Object 0xffff8807c3aed280 @offset=21120 INFO: Allocated in sas_alloc_task+0x22/0x90 [libsas] age=4615311 cpu=2 pid=12966 __slab_alloc.clone.3+0x1d1/0x234 kmem_cache_alloc+0x52/0x10d sas_alloc_task+0x22/0x90 [libsas] sas_queuecommand+0x20e/0x230 [libsas] scsi_send_eh_cmnd+0xd1/0x30c scsi_eh_try_stu+0x4f/0x6b scsi_eh_ready_devs+0xba/0x6ef sas_scsi_recover_host+0xa35/0xab1 [libsas] scsi_error_handler+0x14b/0x5fa kthread+0x9d/0xa5 kernel_thread_helper+0x4/0x10
--- drivers/scsi/libsas/sas_scsi_host.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +7 -6
@@ -521,8 +521,7 @@ try_bus_reset:return FAILED ; } -static int sas_eh_handle_sas_errors (struct Scsi_Host *shost, -struct list_head *work_q) +static void sas_eh_handle_sas_errors (struct Scsi_Host *shost,struct list_head *work_q) {struct scsi_cmnd *cmd, *n;enum task_disposition res =TASK_IS_DONE ;
@@ -658,7 +657,7 @@ static int sas_eh_handle_sas_errors(struct Scsi_Host *shost, out:list_splice_tail (&done, work_q);list_splice_tail_init (&ha->eh_ata_q, work_q); -return list_empty (work_q); +return ; clear_q:SAS_DPRINTK ("--- Exit %s -- clear_q\n" , __func__);
@@ -682,10 +681,13 @@ void sas_scsi_recover_host(struct Scsi_Host *shost) __func__, shost->host_busy, shost->host_failed);/* * Deal with commands that still have SAS tasks (i.e. they didn't -* complete via the normal sas_task completion mechanism) +* complete via the normal sas_task completion mechanism), +* SAS_HA_FROZEN gives eh dominion over all sas_task completion. */ set_bit (SAS_HA_FROZEN , &ha->state); -if (sas_eh_handle_sas_errors (shost, &eh_work_q)) +sas_eh_handle_sas_errors (shost, &eh_work_q); +clear_bit (SAS_HA_FROZEN , &ha->state); +if (list_empty (&eh_work_q)) goto out;/*
@@ -699,7 +701,6 @@ void sas_scsi_recover_host(struct Scsi_Host *shost)scsi_eh_ready_devs (shost, &eh_work_q, &ha->eh_done_q); out: -clear_bit (SAS_HA_FROZEN , &ha->state);if (ha->lldd_max_execute_num >1 )wake_up_process (ha->core.queue_thread);
PATCH v7 6/6 libsas: revert ata srst
In reply to Dan Williamslibata issues follow up srsts when the controller has a hard time recording the signature-fis after a reset, or if the link supports port multipliers. libsas does not support port multipliers and no current libsas lldds appear to need help retrieving the signature fis. Revert it for now to remove confusion.
--- drivers/scsi/libsas/sas_ata.c | 38 -------------------------------------- include/scsi/libsas.h | 1 - 2 files changed, 0 insertions(+), 39 deletions(-)
drivers/scsi/libsas/sas_ata.c +0 -38
@@ -443,43 +443,6 @@ static int sas_ata_hard_reset(struct ata_link *link, unsigned int *class,return ret; } -static int sas_ata_soft_reset (struct ata_link *link,unsigned int *class, -unsigned long deadline) -{ -struct ata_port *ap = link->ap; -struct domain_device *dev = ap->private_data; -struct sas_internal *i =dev_to_sas_internal (dev); -int res =TMF_RESP_FUNC_FAILED ; -int ret =0 ; - -if (i->dft->lldd_ata_soft_reset) - res = i->dft->lldd_ata_soft_reset (dev); - -if (res !=TMF_RESP_FUNC_COMPLETE ) { -SAS_DPRINTK ("%s: Unable to soft reset\n" , __func__); - ret = -EAGAIN ; - } - -switch (dev->sata_dev.command_set) { -case ATA_COMMAND_SET : -SAS_DPRINTK ("%s: Found ATA device.\n" , __func__); - *class =ATA_DEV_ATA ; -break ; -case ATAPI_COMMAND_SET : -SAS_DPRINTK ("%s: Found ATAPI device.\n" , __func__); - *class =ATA_DEV_ATAPI ; -break ; -default : -SAS_DPRINTK ("%s: Unknown SATA command set: %d.\n" , - __func__, dev->sata_dev.command_set); - *class =ATA_DEV_UNKNOWN ; -break ; - } - - ap->cbl =ATA_CBL_SATA ; -return ret; -} -/* * notify the lldd to forget the sas_task for this internal ata command * that bypasses scsi-eh
@@ -563,7 +526,6 @@ static void sas_ata_set_dmamode(struct ata_port *ap, struct ata_device *ata_dev)static struct ata_port_operations sas_sata_ops = { .prereset = ata_std_prereset, - .softreset = sas_ata_soft_reset, .hardreset = sas_ata_hard_reset, .postreset = ata_std_postreset, .error_handler = ata_std_error_handler,
include/scsi/libsas.h +0 -1
@@ -619,7 +619,6 @@ struct sas_domain_function_template {int (*lldd_clear_aca)(struct domain_device *,u8 *lun);int (*lldd_clear_task_set)(struct domain_device *,u8 *lun);int (*lldd_I_T_nexus_reset)(struct domain_device *); -int (*lldd_ata_soft_reset)(struct domain_device *);int (*lldd_ata_check_ready)(struct domain_device *);void (*lldd_ata_set_dmamode)(struct domain_device *);int (*lldd_lu_reset)(struct domain_device *,u8 *lun);