[POWERPC] Remove iSeries_vio_dev
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 11 Oct 2007 04:53:32 +0000 (14:53 +1000)
committerPaul Mackerras <paulus@samba.org>
Thu, 11 Oct 2007 10:40:45 +0000 (20:40 +1000)
It was only being used to carry around dma_iommu_ops and vio_iommu_table
which we can use directly instead.  This also means that vio_bus_device
doesn't need to refer to them either.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
arch/powerpc/kernel/vio.c
arch/powerpc/platforms/iseries/iommu.c
arch/powerpc/platforms/iseries/mf.c
arch/powerpc/platforms/iseries/viopath.c
drivers/cdrom/viocd.c
drivers/char/viotape.c
include/asm-powerpc/iseries/hv_call_event.h
include/asm-powerpc/iseries/vio.h

index fd631d4d1602a2cddd3ba215c91aaa76fa3277a6..eaf7f6992a2f943764b6ef5234ebcf9db659fac2 100644 (file)
@@ -49,11 +49,8 @@ static struct vio_dev vio_bus_device  = { /* fake "parent" device */
 };
 
 #ifdef CONFIG_PPC_ISERIES
-struct device *iSeries_vio_dev = &vio_bus_device.dev;
-EXPORT_SYMBOL(iSeries_vio_dev);
-
 static struct iommu_table veth_iommu_table;
-static struct iommu_table vio_iommu_table;
+struct iommu_table vio_iommu_table;
 
 static void __init iommu_vio_init(void)
 {
@@ -66,8 +63,6 @@ static void __init iommu_vio_init(void)
                printk("Virtual Bus VETH TCE table failed.\n");
        if (!iommu_init_table(&vio_iommu_table, -1))
                printk("Virtual Bus VIO TCE table failed.\n");
-       vio_bus_device.dev.archdata.dma_ops = &dma_iommu_ops;
-       vio_bus_device.dev.archdata.dma_data = &vio_iommu_table;
 }
 #else
 static void __init iommu_vio_init(void)
index 3b6a9666c2c07c0407989a5a17d98e2cdcdf4179..3281f10bbd16ef328c202c37e66f87b6f0f9b229 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/list.h>
 #include <linux/pci.h>
+#include <linux/module.h>
 
 #include <asm/iommu.h>
 #include <asm/tce.h>
@@ -36,6 +37,7 @@
 #include <asm/prom.h>
 #include <asm/pci-bridge.h>
 #include <asm/iseries/hv_call_xm.h>
+#include <asm/iseries/hv_call_event.h>
 #include <asm/iseries/iommu.h>
 
 static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
@@ -189,6 +191,34 @@ void iommu_devnode_init_iSeries(struct pci_dev *pdev, struct device_node *dn)
 }
 #endif
 
+extern struct iommu_table vio_iommu_table;
+
+void *iseries_hv_alloc(size_t size, dma_addr_t *dma_handle, gfp_t flag)
+{
+       return iommu_alloc_coherent(&vio_iommu_table, size, dma_handle,
+                               DMA_32BIT_MASK, flag, -1);
+}
+EXPORT_SYMBOL_GPL(iseries_hv_alloc);
+
+void iseries_hv_free(size_t size, void *vaddr, dma_addr_t dma_handle)
+{
+       iommu_free_coherent(&vio_iommu_table, size, vaddr, dma_handle);
+}
+EXPORT_SYMBOL_GPL(iseries_hv_free);
+
+dma_addr_t iseries_hv_map(void *vaddr, size_t size,
+                       enum dma_data_direction direction)
+{
+       return iommu_map_single(&vio_iommu_table, vaddr, size,
+                               DMA_32BIT_MASK, direction);
+}
+
+void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
+                       enum dma_data_direction direction)
+{
+       iommu_unmap_single(&vio_iommu_table, dma_handle, size, direction);
+}
+
 void iommu_init_early_iSeries(void)
 {
        ppc_md.tce_build = tce_build_iSeries;
index b1187d95e3b27fc6da3a873e374babcc1d265c4b..c0f2433bc16e75c20532982c65e581902b0e5481 100644 (file)
@@ -39,9 +39,9 @@
 #include <asm/paca.h>
 #include <asm/abs_addr.h>
 #include <asm/firmware.h>
-#include <asm/iseries/vio.h>
 #include <asm/iseries/mf.h>
 #include <asm/iseries/hv_lp_config.h>
+#include <asm/iseries/hv_lp_event.h>
 #include <asm/iseries/it_lp_queue.h>
 
 #include "setup.h"
@@ -870,8 +870,7 @@ static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
        if ((off + count) > 256)
                count = 256 - off;
 
-       dma_addr = dma_map_single(iSeries_vio_dev, page, off + count,
-                       DMA_FROM_DEVICE);
+       dma_addr = iseries_hv_map(page, off + count, DMA_FROM_DEVICE);
        if (dma_mapping_error(dma_addr))
                return -ENOMEM;
        memset(page, 0, off + count);
@@ -883,8 +882,7 @@ static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
        vsp_cmd.sub_data.kern.length = off + count;
        mb();
        rc = signal_vsp_instruction(&vsp_cmd);
-       dma_unmap_single(iSeries_vio_dev, dma_addr, off + count,
-                       DMA_FROM_DEVICE);
+       iseries_hv_unmap(dma_addr, off + count, DMA_FROM_DEVICE);
        if (rc)
                return rc;
        if (vsp_cmd.result_code != 0)
@@ -919,8 +917,7 @@ static int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
        int len = *size;
        dma_addr_t dma_addr;
 
-       dma_addr = dma_map_single(iSeries_vio_dev, buffer, len,
-                       DMA_FROM_DEVICE);
+       dma_addr = iseries_hv_map(buffer, len, DMA_FROM_DEVICE);
        memset(buffer, 0, len);
        memset(&vsp_cmd, 0, sizeof(vsp_cmd));
        vsp_cmd.cmd = 32;
@@ -938,7 +935,7 @@ static int mf_getVmlinuxChunk(char *buffer, int *size, int offset, u64 side)
                        rc = -ENOMEM;
        }
 
-       dma_unmap_single(iSeries_vio_dev, dma_addr, len, DMA_FROM_DEVICE);
+       iseries_hv_unmap(dma_addr, len, DMA_FROM_DEVICE);
 
        return rc;
 }
@@ -1149,8 +1146,7 @@ static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
                goto out;
 
        dma_addr = 0;
-       page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
-                       GFP_ATOMIC);
+       page = iseries_hv_alloc(count, &dma_addr, GFP_ATOMIC);
        ret = -ENOMEM;
        if (page == NULL)
                goto out;
@@ -1170,7 +1166,7 @@ static int proc_mf_change_cmdline(struct file *file, const char __user *buffer,
        ret = count;
 
 out_free:
-       dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
+       iseries_hv_free(count, page, dma_addr);
 out:
        return ret;
 }
@@ -1190,8 +1186,7 @@ static ssize_t proc_mf_change_vmlinux(struct file *file,
                goto out;
 
        dma_addr = 0;
-       page = dma_alloc_coherent(iSeries_vio_dev, count, &dma_addr,
-                       GFP_ATOMIC);
+       page = iseries_hv_alloc(count, &dma_addr, GFP_ATOMIC);
        rc = -ENOMEM;
        if (page == NULL) {
                printk(KERN_ERR "mf.c: couldn't allocate memory to set vmlinux chunk\n");
@@ -1219,7 +1214,7 @@ static ssize_t proc_mf_change_vmlinux(struct file *file,
        *ppos += count;
        rc = count;
 out_free:
-       dma_free_coherent(iSeries_vio_dev, count, page, dma_addr);
+       iseries_hv_free(count, page, dma_addr);
 out:
        return rc;
 }
index 45f2fe39c87eb8fd17cbd8ea0b8a8c5e43573da3..df23331eb25c2416b99fd91c137fa62675c7bbb8 100644 (file)
@@ -124,8 +124,7 @@ static int proc_viopath_show(struct seq_file *m, void *v)
        if (!buf)
                return 0;
 
-       handle = dma_map_single(iSeries_vio_dev, buf, HW_PAGE_SIZE,
-                               DMA_FROM_DEVICE);
+       handle = iseries_hv_map(buf, HW_PAGE_SIZE, DMA_FROM_DEVICE);
 
        hvrc = HvCallEvent_signalLpEventFast(viopath_hostLp,
                        HvLpEvent_Type_VirtualIo,
@@ -146,8 +145,7 @@ static int proc_viopath_show(struct seq_file *m, void *v)
        buf[HW_PAGE_SIZE-1] = '\0';
        seq_printf(m, "%s", buf);
 
-       dma_unmap_single(iSeries_vio_dev, handle, HW_PAGE_SIZE,
-                        DMA_FROM_DEVICE);
+       iseries_hv_unmap(handle, HW_PAGE_SIZE, DMA_FROM_DEVICE);
        kfree(buf);
 
        seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
index b88fdebe77f66b9dbdfacfa957945d7ab962055b..c081e5400ce00a47bd8077bfac96e3a1ee59dbe9 100644 (file)
@@ -220,7 +220,7 @@ static void __init get_viocd_info(void)
        struct cdrom_info *viocd_unitinfo;
        dma_addr_t unitinfo_dmaaddr;
 
-       viocd_unitinfo = dma_alloc_coherent(iSeries_vio_dev,
+       viocd_unitinfo = iseries_hv_alloc(
                        sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
                        &unitinfo_dmaaddr, GFP_ATOMIC);
        if (viocd_unitinfo == NULL) {
@@ -262,8 +262,7 @@ static void __init get_viocd_info(void)
        }
 
 error_ret:
-       dma_free_coherent(iSeries_vio_dev,
-                       sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
+       iseries_hv_free(sizeof(*viocd_unitinfo) * VIOCD_MAX_CD,
                        viocd_unitinfo, unitinfo_dmaaddr);
 }
 
index e12275df6ea2d271ec630f9c89945c6753bdf726..064c091952152861814d7295c6cc9e687352d2f8 100644 (file)
@@ -392,8 +392,8 @@ static int get_viotape_info(void)
        if (op == NULL)
                return -ENOMEM;
 
-       viotape_unitinfo = dma_alloc_coherent(iSeries_vio_dev, len,
-               &viotape_unitinfo_token, GFP_ATOMIC);
+       viotape_unitinfo = iseries_hv_alloc(len, &viotape_unitinfo_token,
+               GFP_ATOMIC);
        if (viotape_unitinfo == NULL) {
                free_op_struct(op);
                return -ENOMEM;
@@ -1103,8 +1103,7 @@ static void __exit viotap_exit(void)
        class_destroy(tape_class);
        unregister_chrdev(VIOTAPE_MAJOR, "viotape");
        if (viotape_unitinfo)
-               dma_free_coherent(iSeries_vio_dev,
-                               sizeof(viotape_unitinfo[0]) * VIOTAPE_MAX_TAPE,
+               iseries_hv_free(sizeof(viotape_unitinfo[0]) * VIOTAPE_MAX_TAPE,
                                viotape_unitinfo, viotape_unitinfo_token);
        viopath_close(viopath_hostLp, viomajorsubtype_tape, VIOTAPE_MAXREQ + 2);
        vio_clearHandler(viomajorsubtype_tape);
index 4cec4762076dffa99ce78ddc86401f2721af0ede..cc029d388e11a6bf3f5f1eda0bf53c91b0925c18 100644 (file)
@@ -21,6 +21,9 @@
 #ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
 #define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
 
+#include <linux/types.h>
+#include <linux/dma-mapping.h>
+
 #include <asm/iseries/hv_call_sc.h>
 #include <asm/iseries/hv_types.h>
 #include <asm/abs_addr.h>
@@ -113,6 +116,13 @@ static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
                        eventData3, eventData4, eventData5);
 }
 
+extern void *iseries_hv_alloc(size_t size, dma_addr_t *dma_handle, gfp_t flag);
+extern void iseries_hv_free(size_t size, void *vaddr, dma_addr_t dma_handle);
+extern dma_addr_t iseries_hv_map(void *vaddr, size_t size,
+                       enum dma_data_direction direction);
+extern void iseries_hv_unmap(dma_addr_t dma_handle, size_t size,
+                       enum dma_data_direction direction);
+
 static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
 {
        return HvCall1(HvCallEventAckLpEvent, virt_to_abs(event));
index 7a95d296abd12201a0e75dff0d228c14a2770bbc..5a5cd0f0c095e52436d8cbf59821f7d6e6977192 100644 (file)
@@ -150,8 +150,4 @@ enum viochar_rc {
        viochar_rc_ebusy = 1
 };
 
-struct device;
-
-extern struct device *iSeries_vio_dev;
-
 #endif /* _ASM_POWERPC_ISERIES_VIO_H */