From: Boaz Harrosh <bharrosh@panasas.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-scsi@vger.kernel.org, Matthew Wilcox <willy@linux.intel.com>
Subject: Re: [PATCH 04/21] advansys: Fix simultaneous calls to ->queuecommand
Date: Mon, 08 Oct 2007 12:07:47 +0200 [thread overview]
Message-ID: <470A0173.7000603@panasas.com> (raw)
In-Reply-To: <11913765423981-git-send-email-matthew@wil.cx>
On Wed, Oct 03 2007 at 3:55 +0200, Matthew Wilcox <matthew@wil.cx> wrote:
> The narrow board used two global structures to set up a command;
> unfortunately they weren't locked, so with two boards in the machine,
> one call to queuecommand could corrupt the data being used by the other
> call to queuecommand.
>
> Fix this by allocating asc_scsi_q on the stack (64 bytes) and using kmalloc
> for the asc_sg_head (2k)
>
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> ---
> drivers/scsi/advansys.c | 88 +++++++++++++++++++++--------------------------
> 1 files changed, 39 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
> index 3dd7856..fd4d669 100644
> @@ -10257,12 +10240,12 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
> dma_map_single(boardp->dev, scp->request_buffer,
> scp->request_bufflen,
> scp->sc_data_direction) : 0;
> - asc_scsi_q.q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
> - asc_scsi_q.q1.data_cnt = cpu_to_le32(scp->request_bufflen);
> + asc_scsi_q->q1.data_addr = cpu_to_le32(scp->SCp.dma_handle);
> + asc_scsi_q->q1.data_cnt = cpu_to_le32(scp->request_bufflen);
> ASC_STATS_ADD(scp->device->host, cont_xfer,
> ASC_CEILING(scp->request_bufflen, 512));
> - asc_scsi_q.q1.sg_queue_cnt = 0;
> - asc_scsi_q.sg_head = NULL;
> + asc_scsi_q->q1.sg_queue_cnt = 0;
> + asc_scsi_q->sg_head = NULL;
> } else {
> /*
> * CDB scatter-gather request list.
> @@ -10270,6 +10253,7 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
> int sgcnt;
> int use_sg;
> struct scatterlist *slp;
> + struct asc_sg_head *asc_sg_head;
>
> slp = (struct scatterlist *)scp->request_buffer;
> use_sg = dma_map_sg(boardp->dev, slp, scp->use_sg,
> @@ -10287,28 +10271,31 @@ static int asc_build_req(asc_board_t *boardp, struct scsi_cmnd *scp)
>
> ASC_STATS(scp->device->host, sg_cnt);
>
> - /*
> - * Use global ASC_SG_HEAD structure and set the ASC_SCSI_Q
> - * structure to point to it.
> - */
> - memset(&asc_sg_head, 0, sizeof(ASC_SG_HEAD));
> + asc_sg_head = kzalloc(sizeof(asc_scsi_q->sg_head) +
> + use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);
> + if (!asc_sg_head) {
> + dma_unmap_sg(boardp->dev, slp, scp->use_sg,
> + scp->sc_data_direction);
> + scp->result = HOST_BYTE(DID_SOFT_ERROR);
> + return ASC_ERROR;
> + }
>
> - asc_scsi_q.q1.cntl |= QC_SG_HEAD;
> - asc_scsi_q.sg_head = &asc_sg_head;
> - asc_scsi_q.q1.data_cnt = 0;
> - asc_scsi_q.q1.data_addr = 0;
> + asc_scsi_q->q1.cntl |= QC_SG_HEAD;
> + asc_scsi_q->sg_head = asc_sg_head;
> + asc_scsi_q->q1.data_cnt = 0;
> + asc_scsi_q->q1.data_addr = 0;
> /* This is a byte value, otherwise it would need to be swapped. */
> - asc_sg_head.entry_cnt = asc_scsi_q.q1.sg_queue_cnt = use_sg;
> + asc_sg_head->entry_cnt = asc_scsi_q->q1.sg_queue_cnt = use_sg;
> ASC_STATS_ADD(scp->device->host, sg_elem,
> - asc_sg_head.entry_cnt);
> + asc_sg_head->entry_cnt);
>
> /*
> * Convert scatter-gather list into ASC_SG_HEAD list.
> */
> for (sgcnt = 0; sgcnt < use_sg; sgcnt++, slp++) {
> - asc_sg_head.sg_list[sgcnt].addr =
> + asc_sg_head->sg_list[sgcnt].addr =
> cpu_to_le32(sg_dma_address(slp));
> - asc_sg_head.sg_list[sgcnt].bytes =
> + asc_sg_head->sg_list[sgcnt].bytes =
> cpu_to_le32(sg_dma_len(slp));
> ASC_STATS_ADD(scp->device->host, sg_xfer,
> ASC_CEILING(sg_dma_len(slp), 512));
> @@ -11338,14 +11325,17 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)
>
> if (ASC_NARROW_BOARD(boardp)) {
> ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
> + struct asc_scsi_q asc_scsi_q;
>
> /* asc_build_req() can not return ASC_BUSY. */
> - if (asc_build_req(boardp, scp) == ASC_ERROR) {
> + ret = asc_build_req(boardp, scp, &asc_scsi_q);
> + if (ret == ASC_ERROR) {
> ASC_STATS(scp->device->host, build_error);
> return ASC_ERROR;
> }
>
> ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
> + kfree(asc_scsi_q.sg_head);
> err_code = asc_dvc->err_code;
> } else {
> ADV_DVC_VAR *adv_dvc = &boardp->dvc_var.adv_dvc_var;
Matthew
I see that these patches are before the conversion to scsi data accessors
and !use_sg cleanup that was posted by TOMO:
http://www.spinics.net/lists/linux-scsi/msg19055.html
Could you please also post that patch rebased to latest changes as part of
your patchset?
I was hoping we could get all the data accessors patches into 2.6.24,
Is this patchset for the 2.6.24 window?
Thanks
Boaz
next prev parent reply other threads:[~2007-10-08 10:07 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-03 1:55 [PATCH 01/21] advansys: Eliminate prototypes Matthew Wilcox
2007-10-03 1:55 ` [PATCH 02/21] advansys: Remove array of scsi targets Matthew Wilcox
2007-10-03 2:19 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 03/21] advansys: Restructure asc_execute_scsi_cmnd() Matthew Wilcox
2007-10-03 2:17 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 04/21] advansys: Fix simultaneous calls to ->queuecommand Matthew Wilcox
2007-10-08 10:07 ` Boaz Harrosh [this message]
2007-10-09 13:27 ` Matthew Wilcox
2007-10-03 1:55 ` [PATCH 05/21] advansys: Improve reset handler Matthew Wilcox
2007-10-03 1:55 ` [PATCH 06/21] advansys: Remove ASC_SELECT_QUEUE_DEPTHS Matthew Wilcox
2007-10-03 2:17 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 07/21] advansys: Remove ASC_WIDE_BOARD predicate Matthew Wilcox
2007-10-03 1:55 ` [PATCH 08/21] advansys: Sort out irq number mess Matthew Wilcox
2007-10-03 1:55 ` [PATCH 09/21] advansys: Merge ASC_IERR definitions Matthew Wilcox
2007-10-03 1:55 ` [PATCH 10/21] advansys: Remove asc_board_t typedef and ASC_BOARDP macro Matthew Wilcox
2007-10-03 2:02 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 11/21] advansys: Remove library version & serial numbers Matthew Wilcox
2007-10-03 2:14 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 12/21] advansys: Sort out debug macros Matthew Wilcox
2007-10-03 2:02 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 13/21] advansys: Remove private lock Matthew Wilcox
2007-10-03 2:09 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 14/21] advansys: Get rid of board index number Matthew Wilcox
2007-10-03 2:04 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 15/21] advansys: Make sdtr_period_tbl a pointer Matthew Wilcox
2007-10-03 1:55 ` [PATCH 16/21] advansys: Move a couple of fields from struct board to struct adv_dvc Matthew Wilcox
2007-10-03 1:55 ` [PATCH 17/21] advansys: Remove DvcGetPhyAddr Matthew Wilcox
2007-10-03 2:13 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 18/21] advansys: convert to use the data buffer accessors Matthew Wilcox
2007-10-03 1:55 ` [PATCH 19/21] advansys: Remove a couple of uses of bus_to_virt Matthew Wilcox
2007-10-03 2:13 ` Jeff Garzik
2007-10-03 12:37 ` Matthew Wilcox
2007-10-03 14:28 ` Jeff Garzik
2007-10-03 14:34 ` Matthew Wilcox
2007-10-03 14:46 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 20/21] advansys: Use dma mapping for overrun buffer Matthew Wilcox
2007-10-03 2:11 ` Jeff Garzik
2007-10-03 1:55 ` [PATCH 21/21] advansys: Changes to work on parisc Matthew Wilcox
2007-10-03 2:00 ` Jeff Garzik
2007-10-03 2:15 ` Matthew Wilcox
2007-10-03 2:28 ` Jeff Garzik
2007-10-03 3:00 ` Matthew Wilcox
2007-10-03 3:15 ` Jeff Garzik
2007-10-03 8:06 ` Christoph Hellwig
2007-10-03 8:05 ` Christoph Hellwig
2007-10-03 14:45 ` Jeff Garzik
2007-10-05 19:03 ` Andrew Morton
2007-10-05 19:34 ` Matthew Wilcox
2007-10-05 20:00 ` Andrew Morton
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=470A0173.7000603@panasas.com \
--to=bharrosh@panasas.com \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=willy@linux.intel.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.