Why cann’t we remove the ZONE_DMA from Linux

ZONE_DMA设置的原因是因为,当年主板上的ISA总线中的DMA控制器只能寻址24位物理地址,因此最多能够寻址到16MB的地方。现在,随着硬件的发展,ISA早已经成为历史。可是,为什么现在还要保留着ZONE_DMA区呢?

这是在linux-kernel mail list上的答案:

http://lkml.org/lkml/2010/4/4/2
While ISA is gone as a true peripheral interconnect for new systems it does, 
actually, still live on in a lot of systems that Linux still supports. While
those systems, generally, are running the same kernel and userspace they were
a decade ago I have no doubt that somebody might find an old machine and put
Linux on it - just because they could.

And that also discounts the non-IBM PC machines that are out there that Linux
also supports. While I don't know enough about them to say for sure, I am
quite certain that at least some of them are still using the ISA bus.

DRH


> Thanks for your reply.And do you means that , If I use a modern PC,such as
> my pc (CPU:Intel dual-core 2.6GHZ; Memory 2GB; And no pci ).I can remove
> the ZONE_DMA .And make sure this system also run smoothly as before?

*MAYBE* - if you don't use parallel ports, floppy drives or similar. There
actually are still a lot of devices that use the ISA bus in a modern PC - even
the keyboard (well, not USB ones) is an ISA device.

Simple fact is that if it was possible to configure it out and not cause
massive problems somebody would have already spun out a patch to allow just
that.

DRH


Incorrect about that. The i810 chipset doesn't support the ISA bus as an
*EXPANSION* *BUS* - it does, however, have an internal ISA bus that happens to
be hardwired for certain chips. Among those chips is the keyboard controller
that is a part of the PS/2 keyboard and mouse system. But for those components
that do DMA... Look at the parallel port and the floppy drive - both
(technically) live on the ISA bus.
But I'm not a hardware expert by any stretch - most of what I know is gleaned
from reading code and manual. However... the bits I'm talking about have
interfaces that are, for the most part, carved in stone. Changing them would
require adding circuitry to allow the existing interface continued function -
so I doubt anyone has changed them. (I mean... it'd be almost stupid - have
you ever really looked at the amount of real-estate on a modern MB devoted to
nothing but making sure traces are properly routed? There is a reason they
talk about boards being "4 layer" and such...)
DRH
---------------------

Last I heard this discussed it was mentioned that there were some 
fairly common integrated sound devices using ISA DMA.

As for the i810 chipset not supporting ISA that isn't really true. No
one implements ISA plug-in slots, but at least in the for of LPC
hardware that is effectively ISA continues to be supported for various
legacy devices.

Ultimately I don't see much point in disabling ZONE_DMA. It is a lot of
work to track down if it is really needed, and it only costs 16MB. So
unless someone shows me that ZONE_DMA triggers the OOM killer unnecessarily
or otherwise impacts the system what does legacy code hurt?

Eric

---------------------

Some onboard motherboard devices may also be ISA devices.

Thomas Fjellstrom

----------------------------------
Floppy disks & paralell ports still use DMA

Regards
Oliver

------------------------------------
There are a couple of reasons to keep ZONE_DMA. It is not used by ISA
device drivers exclusivly. Old style PCI devices may have small DMA
masks (so they could address between 16 MB and 4GB depending on the
device) too. Drivers for these devices often use ZONE_DMA as a fallback
if they can't allocate memory addressable by the device using
ZONE_NORMAL. So there is a use for ZONE_DMA with 32bit PCI too.
(And I also remember I have seen an AM2 board with an ISA slot for
embedded purposes too, so ISA is not completly dead)

Joerg

--------------------------------------

I think Joerg is right. In short wods, ZONE_DMA is not only an relative thing to ISA devices. ISA devices need it in the ancient board because they could not refer to all the memory addresses which are usually 32-bit, on the contrary, ISA devices just use 24-bit address. ZONE_DMA serves those kmalloc call with GFP_DMA and __GFP_DMA flags, and that is the true meaning of it.
It is not reasonable to truncate ZONE_DMA, because although it could be defined as a size of 16MB, the actual size of DMA transferring region is decided by the watermark of  ZONE_NORMAL. It is saying that a part of ZONE_DMA could be used as ZONE_NORMAL memory when lowmem_reserved_ratio is set to a certain value. Refer to Documentation/sysctl/vm.txt for more information.
Best regards,
--
Adam Jiang

总结以上大牛的观点,我分析如下:

1、现在的一些机器必须使用ISA插槽的主板,比如税务部门,他们需要使用税控卡,税控卡有很多是ISA插槽的,另外,对于部分主板集成的声卡,内部也在使用ISA总线。我听说还有工程控制卡,用于工程监控,也是ISA接口的。

2、虽然在有些机器中,没有使用ISA扩展总线,但是ZONE_DMA仍然有它的作用:
若ZONE_NORMAL区中的内存量不足的话,ZONE_DMA就会被当作ZONE_NORMAL区来使用。

评论

此博客中的热门博文

Linux/ARM Page Table Entry 属性设置分析

提交了30次才AC ---【附】POJ 2488解题报告

ARM Linux 如何模拟X86 PTE中的Present Young和Dirty标志位