RE: NPIV mapping problems (was Re: [PATCH 1/19] add data buffer accessors)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 29 June 2007, Andrew Vasquez wrote:
> On Sat, 12 May 2007, James Bottomley wrote:
> 
> > On Sat, 2007-05-12 at 19:05 +0900, FUJITA Tomonori wrote:
> > > Add a set of accessors for the scsi data buffer. This is in 
> > > preparation for chaining sg lists and bidirectional requests (and 
> > > possibly, the mid-layer dma mapping).
> > > 
> > > Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
> > > ---
> > >  drivers/scsi/scsi_lib.c  |   26 ++++++++++++++++++++++++++
> > >  include/scsi/scsi_cmnd.h |   11 +++++++++++
> > >  2 files changed, 37 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/drivers/scsi/scsi_lib.c 
> b/drivers/scsi/scsi_lib.c index 
> > > 1f5a07b..a2ebe61 100644
> > > --- a/drivers/scsi/scsi_lib.c
> > > +++ b/drivers/scsi/scsi_lib.c
> > > @@ -2290,3 +2290,29 @@ void scsi_kunmap_atomic_sg(void *virt)
> > >  	kunmap_atomic(virt, KM_BIO_SRC_IRQ);  }  
> > > EXPORT_SYMBOL(scsi_kunmap_atomic_sg);
> > > +
> > > +int scsi_dma_map(struct device *dev, struct scsi_cmnd *cmd)
> > 
> > Actually, this is redundant.  We make sure the
> > shost->shost_gendev.parent is the device which should have 
> been passed
> > in to scsi_add_host().
> 
> Well, there's perhaps an unintended side-effect with this 
> assumption, NPIV-based 'vports' (and their subsequent 'struct 
> device' members) are not fully initialized objects.
> 
> This is what we've run into while working on our NPIV (based) 
> driver with the 'data buffer' accessors works, while queueing 
> the first command to an sdev of a freshly created vport:
> ... 
> One possiblity (the least intrusive) would be to add a
> scsi_dma_map_with_device() function which takes the proper (LLD
> defined) 'struct device' as a parameter, as was originally 
> proposed, and have NPIV-aware drivers call that function 
> during the mappings of physical *and* virtual dma-mappings.
As a one possible solution, scsi_dma_map_with_device() has added.
With this change, the QLogic NPIV enabled driver has tested and it works
fine.
With the patch attached, would like to stroke this thread so that it can
move forward.

Thank you,
Seokmann
---
>From cddc43e416deeb875982f371d27c4fb074d5970e Mon Sep 17 00:00:00 2001
From: Seokmann Ju <seokmann.ju@xxxxxxxxxx>
Date: Tue, 3 Jul 2007 11:53:34 -0700
Subject: [PATCH] add data buffer accessor with device structure.

- in addition to scsi_dma_map(), scsi_dma_map_with_device() has added.
- this addition is for not fully instantiated host, like virtual hosts
on
  NPIV based implementation.

Signed-off-by: Seokmann Ju <seokmann.ju@xxxxxxxxxx>
---
 drivers/scsi/scsi_lib.c  |   22 ++++++++++++++++++++++
 include/scsi/scsi_cmnd.h |    1 +
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 70454b4..90601ed 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2315,6 +2315,28 @@ int scsi_dma_map(struct scsi_cmnd *cmd)
 EXPORT_SYMBOL(scsi_dma_map);

 /**
+ * scsi_dma_map_with_device - perform DMA mapping against command's sg
lists
+ * @dev:       device structure
+ * @cmd:       scsi command
+ *
+ * Returns the number of sg lists actually used, zero if the sg lists
+ * is NULL, or -ENOMEM if the mapping failed.
+ */
+int scsi_dma_map_with_device(struct device *dev, struct scsi_cmnd *cmd)
+{
+       int nseg = 0;
+
+       if (scsi_sg_count(cmd)) {
+               nseg = dma_map_sg(dev, scsi_sglist(cmd),
scsi_sg_count(cmd),
+                                 cmd->sc_data_direction);
+               if (unlikely(!nseg))
+                       return -ENOMEM;
+       }
+       return nseg;
+}
+EXPORT_SYMBOL(scsi_dma_map_with_device);
+
+/**
  * scsi_dma_unmap - unmap command's sg lists mapped by scsi_dma_map
  * @cmd:       scsi command
  */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 53e1705..a223331 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -136,6 +136,7 @@ extern struct scatterlist *scsi_alloc_sgtable(struct
scsi_cmnd *, gfp_t);
 extern void scsi_free_sgtable(struct scatterlist *, int);

 extern int scsi_dma_map(struct scsi_cmnd *cmd);
+extern int scsi_dma_map_with_device(struct device *dev, struct
scsi_cmnd *cmd);
 extern void scsi_dma_unmap(struct scsi_cmnd *cmd);

 #define scsi_sg_count(cmd) ((cmd)->use_sg)
--
1.5.2.2.603.g7c851
---

Attachment: 0001-add-data-buffer-accessor-with-device-structure.patch
Description: 0001-add-data-buffer-accessor-with-device-structure.patch


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux