From patchwork Fri Apr 12 08:57:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 162097 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp364741jan; Fri, 12 Apr 2019 01:58:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+n+DKRFG4ZS/Go5ReBsLfoTBr5HoKn/4jCDVZYC+7OJrNVT3FnFaPb9JlClTYAwUDKUBG X-Received: by 2002:a17:902:56e:: with SMTP id 101mr6784317plf.142.1555059512264; Fri, 12 Apr 2019 01:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555059512; cv=none; d=google.com; s=arc-20160816; b=xtXHIRo6ZyWjCbv+bRuLbToWWmUY59aLeBRip5veLBvIos5q2L+iouuXGqWJ0kb8Uc ssWt4OXS7MmEdI9UwUjKztpwuq4bNzO8dy37E7pUMbkPQE0Ji87D3uwj/EUUG2S+jvur XeS7Rho4aOGdYINqmRBRa6EDBZFnFfwoOjsj8p/HgOlBur7eDkJr2hA79qfcMWscu63m Ib2Wo5veAr6YTX/okMN6RY5S3Hq50Buid8zYPTQZCyi4lZIg3WATB2oieUKOgaU2uNEs jC3BAd3xYzEsby+fsjIfsM9X/cQ6kH2TQScmrLf6K/MDSqoApqhLUxEDTfsois7L5YqT v6lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=zBaka+U9w2QfrrJ17+PW+qcM5J1+VIbWaaJFF9slFcc=; b=CXy7HCP0sr8KB04RDUCaaB6C2QWFLr1+UWLPAlW5dNpaITeJjPYIBPzwOnt/7buw9e aPmiOg2dtRa8IXxPDJahZ76VGJa/MAWxcDJNdL0H5/CsOxa8HvfYcvJEwnJJDdFZEvjV n1kpUuV6nBFIk4TcEaAwJlgLNXt/A1auzlf+imOg6b9k9QBBBFuwFVpV64w0SAkvNO07 cs9ufNUERV/W1zzqVyXoGDzBgJOd9m1Z9MrMLytOAvLyn2haD/Ttz3TLms9PRSeEcVr/ ntYBxFGoY3bxXtQC2duXcXPzZa+DUSvhMtcmrILPShwmrSEDsLZm+P9Rlyuq/Q6Rey6Y irzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2si36052809pgt.494.2019.04.12.01.58.31; Fri, 12 Apr 2019 01:58:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbfDLI6a (ORCPT + 31 others); Fri, 12 Apr 2019 04:58:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6735 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727278AbfDLI61 (ORCPT ); Fri, 12 Apr 2019 04:58:27 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id B481B12ED4669CC8B778; Fri, 12 Apr 2019 16:58:24 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Fri, 12 Apr 2019 16:58:16 +0800 From: John Garry To: , CC: , , , , , , John Garry Subject: [PATCH 4/6] scsi: libsas: Inject revalidate event for root port event Date: Fri, 12 Apr 2019 16:57:55 +0800 Message-ID: <1555059478-36224-5-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1555059478-36224-1-git-send-email-john.garry@huawei.com> References: <1555059478-36224-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/scsi/libsas/sas_port.c | 24 +++++++++++++++++++++--- include/scsi/libsas.h | 7 +++++++ 2 files changed, 28 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c index 03fe479359b6..38a10478605c 100644 --- a/drivers/scsi/libsas/sas_port.c +++ b/drivers/scsi/libsas/sas_port.c @@ -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; } diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index cfaaf1254211..b08febec7895 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -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);