Skip to contentSkip to conversation

__get_free_pages() problem on ia64

DISCUSSION Adhiraj 3 participants 6 messages Sep 26, 2006 – Sep 27, 2006

lore
Share & tools
lore

Adhiraj

author
#0 lore raw

Hi All,

I found a strange thing on ia64 platform. When I allocate pages using __get_free_pages() with GFP_DMA, sometimes the physical addresses of allocated pages fall beyond 4G.

I am working on a device driver where the device does not support addresses above 4G and hence I have to implement bounce buffers. The bounce buffer code works fine on other architectures. But since I get 4G+ addresses on ia64, the code would not work. Any idea why should this happen? And any workaround if I _NEED_ addresses below 4G. The machine has 2G of physical memory.

The dma mask for the driver is set to 64 bits using pci_set_dma_mask().

Thanks in advance,
Adhiraj.

#1 lore raw
Quoted 6 lines · Adhiraj

I found a strange thing on ia64 platform. When I allocate pages using __get_free_pages() with GFP_DMA, sometimes the physical addresses of allocated pages fall beyond 4G.

I am working on a device driver where the device does not support addresses above 4G and hence I have to implement bounce buffers. The

You should be using the services described in Documentation/DMA-mapping.txt rather than allocating your own bounce buffers.

Quoted 1 line

The dma mask for the driver is set to 64 bits using pci_set_dma_mask().

Well, that's one of your problems right there .... if your device can only DMA up to 4GB then you should set it to DMA_32BIT_MASK.

author
#2 lore raw
In reply to Adhiraj
Quoted 11 lines · Matthew Wilcox
Quoted 6 lines · Adhiraj

I found a strange thing on ia64 platform. When I allocate pages using __get_free_pages() with GFP_DMA, sometimes the physical addresses of allocated pages fall beyond 4G.

I am working on a device driver where the device does not support addresses above 4G and hence I have to implement bounce buffers. The

You should be using the services described in Documentation/DMA-mapping.txt rather than allocating your own bounce buffers.

Ok, thanks, I will look into it. But the question is why do I get addresses beyond 4G (virt_to_phys() of returned addresses) even when I use GFP_DMA. Is this a known problem on ia64?

Quoted 7 lines
Quoted 2 lines

The dma mask for the driver is set to 64 bits using pci_set_dma_mask().

Well, that's one of your problems right there .... if your device can only DMA up to 4GB then you should set it to DMA_32BIT_MASK.

#3 lore raw
In reply to Adhiraj
Quoted 3 lines · Adhiraj

Ok, thanks, I will look into it. But the question is why do I get addresses beyond 4G (virt_to_phys() of returned addresses) even when I use GFP_DMA. Is this a known problem on ia64?

All memory is DMAable as we have an IOMMU. ZONE_DMA doesn't mean what you think it means.

#4 lore raw
In reply to Adhiraj
Quoted 6 lines
Quoted 3 lines

Ok, thanks, I will look into it. But the question is why do I get addresses beyond 4G (virt_to_phys() of returned addresses) even when I use GFP_DMA. Is this a known problem on ia64?

All memory is DMAable as we have an IOMMU. ZONE_DMA doesn't mean what you think it means.

You have an IOMMU ... but not all ia64 systems do (hence the need for swiotlb).

-Tony

#5 lore raw
In reply to Adhiraj
Quoted 8 lines · Tony
Quoted 6 lines
Quoted 3 lines

Ok, thanks, I will look into it. But the question is why do I get addresses beyond 4G (virt_to_phys() of returned addresses) even when I use GFP_DMA. Is this a known problem on ia64?

All memory is DMAable as we have an IOMMU. ZONE_DMA doesn't mean what you think it means.

You have an IOMMU ... but not all ia64 systems do (hence the need for swiotlb).

From the device driver's point of view, all ia64 systems have an IOMMU, whether it be implemented in hardware (all sane systems) or software (Intel ones).