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

misc: mic: Remove COSM functionality from the MIC card driver

Since card side COSM functionality, to trigger MIC device shutdowns
and communicate shutdown status to the host, is now moved into a
separate COSM client driver, this patch removes this functionality
from the base MIC card driver. The mic_bus driver is also updated to
use the device index provided by COSM rather than maintain its own
device index.

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

authored by

Ashutosh Dixit and committed by
Greg Kroah-Hartman
d411e793 1da2b3ee

+23 -105
+4 -18
drivers/misc/mic/bus/mic_bus.c
··· 25 25 #include <linux/idr.h> 26 26 #include <linux/mic_bus.h> 27 27 28 - /* Unique numbering for mbus devices. */ 29 - static DEFINE_IDA(mbus_index_ida); 30 - 31 28 static ssize_t device_show(struct device *d, 32 29 struct device_attribute *attr, char *buf) 33 30 { ··· 144 147 145 148 struct mbus_device * 146 149 mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, 147 - struct mbus_hw_ops *hw_ops, void __iomem *mmio_va) 150 + struct mbus_hw_ops *hw_ops, int index, 151 + void __iomem *mmio_va) 148 152 { 149 153 int ret; 150 154 struct mbus_device *mbdev; ··· 164 166 mbdev->dev.release = mbus_release_dev; 165 167 mbdev->hw_ops = hw_ops; 166 168 mbdev->dev.bus = &mic_bus; 167 - 168 - /* Assign a unique device index and hence name. */ 169 - ret = ida_simple_get(&mbus_index_ida, 0, 0, GFP_KERNEL); 170 - if (ret < 0) 171 - goto free_mbdev; 172 - 173 - mbdev->index = ret; 169 + mbdev->index = index; 174 170 dev_set_name(&mbdev->dev, "mbus-dev%u", mbdev->index); 175 171 /* 176 172 * device_register() causes the bus infrastructure to look for a ··· 172 180 */ 173 181 ret = device_register(&mbdev->dev); 174 182 if (ret) 175 - goto ida_remove; 183 + goto free_mbdev; 176 184 return mbdev; 177 - ida_remove: 178 - ida_simple_remove(&mbus_index_ida, mbdev->index); 179 185 free_mbdev: 180 186 kfree(mbdev); 181 187 return ERR_PTR(ret); ··· 182 192 183 193 void mbus_unregister_device(struct mbus_device *mbdev) 184 194 { 185 - int index = mbdev->index; /* save for after device release */ 186 - 187 195 device_unregister(&mbdev->dev); 188 - ida_simple_remove(&mbus_index_ida, index); 189 196 } 190 197 EXPORT_SYMBOL_GPL(mbus_unregister_device); 191 198 ··· 194 207 static void __exit mbus_exit(void) 195 208 { 196 209 bus_unregister(&mic_bus); 197 - ida_destroy(&mbus_index_ida); 198 210 } 199 211 200 212 core_initcall(mbus_init);
+3 -85
drivers/misc/mic/card/mic_device.c
··· 37 37 #include "mic_virtio.h" 38 38 39 39 static struct mic_driver *g_drv; 40 - static struct mic_irq *shutdown_cookie; 41 - 42 - static void mic_notify_host(u8 state) 43 - { 44 - struct mic_driver *mdrv = g_drv; 45 - struct mic_bootparam __iomem *bootparam = mdrv->dp; 46 - 47 - iowrite8(state, &bootparam->shutdown_status); 48 - dev_dbg(mdrv->dev, "%s %d system_state %d\n", 49 - __func__, __LINE__, state); 50 - mic_send_intr(&mdrv->mdev, ioread8(&bootparam->c2h_shutdown_db)); 51 - } 52 - 53 - static int mic_panic_event(struct notifier_block *this, unsigned long event, 54 - void *ptr) 55 - { 56 - struct mic_driver *mdrv = g_drv; 57 - struct mic_bootparam __iomem *bootparam = mdrv->dp; 58 - 59 - iowrite8(-1, &bootparam->h2c_config_db); 60 - iowrite8(-1, &bootparam->h2c_shutdown_db); 61 - mic_notify_host(MIC_CRASHED); 62 - return NOTIFY_DONE; 63 - } 64 - 65 - static struct notifier_block mic_panic = { 66 - .notifier_call = mic_panic_event, 67 - }; 68 - 69 - static irqreturn_t mic_shutdown_isr(int irq, void *data) 70 - { 71 - struct mic_driver *mdrv = g_drv; 72 - struct mic_bootparam __iomem *bootparam = mdrv->dp; 73 - 74 - mic_ack_interrupt(&g_drv->mdev); 75 - if (ioread8(&bootparam->shutdown_card)) 76 - orderly_poweroff(true); 77 - return IRQ_HANDLED; 78 - } 79 - 80 - static int mic_shutdown_init(void) 81 - { 82 - int rc = 0; 83 - struct mic_driver *mdrv = g_drv; 84 - struct mic_bootparam __iomem *bootparam = mdrv->dp; 85 - int shutdown_db; 86 - 87 - shutdown_db = mic_next_card_db(); 88 - shutdown_cookie = mic_request_card_irq(mic_shutdown_isr, NULL, 89 - "Shutdown", mdrv, shutdown_db); 90 - if (IS_ERR(shutdown_cookie)) 91 - rc = PTR_ERR(shutdown_cookie); 92 - else 93 - iowrite8(shutdown_db, &bootparam->h2c_shutdown_db); 94 - return rc; 95 - } 96 - 97 - static void mic_shutdown_uninit(void) 98 - { 99 - struct mic_driver *mdrv = g_drv; 100 - struct mic_bootparam __iomem *bootparam = mdrv->dp; 101 - 102 - iowrite8(-1, &bootparam->h2c_shutdown_db); 103 - mic_free_card_irq(shutdown_cookie, mdrv); 104 - } 105 40 106 41 static int __init mic_dp_init(void) 107 42 { ··· 294 359 u8 node_id; 295 360 296 361 g_drv = mdrv; 297 - /* 298 - * Unloading the card module is not supported. The MIC card module 299 - * handles fundamental operations like host/card initiated shutdowns 300 - * and informing the host about card crashes and cannot be unloaded. 301 - */ 362 + /* Unloading the card module is not supported. */ 302 363 if (!try_module_get(mdrv->dev->driver->owner)) { 303 364 rc = -ENODEV; 304 365 goto done; ··· 305 374 rc = mic_init_irq(); 306 375 if (rc) 307 376 goto dp_uninit; 308 - rc = mic_shutdown_init(); 309 - if (rc) 310 - goto irq_uninit; 311 377 if (!mic_request_dma_chans(mdrv)) { 312 378 rc = -ENODEV; 313 - goto shutdown_uninit; 379 + goto irq_uninit; 314 380 } 315 381 rc = mic_devices_init(mdrv); 316 382 if (rc) ··· 318 390 NULL, &scif_hw_ops, 319 391 0, node_id, &mdrv->mdev.mmio, NULL, 320 392 NULL, mdrv->dp, mdrv->dma_ch, 321 - mdrv->num_dma_ch); 393 + mdrv->num_dma_ch, true); 322 394 if (IS_ERR(mdrv->scdev)) { 323 395 rc = PTR_ERR(mdrv->scdev); 324 396 goto device_uninit; 325 397 } 326 398 mic_create_card_debug_dir(mdrv); 327 - atomic_notifier_chain_register(&panic_notifier_list, &mic_panic); 328 399 done: 329 400 return rc; 330 401 device_uninit: 331 402 mic_devices_uninit(mdrv); 332 403 dma_free: 333 404 mic_free_dma_chans(mdrv); 334 - shutdown_uninit: 335 - mic_shutdown_uninit(); 336 405 irq_uninit: 337 406 mic_uninit_irq(); 338 407 dp_uninit: ··· 350 425 scif_unregister_device(mdrv->scdev); 351 426 mic_devices_uninit(mdrv); 352 427 mic_free_dma_chans(mdrv); 353 - /* 354 - * Inform the host about the shutdown status i.e. poweroff/restart etc. 355 - * The module cannot be unloaded so the only code path to call 356 - * mic_devices_uninit(..) is the shutdown callback. 357 - */ 358 - mic_notify_host(system_state); 359 - mic_shutdown_uninit(); 360 428 mic_uninit_irq(); 361 429 mic_dp_uninit(); 362 430 module_put(mdrv->dev->driver->owner);
+1 -1
drivers/misc/mic/card/mic_x100.c
··· 261 261 mic_hw_intr_init(mdrv); 262 262 platform_set_drvdata(pdev, mdrv); 263 263 mdrv->dma_mbdev = mbus_register_device(mdrv->dev, MBUS_DEV_DMA_MIC, 264 - NULL, &mbus_hw_ops, 264 + NULL, &mbus_hw_ops, 0, 265 265 mdrv->mdev.mmio.va); 266 266 if (IS_ERR(mdrv->dma_mbdev)) { 267 267 rc = PTR_ERR(mdrv->dma_mbdev);
+13
drivers/misc/mic/common/mic_dev.h
··· 21 21 #ifndef __MIC_DEV_H__ 22 22 #define __MIC_DEV_H__ 23 23 24 + /* The maximum number of MIC devices supported in a single host system. */ 25 + #define MIC_MAX_NUM_DEVS 128 26 + 27 + /** 28 + * enum mic_hw_family - The hardware family to which a device belongs. 29 + */ 30 + enum mic_hw_family { 31 + MIC_FAMILY_X100 = 0, 32 + MIC_FAMILY_X200, 33 + MIC_FAMILY_UNKNOWN, 34 + MIC_FAMILY_LAST 35 + }; 36 + 24 37 /** 25 38 * struct mic_mw - MIC memory window 26 39 *
+2 -1
include/linux/mic_bus.h
··· 91 91 92 92 struct mbus_device * 93 93 mbus_register_device(struct device *pdev, int id, struct dma_map_ops *dma_ops, 94 - struct mbus_hw_ops *hw_ops, void __iomem *mmio_va); 94 + struct mbus_hw_ops *hw_ops, int index, 95 + void __iomem *mmio_va); 95 96 void mbus_unregister_device(struct mbus_device *mbdev); 96 97 97 98 int mbus_register_driver(struct mbus_driver *drv);