From patchwork Thu Jan 4 12:57:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10144701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8313A6034B for ; Thu, 4 Jan 2018 12:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7020D2817F for ; Thu, 4 Jan 2018 12:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64FA128635; Thu, 4 Jan 2018 12:57:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C414E2817F for ; Thu, 4 Jan 2018 12:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbeADM5w (ORCPT ); Thu, 4 Jan 2018 07:57:52 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:46977 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752744AbeADM5u (ORCPT ); Thu, 4 Jan 2018 07:57:50 -0500 Received: by mail-qt0-f195.google.com with SMTP id r39so1708771qtr.13 for ; Thu, 04 Jan 2018 04:57:50 -0800 (PST) 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=d65jZ73A9nJp1gSU5KVU7swpivgA0JVdhOMEGd+5Lis=; b=FZY7OEHp0+tU+tTXmqEWYGPP/bkRh498w6GsVPHabqpJNMl2jHsu37dh2CPHLaW9hD LhH5+HQFL9QARNvxQlWM9j8/Mb08GlH/xZ1elIJHKl6KR6KkhjGObu1W1M18mqU53IcM auDLfm50rnzYb9DiZ7m7scK/ovPh6yg27IqAI= 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=d65jZ73A9nJp1gSU5KVU7swpivgA0JVdhOMEGd+5Lis=; b=Akxk8IZzx8XHR80BlpZfZpkdr1i977tV2nCNyfhtS3IznPKEAzvhGh//LCZq/LGrVJ nLy0PQQr6A04Wrfkj1r+lYgIk/rOWIw/o4OlVgasl/5LUJ8+LktdImyAXJDB6slsJYHx dD/k0QO8cpBmO/fUD9UEhAV40eZzjYc6QWFUBIefbI3oG9Xny4axxaYn/ywuURGDPWwK /yBEACEkx9+zwHwbfba47Y574Adm/3/91LLoIHO5WTL8FGokdw2K12u7u5X0majHgRbc a61+AIM59I8NeDjZUqWjaCsCq3D2EUH7HWP8zx+FUneBY18YMPPwU2LhrRCsBvCoFPta 7YIg== X-Gm-Message-State: AKGB3mKLhAyZEWSOo/vKivX0+9ls/hH/DXrAqqFm0ykM6hG6SmRrzL5+ TUAhPx6bTsyvZqhYmn2ldMhmPHmI X-Google-Smtp-Source: ACJfBosur3SfW8IL+nGbhRNibAJtXoYXvYKctmrWP9bR4Kyinkh9sFMu0KYSiUvtDGSrQLfFeXa2UA== X-Received: by 10.200.23.146 with SMTP id o18mr6218294qtj.159.1515070669424; Thu, 04 Jan 2018 04:57:49 -0800 (PST) Received: from dhcp-135-24-192-103.dhcp.broadcom.net ([192.19.239.250]) by smtp.googlemail.com with ESMTPSA id v58sm2064328qtk.18.2018.01.04.04.57.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 04:57:48 -0800 (PST) From: Suganath Prabu S To: linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Sathya.Prakash@broadcom.com, sreekanth.reddy@broadcom.com, chaitra.basappa@broadcom.com, Hannes Reinecke , Hannes Reinecke , Suganath Prabu S Subject: [Resend 05/11] mpt3sas: Introduce mpt3sas_get_st_from_smid() Date: Thu, 4 Jan 2018 04:57:05 -0800 Message-Id: <1515070631-14740-6-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1515070631-14740-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1515070631-14740-1-git-send-email-suganath-prabu.subramani@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hannes Reinecke Abstract accesses to the scsi_lookup array by introducing mpt3sas_get_st_from_smid(). Signed-off-by: Hannes Reinecke Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 22 ++++++++++++++++++---- drivers/scsi/mpt3sas/mpt3sas_base.h | 2 ++ drivers/scsi/mpt3sas/mpt3sas_scsih.c | 7 ++++--- drivers/scsi/mpt3sas/mpt3sas_warpdrive.c | 4 +++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 55aa80c..1ea4232 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -888,6 +888,15 @@ _base_async_event(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, u32 reply) return 1; } +struct scsiio_tracker * +mpt3sas_get_st_from_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid) +{ + if (WARN_ON(!smid) || + WARN_ON(smid >= ioc->hi_priority_smid)) + return NULL; + return &ioc->scsi_lookup[smid - 1]; +} + /** * _base_get_cb_idx - obtain the callback index * @ioc: per adapter object @@ -902,8 +911,11 @@ _base_get_cb_idx(struct MPT3SAS_ADAPTER *ioc, u16 smid) u8 cb_idx = 0xFF; if (smid < ioc->hi_priority_smid) { - i = smid - 1; - cb_idx = ioc->scsi_lookup[i].cb_idx; + struct scsiio_tracker *st; + + st = mpt3sas_get_st_from_smid(ioc, smid); + if (st) + cb_idx = st->cb_idx; } else if (smid < ioc->internal_smid) { i = smid - ioc->hi_priority_smid; cb_idx = ioc->hpr_lookup[i].cb_idx; @@ -1294,6 +1306,7 @@ static struct chain_tracker * _base_get_chain_buffer_tracker(struct MPT3SAS_ADAPTER *ioc, u16 smid) { struct chain_tracker *chain_req; + struct scsiio_tracker *st; unsigned long flags; spin_lock_irqsave(&ioc->scsi_lookup_lock, flags); @@ -1306,8 +1319,9 @@ _base_get_chain_buffer_tracker(struct MPT3SAS_ADAPTER *ioc, u16 smid) chain_req = list_entry(ioc->free_chain_list.next, struct chain_tracker, tracker_list); list_del_init(&chain_req->tracker_list); - list_add_tail(&chain_req->tracker_list, - &ioc->scsi_lookup[smid - 1].chain_list); + st = mpt3sas_get_st_from_smid(ioc, smid); + if (st) + list_add_tail(&chain_req->tracker_list, &st->chain_list); spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); return chain_req; } diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 60f42ca..23e9af5 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -1402,6 +1402,8 @@ void mpt3sas_base_sync_reply_irqs(struct MPT3SAS_ADAPTER *ioc); u16 mpt3sas_base_get_smid_hpr(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx); u16 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx, struct scsi_cmnd *scmd); +struct scsiio_tracker *mpt3sas_get_st_from_smid(struct MPT3SAS_ADAPTER *ioc, + u16 smid); u16 mpt3sas_base_get_smid(struct MPT3SAS_ADAPTER *ioc, u8 cb_idx); void mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid); diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index e482fa2..a11774b 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -2779,7 +2779,7 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, } if (type == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) - scsi_lookup = &ioc->scsi_lookup[smid_task - 1]; + scsi_lookup = mpt3sas_get_st_from_smid(ioc, smid_task); dtmprintk(ioc, pr_info(MPT3SAS_FMT "sending tm: handle(0x%04x), task_type(0x%02x), smid(%d)\n", @@ -2797,7 +2797,8 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, mpt3sas_scsih_set_tm_flag(ioc, handle); init_completion(&ioc->tm_cmds.done); if ((type == MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK) && - (scsi_lookup->msix_io < ioc->reply_queue_count)) + scsi_lookup && + (scsi_lookup->msix_io < ioc->reply_queue_count)) msix_task = scsi_lookup->msix_io; else msix_task = 0; @@ -2838,7 +2839,7 @@ mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, uint channel, switch (type) { case MPI2_SCSITASKMGMT_TASKTYPE_ABORT_TASK: rc = SUCCESS; - if (scsi_lookup->scmd == NULL) + if (scsi_lookup && scsi_lookup->scmd == NULL) break; rc = FAILED; break; diff --git a/drivers/scsi/mpt3sas/mpt3sas_warpdrive.c b/drivers/scsi/mpt3sas/mpt3sas_warpdrive.c index ced7d9f..890d6a9 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_warpdrive.c +++ b/drivers/scsi/mpt3sas/mpt3sas_warpdrive.c @@ -270,7 +270,9 @@ out_error: inline u8 mpt3sas_scsi_direct_io_get(struct MPT3SAS_ADAPTER *ioc, u16 smid) { - return ioc->scsi_lookup[smid - 1].direct_io; + struct scsiio_tracker *st = mpt3sas_get_st_from_smid(ioc, smid); + + return st ? st->direct_io : 0; } /**