From patchwork Fri Oct 9 17:14:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 11826937 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 CB83E109B for ; Fri, 9 Oct 2020 17:14:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CFC022267 for ; Fri, 9 Oct 2020 17:14:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="iNYk3zso" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732999AbgJIROt (ORCPT ); Fri, 9 Oct 2020 13:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731745AbgJIROr (ORCPT ); Fri, 9 Oct 2020 13:14:47 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30AD3C0613D5 for ; Fri, 9 Oct 2020 10:14:47 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id 7so7672913pgm.11 for ; Fri, 09 Oct 2020 10:14:47 -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=d6J1fjKXrnaRDwolj8h8mOhIFSxetmOlRplJZt5LDHU=; b=iNYk3zso6OR7jIeR9ciW3l5Op2KGVw8l+K85qTIRtRO8dQGUnQgojtuTlStvcGDTA7 BjLKIzEgjXsa9DceEkH956sJH0U11JYzhvDEcJ3WW5RSmufsLFnEuWINcut4zGiuO1Yz Z6aaZJ58loYottnb/ynJw+WWS3k9QGGGD9CRw= 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=d6J1fjKXrnaRDwolj8h8mOhIFSxetmOlRplJZt5LDHU=; b=paMm8Pp97zt5CicE22A64l0gbDmkSzbiZago68j8o1eWq36W5k/JsNuuDm5tvlUhxu nZqu2g//PW3ppfGi7qT1HGXr5XiXBn4u2ojQn/4+d5NgLhjXq/B0ZM64/23wpdGas0As xebtjAE4wVKvcxGYOHapYDyMo/rYD/BdyGF5N3Z4yPnyx7z4KPzfSYM3EH4/sSRMPlp2 QkLsLFx3s32thT2LtViC7pbeKWSRTPjCbE5C8dPr0NSHm5ts9S5WEf+UpMcBLjiHRSQ0 Fd5H06JNqRA041qPzaA3GAPUFLWn+xA19IUXXFvg3AuV3ktmiAQuzT5rq/PfAFkB51jw /tNA== X-Gm-Message-State: AOAM533KL6InjuNE6OIsuLqWSccuLn7OLZnj4u1qIg99nTuAULxqy7TO wlMUVtCDk3fRWXzdQZUAxquQKA== X-Google-Smtp-Source: ABdhPJxdbdy2F6XBKxJTtoXbMyf/w3unb5daLLDAkllb4nTCSkGYMfvvvaNnAwnSb2J/54CZQ6947g== X-Received: by 2002:a65:4bcc:: with SMTP id p12mr4037430pgr.353.1602263686574; Fri, 09 Oct 2020 10:14:46 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Oct 2020 10:14:45 -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 11/14] mpt3sas: Add bypass_dirty_port_flag parameter Date: Fri, 9 Oct 2020 22:44:37 +0530 Message-Id: <20201009171440.4949-12-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 Added a new parameter bypass_dirty_port_flag in function mpt3sas_get_port_by_id(). When this parameter is set to one then search for matching hba port entry from port_table_list even when this hba_port entry is marked as dirty. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpt3sas/mpt3sas_base.h | 3 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 63 ++++++++++++++---------- drivers/scsi/mpt3sas/mpt3sas_transport.c | 8 +-- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index e7d047a..cca14ab 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1684,7 +1684,8 @@ void mpt3sas_device_remove_by_sas_address(struct MPT3SAS_ADAPTER *ioc, u8 mpt3sas_check_for_pending_internal_cmds(struct MPT3SAS_ADAPTER *ioc, u16 smid); struct hba_port * -mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port); +mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port, + u8 bypass_dirty_port_flag); struct _sas_node *mpt3sas_scsih_expander_find_by_handle( struct MPT3SAS_ADAPTER *ioc, u16 handle); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 22ffc50..522e4d0 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -361,20 +361,27 @@ _scsih_srch_boot_encl_slot(u64 enclosure_logical_id, u16 slot_number, * port number from port list * @ioc: per adapter object * @port_id: port number + * @bypass_dirty_port_flag: when set look the matching hba port entry even + * if hba port entry is marked as dirty. * * Search for hba port entry corresponding to provided port number, * if available return port object otherwise return NULL. */ struct hba_port * -mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, u8 port_id) +mpt3sas_get_port_by_id(struct MPT3SAS_ADAPTER *ioc, + u8 port_id, u8 bypass_dirty_port_flag) { struct hba_port *port, *port_next; list_for_each_entry_safe(port, port_next, &ioc->port_table_list, list) { - if (port->port_id == port_id && - !(port->flags & HBA_PORT_FLAG_DIRTY_PORT)) + if (port->port_id != port_id) + continue; + if (bypass_dirty_port_flag) return port; + if (port->flags & HBA_PORT_FLAG_DIRTY_PORT) + continue; + return port; } return NULL; @@ -6189,7 +6196,7 @@ _scsih_alloc_vphy(struct MPT3SAS_ADAPTER *ioc, u8 port_id, u8 phy_num) struct virtual_phy *vphy; struct hba_port *port; - port = mpt3sas_get_port_by_id(ioc, port_id); + port = mpt3sas_get_port_by_id(ioc, port_id, 0); if (!port) return NULL; @@ -6263,7 +6270,7 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc) ioc->sas_hba.handle = le16_to_cpu( sas_iounit_pg0->PhyData[0].ControllerDevHandle); port_id = sas_iounit_pg0->PhyData[i].Port; - if (!(mpt3sas_get_port_by_id(ioc, port_id))) { + if (!(mpt3sas_get_port_by_id(ioc, port_id, 0))) { port = kzalloc(sizeof(struct hba_port), GFP_KERNEL); if (!port) goto out; @@ -6306,7 +6313,8 @@ _scsih_sas_host_refresh(struct MPT3SAS_ADAPTER *ioc) AttachedDevHandle); if (attached_handle && link_rate < MPI2_SAS_NEG_LINK_RATE_1_5) link_rate = MPI2_SAS_NEG_LINK_RATE_1_5; - ioc->sas_hba.phy[i].port = mpt3sas_get_port_by_id(ioc, port_id); + ioc->sas_hba.phy[i].port = + mpt3sas_get_port_by_id(ioc, port_id, 0); mpt3sas_transport_update_links(ioc, ioc->sas_hba.sas_address, attached_handle, i, link_rate, ioc->sas_hba.phy[i].port); @@ -6430,7 +6438,7 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc) PhyData[0].ControllerDevHandle); port_id = sas_iounit_pg0->PhyData[i].Port; - if (!(mpt3sas_get_port_by_id(ioc, port_id))) { + if (!(mpt3sas_get_port_by_id(ioc, port_id, 0))) { port = kzalloc(sizeof(struct hba_port), GFP_KERNEL); if (!port) goto out; @@ -6460,7 +6468,8 @@ _scsih_sas_host_add(struct MPT3SAS_ADAPTER *ioc) ioc->sas_hba.phy[i].handle = ioc->sas_hba.handle; ioc->sas_hba.phy[i].phy_id = i; - ioc->sas_hba.phy[i].port = mpt3sas_get_port_by_id(ioc, port_id); + ioc->sas_hba.phy[i].port = + mpt3sas_get_port_by_id(ioc, port_id, 0); mpt3sas_transport_add_host_phy(ioc, &ioc->sas_hba.phy[i], phy_pg0, ioc->sas_hba.parent_dev); } @@ -6552,7 +6561,8 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) if (sas_address_parent != ioc->sas_hba.sas_address) { spin_lock_irqsave(&ioc->sas_node_lock, flags); sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc, - sas_address_parent, mpt3sas_get_port_by_id(ioc, port_id)); + sas_address_parent, + mpt3sas_get_port_by_id(ioc, port_id, 0)); spin_unlock_irqrestore(&ioc->sas_node_lock, flags); if (!sas_expander) { rc = _scsih_expander_add(ioc, parent_handle); @@ -6564,7 +6574,7 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) spin_lock_irqsave(&ioc->sas_node_lock, flags); sas_address = le64_to_cpu(expander_pg0.SASAddress); sas_expander = mpt3sas_scsih_expander_find_by_sas_address(ioc, - sas_address, mpt3sas_get_port_by_id(ioc, port_id)); + sas_address, mpt3sas_get_port_by_id(ioc, port_id, 0)); spin_unlock_irqrestore(&ioc->sas_node_lock, flags); if (sas_expander) @@ -6582,7 +6592,7 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) sas_expander->num_phys = expander_pg0.NumPhys; sas_expander->sas_address_parent = sas_address_parent; sas_expander->sas_address = sas_address; - sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id); + sas_expander->port = mpt3sas_get_port_by_id(ioc, port_id, 0); if (!sas_expander->port) { ioc_err(ioc, "failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); @@ -6627,7 +6637,8 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle) } sas_expander->phy[i].handle = handle; sas_expander->phy[i].phy_id = i; - sas_expander->phy[i].port = mpt3sas_get_port_by_id(ioc, port_id); + sas_expander->phy[i].port = + mpt3sas_get_port_by_id(ioc, port_id, 0); if ((mpt3sas_transport_add_expander_phy(ioc, &sas_expander->phy[i], expander_pg1, @@ -6834,7 +6845,7 @@ _scsih_check_device(struct MPT3SAS_ADAPTER *ioc, spin_lock_irqsave(&ioc->sas_device_lock, flags); sas_address = le64_to_cpu(sas_device_pg0.SASAddress); - port = mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort); + port = mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort, 0); if (!port) goto out_unlock; sas_device = __mpt3sas_get_sdev_by_addr(ioc, @@ -6967,7 +6978,7 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num, port_id = sas_device_pg0.PhysicalPort; sas_device = mpt3sas_get_sdev_by_addr(ioc, - sas_address, mpt3sas_get_port_by_id(ioc, port_id)); + sas_address, mpt3sas_get_port_by_id(ioc, port_id, 0)); if (sas_device) { clear_bit(handle, ioc->pend_os_device_add); sas_device_put(sas_device); @@ -7008,7 +7019,7 @@ _scsih_add_device(struct MPT3SAS_ADAPTER *ioc, u16 handle, u8 phy_num, sas_device->phy = sas_device_pg0.PhyNum; sas_device->fast_path = (le16_to_cpu(sas_device_pg0.Flags) & MPI25_SAS_DEVICE0_FLAGS_FAST_PATH_CAPABLE) ? 1 : 0; - sas_device->port = mpt3sas_get_port_by_id(ioc, port_id); + sas_device->port = mpt3sas_get_port_by_id(ioc, port_id, 0); if (!sas_device->port) { ioc_err(ioc, "failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); @@ -7223,7 +7234,7 @@ _scsih_sas_topology_change_event(struct MPT3SAS_ADAPTER *ioc, } parent_handle = le16_to_cpu(event_data->ExpanderDevHandle); - port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort); + port = mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0); /* handle expander add */ if (event_data->ExpStatus == MPI2_EVENT_SAS_TOPO_ES_ADDED) @@ -7414,7 +7425,8 @@ _scsih_sas_device_status_change_event(struct MPT3SAS_ADAPTER *ioc, spin_lock_irqsave(&ioc->sas_device_lock, flags); sas_address = le64_to_cpu(event_data->SASAddress); sas_device = __mpt3sas_get_sdev_by_addr(ioc, - sas_address, mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort)); + sas_address, + mpt3sas_get_port_by_id(ioc, event_data->PhysicalPort, 0)); if (!sas_device || !sas_device->starget) goto out; @@ -8855,7 +8867,8 @@ _scsih_sas_pd_add(struct MPT3SAS_ADAPTER *ioc, if (!_scsih_get_sas_address(ioc, parent_handle, &sas_address)) mpt3sas_transport_update_links(ioc, sas_address, handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5, - mpt3sas_get_port_by_id(ioc, sas_device_pg0.PhysicalPort)); + mpt3sas_get_port_by_id(ioc, + sas_device_pg0.PhysicalPort, 0)); _scsih_ir_fastpath(ioc, handle, element->PhysDiskNum); _scsih_add_device(ioc, handle, 0, 1); @@ -9163,7 +9176,7 @@ _scsih_sas_ir_physical_disk_event(struct MPT3SAS_ADAPTER *ioc, mpt3sas_transport_update_links(ioc, sas_address, handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5, mpt3sas_get_port_by_id(ioc, - sas_device_pg0.PhysicalPort)); + sas_device_pg0.PhysicalPort, 0)); _scsih_add_device(ioc, handle, 0, 1); @@ -9289,7 +9302,7 @@ Mpi2SasDevicePage0_t *sas_device_pg0) struct _enclosure_node *enclosure_dev = NULL; unsigned long flags; struct hba_port *port = mpt3sas_get_port_by_id( - ioc, sas_device_pg0->PhysicalPort); + ioc, sas_device_pg0->PhysicalPort, 0); if (sas_device_pg0->EnclosureHandle) { enclosure_dev = @@ -9717,7 +9730,7 @@ _scsih_mark_responding_expander(struct MPT3SAS_ADAPTER *ioc, u16 enclosure_handle = le16_to_cpu(expander_pg0->EnclosureHandle); u64 sas_address = le64_to_cpu(expander_pg0->SASAddress); struct hba_port *port = mpt3sas_get_port_by_id( - ioc, expander_pg0->PhysicalPort); + ioc, expander_pg0->PhysicalPort, 0); if (enclosure_handle) enclosure_dev = @@ -9964,7 +9977,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) port_id = expander_pg0.PhysicalPort; expander_device = mpt3sas_scsih_expander_find_by_sas_address( ioc, le64_to_cpu(expander_pg0.SASAddress), - mpt3sas_get_port_by_id(ioc, port_id)); + mpt3sas_get_port_by_id(ioc, port_id, 0)); spin_unlock_irqrestore(&ioc->sas_node_lock, flags); if (expander_device) _scsih_refresh_expander_links(ioc, expander_device, @@ -10027,7 +10040,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) mpt3sas_transport_update_links(ioc, sas_address, handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5, - mpt3sas_get_port_by_id(ioc, port_id)); + mpt3sas_get_port_by_id(ioc, port_id, 0)); set_bit(handle, ioc->pd_handles); retry_count = 0; /* This will retry adding the end device. @@ -10116,7 +10129,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) port_id = sas_device_pg0.PhysicalPort; sas_device = mpt3sas_get_sdev_by_addr(ioc, le64_to_cpu(sas_device_pg0.SASAddress), - mpt3sas_get_port_by_id(ioc, port_id)); + mpt3sas_get_port_by_id(ioc, port_id, 0)); if (sas_device) { sas_device_put(sas_device); continue; @@ -10128,7 +10141,7 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) (u64)le64_to_cpu(sas_device_pg0.SASAddress)); mpt3sas_transport_update_links(ioc, sas_address, handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5, - mpt3sas_get_port_by_id(ioc, port_id)); + mpt3sas_get_port_by_id(ioc, port_id, 0)); retry_count = 0; /* This will retry adding the end device. * _scsih_add_device() will decide on retries and diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c index 256dae1..0d06025 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_transport.c +++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c @@ -1414,7 +1414,7 @@ _transport_get_linkerrors(struct sas_phy *phy) spin_lock_irqsave(&ioc->sas_node_lock, flags); if (_transport_sas_node_find_by_sas_address(ioc, phy->identify.sas_address, - mpt3sas_get_port_by_id(ioc, port_id)) == NULL) { + mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) { spin_unlock_irqrestore(&ioc->sas_node_lock, flags); return -EINVAL; } @@ -1703,7 +1703,7 @@ _transport_phy_reset(struct sas_phy *phy, int hard_reset) spin_lock_irqsave(&ioc->sas_node_lock, flags); if (_transport_sas_node_find_by_sas_address(ioc, phy->identify.sas_address, - mpt3sas_get_port_by_id(ioc, port_id)) == NULL) { + mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) { spin_unlock_irqrestore(&ioc->sas_node_lock, flags); return -EINVAL; } @@ -1762,7 +1762,7 @@ _transport_phy_enable(struct sas_phy *phy, int enable) spin_lock_irqsave(&ioc->sas_node_lock, flags); if (_transport_sas_node_find_by_sas_address(ioc, phy->identify.sas_address, - mpt3sas_get_port_by_id(ioc, port_id)) == NULL) { + mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) { spin_unlock_irqrestore(&ioc->sas_node_lock, flags); return -EINVAL; } @@ -1902,7 +1902,7 @@ _transport_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates) spin_lock_irqsave(&ioc->sas_node_lock, flags); if (_transport_sas_node_find_by_sas_address(ioc, phy->identify.sas_address, - mpt3sas_get_port_by_id(ioc, port_id)) == NULL) { + mpt3sas_get_port_by_id(ioc, port_id, 0)) == NULL) { spin_unlock_irqrestore(&ioc->sas_node_lock, flags); return -EINVAL; }