From: "Stephen M. Cameron" <scameron@beardog.cce.hp.com>
To: axboe@kernel.dk, akpm@linux-foundation.org, james.bottomley@suse.de
Cc: linux-kernel@vger.kernel.org, mikem@beardog.cce.hp.com,
linux-scsi@vger.kernel.org, brace@beardog.cce.hp.com
Subject: [PATCH 4/9] cciss: simplify scatter gather code
Date: Fri, 26 Feb 2010 16:01:27 -0600 [thread overview]
Message-ID: <20100226220127.11979.29389.stgit@beardog.cce.hp.com> (raw)
In-Reply-To: <20100226220023.11979.4999.stgit@beardog.cce.hp.com>
From: Stephen M. Cameron <scameron@beardog.cce.hp.com>
cciss: simplify scatter gather code.
Instead of allocating an array of pointers to a structure
containing an SGDescriptor structure, and two other elements
that aren't really used, just allocate SGDescriptor structs.
Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
---
drivers/block/cciss.c | 43 +++++++++++++++----------------------------
drivers/block/cciss.h | 8 +-------
2 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index eddb916..adc517c 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -257,7 +257,7 @@ static inline void removeQ(CommandList_struct *c)
hlist_del_init(&c->list);
}
-static void cciss_free_sg_chain_blocks(struct Cmd_sg_list **cmd_sg_list,
+static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list,
int nr_cmds)
{
int i;
@@ -265,20 +265,17 @@ static void cciss_free_sg_chain_blocks(struct Cmd_sg_list **cmd_sg_list,
if (!cmd_sg_list)
return;
for (i = 0; i < nr_cmds; i++) {
- if (cmd_sg_list[i]) {
- kfree(cmd_sg_list[i]->sgchain);
- kfree(cmd_sg_list[i]);
- cmd_sg_list[i] = NULL;
- }
+ kfree(cmd_sg_list[i]);
+ cmd_sg_list[i] = NULL;
}
kfree(cmd_sg_list);
}
-static struct Cmd_sg_list **cciss_allocate_sg_chain_blocks(ctlr_info_t *h,
- int chainsize, int nr_cmds)
+static SGDescriptor_struct **cciss_allocate_sg_chain_blocks(
+ ctlr_info_t *h, int chainsize, int nr_cmds)
{
int j;
- struct Cmd_sg_list **cmd_sg_list;
+ SGDescriptor_struct **cmd_sg_list;
if (chainsize <= 0)
return NULL;
@@ -289,16 +286,10 @@ static struct Cmd_sg_list **cciss_allocate_sg_chain_blocks(ctlr_info_t *h,
/* Build up chain blocks for each command */
for (j = 0; j < nr_cmds; j++) {
- cmd_sg_list[j] = kmalloc(sizeof(*cmd_sg_list[j]), GFP_KERNEL);
- if (!cmd_sg_list[j]) {
- dev_err(&h->pdev->dev, "Cannot get memory "
- "for chain block.\n");
- goto clean;
- }
/* Need a block of chainsized s/g elements. */
- cmd_sg_list[j]->sgchain = kmalloc((chainsize *
- sizeof(SGDescriptor_struct)), GFP_KERNEL);
- if (!cmd_sg_list[j]->sgchain) {
+ cmd_sg_list[j] = kmalloc((chainsize *
+ sizeof(*cmd_sg_list[j])), GFP_KERNEL);
+ if (!cmd_sg_list[j]) {
dev_err(&h->pdev->dev, "Cannot get memory "
"for s/g chains.\n");
goto clean;
@@ -1731,7 +1722,7 @@ static void cciss_softirq_done(struct request *rq)
pci_unmap_single(h->pdev, temp64.val,
cmd->SG[i].Len, ddir);
/* Point to the next block */
- curr_sg = h->cmd_sg_list[cmd->cmdindex]->sgchain;
+ curr_sg = h->cmd_sg_list[cmd->cmdindex];
sg_index = 0;
}
temp64.val32.lower = curr_sg[sg_index].Addr.lower;
@@ -3206,7 +3197,7 @@ static void do_cciss_request(struct request_queue *q)
curr_sg[sg_index].Ext = CCISS_SG_CHAIN;
/* Point to next chain block. */
- curr_sg = h->cmd_sg_list[c->cmdindex]->sgchain;
+ curr_sg = h->cmd_sg_list[c->cmdindex];
sg_index = 0;
chained = 1;
}
@@ -3223,6 +3214,7 @@ static void do_cciss_request(struct request_queue *q)
if (chained) {
int len;
+ dma_addr_t dma_addr;
curr_sg = c->SG;
sg_index = h->max_cmd_sgentries - 1;
len = curr_sg[sg_index].Len;
@@ -3231,16 +3223,11 @@ static void do_cciss_request(struct request_queue *q)
* block with address of next chain block.
*/
temp64.val = pci_map_single(h->pdev,
- h->cmd_sg_list[c->cmdindex]->sgchain,
- len, dir);
-
- h->cmd_sg_list[c->cmdindex]->sg_chain_dma = temp64.val;
+ h->cmd_sg_list[c->cmdindex], len, dir);
+ dma_addr = temp64.val;
curr_sg[sg_index].Addr.lower = temp64.val32.lower;
curr_sg[sg_index].Addr.upper = temp64.val32.upper;
-
- pci_dma_sync_single_for_device(h->pdev,
- h->cmd_sg_list[c->cmdindex]->sg_chain_dma,
- len, dir);
+ pci_dma_sync_single_for_device(h->pdev, dma_addr, len, dir);
}
/* track how many SG entries we are using */
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 2b07bda..ac454fd 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -55,12 +55,6 @@ typedef struct _drive_info_struct
char device_initialized; /* indicates whether dev is initialized */
} drive_info_struct;
-struct Cmd_sg_list {
- SGDescriptor_struct *sgchain;
- dma_addr_t sg_chain_dma;
- int chain_block_size;
-};
-
struct ctlr_info
{
int ctlr;
@@ -89,7 +83,7 @@ struct ctlr_info
int maxsgentries;
int chainsize;
int max_cmd_sgentries;
- struct Cmd_sg_list **cmd_sg_list;
+ SGDescriptor_struct **cmd_sg_list;
# define DOORBELL_INT 0
# define PERF_MODE_INT 1
next prev parent reply other threads:[~2010-02-26 21:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-26 22:01 [PATCH 0/9] cciss driver SCSI updates Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 1/9] cciss: clarify command list padding calculation Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 2/9] cciss: detect bad alignment of scsi commands at build time Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 3/9] cciss: factor out scatter gather chain block allocation and freeing Stephen M. Cameron
2010-02-26 22:01 ` Stephen M. Cameron [this message]
2010-02-26 22:01 ` [PATCH 5/9] cciss: fix scatter gather chain block dma direction kludge Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 6/9] cciss: factor out scatter gather chain block mapping code Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 7/9] cciss: do not use void pointer for scsi hba data Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 8/9] cciss: eliminate unnecessary pointer use in cciss scsi code Stephen M. Cameron
2010-02-26 22:01 ` [PATCH 9/9] cciss: Fix problem with scatter gather elements in the scsi half of the driver Stephen M. Cameron
2010-02-28 18:43 ` [PATCH 0/9] cciss driver SCSI updates Jens Axboe
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=20100226220127.11979.29389.stgit@beardog.cce.hp.com \
--to=scameron@beardog.cce.hp.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=brace@beardog.cce.hp.com \
--cc=james.bottomley@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mikem@beardog.cce.hp.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 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.