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

dmaengine: idxd: iax bus removal

There is no need to have an additional bus for the IAX device. The removal
of IAX will change user ABI as /sys/bus/iax will no longer exist.
The iax device will be moved to the dsa bus. The device id for dsa and
iax will now be combined rather than unique for each device type in order
to accommodate the iax devices. This is in preparation for fixing the
sub-driver code for idxd. There's no hardware deployment for Sapphire
Rapids platform yet, which means that users have no reason to have
developed scripts against this ABI. There is some exposure to
released versions of accel-config, but those are being fixed up and
an accel-config upgrade is reasonable to get IAX support. As far as
accel-config is concerned IAX support starts when these devices appear
under /sys/bus/dsa, and old accel-config just assumes that an empty /
missing /sys/bus/iax just means a lack of platform support.

Fixes: f25b463883a8 ("dmaengine: idxd: add IAX configuration support in the IDXD driver")
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161852988298.2203940.4529909758034944428.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Dave Jiang and committed by
Vinod Koul
4b73e4eb 04922b74

+13 -87
+1 -1
drivers/dma/idxd/cdev.c
··· 268 268 269 269 device_initialize(dev); 270 270 dev->parent = &wq->conf_dev; 271 - dev->bus = idxd_get_bus_type(idxd); 271 + dev->bus = &dsa_bus_type; 272 272 dev->type = &idxd_cdev_device_type; 273 273 dev->devt = MKDEV(MAJOR(cdev_ctx->devt), minor); 274 274
+1 -2
drivers/dma/idxd/idxd.h
··· 257 257 extern struct bus_type iax_bus_type; 258 258 259 259 extern bool support_enqcmd; 260 + extern struct ida idxd_ida; 260 261 extern struct device_type dsa_device_type; 261 262 extern struct device_type iax_device_type; 262 263 extern struct device_type idxd_wq_device_type; ··· 347 346 return wq->client_count; 348 347 }; 349 348 350 - struct ida *idxd_ida(struct idxd_device *idxd); 351 349 const char *idxd_get_dev_name(struct idxd_device *idxd); 352 350 int idxd_register_bus_type(void); 353 351 void idxd_unregister_bus_type(void); ··· 354 354 void idxd_unregister_devices(struct idxd_device *idxd); 355 355 int idxd_register_driver(void); 356 356 void idxd_unregister_driver(void); 357 - struct bus_type *idxd_get_bus_type(struct idxd_device *idxd); 358 357 struct device_type *idxd_get_device_type(struct idxd_device *idxd); 359 358 360 359 /* device interrupt control */
+6 -15
drivers/dma/idxd/init.c
··· 33 33 #define DRV_NAME "idxd" 34 34 35 35 bool support_enqcmd; 36 - 37 - static struct ida idxd_idas[IDXD_TYPE_MAX]; 36 + DEFINE_IDA(idxd_ida); 38 37 39 38 static struct pci_device_id idxd_pci_tbl[] = { 40 39 /* DSA ver 1.0 platforms */ ··· 49 50 "dsa", 50 51 "iax" 51 52 }; 52 - 53 - struct ida *idxd_ida(struct idxd_device *idxd) 54 - { 55 - return &idxd_idas[idxd->type]; 56 - } 57 53 58 54 const char *idxd_get_dev_name(struct idxd_device *idxd) 59 55 { ··· 161 167 wq->idxd = idxd; 162 168 device_initialize(&wq->conf_dev); 163 169 wq->conf_dev.parent = &idxd->conf_dev; 164 - wq->conf_dev.bus = idxd_get_bus_type(idxd); 170 + wq->conf_dev.bus = &dsa_bus_type; 165 171 wq->conf_dev.type = &idxd_wq_device_type; 166 172 rc = dev_set_name(&wq->conf_dev, "wq%d.%d", idxd->id, wq->id); 167 173 if (rc < 0) { ··· 252 258 group->idxd = idxd; 253 259 device_initialize(&group->conf_dev); 254 260 group->conf_dev.parent = &idxd->conf_dev; 255 - group->conf_dev.bus = idxd_get_bus_type(idxd); 261 + group->conf_dev.bus = &dsa_bus_type; 256 262 group->conf_dev.type = &idxd_group_device_type; 257 263 rc = dev_set_name(&group->conf_dev, "group%d.%d", idxd->id, group->id); 258 264 if (rc < 0) { ··· 403 409 404 410 idxd->pdev = pdev; 405 411 idxd_set_type(idxd); 406 - idxd->id = ida_alloc(idxd_ida(idxd), GFP_KERNEL); 412 + idxd->id = ida_alloc(&idxd_ida, GFP_KERNEL); 407 413 if (idxd->id < 0) 408 414 return NULL; 409 415 410 416 device_initialize(&idxd->conf_dev); 411 417 idxd->conf_dev.parent = dev; 412 - idxd->conf_dev.bus = idxd_get_bus_type(idxd); 418 + idxd->conf_dev.bus = &dsa_bus_type; 413 419 idxd->conf_dev.type = idxd_get_device_type(idxd); 414 420 rc = dev_set_name(&idxd->conf_dev, "%s%d", idxd_get_dev_name(idxd), idxd->id); 415 421 if (rc < 0) { ··· 663 669 664 670 static int __init idxd_init_module(void) 665 671 { 666 - int err, i; 672 + int err; 667 673 668 674 /* 669 675 * If the CPU does not support MOVDIR64B or ENQCMDS, there's no point in ··· 678 684 pr_warn("Platform does not have ENQCMD(S) support.\n"); 679 685 else 680 686 support_enqcmd = true; 681 - 682 - for (i = 0; i < IDXD_TYPE_MAX; i++) 683 - ida_init(&idxd_idas[i]); 684 687 685 688 err = idxd_register_bus_type(); 686 689 if (err < 0)
+5 -69
drivers/dma/idxd/sysfs.c
··· 301 301 .shutdown = idxd_config_bus_shutdown, 302 302 }; 303 303 304 - struct bus_type iax_bus_type = { 305 - .name = "iax", 306 - .match = idxd_config_bus_match, 307 - .probe = idxd_config_bus_probe, 308 - .remove = idxd_config_bus_remove, 309 - .shutdown = idxd_config_bus_shutdown, 310 - }; 311 - 312 - static struct bus_type *idxd_bus_types[] = { 313 - &dsa_bus_type, 314 - &iax_bus_type 315 - }; 316 - 317 304 static struct idxd_device_driver dsa_drv = { 318 305 .drv = { 319 306 .name = "dsa", ··· 309 322 .mod_name = KBUILD_MODNAME, 310 323 }, 311 324 }; 312 - 313 - static struct idxd_device_driver iax_drv = { 314 - .drv = { 315 - .name = "iax", 316 - .bus = &iax_bus_type, 317 - .owner = THIS_MODULE, 318 - .mod_name = KBUILD_MODNAME, 319 - }, 320 - }; 321 - 322 - static struct idxd_device_driver *idxd_drvs[] = { 323 - &dsa_drv, 324 - &iax_drv 325 - }; 326 - 327 - struct bus_type *idxd_get_bus_type(struct idxd_device *idxd) 328 - { 329 - return idxd_bus_types[idxd->type]; 330 - } 331 325 332 326 struct device_type *idxd_get_device_type(struct idxd_device *idxd) 333 327 { ··· 323 355 /* IDXD generic driver setup */ 324 356 int idxd_register_driver(void) 325 357 { 326 - int i, rc; 327 - 328 - for (i = 0; i < IDXD_TYPE_MAX; i++) { 329 - rc = driver_register(&idxd_drvs[i]->drv); 330 - if (rc < 0) 331 - goto drv_fail; 332 - } 333 - 334 - return 0; 335 - 336 - drv_fail: 337 - while (--i >= 0) 338 - driver_unregister(&idxd_drvs[i]->drv); 339 - return rc; 358 + return driver_register(&dsa_drv.drv); 340 359 } 341 360 342 361 void idxd_unregister_driver(void) 343 362 { 344 - int i; 345 - 346 - for (i = 0; i < IDXD_TYPE_MAX; i++) 347 - driver_unregister(&idxd_drvs[i]->drv); 363 + driver_unregister(&dsa_drv.drv); 348 364 } 349 365 350 366 /* IDXD engine attributes */ ··· 1589 1637 kfree(idxd->wqs); 1590 1638 kfree(idxd->engines); 1591 1639 kfree(idxd->irq_entries); 1592 - ida_free(idxd_ida(idxd), idxd->id); 1640 + ida_free(&idxd_ida, idxd->id); 1593 1641 kfree(idxd); 1594 1642 } 1595 1643 ··· 1744 1792 1745 1793 int idxd_register_bus_type(void) 1746 1794 { 1747 - int i, rc; 1748 - 1749 - for (i = 0; i < IDXD_TYPE_MAX; i++) { 1750 - rc = bus_register(idxd_bus_types[i]); 1751 - if (rc < 0) 1752 - goto bus_err; 1753 - } 1754 - 1755 - return 0; 1756 - 1757 - bus_err: 1758 - while (--i >= 0) 1759 - bus_unregister(idxd_bus_types[i]); 1760 - return rc; 1795 + return bus_register(&dsa_bus_type); 1761 1796 } 1762 1797 1763 1798 void idxd_unregister_bus_type(void) 1764 1799 { 1765 - int i; 1766 - 1767 - for (i = 0; i < IDXD_TYPE_MAX; i++) 1768 - bus_unregister(idxd_bus_types[i]); 1800 + bus_unregister(&dsa_bus_type); 1769 1801 }