Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: mic: add dma support in card driver

This patch adds a dma device on the mic virtual bus

Reviewed-by: Nikhil Rao <nikhil.rao@intel.com>
Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: Siva Yerramreddy <yshivakrishna@gmail.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Siva Yerramreddy and committed by
Greg Kroah-Hartman
a93a5244 9c3d37c7

+61 -4
+1 -1
drivers/misc/mic/Kconfig
··· 39 39 40 40 config INTEL_MIC_CARD 41 41 tristate "Intel MIC Card Driver" 42 - depends on 64BIT && X86 42 + depends on 64BIT && X86 && INTEL_MIC_BUS 43 43 select VIRTIO 44 44 help 45 45 This enables card driver support for the Intel Many Integrated
+6 -2
drivers/misc/mic/card/mic_device.h
··· 31 31 #include <linux/io.h> 32 32 #include <linux/irqreturn.h> 33 33 #include <linux/interrupt.h> 34 + #include <linux/mic_bus.h> 34 35 35 36 /** 36 37 * struct mic_intr_info - Contains h/w specific interrupt sources info ··· 72 71 * @hotplug_work: Hot plug work for adding/removing virtio devices. 73 72 * @irq_info: The OS specific irq information 74 73 * @intr_info: H/W specific interrupt information. 74 + * @dma_mbdev: dma device on the MIC virtual bus. 75 75 */ 76 76 struct mic_driver { 77 77 char name[20]; ··· 83 81 struct work_struct hotplug_work; 84 82 struct mic_irq_info irq_info; 85 83 struct mic_intr_info intr_info; 84 + struct mbus_device *dma_mbdev; 86 85 }; 87 86 88 87 /** ··· 120 117 int mic_driver_init(struct mic_driver *mdrv); 121 118 void mic_driver_uninit(struct mic_driver *mdrv); 122 119 int mic_next_card_db(void); 123 - struct mic_irq *mic_request_card_irq(irq_handler_t handler, 124 - irq_handler_t thread_fn, const char *name, void *data, int intr_src); 120 + struct mic_irq * 121 + mic_request_card_irq(irq_handler_t handler, irq_handler_t thread_fn, 122 + const char *name, void *data, int intr_src); 125 123 void mic_free_card_irq(struct mic_irq *cookie, void *data); 126 124 u32 mic_read_spad(struct mic_device *mdev, unsigned int idx); 127 125 void mic_send_intr(struct mic_device *mdev, int doorbell);
+54 -1
drivers/misc/mic/card/mic_x100.c
··· 148 148 iounmap(addr); 149 149 } 150 150 151 + static inline struct mic_driver *mbdev_to_mdrv(struct mbus_device *mbdev) 152 + { 153 + return dev_get_drvdata(mbdev->dev.parent); 154 + } 155 + 156 + static struct mic_irq * 157 + _mic_request_threaded_irq(struct mbus_device *mbdev, 158 + irq_handler_t handler, irq_handler_t thread_fn, 159 + const char *name, void *data, int intr_src) 160 + { 161 + int rc = 0; 162 + unsigned int irq = intr_src; 163 + unsigned long cookie = irq; 164 + 165 + rc = request_threaded_irq(irq, handler, thread_fn, 0, name, data); 166 + if (rc) { 167 + dev_err(mbdev_to_mdrv(mbdev)->dev, 168 + "request_threaded_irq failed rc = %d\n", rc); 169 + return ERR_PTR(rc); 170 + } 171 + return (struct mic_irq *)cookie; 172 + } 173 + 174 + static void _mic_free_irq(struct mbus_device *mbdev, 175 + struct mic_irq *cookie, void *data) 176 + { 177 + unsigned long irq = (unsigned long)cookie; 178 + free_irq(irq, data); 179 + } 180 + 181 + static void _mic_ack_interrupt(struct mbus_device *mbdev, int num) 182 + { 183 + mic_ack_interrupt(&mbdev_to_mdrv(mbdev)->mdev); 184 + } 185 + 186 + static struct mbus_hw_ops mbus_hw_ops = { 187 + .request_threaded_irq = _mic_request_threaded_irq, 188 + .free_irq = _mic_free_irq, 189 + .ack_interrupt = _mic_ack_interrupt, 190 + }; 191 + 151 192 static int __init mic_probe(struct platform_device *pdev) 152 193 { 153 194 struct mic_driver *mdrv = &g_drv; ··· 207 166 goto done; 208 167 } 209 168 mic_hw_intr_init(mdrv); 169 + platform_set_drvdata(pdev, mdrv); 170 + mdrv->dma_mbdev = mbus_register_device(mdrv->dev, MBUS_DEV_DMA_MIC, 171 + NULL, &mbus_hw_ops, 172 + mdrv->mdev.mmio.va); 173 + if (IS_ERR(mdrv->dma_mbdev)) { 174 + rc = PTR_ERR(mdrv->dma_mbdev); 175 + dev_err(&pdev->dev, "mbus_add_device failed rc %d\n", rc); 176 + goto iounmap; 177 + } 210 178 rc = mic_driver_init(mdrv); 211 179 if (rc) { 212 180 dev_err(&pdev->dev, "mic_driver_init failed rc %d\n", rc); 213 - goto iounmap; 181 + goto remove_dma; 214 182 } 215 183 done: 216 184 return rc; 185 + remove_dma: 186 + mbus_unregister_device(mdrv->dma_mbdev); 217 187 iounmap: 218 188 iounmap(mdev->mmio.va); 219 189 return rc; ··· 236 184 struct mic_device *mdev = &mdrv->mdev; 237 185 238 186 mic_driver_uninit(mdrv); 187 + mbus_unregister_device(mdrv->dma_mbdev); 239 188 iounmap(mdev->mmio.va); 240 189 return 0; 241 190 }