]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
scsi: libsas: Inject revalidate event for root port event
authorJohn Garry <john.garry@huawei.com>
Fri, 12 Apr 2019 08:57:55 +0000 (16:57 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 15 Apr 2019 22:55:00 +0000 (18:55 -0400)
According to the SAS spec, an expander device shall transmit BROADCAST
(CHANGE) from at least one phy in each expander port other than the
expander port that is the cause for transmitting BROADCAST (CHANGE).

As such, for when the link is lost for a root PHY attached to an expander
PHY, we get no broadcast event.

This causes an issue for libsas, in that we will not revalidate the domain
for these events.

As a solution, for when a root PHY is formed or deformed from a root port,
insert a broadcast event to trigger a domain revalidation.

Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/libsas/sas_port.c
include/scsi/libsas.h

index 03fe479359b6f0b34ac07072a737bed479e2b7c8..38a10478605cb0662f2a724061236fd95cef90e4 100644 (file)
@@ -95,6 +95,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
        int i;
        struct sas_ha_struct *sas_ha = phy->ha;
        struct asd_sas_port *port = phy->port;
+       struct domain_device *port_dev;
        struct sas_internal *si =
                to_sas_internal(sas_ha->core.shost->transportt);
        unsigned long flags;
@@ -153,8 +154,9 @@ static void sas_form_port(struct asd_sas_phy *phy)
        }
 
        /* add the phy to the port */
+       port_dev = port->port_dev;
        list_add_tail(&phy->port_phy_el, &port->phy_list);
-       sas_phy_set_target(phy, port->port_dev);
+       sas_phy_set_target(phy, port_dev);
        phy->port = port;
        port->num_phys++;
        port->phy_mask |= (1U << phy->id);
@@ -184,14 +186,21 @@ static void sas_form_port(struct asd_sas_phy *phy)
                 port->phy_mask,
                 SAS_ADDR(port->attached_sas_addr));
 
-       if (port->port_dev)
-               port->port_dev->pathways = port->num_phys;
+       if (port_dev)
+               port_dev->pathways = port->num_phys;
 
        /* Tell the LLDD about this port formation. */
        if (si->dft->lldd_port_formed)
                si->dft->lldd_port_formed(phy);
 
        sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN);
+       /* Only insert a revalidate event after initial discovery */
+       if (port_dev && sas_dev_type_is_expander(port_dev->dev_type)) {
+               struct expander_device *ex_dev = &port_dev->ex_dev;
+
+               ex_dev->ex_change_count = -1;
+               sas_discover_event(port, DISCE_REVALIDATE_DOMAIN);
+       }
        flush_workqueue(sas_ha->disco_q);
 }
 
@@ -254,6 +263,15 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone)
        spin_unlock(&port->phy_list_lock);
        spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags);
 
+       /* Only insert revalidate event if the port still has members */
+       if (port->port && dev && sas_dev_type_is_expander(dev->dev_type)) {
+               struct expander_device *ex_dev = &dev->ex_dev;
+
+               ex_dev->ex_change_count = -1;
+               sas_discover_event(port, DISCE_REVALIDATE_DOMAIN);
+       }
+       flush_workqueue(sas_ha->disco_q);
+
        return;
 }
 
index cfaaf1254211a11ffe25c0ac6860dea1df3e7f25..b08febec789563cb7730ae9d451869f6c8174d54 100644 (file)
@@ -224,6 +224,13 @@ struct sas_work {
        struct work_struct work;
 };
 
+/* Lots of code duplicates this in the SCSI tree, which can be factored out */
+static inline bool sas_dev_type_is_expander(enum sas_device_type type)
+{
+       return type == SAS_EDGE_EXPANDER_DEVICE ||
+              type == SAS_FANOUT_EXPANDER_DEVICE;
+}
+
 static inline void INIT_SAS_WORK(struct sas_work *sw, void (*fn)(struct work_struct *))
 {
        INIT_WORK(&sw->work, fn);