public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
	James Bottomley <james.bottomley@hansenpartnership.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Kashyap Desai <kashyap.desai@broadcom.com>,
	Sathya Prakash <sathya.prakash@broadcom.com>,
	linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
	Hannes Reinecke <hare@suse.com>
Subject: [PATCHv2 08/11] mpt3sas: always use smid 1 for ioctl passthrough
Date: Fri, 17 Feb 2017 09:23:07 +0100	[thread overview]
Message-ID: <1487319790-97340-9-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1487319790-97340-1-git-send-email-hare@suse.de>

ioctl passthrough commands require a SCSIIO smid, but cannot
easily integrate with the block layer. But as we're only ever
allowing one ioctl command at a time we can reserve smid 1
for ioctl commands.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/mpt3sas/mpt3sas_base.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index 9b7273b..dec86c4 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -2355,13 +2355,20 @@ struct scsiio_tracker *
 		return 0;
 	}
 
-	request = list_entry(ioc->free_list.next,
-	    struct scsiio_tracker, tracker_list);
-	request->scmd = scmd;
+	if (!scmd) {
+		/* ioctl command, always use the first slot */
+		request = ioc->lookup[0];
+		request->scmd = NULL;
+	} else {
+		request = list_entry(ioc->free_list.next,
+				     struct scsiio_tracker, tracker_list);
+		request->scmd = scmd;
+	}
 	request->cb_idx = cb_idx;
 	smid = request->smid;
 	request->msix_io = _base_get_msix_index(ioc);
-	list_del(&request->tracker_list);
+	if (scmd)
+		list_del(&request->tracker_list);
 	spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
 	return smid;
 }
@@ -2429,7 +2436,9 @@ struct scsiio_tracker *
 		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 > 0)
+			list_add(&ioc->scsi_lookup[i].tracker_list,
+				 &ioc->free_list);
 		spin_unlock_irqrestore(&ioc->scsi_lookup_lock, flags);
 
 		_base_recovery_check(ioc);
@@ -5165,14 +5174,17 @@ struct scsiio_tracker *
 	spin_lock_irqsave(&ioc->scsi_lookup_lock, flags);
 	INIT_LIST_HEAD(&ioc->free_list);
 	smid = 1;
-	for (i = 0; i < ioc->scsiio_depth; i++, smid++) {
+	for (i = 1; i < ioc->scsiio_depth; i++, smid++) {
 		INIT_LIST_HEAD(&ioc->scsi_lookup[i].chain_list);
 		ioc->scsi_lookup[i].cb_idx = 0xFF;
 		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 == 1)
+			INIT_LIST_HEAD(&ioc->lookup[i].tracker_list);
+		else
+			list_add_tail(&ioc->scsi_lookup[i].tracker_list,
+				      &ioc->free_list);
 	}
 
 	/* hi-priority queue */
-- 
1.8.5.6

  parent reply	other threads:[~2017-02-17  8:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  8:22 [PATCHv2 00/11] mpt3sas: Full mq support, part 1 Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 01/11] mpt3sas: switch to pci_alloc_irq_vectors Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 02/11] mpt3sas: set default value for cb_idx Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 03/11] mpt3sas: use 'list_splice_init()' Hannes Reinecke
2017-02-17  8:33   ` Christoph Hellwig
2017-02-17  8:23 ` [PATCHv2 04/11] mpt3sas: separate out _base_recovery_check() Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 05/11] mpt3sas: open-code _scsih_scsi_lookup_get() Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 06/11] mpt3sas: Introduce mpt3sas_get_st_from_smid() Hannes Reinecke
2017-02-17  9:35   ` Johannes Thumshirn
2017-02-17  9:40     ` Johannes Thumshirn
2017-02-17  8:23 ` [PATCHv2 07/11] mpt3sas: check command status before attempting abort Hannes Reinecke
2017-02-17  8:35   ` Christoph Hellwig
2017-02-17  8:39     ` Hannes Reinecke
2017-02-17  8:23 ` Hannes Reinecke [this message]
2017-02-17  8:45   ` [PATCHv2 08/11] mpt3sas: always use smid 1 for ioctl passthrough Christoph Hellwig
2017-02-17  8:52     ` Hannes Reinecke
2017-02-17  8:23 ` [PATCHv2 09/11] mpt3sas: lockless command submission for scsi-mq Hannes Reinecke
2017-02-17  8:54   ` Christoph Hellwig
2017-02-17  9:03     ` Hannes Reinecke
2017-02-17  9:09       ` Christoph Hellwig
2017-02-17  8:23 ` [PATCHv2 10/11] scsi: allocate reserved commands Hannes Reinecke
2017-02-17  8:55   ` Christoph Hellwig
2017-02-17  9:00     ` Hannes Reinecke
2017-02-17 12:37       ` Christoph Hellwig
2017-02-17  8:23 ` [PATCHv2 11/11] mpt3sas: register " Hannes Reinecke
2017-02-17 12:38   ` Christoph Hellwig
2017-02-17 13:18     ` Hannes Reinecke
2017-02-17 13:23       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487319790-97340-9-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox