From patchwork Fri Dec 22 07:31:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suganath Prabu S X-Patchwork-Id: 10128909 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 9849C60318 for ; Fri, 22 Dec 2017 07:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A7D529EE0 for ; Fri, 22 Dec 2017 07:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2A129FCE; Fri, 22 Dec 2017 07:32:44 +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 13C9329EE0 for ; Fri, 22 Dec 2017 07:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755152AbdLVHcn (ORCPT ); Fri, 22 Dec 2017 02:32:43 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:39910 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109AbdLVHcm (ORCPT ); Fri, 22 Dec 2017 02:32:42 -0500 Received: by mail-wm0-f67.google.com with SMTP id i11so19803080wmf.4 for ; Thu, 21 Dec 2017 23:32:42 -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=2DC5ld3XKxu+6qGQlUvN28uNcpQ+QfhOR+mhKYxl2n8=; b=QgKcdZ8CO7rdqvux7y3n6/PXUiyg2VNtLUUxApoIq+XTQ0oO5A+NCZ9LDQFDjSBuIB wfM2uwJeS106/9n1mpFAhybgoTMUYIHWg8rqfvdhGafAabAo4KsPTy3yygtHYyzayxQL quY8v6K5lHlN8PNUFdqK5EQKki842v20GMs38= 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=2DC5ld3XKxu+6qGQlUvN28uNcpQ+QfhOR+mhKYxl2n8=; b=aOoXJqGHLqpckxH4O2tVugNx3Cc7ABWYuNRpqBQC/UBvihtzrfqLItrHaBlQ7ng4RP MIOf4XAtQ3srpWWxBLa8TKJ1BTViHDW8CytkBEdejx0bWK8lS8DIG8NFY1Ou3WPuKiDk 3x/SYzD4ZmXn4m4+kBAeyMD/bqvCG9SqOc3wsWp3sp2IKZU/m4Qf8tDtYNp79jEuBJqp bYybdBdc5i79iAr76OYXNRhaJNaNPsnlAlZCzQotFhVys81I/ckkWTIe2XTVI/WLxuja 3/O9KzkF5DiXY02+SEzlSh94VnOjlwMsch7yFjzV3G53twK1I3D2tNVxxesUluC5zoK5 qbYA== X-Gm-Message-State: AKGB3mKyKyS9/P5Po2HzHO0IwRZJW2MwaiIFMVj6CPGvaJBgYPRzEoGW YwGmV/0B/R9mhrwSNi0SaDQ2sJlF X-Google-Smtp-Source: ACJfBos6psbmFzk0a4HFkDUx5ULfkmX0guRiHcirzEwH2VbDVvEsmM7YUmFzNjpJ2sBeMSmRY7o6NA== X-Received: by 10.28.110.26 with SMTP id j26mr11454593wmc.46.1513927961235; Thu, 21 Dec 2017 23:32:41 -0800 (PST) Received: from dhcp-135-24-192-103.dhcp.broadcom.net ([192.19.239.250]) by smtp.googlemail.com with ESMTPSA id b7sm10379462wrd.69.2017.12.21.23.32.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2017 23:32:40 -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, Hannes Reinecke , Suganath Prabu S , Chaitra P B Subject: [PATCH 07/11] mpt3sas: always use first reserved smid for ioctl passthrough Date: Thu, 21 Dec 2017 23:31:43 -0800 Message-Id: <1513927907-19735-8-git-send-email-suganath-prabu.subramani@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1513927907-19735-1-git-send-email-suganath-prabu.subramani@broadcom.com> References: <1513927907-19735-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: Suganath Prabu S Signed-off-by: Chaitra P B --- 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 afe42a8..a49040e 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;