Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Christof Schmitt <christof.schmitt@de.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
	schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com,
	Christof Schmitt <christof.schmitt@de.ibm.com>,
	Felix Beck <felix@linux.vnet.ibm.com>
Subject: [patch 03/11] zfcp: Simplify SBAL allocation to fix sparse warnings
Date: Fri, 19 Dec 2008 16:56:54 +0100	[thread overview]
Message-ID: <20081219155751.867385000@de.ibm.com> (raw)
In-Reply-To: 20081219155651.010878000@de.ibm.com

[-- Attachment #1: sparse.diff --]
[-- Type: text/plain, Size: 2099 bytes --]

From: Christof Schmitt <christof.schmitt@de.ibm.com>

When waiting for a request claim the SBAL before waiting. This way,
locking before each check of the free counter is not required and
sparse does not emit warnings for the complicated locking scheme.

Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Acked-by: Felix Beck <felix@linux.vnet.ibm.com>
---
 drivers/s390/scsi/zfcp_fsf.c |   34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

--- a/drivers/s390/scsi/zfcp_fsf.c	2008-12-19 14:38:21.000000000 +0100
+++ b/drivers/s390/scsi/zfcp_fsf.c	2008-12-19 14:38:28.000000000 +0100
@@ -641,38 +641,38 @@ static void zfcp_fsf_exchange_port_data_
 	}
 }
 
-static int zfcp_fsf_sbal_check(struct zfcp_adapter *adapter)
+static int zfcp_fsf_sbal_available(struct zfcp_adapter *adapter)
 {
-	struct zfcp_qdio_queue *req_q = &adapter->req_q;
-
-	spin_lock_bh(&adapter->req_q_lock);
-	if (atomic_read(&req_q->count))
+	if (atomic_read(&adapter->req_q.count) > 0)
 		return 1;
-	spin_unlock_bh(&adapter->req_q_lock);
+	atomic_inc(&adapter->qdio_outb_full);
 	return 0;
 }
 
-static int zfcp_fsf_sbal_available(struct zfcp_adapter *adapter)
-{
-	unsigned int count = atomic_read(&adapter->req_q.count);
-	if (!count)
-		atomic_inc(&adapter->qdio_outb_full);
-	return count > 0;
-}
-
 static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter)
+	__releases(&adapter->req_q_lock)
+	__acquires(&adapter->req_q_lock)
 {
+	struct zfcp_qdio_queue *req_q = &adapter->req_q;
 	long ret;
 
+	if (atomic_read(&req_q->count) <= -REQUEST_LIST_SIZE)
+		return -EIO;
+	if (atomic_read(&req_q->count) > 0)
+		return 0;
+
+	atomic_dec(&req_q->count);
 	spin_unlock_bh(&adapter->req_q_lock);
 	ret = wait_event_interruptible_timeout(adapter->request_wq,
-					zfcp_fsf_sbal_check(adapter), 5 * HZ);
+					atomic_read(&req_q->count) >= 0,
+					5 * HZ);
+	spin_lock_bh(&adapter->req_q_lock);
+	atomic_inc(&req_q->count);
+
 	if (ret > 0)
 		return 0;
 	if (!ret)
 		atomic_inc(&adapter->qdio_outb_full);
-
-	spin_lock_bh(&adapter->req_q_lock);
 	return -EIO;
 }
 

-- 

  parent reply	other threads:[~2008-12-19 15:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-19 15:56 [patch 00/11] zfcp patches for 2.6.29 Christof Schmitt
2008-12-19 15:56 ` [patch 01/11] zfcp: Fix message line break Christof Schmitt
2008-12-19 15:56 ` [patch 02/11] zfcp: register with SCSI layer on ccw registration Christof Schmitt
2008-12-19 15:56 ` Christof Schmitt [this message]
2008-12-19 15:56 ` [patch 04/11] zfcp: Remove adapter list Christof Schmitt
2008-12-19 15:56 ` [patch 05/11] zfcp: fix compile warning Christof Schmitt
2008-12-19 15:56 ` [patch 06/11] zfcp: Remove initial device data from zfcp_data Christof Schmitt
2008-12-19 15:56 ` [patch 07/11] zfcp: Simplify mask lookups for incoming RSCNs Christof Schmitt
2008-12-19 15:56 ` [patch 08/11] zfcp: remove DID_DID flag Christof Schmitt
2008-12-19 15:57 ` [patch 09/11] zfcp: Remove busid macro Christof Schmitt
2008-12-19 15:57 ` [patch 10/11] zfcp: Add support for unchained FSF requests Christof Schmitt
2008-12-19 15:57 ` [patch 11/11] zfcp: Remove unnecessary warning message Christof Schmitt

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=20081219155751.867385000@de.ibm.com \
    --to=christof.schmitt@de.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=felix@linux.vnet.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=schwidefsky@de.ibm.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