From: James Smart <James.Smart@Emulex.Com>
To: linux-scsi <linux-scsi@vger.kernel.org>
Subject: [PATCH] scsi_lib_dma.c : fix bug /w dma mpas on virtual vc ports
Date: Wed, 23 Sep 2009 13:39:00 -0400 [thread overview]
Message-ID: <1253727540.30846.4.camel@ogier> (raw)
James,
This patch was originally posted 10/7/2008. It hasn't been picked up yet. Please incorporate the patch.
The original threads are at:
http://marc.info/?l=linux-scsi&m=122339015023134&w=2
http://marc.info/?l=linux-scsi&m=122338653014680&w=2
-- james s
Signed-off-by: James Smart <james.smart@emulex.com>
---
drivers/scsi/scsi_lib.c | 2 +-
drivers/scsi/scsi_lib_dma.c | 7 +++++--
include/scsi/scsi_host.h | 15 +++++++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
diff -upNr a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
--- a/drivers/scsi/scsi_lib.c 2009-09-23 12:37:53.000000000 -0400
+++ b/drivers/scsi/scsi_lib.c 2009-09-23 13:31:43.000000000 -0400
@@ -1611,7 +1611,7 @@ struct request_queue *__scsi_alloc_queue
request_fn_proc *request_fn)
{
struct request_queue *q;
- struct device *dev = shost->shost_gendev.parent;
+ struct device *dev = dev_to_nonscsi_dev(shost->shost_gendev.parent);
q = blk_init_queue(request_fn, NULL);
if (!q)
diff -upNr a/drivers/scsi/scsi_lib_dma.c b/drivers/scsi/scsi_lib_dma.c
--- a/drivers/scsi/scsi_lib_dma.c 2008-09-23 15:12:13.000000000 -0400
+++ b/drivers/scsi/scsi_lib_dma.c 2009-09-23 13:31:43.000000000 -0400
@@ -23,7 +23,8 @@ int scsi_dma_map(struct scsi_cmnd *cmd)
int nseg = 0;
if (scsi_sg_count(cmd)) {
- struct device *dev = cmd->device->host->shost_gendev.parent;
+ struct device *dev = dev_to_nonscsi_dev(
+ cmd->device->host->shost_gendev.parent);
nseg = dma_map_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
cmd->sc_data_direction);
@@ -41,10 +42,12 @@ EXPORT_SYMBOL(scsi_dma_map);
void scsi_dma_unmap(struct scsi_cmnd *cmd)
{
if (scsi_sg_count(cmd)) {
- struct device *dev = cmd->device->host->shost_gendev.parent;
+ struct device *dev = dev_to_nonscsi_dev(
+ cmd->device->host->shost_gendev.parent);
dma_unmap_sg(dev, scsi_sglist(cmd), scsi_sg_count(cmd),
cmd->sc_data_direction);
}
}
EXPORT_SYMBOL(scsi_dma_unmap);
+
diff -upNr a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
--- a/include/scsi/scsi_host.h 2009-06-29 10:31:27.000000000 -0400
+++ b/include/scsi/scsi_host.h 2009-09-23 13:31:43.000000000 -0400
@@ -698,6 +698,10 @@ static inline void *shost_priv(struct Sc
int scsi_is_host_device(const struct device *);
+/*
+ * walks object list backward, to find the first shost object.
+ * Skips over transport objects that may not be stargets, etc
+ */
static inline struct Scsi_Host *dev_to_shost(struct device *dev)
{
while (!scsi_is_host_device(dev)) {
@@ -708,6 +712,17 @@ static inline struct Scsi_Host *dev_to_s
return container_of(dev, struct Scsi_Host, shost_gendev);
}
+/*
+ * walks object list backward, to find the first non-scsi object
+ * Skips over transport objects that may be vports, shosts under vports, etc
+ */
+static inline struct device *dev_to_nonscsi_dev(struct device *dev)
+{
+ while (dev->type == NULL || scsi_is_host_device(dev))
+ dev = dev->parent;
+ return dev;
+}
+
static inline int scsi_host_in_recovery(struct Scsi_Host *shost)
{
return shost->shost_state == SHOST_RECOVERY ||
reply other threads:[~2009-09-23 17:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1253727540.30846.4.camel@ogier \
--to=james.smart@emulex.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox