From patchwork Fri Oct 9 17:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11826909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A0FE109B for ; Fri, 9 Oct 2020 17:14:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E921022265 for ; Fri, 9 Oct 2020 17:14:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="bJGYk0rW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733075AbgJIROj (ORCPT ); Fri, 9 Oct 2020 13:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgJIROb (ORCPT ); Fri, 9 Oct 2020 13:14:31 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5CD7C0613D5 for ; Fri, 9 Oct 2020 10:14:31 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x13so4776615pfa.9 for ; Fri, 09 Oct 2020 10:14:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SF1gi20AYFwbj6S4mgnFZSZs57yPB1dR67FeE9iWWGU=; b=bJGYk0rWhex4V0Dt013ZjWPJfr9EJqipUXUqA6qwgB2ShTRqtCoBIsC3HuVkdGSaF9 cUOQ12Zf78QdnhMHVBknbXdh7EkIH7P//SBUWpmjy+lXqV4DZETIIp3dcFUk8vkTZ2Z+ bRpFLCYyVTf/R8IsOxHRml9Pt5ZBrwdfFKs3w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SF1gi20AYFwbj6S4mgnFZSZs57yPB1dR67FeE9iWWGU=; b=H/znNntd46FSd8QsXEgpw6kHuP8XW/zljWZRzaoJ8Bjc7ZjG2Yu5fxEY5MI7jBwZqG KN/P/wjYsG6ddMuoQ1FvHjqsFbc7yuv1Z56bBR83Qj/fUHmsLac4dOW7eQUCHZZuVqNh LQuFck8ij94DCWHVrMG/UL2GL6VvqjyjYop2MAiHY3Y+FJ3MMC5XX2LEci7SHNbHJ+YY UjHYNsZFHES+XM1s9S+3iV+hJ2C/JZDhgHhEww3d4fqQ5SR1B93Yrlr19t6eGpfZ6rmW /i8AdTl2meoIHil08x6kCwqWiFjjll7aEYuM39/mItec91W9expRUNTCSmN/O1WLoJBp k6Hw== X-Gm-Message-State: AOAM533M3RIKqVvkiaR+eoRkHGWrFAK2PVLM+mUZD5R78r5wRUp0RWC0 pMB7kwtF6DVMijgJTL7Yjl4Uhg== X-Google-Smtp-Source: ABdhPJzUBZIMK+ZQL3EEOFrjEXX++w9obpQyOgKA45GjRb/XuO2DwZ/7F6u6qhUgroAM+b2KRaUwaQ== X-Received: by 2002:a62:c1c5:0:b029:155:2a10:504f with SMTP id i188-20020a62c1c50000b02901552a10504fmr11386452pfg.13.1602263671068; Fri, 09 Oct 2020 10:14:31 -0700 (PDT) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id fy24sm12299055pjb.35.2020.10.09.10.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 10:14:30 -0700 (PDT) From: Sreekanth Reddy To: martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, sathya.prakash@broadcom.com, suganath-prabu.subramani@broadcom.com, Sreekanth Reddy Subject: [PATCH 06/14] mpt3sas: Rename transport_del_phy_from_an_existing_port Date: Fri, 9 Oct 2020 22:44:32 +0530 Message-Id: <20201009171440.4949-7-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20201009171440.4949-1-sreekanth.reddy@broadcom.com> References: <20201009171440.4949-1-sreekanth.reddy@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org * Renamed _transport_add_phy_to_an_existing_port to mpt3sas_transport_add_phy_to_an_existing_port & _transport_del_phy_from_an_existing_port to mpt3sas_transport_del_phy_from_an_existing_port, as driver has to call these functions from outside mpt3sas_transport.c file now. * Added extra function argument 'port' of type struct hba_port in above renamed functions. * Also in above functions, check for portID before adding/removing the phy from the _sas_port object. i.e. add/remove the phy from _sas_port object only if _sas_port's port object and phy's port object are the same. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.h | 7 +++++ drivers/scsi/mpt3sas/mpt3sas_transport.c | 35 ++++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index b5d1fc5..24db627 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1811,6 +1811,13 @@ void mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, struct hba_port *port); extern struct sas_function_template mpt3sas_transport_functions; extern struct scsi_transport_template *mpt3sas_transport_template; +void +mpt3sas_transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc, + struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy); +void +mpt3sas_transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, + struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy, + u64 sas_address, struct hba_port *port); /* trigger data externs */ void mpt3sas_send_trigger_data_event(struct MPT3SAS_ADAPTER *ioc, struct SL_WH_TRIGGERS_EVENT_DATA_T *event_data); diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 54c004e..560ce32 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -503,16 +503,17 @@ _transport_add_phy(struct MPT3SAS_ADAPTER *ioc, struct _sas_port *mpt3sas_port, } /** - * _transport_add_phy_to_an_existing_port - adding new phy to existing port + * mpt3sas_transport_add_phy_to_an_existing_port - adding new phy to existing port * @ioc: per adapter object * @sas_node: sas node object (either expander or sas host) * @mpt3sas_phy: mpt3sas per phy object * @sas_address: sas address of device/expander were phy needs to be added to + * @port: hba port entry */ -static void -_transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, +void +mpt3sas_transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy, - u64 sas_address) + u64 sas_address, struct hba_port *port) { struct _sas_port *mpt3sas_port; struct _sas_phy *phy_srch; @@ -520,11 +521,16 @@ _transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, if (mpt3sas_phy->phy_belongs_to_port == 1) return; + if (!port) + return; + list_for_each_entry(mpt3sas_port, &sas_node->sas_port_list, port_list) { if (mpt3sas_port->remote_identify.sas_address != sas_address) continue; + if (mpt3sas_port->hba_port != port) + continue; list_for_each_entry(phy_srch, &mpt3sas_port->phy_list, port_siblings) { if (phy_srch == mpt3sas_phy) @@ -537,13 +543,13 @@ _transport_add_phy_to_an_existing_port(struct MPT3SAS_ADAPTER *ioc, } /** - * _transport_del_phy_from_an_existing_port - delete phy from existing port + * mpt3sas_transport_del_phy_from_an_existing_port - delete phy from existing port * @ioc: per adapter object * @sas_node: sas node object (either expander or sas host) * @mpt3sas_phy: mpt3sas per phy object */ -static void -_transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc, +void +mpt3sas_transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc, struct _sas_node *sas_node, struct _sas_phy *mpt3sas_phy) { struct _sas_port *mpt3sas_port, *next; @@ -559,7 +565,11 @@ _transport_del_phy_from_an_existing_port(struct MPT3SAS_ADAPTER *ioc, if (phy_srch != mpt3sas_phy) continue; - if (mpt3sas_port->num_phys == 1) + /* + * Don't delete port during host reset, + * just delete phy. + */ + if (mpt3sas_port->num_phys == 1 && !ioc->shost_recovery) _transport_delete_port(ioc, mpt3sas_port); else _transport_delete_phy(ioc, mpt3sas_port, @@ -590,8 +600,8 @@ _transport_sanity_check(struct MPT3SAS_ADAPTER *ioc, struct _sas_node *sas_node, if (sas_node->phy[i].port != port) continue; if (sas_node->phy[i].phy_belongs_to_port == 1) - _transport_del_phy_from_an_existing_port(ioc, sas_node, - &sas_node->phy[i]); + mpt3sas_transport_del_phy_from_an_existing_port(ioc, + sas_node, &sas_node->phy[i]); } } @@ -1040,8 +1050,6 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, if (handle && (link_rate >= MPI2_SAS_NEG_LINK_RATE_1_5)) { _transport_set_identify(ioc, handle, &mpt3sas_phy->remote_identify); - _transport_add_phy_to_an_existing_port(ioc, sas_node, - mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address); if (sas_node->handle <= ioc->sas_hba.num_phys) { list_for_each_entry(hba_port, &ioc->port_table_list, list) { @@ -1051,6 +1059,9 @@ mpt3sas_transport_update_links(struct MPT3SAS_ADAPTER *ioc, (1 << mpt3sas_phy->phy_id); } } + mpt3sas_transport_add_phy_to_an_existing_port(ioc, sas_node, + mpt3sas_phy, mpt3sas_phy->remote_identify.sas_address, + port); } else memset(&mpt3sas_phy->remote_identify, 0 , sizeof(struct sas_identify));