diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-01-15 23:32:17 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-23 12:37:37 -0500 |
commit | de25deb18016f66dcdede165d07654559bb332bc (patch) | |
tree | b566c2a369d3dce85507ab28ea20ffee020e0c06 /drivers/scsi/hosts.c | |
parent | b30c2fc1113edfb2371427c10503ff942b0a0370 (diff) |
[SCSI] use dynamically allocated sense buffer
This removes static array sense_buffer in scsi_cmnd and uses
dynamically allocated sense_buffer (with GFP_DMA).
The reason for doing this is that some architectures need cacheline
aligned buffer for DMA:
http://lkml.org/lkml/2007/11/19/2
The problems are that scsi_eh_prep_cmnd puts scsi_cmnd::sense_buffer
to sglist and some LLDs directly DMA to scsi_cmnd::sense_buffer. It's
necessary to DMA to scsi_cmnd::sense_buffer safely. This patch solves
these issues.
__scsi_get_command allocates sense_buffer via kmem_cache_alloc and
attaches it to a scsi_cmnd so everything just work as before.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/hosts.c')
-rw-r--r-- | drivers/scsi/hosts.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 9a10b4335e76..f5d3fbb55717 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c | |||
@@ -268,6 +268,7 @@ static void scsi_host_dev_release(struct device *dev) | |||
268 | } | 268 | } |
269 | 269 | ||
270 | scsi_destroy_command_freelist(shost); | 270 | scsi_destroy_command_freelist(shost); |
271 | scsi_destroy_command_sense_buffer(shost); | ||
271 | if (shost->bqt) | 272 | if (shost->bqt) |
272 | blk_free_tags(shost->bqt); | 273 | blk_free_tags(shost->bqt); |
273 | 274 | ||
@@ -372,10 +373,14 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
372 | else | 373 | else |
373 | shost->dma_boundary = 0xffffffff; | 374 | shost->dma_boundary = 0xffffffff; |
374 | 375 | ||
375 | rval = scsi_setup_command_freelist(shost); | 376 | rval = scsi_setup_command_sense_buffer(shost); |
376 | if (rval) | 377 | if (rval) |
377 | goto fail_kfree; | 378 | goto fail_kfree; |
378 | 379 | ||
380 | rval = scsi_setup_command_freelist(shost); | ||
381 | if (rval) | ||
382 | goto fail_destroy_sense; | ||
383 | |||
379 | device_initialize(&shost->shost_gendev); | 384 | device_initialize(&shost->shost_gendev); |
380 | snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d", | 385 | snprintf(shost->shost_gendev.bus_id, BUS_ID_SIZE, "host%d", |
381 | shost->host_no); | 386 | shost->host_no); |
@@ -399,6 +404,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) | |||
399 | 404 | ||
400 | fail_destroy_freelist: | 405 | fail_destroy_freelist: |
401 | scsi_destroy_command_freelist(shost); | 406 | scsi_destroy_command_freelist(shost); |
407 | fail_destroy_sense: | ||
408 | scsi_destroy_command_sense_buffer(shost); | ||
402 | fail_kfree: | 409 | fail_kfree: |
403 | kfree(shost); | 410 | kfree(shost); |
404 | return NULL; | 411 | return NULL; |