Patch added to scsi-rc-fixes-2.6: [SCSI] arcmsr: fix message allocation
A message that is not in the archive (sent off-list or not yet received): 001401c87753$3edf4670$8800a8c0@Nick
Quoted 4 lines · nickcheng
Hi,
I definitely agree it is in atomic context but why is the memory not for DMA?
Would you please show me why?
It would probably be easier if you could explain where you believe the memory IS used for DMA :)
Anyway, looking at ARCMSR_MESSAGE_READ_RQBUFFER
current code does this:
ver_addr = kmalloc(1032, GFP_ATOMIC);
Here are the cases when that buffer is used:
checking for successful malloc: not DMA
if (!ver_addr) {copying the address: not DMA
ptmpQbuffer = ver_addr;
memcpying 1 byte into the buffer: not DMA
memcpy(ptmpQbuffer, pQbuffer, 1);
incrementing address: not DMA
ptmpQbuffer++;
memcpying from the buffer: not DMA
memcpy(pcmdmessagefld->messagedatabuffer, ver_addr, allxfer_len);
freeing the buffer: not DMA
kfree(ver_addr);
Daniel
Sorry, maybe I did not ask distinctly enough.
I mean if I would like to allocate a memory space from ZONE_DMA for atomic context, why can I not use kmalloc(1032, GFP_ATOMIC|GFP_DMA)? In case of lack of GFP_DMA, kmalloc would grab the memory from ZONE_HIGH or ZONE_HIGHMEM, isn't it?(I read it from the textbook of Linux Kernel Development by Robert Love)
Or the basic is that you don't think it is necessary to allocate a memory space from DMA area?
Please give me some comments.
Thank you very much, :-)
-----Original Message-----
From: Daniel Drake [mailto:[email protected]]
Sent: Monday, February 25, 2008 6:15 PM
To: [email protected]
Cc: 'James Bottomley'; [email protected]
Subject: Re: Patch added to scsi-rc-fixes-2.6: [SCSI] arcmsr: fix message allocation
Quoted 4 lines · nickcheng
Hi,
I definitely agree it is in atomic context but why is the memory not for DMA?
Would you please show me why?
It would probably be easier if you could explain where you believe the memory IS used for DMA :)
Anyway, looking at ARCMSR_MESSAGE_READ_RQBUFFER
current code does this:
ver_addr = kmalloc(1032, GFP_ATOMIC);
Here are the cases when that buffer is used:
checking for successful malloc: not DMA
if (!ver_addr) {copying the address: not DMA
ptmpQbuffer = ver_addr;
memcpying 1 byte into the buffer: not DMA
memcpy(ptmpQbuffer, pQbuffer, 1);
incrementing address: not DMA
ptmpQbuffer++;
memcpying from the buffer: not DMA
memcpy(pcmdmessagefld->messagedatabuffer, ver_addr,
allxfer_len);
freeing the buffer: not DMA
kfree(ver_addr);
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
James Bottomley
maintainerQuoted 6 lines · nickcheng
Sorry, maybe I did not ask distinctly enough.
I mean if I would like to allocate a memory space fromZONE_DMAfor atomic context, why can I not usekmalloc(1032, GFP_ATOMIC|GFP_DMA)? In case of lack ofGFP_DMA, kmalloc would grab the memory fromZONE_HIGHorZONE_HIGHMEM, isn't it?(I read it from the textbook of Linux Kernel Development by Robert Love)
Um, no that's not true at all. GFP_DMA only allocates memory from ZONE_DMA and fails otherwise. You only need memory from ZONE_DMA if you cannot address physical memory above 24 bits (the old ISA restriction). This only applies if you're a standard ISA device and you're going actually to DMA to the memory in question. Neither of which applies in the arcmsr case, since you're only using the memory as a copy buffer within the kernel (it never sees an actual DMA transfer), and arcmsr doesn't have the ISA restrictions.
Quoted 3 lines
Or the basic is that you don't think it is necessary to allocate a memory space from DMA area?
Please give me some comments.
It's unnecessary because you never DMA to it, but even if you did, since arcmsr is a non-ISA device (with 64 bit DMA mask falling back to 32) you can just use ordinary kmalloc'd memory for that (provided you obey the coherence requirements).
James
RE: Patch added to scsi-rc-fixes-2.6: [SCSI] arcmsr: fix messageallocation
James,
Appreciate for your answer.
One more question: do you think there are any compatibility issues on kmalloc/kfree pair?
I just trace the kernel code. It looks like it would not. But I am not quite sure absolutely.
May I have your comments?
Thank you,
-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Monday, February 25, 2008 10:39 PM
To: [email protected]
Cc: 'Daniel Drake'; [email protected]; 'erich'
Subject: RE: Patch added to scsi-rc-fixes-2.6: [SCSI] arcmsr: fix messageallocation
Quoted 4 lines · nickcheng
Sorry, maybe I did not ask distinctly enough.
I mean if I would like to allocate a memory space fromZONE_DMAfor atomic context, why can I not usekmalloc(1032, GFP_ATOMIC|GFP_DMA)? In case of lack ofGFP_DMA, kmalloc would grab the memory fromZONE_HIGH
or
Quoted 2 lines
ZONE_HIGHMEM, isn't it?(I read it from the textbook of Linux Kernel Development by Robert Love)
Um, no that's not true at all. GFP_DMA only allocates memory from ZONE_DMA and fails otherwise. You only need memory from ZONE_DMA if you cannot address physical memory above 24 bits (the old ISA restriction). This only applies if you're a standard ISA device and you're going actually to DMA to the memory in question. Neither of which applies in the arcmsr case, since you're only using the memory as a copy buffer within the kernel (it never sees an actual DMA transfer), and arcmsr doesn't have the ISA restrictions.
Quoted 3 lines
Or the basic is that you don't think it is necessary to allocate a memory space from DMA area?
Please give me some comments.
It's unnecessary because you never DMA to it, but even if you did, since arcmsr is a non-ISA device (with 64 bit DMA mask falling back to 32) you can just use ordinary kmalloc'd memory for that (provided you obey the coherence requirements).
James
James Bottomley
maintainerRE: Patch added to scsi-rc-fixes-2.6: [SCSI] arcmsr: fix messageallocation
Quoted 7 lines · nickcheng
James,
Appreciate for your answer.
One more question: do you think there are any compatibility issues on kmalloc/kfree pair?
I just trace the kernel code. It looks like it would not. But I am not quite sure absolutely.
May I have your comments?
You mean does kmalloc/kfree obey the same rules as the coherent allocators in all regards except coherence ... pretty much, yes. There are some technical differences at the bottom in terms of page alignment, but nothing you need to worry about.
James