From patchwork Tue Feb 28 14:08:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78BBFC64ED6 for ; Tue, 28 Feb 2023 14:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbjB1OJE (ORCPT ); Tue, 28 Feb 2023 09:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229821AbjB1OJC (ORCPT ); Tue, 28 Feb 2023 09:09:02 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E78F540C5 for ; Tue, 28 Feb 2023 06:08:56 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id u5so7152834plq.7 for ; Tue, 28 Feb 2023 06:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=DPAZ+DyQMPqAhaZ6QueG0f3uMjOUkdP2TgQuzmJmNCg=; b=Iovp/w0gmqRFvY08uYbNzcsoi75wBM6zPzYPLElzMPIWV4qzaDpwAyNly8m/bbGzZ1 b2XynANeu16wNKDzJPJu92FkxUP4AXhQxURMw1zquO36ZTjrBJjL95TY6A45KPKIaWrE 5S+EPQhGS+ND/0Y42+UUqP9JXdPSVTWFQ4DXA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DPAZ+DyQMPqAhaZ6QueG0f3uMjOUkdP2TgQuzmJmNCg=; b=DuKCi/+haGIA7XWkbiqp/Y0Mj1ZKhfuW2kddeexgy/aHmJNeZ/nN/4Rg7MeQ2SkE5E BsTVC1/FH5n/9v80Shbc8Bc46vr2YkO/vYqXj3f8yICvEG6u3i0py4Ew+uTF5Ocb1Rbl dSmieh5CrID0xnLW+N/eAIW/qfM2Bh3b5igDzfE9bBhGklyOOj8mHoh4EUtt9Aox+PEh yvN2I8QAnZsSVUaN96YAAK5a+zbinXQma2tRoRa96F98KuzfFY7Ho53fBxusOKcFXJnU uUWTPs7OJh8W9tWHmRZ1M4FaOKc5eYAQunl2ty7DZ2KwwzsKyMA37y6KfJ512XeB1ZI4 3XNw== X-Gm-Message-State: AO0yUKV378uj3GZUq/G+hX/LQG19jx3kQEYkSc4Q16syvyUEUu6fbU52 wMc6eGLvi8RfIir0c05O1uCc5QXkAMo8aQnsCy/h7+N8pgbcO8jE62dc5yUOhbREmsKmCMufH3T UhCjlCPS1Ll1svziGOl5ZFxUKJ3QPke7l3E5W8vmb7yMMJHN5nmrjxFHhiGucreYHLSxw6Nq6xh a0l/pUwpE= X-Google-Smtp-Source: AK7set+6rsJI/w2ufJ2EkfcqOzMLXwFZ2c/2tdFzGHgbhMPZqcDzl40llVjFwG2kQEHcsc8vc0Qyhg== X-Received: by 2002:a17:902:dac8:b0:19c:fc41:2dfd with SMTP id q8-20020a170902dac800b0019cfc412dfdmr3376207plx.29.1677593336108; Tue, 28 Feb 2023 06:08:56 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:08:55 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 1/6] mpi3mr: IOCTL timeout when disable/enable Interpt Date: Tue, 28 Feb 2023 06:08:30 -0800 Message-Id: <20230228140835.4075-2-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org As part of Task Management handling, the driver will disable and enable the MSIx index zero which belongs to the Admin reply queue. And while enabling the interrupts driver loses some interrupts and it leads to Admin requests such as IOCTL timeout. So, after enabling the interrupts, poll the Admin reply queue to avoid timeouts. Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr.h | 3 +++ drivers/scsi/mpi3mr/mpi3mr_fw.c | 12 ++++++++++-- drivers/scsi/mpi3mr/mpi3mr_os.c | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index def4c5e15cd8..24e6b1f71107 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -903,6 +903,7 @@ struct scmd_priv { * @admin_reply_ephase:Admin reply queue expected phase * @admin_reply_base: Admin reply queue base virtual address * @admin_reply_dma: Admin reply queue base dma address + * @admin_reply_q_in_use: Queue is handled by poll/ISR * @ready_timeout: Controller ready timeout * @intr_info: Interrupt cookie pointer * @intr_info_count: Number of interrupt cookies @@ -1059,6 +1060,7 @@ struct mpi3mr_ioc { u8 admin_reply_ephase; void *admin_reply_base; dma_addr_t admin_reply_dma; + atomic_t admin_reply_q_in_use; u32 ready_timeout; @@ -1397,4 +1399,5 @@ void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc); void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc); void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc); void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc); +int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc); #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index 0c4aabaefdcc..e7ea3f7b9205 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -415,7 +415,7 @@ static void mpi3mr_process_admin_reply_desc(struct mpi3mr_ioc *mrioc, le64_to_cpu(scsi_reply->sense_data_buffer_address)); } -static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc) +int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc) { u32 exp_phase = mrioc->admin_reply_ephase; u32 admin_reply_ci = mrioc->admin_reply_ci; @@ -423,12 +423,17 @@ static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc) u64 reply_dma = 0; struct mpi3_default_reply_descriptor *reply_desc; + if (!atomic_add_unless(&mrioc->admin_reply_q_in_use, 1, 1)) + return 0; + reply_desc = (struct mpi3_default_reply_descriptor *)mrioc->admin_reply_base + admin_reply_ci; if ((le16_to_cpu(reply_desc->reply_flags) & - MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase) + MPI3_REPLY_DESCRIPT_FLAGS_PHASE_MASK) != exp_phase) { + atomic_dec(&mrioc->admin_reply_q_in_use); return 0; + } do { if (mrioc->unrecoverable) @@ -454,6 +459,7 @@ static int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc) writel(admin_reply_ci, &mrioc->sysif_regs->admin_reply_queue_ci); mrioc->admin_reply_ci = admin_reply_ci; mrioc->admin_reply_ephase = exp_phase; + atomic_dec(&mrioc->admin_reply_q_in_use); return num_admin_replies; } @@ -2608,6 +2614,7 @@ static int mpi3mr_setup_admin_qpair(struct mpi3mr_ioc *mrioc) mrioc->admin_reply_ci = 0; mrioc->admin_reply_ephase = 1; mrioc->admin_reply_base = NULL; + atomic_set(&mrioc->admin_reply_q_in_use, 0); if (!mrioc->admin_req_base) { mrioc->admin_req_base = dma_alloc_coherent(&mrioc->pdev->dev, @@ -4171,6 +4178,7 @@ void mpi3mr_memset_buffers(struct mpi3mr_ioc *mrioc) memset(mrioc->admin_req_base, 0, mrioc->admin_req_q_sz); if (mrioc->admin_reply_base) memset(mrioc->admin_reply_base, 0, mrioc->admin_reply_q_sz); + atomic_set(&mrioc->admin_reply_q_in_use, 0); if (mrioc->init_cmds.reply) { memset(mrioc->init_cmds.reply, 0, sizeof(*mrioc->init_cmds.reply)); diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 3306de7170f6..2ba1b7641bc2 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -3720,6 +3720,7 @@ int mpi3mr_issue_tm(struct mpi3mr_ioc *mrioc, u8 tm_type, mpi3mr_poll_pend_io_completions(mrioc); mpi3mr_ioc_enable_intr(mrioc); mpi3mr_poll_pend_io_completions(mrioc); + mpi3mr_process_admin_reply_q(mrioc); } switch (tm_type) { case MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET: From patchwork Tue Feb 28 14:08:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE886C64EC7 for ; Tue, 28 Feb 2023 14:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjB1OJG (ORCPT ); Tue, 28 Feb 2023 09:09:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229812AbjB1OJC (ORCPT ); Tue, 28 Feb 2023 09:09:02 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6862A5D8 for ; Tue, 28 Feb 2023 06:08:59 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id p6so9709976plf.0 for ; Tue, 28 Feb 2023 06:08:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Ytn0DtbefU3swaCSf2rHim4DT8rE+pH1jf2M+JdD3KI=; b=P6LMcG07eguW74mPnaLjRkFBCGHQoFEd7DoP4zDtXDwdQoiLc5XCH6zdb/mv9tYrpU W+D3tyhL/dz5GyZnFtUkvIZuHKu7ks7+5beEES5TOKnK0cv5R4eETxC6fmM8/Q0EvmEM 95te9Xl65FEdsWdGuTUMcwNznvKj4q+dWc2EY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ytn0DtbefU3swaCSf2rHim4DT8rE+pH1jf2M+JdD3KI=; b=b+wUux3NQ0kj14qsLe4Bul8ZXsBOLglZfYxWIWcHGEXWBovQrFoNGehsmKvpraJrnL gq39yTWNyY3dFTce9Rv0aOZS5nPPHflT7APKpu4HMFd3jhncA1EcBPe06DE/ojrTM2M0 ObsZiwOwuuSFM+5D1XN04TNOEJEq7nBwpOnTWlCUIVrqILB/vz4yrKnDdzk7DIdmsdYN KbttHkeOg4wn8/oOw5QFUpWHTUkrnXTuvIeSw3gqw5qpSXOVaAh3BGD0+awjWqNvRNOh 5EnkKjSS7xV+eGygdGrPomOn568B4M1laCc1NnapMVKuBZVmEoqCT2xsvxkkrjPGpXuQ ZGAQ== X-Gm-Message-State: AO0yUKX+Zoh/C286grQ3Z0PYHOaF1n9+8VX+1RNKgdFwzY7n7CbbTpVU oqwNWuxU1onH1filraBs0fSVPe+REBNuwkK0SXv6lGnBdbeYID4OBNx7TU7I84pD2UQwyjK3d2G z7IgQrB2jTpsg2Q9dDNaZUlqbQjPq32H3IWE6QlHIjAMW9PeBuk7gTR7eDQ6vNPVMs0zi5quHK9 MWi4HZdrE= X-Google-Smtp-Source: AK7set+P20j/cs7R4q6fJxRo3I/qDMqwmvnAFeSgBx0iH4HWjxd0vxMgkNiVK4O7aR3bqK0WPT9Dzw== X-Received: by 2002:a17:902:ec91:b0:19a:a80e:a6d5 with SMTP id x17-20020a170902ec9100b0019aa80ea6d5mr3269267plg.23.1677593338711; Tue, 28 Feb 2023 06:08:58 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:08:58 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 2/6] mpi3mr: Driver unload crash host when enhanced logging is enabled Date: Tue, 28 Feb 2023 06:08:31 -0800 Message-Id: <20230228140835.4075-3-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Driver was trying to access null pointer in a debug print while removing a device during driver unload Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c index 3fc897336b5e..584daf8a3ac9 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_transport.c +++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c @@ -1552,7 +1552,8 @@ static void mpi3mr_sas_port_remove(struct mpi3mr_ioc *mrioc, u64 sas_address, list_for_each_entry_safe(mr_sas_phy, next_phy, &mr_sas_port->phy_list, port_siblings) { - if ((mrioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO)) + if ((!mrioc->stop_drv_processing) && + (mrioc->logging_level & MPI3_DEBUG_TRANSPORT_INFO)) dev_info(&mr_sas_port->port->dev, "remove: sas_address(0x%016llx), phy(%d)\n", (unsigned long long) From patchwork Tue Feb 28 14:08:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09010C64EC7 for ; Tue, 28 Feb 2023 14:09:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbjB1OJH (ORCPT ); Tue, 28 Feb 2023 09:09:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229816AbjB1OJE (ORCPT ); Tue, 28 Feb 2023 09:09:04 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38B4E3A8E for ; Tue, 28 Feb 2023 06:09:02 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id ky4so10576497plb.3 for ; Tue, 28 Feb 2023 06:09:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=BkvNywLQA1LEffvNBLuzG6qT4Ha0dSCflwL/WKv/nlc=; b=YUHPIoS4XSmhIx3idMjeq/toBzsWHxp4CFQ0Ohd3Bf5KcjQo0T4PuNNA8HrNrz80eB pprMJxgKBdJhLD3WhKPLYfXApaXwMUR+J+GGMkig/E8q8vLbvOEkdPlpSbab4H5RlxZ6 Wayk7OnUErCdoHwr/s85uWakBgxefilTLV/XE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BkvNywLQA1LEffvNBLuzG6qT4Ha0dSCflwL/WKv/nlc=; b=av3AUUGizgcuFK/m94AfxGVq5YJBqUiD7AZwh3mDqNMxiOo1egcqBdG9+hUmhnBKDd h35q++t7wHSqz9zxGTXzNymxl2q3kR00aZFd4a3TYnYOD9WdN10K4QYWd0oK9bC6Kgp7 oGDiRhHrYgdZX1FnS8HwbQldVQOy/xQxe//cEOFLy0OUlnKvGc+Z68fX78/QVdsInrMa dyv2k2WBHqwn4JvvpZAiU1OFdehZALn2S/oIS7BjEZU778+Q/KSCyh+aSlTlXTXzFWIa BXTZYusgxtXhKnpN4o65TacRLCSfo/SuzB5rrqptdE5m9GhpUMETY6lC8DvlzY904ITE A+IQ== X-Gm-Message-State: AO0yUKU/uCBQQsOpKyr23az1FJS137gDC63AS+NsNo5ExhwraE11ki2z 89pXp6SztnQESsGFXcNR9GlYKqwjpOll7bbuerEUam1I4RMGRdohV3dLG2WEqybxKTx6Mj/zJe3 p6qzpX0f123lPk9D7pG7NQKNeXUeBT4UcQ+mMfl7PoSxptHIaKFFVns0B0/TnVox1VgKbGUGgUB 35PSD3ffs= X-Google-Smtp-Source: AK7set9OIc1exP/rL+T7lAH+rsTM4x6J5MAxr3KZ/TpedOpecyv9wm3TjP8TfHqH4tRIK7ZpHfjFkg== X-Received: by 2002:a17:902:7c97:b0:19d:244:a3a8 with SMTP id y23-20020a1709027c9700b0019d0244a3a8mr2274268pll.10.1677593341339; Tue, 28 Feb 2023 06:09:01 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:09:00 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 3/6] mpi3mr: Wait for diagnostic save during controller init Date: Tue, 28 Feb 2023 06:08:32 -0800 Message-Id: <20230228140835.4075-4-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If the controller reset operation is triggered to recover the controller from the fault state then wait for the snapdump to be saved in the firmware region before proceeding for resetting the controller. Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index e7ea3f7b9205..e5c0bc6d47d5 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -1201,7 +1201,7 @@ mpi3mr_revalidate_factsdata(struct mpi3mr_ioc *mrioc) */ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc) { - u32 ioc_config, ioc_status, timeout; + u32 ioc_config, ioc_status, timeout, host_diagnostic; int retval = 0; enum mpi3mr_iocstate ioc_state; u64 base_info; @@ -1255,6 +1255,23 @@ static int mpi3mr_bring_ioc_ready(struct mpi3mr_ioc *mrioc) retval, mpi3mr_iocstate_name(ioc_state)); } if (ioc_state != MRIOC_STATE_RESET) { + if (ioc_state == MRIOC_STATE_FAULT) { + timeout = MPI3_SYSIF_DIAG_SAVE_TIMEOUT * 10; + mpi3mr_print_fault_info(mrioc); + do { + host_diagnostic = + readl(&mrioc->sysif_regs->host_diagnostic); + if (!(host_diagnostic & + MPI3_SYSIF_HOST_DIAG_SAVE_IN_PROGRESS)) + break; + if (!pci_device_is_present(mrioc->pdev)) { + mrioc->unrecoverable = 1; + ioc_err(mrioc, "controller is not present at the bringup\n"); + goto out_device_not_present; + } + msleep(100); + } while (--timeout); + } mpi3mr_print_fault_info(mrioc); ioc_info(mrioc, "issuing soft reset to bring to reset state\n"); retval = mpi3mr_issue_reset(mrioc, From patchwork Tue Feb 28 14:08:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BBCFC64ED6 for ; Tue, 28 Feb 2023 14:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjB1OJL (ORCPT ); Tue, 28 Feb 2023 09:09:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbjB1OJG (ORCPT ); Tue, 28 Feb 2023 09:09:06 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DEB840C5 for ; Tue, 28 Feb 2023 06:09:05 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id cp7-20020a17090afb8700b0023756229427so13831699pjb.1 for ; Tue, 28 Feb 2023 06:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=grBjESVZbPi8N4EXwWQUFkUyNL7XllQP0w9XKOIgcww=; b=bvTrIBUYvfJCMo5OHMtfoDh83s4cFfioRzxGqTiIL9H66KgANrDS7rBxeG6U/7IdhA 12xX3sGdKbfu0qCeUS5VjwZl6fhLSkn4BHjblerH7nypguJCvsvtSE1HxOLEwzSgk30L nKPrl8GJwLhez46h4y5jGq9khIiwaVZ4h+AMU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=grBjESVZbPi8N4EXwWQUFkUyNL7XllQP0w9XKOIgcww=; b=vPd5eRD7Ob7f3Mb7bpt6u8nDXanGn/hsAIYBsng8QnklDUcfySEZ5XTY0g/ewV5BpX IrHhWiTRmvkaLJEW49PUistVm65E8Dg9pc+fm/kVn+qrI25QcN3SXdKfkzXeUEF6pKnV H+pw3uuHxOdaMJXcfjD4xfGrVs4lpdgQTBNnGciK+wJNQoXFBbxwC+WspMqUzs8MfJC0 9fyzcyJTqskXOi3cw4vR43myIrwOyuSUSWSEhWryPUhjjAo5Whrdd67Twkvy7CjZ1Ec4 tMXaVq0oJqFcpUJsdgZCapa98o6px8eX0TB1FTfkH4sgN2j8Dl44YNBMVzwhfY5KMStA Dh3g== X-Gm-Message-State: AO0yUKWxDIGuFbpoZTzMAE3BkeRREzaVyRrMHplWBvpE7yeLu/YareUD st/67zpZPrJhwGvE+8+w11QxhLsSbDnoSWt9JBYqh1VhnYsuC1XxsoI1NwCeVvJg28SiO9hpygd DQtHKQHzqbhv5eOgCPRL/ui0Kf7lVBcVRh0a3ve/Ocdn7+6eKCGJCAGPBFmsD6tVcoVgKLBre8y b6SFR5/Aw= X-Google-Smtp-Source: AK7set8hKbtjVTUbgH1GZJmtR6KlNn1tV/jhzULwLGrEZ0oPBPaX5mZuTzV+8H33Y9JDFJF5jcQLQw== X-Received: by 2002:a17:902:cec5:b0:19a:6acc:1de2 with SMTP id d5-20020a170902cec500b0019a6acc1de2mr3186707plg.35.1677593344289; Tue, 28 Feb 2023 06:09:04 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:09:03 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 4/6] mpi3mr: appropriate return values for failures in firmware init path Date: Tue, 28 Feb 2023 06:08:33 -0800 Message-Id: <20230228140835.4075-5-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The driver is modified to return a proper non-zero return value for all the cases when the controller initialization and re-initialization fails. Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index e5c0bc6d47d5..8f20dc87bebf 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -3856,8 +3856,10 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc) dprint_init(mrioc, "allocating config page buffers\n"); mrioc->cfg_page = dma_alloc_coherent(&mrioc->pdev->dev, MPI3MR_DEFAULT_CFG_PAGE_SZ, &mrioc->cfg_page_dma, GFP_KERNEL); - if (!mrioc->cfg_page) + if (!mrioc->cfg_page) { + retval = -1; goto out_failed_noretry; + } mrioc->cfg_page_sz = MPI3MR_DEFAULT_CFG_PAGE_SZ; @@ -3919,8 +3921,10 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc) dprint_init(mrioc, "allocating memory for throttle groups\n"); sz = sizeof(struct mpi3mr_throttle_group_info); mrioc->throttle_groups = kcalloc(mrioc->num_io_throttle_group, sz, GFP_KERNEL); - if (!mrioc->throttle_groups) + if (!mrioc->throttle_groups) { + retval = -1; goto out_failed_noretry; + } } retval = mpi3mr_enable_events(mrioc); @@ -3940,6 +3944,7 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc) mpi3mr_memset_buffers(mrioc); goto retry_init; } + retval = -1; out_failed_noretry: ioc_err(mrioc, "controller initialization failed\n"); mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, @@ -4052,6 +4057,7 @@ int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume) ioc_err(mrioc, "cannot create minimum number of operational queues expected:%d created:%d\n", mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q); + retval = -1; goto out_failed_noretry; } @@ -4118,6 +4124,7 @@ int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume) mpi3mr_memset_buffers(mrioc); goto retry_init; } + retval = -1; out_failed_noretry: ioc_err(mrioc, "controller %s is failed\n", (is_resume)?"resume":"re-initialization"); From patchwork Tue Feb 28 14:08:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B6F5C64ED6 for ; Tue, 28 Feb 2023 14:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjB1OJQ (ORCPT ); Tue, 28 Feb 2023 09:09:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjB1OJI (ORCPT ); Tue, 28 Feb 2023 09:09:08 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE1CEB48 for ; Tue, 28 Feb 2023 06:09:07 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id l1so9959674pjt.2 for ; Tue, 28 Feb 2023 06:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ayYvdeRbVGYYaSZ524Y0Mf1rh4wEW+6hdtCnqkadsKA=; b=Ca6SYFrp1DOpEJrPCCimSQKHz4g2i+coi3JOcVpAFqS1YQXkcGUE9HY63y+NppUX6m fzj3I0obaue9kzP1UZ7Yh9462oGup5UMOOMVr88o2lUh9nlu2JEVVokG52gr8LfBX3qh DODT7144vRQ6UaQjB2Xs9Q7pMu6XHGX5ZIzkY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ayYvdeRbVGYYaSZ524Y0Mf1rh4wEW+6hdtCnqkadsKA=; b=ukKFNX2+aW/wHFbVXQNS+N+BBJVle0d5VxEvH27WzK+t/ms0nZ1yxthZHFREYu/bxf zEU8ouOgx1V3X7GPbq2Lib/N41YszYyiiBUc+j7/HV/tYTf7vPSK3SxwWlAAUTJoCPTa b/Z6+t7mROGnLPJTqCD81n+4+R25U12nJgtMnMXac8ttfOaIgkpVocPFu771JCRqNugi mx+ccj7jIzymeu2t0iR2JPC8bUU1feY5SSY+f37zeggMpbr6KZIK96ULTibDcT4GRGD0 qBWMPoADvz28fH4TnDZuIQPTESNO7l61YzAs6cl8hJAhXaFEHPTCo+0s+nZI5e25rAeN aHOw== X-Gm-Message-State: AO0yUKUJJXWtXMmpUOQ0KHNjb0zxmRjv/ksnI/cQFgA9jZJYO+V4MFx/ 0ggJ++3FKoG5xGAZ0f4nkw6Hv+O1Fh9OyQbRBF8yEYdXrGkdZh63Dqn4UC80l9B7Ddy1sqytg3e zg+M5rKmKeY34cDk2tFstdn0tWJ+rT722cHPDndqHSjVM/PE24XGIDuliN5UOFN7Z6fai/qKM2r VVR7rVTPE= X-Google-Smtp-Source: AK7set9GBUe7eBZddKr546vRvzobZ9EYITSv8cdSfQp+0F6GKFQfTYeCVF9fUFnhODXQQCJFYk7T0w== X-Received: by 2002:a17:902:daca:b0:19a:945d:e31 with SMTP id q10-20020a170902daca00b0019a945d0e31mr3830332plx.13.1677593346905; Tue, 28 Feb 2023 06:09:06 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:09:06 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 5/6] mpi3mr: NVMe commands size greater than 8K fails Date: Tue, 28 Feb 2023 06:08:34 -0800 Message-Id: <20230228140835.4075-6-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org A wrong variable is checked while populating PRP entries in the PRP page and that results in failure .Hence no PRP entries in the PRP page were successfully created and any NVMe Encapsulated commands with PRP of size greater than 8K failed Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c index 9baac224b213..49318ba893c8 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_app.c +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c @@ -894,7 +894,7 @@ static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc, * each time through the loop. */ *prp_entry = cpu_to_le64(dma_addr); - if (*prp1_entry & sgemod_mask) { + if (*prp_entry & sgemod_mask) { dprint_bsg_err(mrioc, "%s: PRP address collides with SGE modifier\n", __func__); @@ -903,7 +903,7 @@ static int mpi3mr_build_nvme_prp(struct mpi3mr_ioc *mrioc, *prp_entry &= ~sgemod_mask; *prp_entry |= sgemod_val; prp_entry++; - prp_entry_dma++; + prp_entry_dma += prp_size; } /* From patchwork Tue Feb 28 14:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13154950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6709FC7EE31 for ; Tue, 28 Feb 2023 14:09:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbjB1OJR (ORCPT ); Tue, 28 Feb 2023 09:09:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229822AbjB1OJL (ORCPT ); Tue, 28 Feb 2023 09:09:11 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F1F13511 for ; Tue, 28 Feb 2023 06:09:10 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id u5so7153925plq.7 for ; Tue, 28 Feb 2023 06:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FERgD2iKz0+gFchnxeePritW76LxjZ46d/ToQONGRiA=; b=hubb/lQSMfxufh26WuY0C4rE0a4sAtOo48lvKethloi0qR2jckwF5kcypxlcoTzWAW quVdP9i//Zvm94qFT1d/idArzTcinO+i19/1Jva7gBErikvqHm9FPM7CL8llOVyRrqJb vqvqoHMocs+2m3Pd1qF/4ZPeVTbRO2OE7mbWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FERgD2iKz0+gFchnxeePritW76LxjZ46d/ToQONGRiA=; b=XO/SPVnimqKZkfHREYbPFz0QfvrQA+N+PlsytJI8ZvnfiNSJTVyKYzyOrkZPuM44o5 I3Bois5g0GUUZqoTI1f/LATGl2V4lW5fooozH3L8cteg0w3NDv4v0kPX8baQXaucmb2x Xk9J7Jf/FSZEB+S/lTuMGShhz5SYm1Z67Juv0xMOerFw2Q6lWblM9RIHTKvmAFAu2ZnJ cQsVqjiK3sa/zv+ZwxlsBoFyvCTcE7IJrUSSebXdEdKnQoBIzLgcG17PQEV3RQvuO9uB ABVTLkHuWOMxlAmFM0yYHbzsT61CxRrB78HVlC2gKG8Dt6VTzr7kgCCCFA+GA2DsJHgC 2JqQ== X-Gm-Message-State: AO0yUKXETEmfTZ7MCYYny9FnhNZO5m2KtArGJonUT7xePwE+2cfgEeT+ xOV45RSldL/8gGVjbLfhbcD39J1kGZ6o4Hlw3zW3fctxSaLMOIf3s3+F9BPUR+1sxpNuXiRWi2f n/f6VS5/bk5K2uZgYuYek4tBsYHwjoBvb/vOhi/jyByE5myU9ya2iwV9hiI5AVSs16mMQzgDnYK vKIphv4Ew= X-Google-Smtp-Source: AK7set+DR3Y1GluEqS4g1ocTwW91bNwNNn97AmrOaKygUfxr//xLE+U1yKtgiE/nHC+j7xdEijXCgw== X-Received: by 2002:a17:902:be16:b0:199:190c:3c0a with SMTP id r22-20020a170902be1600b00199190c3c0amr2505269pls.31.1677593349844; Tue, 28 Feb 2023 06:09:09 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id ji1-20020a170903324100b00198e03c3ad4sm6625465plb.278.2023.02.28.06.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Feb 2023 06:09:09 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, Ranjan Kumar , Sreekanth Reddy Subject: [PATCH 6/6] mpi3mr: Bad drive in topology results kernel crash Date: Tue, 28 Feb 2023 06:08:35 -0800 Message-Id: <20230228140835.4075-7-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230228140835.4075-1-ranjan.kumar@broadcom.com> References: <20230228140835.4075-1-ranjan.kumar@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org When the SAS Transport Layer support is enabled and when a device exposed to the OS by the driver failed Inquiry commands then the driver frees up the memory allocated for an internal HBA port data structure. However, in some places, the reference to the freed memory is not cleared.When the firmware sends the Device Info change event for the same device again,then the freed memory is accessed and that leads to memory corruption and OS crash. Signed-off-by: Ranjan Kumar Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_transport.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_transport.c b/drivers/scsi/mpi3mr/mpi3mr_transport.c index 584daf8a3ac9..1869e45e04d4 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_transport.c +++ b/drivers/scsi/mpi3mr/mpi3mr_transport.c @@ -2358,15 +2358,16 @@ int mpi3mr_report_tgtdev_to_sas_transport(struct mpi3mr_ioc *mrioc, tgtdev->host_exposed = 1; if (!mpi3mr_sas_port_add(mrioc, tgtdev->dev_handle, sas_address_parent, hba_port)) { - tgtdev->host_exposed = 0; retval = -1; - } else if ((!tgtdev->starget)) { - if (!mrioc->is_driver_loading) + } else if ((!tgtdev->starget) && (!mrioc->is_driver_loading)) { mpi3mr_sas_port_remove(mrioc, sas_address, sas_address_parent, hba_port); - tgtdev->host_exposed = 0; retval = -1; } + if (retval) { + tgtdev->dev_spec.sas_sata_inf.hba_port = NULL; + tgtdev->host_exposed = 0; + } return retval; } @@ -2395,6 +2396,7 @@ void mpi3mr_remove_tgtdev_from_sas_transport(struct mpi3mr_ioc *mrioc, mpi3mr_sas_port_remove(mrioc, sas_address, sas_address_parent, hba_port); tgtdev->host_exposed = 0; + tgtdev->dev_spec.sas_sata_inf.hba_port = NULL; } /** @@ -2451,7 +2453,7 @@ static u8 mpi3mr_get_port_id_by_rphy(struct mpi3mr_ioc *mrioc, struct sas_rphy * tgtdev = __mpi3mr_get_tgtdev_by_addr_and_rphy(mrioc, rphy->identify.sas_address, rphy); - if (tgtdev) { + if (tgtdev && tgtdev->dev_spec.sas_sata_inf.hba_port) { port_id = tgtdev->dev_spec.sas_sata_inf.hba_port->port_id; mpi3mr_tgtdev_put(tgtdev);