X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fppc64%2Fkernel%2Fvio.c;h=48c4b0a0a69750eea99961b33fb3270af8b415f8;hb=9e1bf581d67d87a1d7fc0ea500729e3a03643a26;hp=ed20451775b69ace621e3991370f9a01d93ebd08;hpb=8d40237c730b8be87c1b80a5d96b9c603fefa829;p=linux-2.6.git diff --git a/arch/ppc64/kernel/vio.c b/arch/ppc64/kernel/vio.c index ed2045177..48c4b0a0a 100644 --- a/arch/ppc64/kernel/vio.c +++ b/arch/ppc64/kernel/vio.c @@ -521,7 +521,24 @@ static struct iommu_table * vio_build_iommu_table(struct vio_dev *dev) newTceTable = (struct iommu_table *) kmalloc(sizeof(struct iommu_table), GFP_KERNEL); - size = ((dma_window[4] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT; + /* RPA docs say that #address-cells is always 1 for virtual + devices, but some older boxes' OF returns 2. This should + be removed by GA, unless there is legacy OFs that still + have 2 for #address-cells */ + size = ((dma_window[1+vio_num_address_cells] >> PAGE_SHIFT) << 3) + >> PAGE_SHIFT; + + /* This is just an ugly kludge. Remove as soon as the OF for all + machines actually follow the spec and encodes the offset field + as phys-encode (that is, #address-cells wide)*/ + if (dma_window_property_size == 12) { + size = ((dma_window[1] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT; + } else if (dma_window_property_size == 20) { + size = ((dma_window[4] >> PAGE_SHIFT) << 3) >> PAGE_SHIFT; + } else { + printk(KERN_WARNING "vio_build_iommu_table: Invalid size of ibm,my-dma-window=%i, using 0x80 for size\n", dma_window_property_size); + size = 0x80; + } /* There should be some code to extract the phys-encoded offset using prom_n_addr_cells(). However, according to a comment