From patchwork Thu Jan 4 12:57:07 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: 10144705 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 977796034B for ; Thu, 4 Jan 2018 12:58:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 853EE2817F for ; Thu, 4 Jan 2018 12:58:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D8D28639; Thu, 4 Jan 2018 12:58:02 +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 226DC2817F for ; Thu, 4 Jan 2018 12:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752696AbeADM57 (ORCPT ); Thu, 4 Jan 2018 07:57:59 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33829 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752564AbeADM55 (ORCPT ); Thu, 4 Jan 2018 07:57:57 -0500 Received: by mail-qt0-f195.google.com with SMTP id 33so1735295qtv.1 for ; Thu, 04 Jan 2018 04:57:57 -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=C7hJ9nHQNI3zFhbtPuh7KElw8YFbow6FRDnHDqsAONY=; b=IeGhYZQ6WCQSSOEyVv3WwV0VV7sfanZG37cYPIxhOja4/W7pgd0+JsVaWXOmyhmpR0 REaUXOqXIkma9nxPMaLbmiE9+BuWR9Qbf0FxWgcvKvJkm+XtmdmPS9jRwHr3THkPotqJ Pggdv2FAhYjpihTRwgWH1n/UZLAHDyrXENtmQ= 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=C7hJ9nHQNI3zFhbtPuh7KElw8YFbow6FRDnHDqsAONY=; b=OdpRHyxmlxu4tVIBrzx9V5xWq0y2/39ikIoqmcNnAIiMhvSQqHCfWXb9rTogSJVBY1 lZKoNNJPkt5CzMKpymDYPNeLSCcpR0Ppr/j0ZuRGaJ4H2j69DIHCJ4KtyDPwjZSDkQ4y Alld4OyTb0uNnN3vnzI2MZ1o+ygI3IC1Nu/salIuBdIa+sIXyYvHbCPwf7okrZiM8WUv 3L9Hjf0JXlF4TIkw7S+yEw+KvTAhVdV7cXP+aFqcRvS4/acxoBUY5iwALKev3sWDD+XY 8czVsVuGWBm3xKTdF/GHpN+GlepeTtvcT9aaudDQ2hjA3mvQYd5950OwxwhZRcjDgd0A dwAw== X-Gm-Message-State: AKGB3mLh5L2Jh938Jt8N+hhgmHrFtNnutkoFa4tCTGJ9ffhQVX0OYlaW cyPXxyt3PsWeOTpYGquWKY2P6Hp5 X-Google-Smtp-Source: ACJfBovYRFN0q88LxZbIf0+t0d4gAD6AlU1iT4uJr8uTW8oUjDCzxzGpZ9JqQreb++2nxlo5ltvUPg== X-Received: by 10.237.59.184 with SMTP id r53mr6299866qte.306.1515070676663; Thu, 04 Jan 2018 04:57:56 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 04:57:56 -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 07/11] mpt3sas: always use first reserved smid for ioctl passthrough Date: Thu, 4 Jan 2018 04:57:07 -0800 Message-Id: <1515070631-14740-8-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 ioctl passthrough commands require a SCSIIO smid, but cannot easily integrate with the block layer. But the driver already has reserved some SCSIIO smids and we're only ever allowing one ioctl command at a time we can use the first reserved smid for ioctl commands. Signed-off-by: Hannes Reinecke Signed-off-by: Suganath Prabu S --- drivers/scsi/mpt3sas/mpt3sas_base.c | 19 +++++++++++++------ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 10 ++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c index 1ea4232..d4b32af 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.c +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c @@ -908,14 +908,18 @@ static u8 _base_get_cb_idx(struct MPT3SAS_ADAPTER *ioc, u16 smid) { int i; + u16 ctl_smid = ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT + 1; u8 cb_idx = 0xFF; if (smid < ioc->hi_priority_smid) { struct scsiio_tracker *st; - st = mpt3sas_get_st_from_smid(ioc, smid); - if (st) - cb_idx = st->cb_idx; + if (smid < ctl_smid) { + st = mpt3sas_get_st_from_smid(ioc, smid); + if (st) + cb_idx = st->cb_idx; + } else if (smid == ctl_smid) + cb_idx = ioc->ctl_cb_idx; } else if (smid < ioc->internal_smid) { i = smid - ioc->hi_priority_smid; cb_idx = ioc->hpr_lookup[i].cb_idx; @@ -2922,7 +2926,9 @@ mpt3sas_base_free_smid(struct MPT3SAS_ADAPTER *ioc, u16 smid) ioc->scsi_lookup[i].cb_idx = 0xFF; ioc->scsi_lookup[i].scmd = NULL; ioc->scsi_lookup[i].direct_io = 0; - list_add(&ioc->scsi_lookup[i].tracker_list, &ioc->free_list); + if (i < ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) + list_add(&ioc->scsi_lookup[i].tracker_list, + &ioc->free_list); spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags); _base_recovery_check(ioc); @@ -5787,8 +5793,9 @@ _base_make_ioc_operational(struct MPT3SAS_ADAPTER *ioc) ioc->scsi_lookup[i].smid = smid; ioc->scsi_lookup[i].scmd = NULL; ioc->scsi_lookup[i].direct_io = 0; - list_add_tail(&ioc->scsi_lookup[i].tracker_list, - &ioc->free_list); + if (i < ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT) + list_add_tail(&ioc->scsi_lookup[i].tracker_list, + &ioc->free_list); } /* hi-priority queue */ diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index b4c374b..4f23498 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -724,14 +724,8 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, goto out; } } else { - - smid = mpt3sas_base_get_smid_scsiio(ioc, ioc->ctl_cb_idx, NULL); - if (!smid) { - pr_err(MPT3SAS_FMT "%s: failed obtaining a smid\n", - ioc->name, __func__); - ret = -EAGAIN; - goto out; - } + /* Use first reserved smid for passthrough ioctls */ + smid = ioc->scsiio_depth - INTERNAL_SCSIIO_CMDS_COUNT + 1; } ret = 0;