All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: "\"Tóth Attila\"" <atoth@atoth.sote.hu>
Cc: adam radford <aradford@gmail.com>,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: twa generates WARNING upon boot
Date: Tue, 29 Sep 2015 11:33:01 -0700	[thread overview]
Message-ID: <1443551581.2207.26.camel@HansenPartnership.com> (raw)
In-Reply-To: <95d34bcc4c0fcf84d02d76a4443ba07c.squirrel@atoth.sote.hu>

On Tue, 2015-09-29 at 20:25 +0200, "Tóth Attila" wrote:
> 2015.Szeptember 29.(K) 20:02 időpontban James Bottomley ezt írta:
> > On Tue, 2015-09-29 at 10:37 -0700, James Bottomley wrote:
> >> On Tue, 2015-09-29 at 18:49 +0200, "Tóth Attila" wrote:
> >> > 2015.Szeptember 27.(V) 23:19 időpontban adam radford ezt írta:
> >> > > On Sun, Sep 27, 2015 at 4:56 AM, "Tóth Attila" <atoth@atoth.sote.hu>
> >> > > wrote:
> >> > >> The 3ware card is a 9650SE-12ML running in a Asus Z8PE-D12X
> >> > >>
> >> > >
> >> > > Can you re-try with Christoph's patch:
> >> > >
> >> > > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=118c855b5623f3e2e6204f02623d88c09e0c34de
> >> >
> >> > As I've told this patch has been already included in the kernel I'm
> >> using
> >> > (4.1.7-hardened-r1, which is based on 4.1.7).
> >> > Out of curiosity I've reverted the patch and the WARNING no longer
> >> appears
> >> > during boot...
> >>
> >> Ah, it looks like there's a bug in the patch, it doesn't take into
> >> account that the driver has a minimum sg map length and it copies for
> >> things under that, so we're likely unmapping something that wasn't
> >> mapped.   It's slightly hard to fix given that the indicator flag we'd
> >> use for this is gone in that patch; does this fix the warning?
> >
> > Actually, strike that, it would still barf on internally generated
> > commands (and it's recursively calling twa_scsi_dma_unmap).  This does a
> > partial revert of the state check which should pick up all cases the
> > input didn't go through the mapping.
> 
> Just to be clear before I try something out.
> In this latter patch you are resurrecting TW_PHASE_SGLIST, which has been
> ment to be removed in Christoph's patch from the header.
> I guess I have to reintroduce those phase defines on top of the changes
> below in your latest email.
> Or please let me know what should I exactly try out.

Heh, sorry forgot the header change.  This should be the complete patch
attached.

James

---

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index add419d..751ed66 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -151,7 +151,13 @@ static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int re
 static char *twa_string_lookup(twa_message_type *table, unsigned int aen_code);
 
 /* Functions */
+static void twa_scsi_dma_unmap(struct scsi_cmnd *SCpnt)
+{
+	if (SCpnt->SCp.phase == TW_PHASE_SGLIST)
+		scsi_dma_unmap(SCpnt);
+}
 
+  
 /* Show some statistics about the card */
 static ssize_t twa_show_stats(struct device *dev,
 			      struct device_attribute *attr, char *buf)
@@ -1339,7 +1345,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
 				}
 
 				/* Now complete the io */
-				scsi_dma_unmap(cmd);
+				twa_scsi_dma_unmap(cmd);
 				cmd->scsi_done(cmd);
 				tw_dev->state[request_id] = TW_S_COMPLETED;
 				twa_free_request_id(tw_dev, request_id);
@@ -1582,7 +1588,7 @@ static int twa_reset_device_extension(TW_Device_Extension *tw_dev)
 				struct scsi_cmnd *cmd = tw_dev->srb[i];
 
 				cmd->result = (DID_RESET << 16);
-				scsi_dma_unmap(cmd);
+				twa_scsi_dma_unmap(cmd);
 				cmd->scsi_done(cmd);
 			}
 		}
@@ -1762,15 +1768,18 @@ static int twa_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_
 	/* Save the scsi command for use by the ISR */
 	tw_dev->srb[request_id] = SCpnt;
 
+	/* Initialize phase to zero */
+	SCpnt->SCp.phase = TW_PHASE_INITIAL;
+
 	retval = twa_scsiop_execute_scsi(tw_dev, request_id, NULL, 0, NULL);
 	switch (retval) {
 	case SCSI_MLQUEUE_HOST_BUSY:
-		scsi_dma_unmap(SCpnt);
+		twa_scsi_dma_unmap(SCpnt);
 		twa_free_request_id(tw_dev, request_id);
 		break;
 	case 1:
 		SCpnt->result = (DID_ERROR << 16);
-		scsi_dma_unmap(SCpnt);
+		twa_scsi_dma_unmap(SCpnt);
 		done(SCpnt);
 		tw_dev->state[request_id] = TW_S_COMPLETED;
 		twa_free_request_id(tw_dev, request_id);
@@ -1845,6 +1854,8 @@ static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id,
 				if (sg_count < 0)
 					goto out;
 
+				srb->SCp.phase = TW_PHASE_SGLIST;
+
 				scsi_for_each_sg(srb, sg, sg_count, i) {
 					command_packet->sg_list[i].address = TW_CPU_TO_SGL(sg_dma_address(sg));
 					command_packet->sg_list[i].length = cpu_to_le32(sg_dma_len(sg));
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 0fdc83c..c88d5bd 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -324,6 +324,10 @@ static twa_message_type twa_error_table[] = {
 #define TW_CURRENT_DRIVER_BUILD 0
 #define TW_CURRENT_DRIVER_BRANCH 0
 
+/* Phase defines */
+#define TW_PHASE_INITIAL 0
+#define TW_PHASE_SGLIST  1
+
 /* Misc defines */
 #define TW_9550SX_DRAIN_COMPLETED	      0xFFFF
 #define TW_SECTOR_SIZE                        512


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2015-09-29 18:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-27 11:56 twa generates WARNING upon boot "Tóth Attila"
2015-09-27 21:19 ` adam radford
2015-09-29 16:49   ` "Tóth Attila"
2015-09-29 17:37     ` James Bottomley
2015-09-29 18:02       ` James Bottomley
2015-09-29 18:25         ` "Tóth Attila"
2015-09-29 18:33           ` James Bottomley [this message]
2015-09-30 16:08             ` Christoph Hellwig
2015-09-30 16:15               ` James Bottomley
2015-09-30 16:31                 ` Christoph Hellwig
2015-09-30 16:36                   ` James Bottomley
2015-09-30 16:41                     ` Christoph Hellwig
2015-09-30 16:43                       ` James Bottomley
2015-09-30 16:44                         ` Christoph Hellwig
2015-09-30 20:18                           ` "Tóth Attila"
2015-09-30 16:20               ` kbuild test robot
2015-09-28  5:55 "Tóth Attila"
2015-09-29 19:17 "Tóth Attila"

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=1443551581.2207.26.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=aradford@gmail.com \
    --cc=atoth@atoth.sote.hu \
    --cc=linux-scsi@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.