* [PATCH] arcmsr: fix message allocation
@ 2008-02-20 13:29 Daniel Drake
2008-02-20 16:28 ` James Bottomley
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Drake @ 2008-02-20 13:29 UTC (permalink / raw)
To: James.Bottomley; +Cc: josh, kimhh, erich, linux-scsi, nick.cheng
arcmsr_iop_message_xfer() is called from atomic context under the
queuecommand scsi_host_template handler. James Bottomley pointed out
that the current GFP_KERNEL|GFP_DMA flags are wrong: firstly we are in
atomic context, secondly this memory is not used for DMA.
Also removed some unneeded casts.
Signed-off-by: Daniel Drake <dsd@gentoo.org>
---
drivers/scsi/arcmsr/arcmsr_hba.c | 26 +++++++++++---------------
1 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index 4f9ff32..f91f79c 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -1387,18 +1387,16 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
switch(controlcode) {
case ARCMSR_MESSAGE_READ_RQBUFFER: {
- unsigned long *ver_addr;
+ unsigned char *ver_addr;
uint8_t *pQbuffer, *ptmpQbuffer;
int32_t allxfer_len = 0;
- void *tmp;
- tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA);
- ver_addr = (unsigned long *)tmp;
- if (!tmp) {
+ ver_addr = kmalloc(1032, GFP_ATOMIC);
+ if (!ver_addr) {
retvalue = ARCMSR_MESSAGE_FAIL;
goto message_out;
}
- ptmpQbuffer = (uint8_t *) ver_addr;
+ ptmpQbuffer = ver_addr;
while ((acb->rqbuf_firstindex != acb->rqbuf_lastindex)
&& (allxfer_len < 1031)) {
pQbuffer = &acb->rqbuffer[acb->rqbuf_firstindex];
@@ -1427,26 +1425,24 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
}
arcmsr_iop_message_read(acb);
}
- memcpy(pcmdmessagefld->messagedatabuffer, (uint8_t *)ver_addr, allxfer_len);
+ memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len);
pcmdmessagefld->cmdmessage.Length = allxfer_len;
pcmdmessagefld->cmdmessage.ReturnCode = ARCMSR_MESSAGE_RETURNCODE_OK;
- kfree(tmp);
+ kfree(ver_addr);
}
break;
case ARCMSR_MESSAGE_WRITE_WQBUFFER: {
- unsigned long *ver_addr;
+ unsigned char *ver_addr;
int32_t my_empty_len, user_len, wqbuf_firstindex, wqbuf_lastindex;
uint8_t *pQbuffer, *ptmpuserbuffer;
- void *tmp;
- tmp = kmalloc(1032, GFP_KERNEL|GFP_DMA);
- ver_addr = (unsigned long *)tmp;
- if (!tmp) {
+ ver_addr = kmalloc(1032, GFP_ATOMIC);
+ if (!ver_addr) {
retvalue = ARCMSR_MESSAGE_FAIL;
goto message_out;
}
- ptmpuserbuffer = (uint8_t *)ver_addr;
+ ptmpuserbuffer = ver_addr;
user_len = pcmdmessagefld->cmdmessage.Length;
memcpy(ptmpuserbuffer, pcmdmessagefld->messagedatabuffer, user_len);
wqbuf_lastindex = acb->wqbuf_lastindex;
@@ -1492,7 +1488,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb, \
retvalue = ARCMSR_MESSAGE_FAIL;
}
}
- kfree(tmp);
+ kfree(ver_addr);
}
break;
--
1.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] arcmsr: fix message allocation
2008-02-20 13:29 [PATCH] arcmsr: fix message allocation Daniel Drake
@ 2008-02-20 16:28 ` James Bottomley
0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2008-02-20 16:28 UTC (permalink / raw)
To: Daniel Drake; +Cc: josh, kimhh, erich, linux-scsi, nick.cheng
On Wed, 2008-02-20 at 13:29 +0000, Daniel Drake wrote:
> arcmsr_iop_message_xfer() is called from atomic context under the
> queuecommand scsi_host_template handler. James Bottomley pointed out
> that the current GFP_KERNEL|GFP_DMA flags are wrong: firstly we are in
> atomic context, secondly this memory is not used for DMA.
> Also removed some unneeded casts.
This looks good to me. It would be nice to have acks from Areca, but
I'll queue it for upstream fixes in a day or so regardless.
James
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-02-20 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-20 13:29 [PATCH] arcmsr: fix message allocation Daniel Drake
2008-02-20 16:28 ` James Bottomley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox