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

spi: spi-mpc52xx-psc: Remove deprecated create_singlethread_workqueue

The workqueue "workqueue" has a single work item(&mps->work)
doesn't require ordering. Also, it is not being used on a memory reclaim
path. Hence, the singlethreaded workqueue has been replaced with the use
of system_wq.

System workqueues have been able to handle high level of concurrency
for a long time now and hence it's not required to have a singlethreaded
workqueue just to gain concurrency. Unlike a dedicated per-cpu workqueue
created with create_singlethread_workqueue(), system_wq allows multiple
work items to overlap executions even on the same CPU; however, a
per-cpu workqueue doesn't have any CPU locality or global ordering
guarantee unless the target CPU is explicitly specified and thus the
increase of local concurrency shouldn't make any difference.

Work item has been flushed in mpc52xx_psc_spi_of_remove() to ensure that
nothing is pending while disconnecting the driver.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Bhaktipriya Shridhar and committed by
Mark Brown
ac96b737 1a695a90

+3 -14
+3 -14
drivers/spi/spi-mpc52xx-psc.c
··· 42 42 u8 bits_per_word; 43 43 u8 busy; 44 44 45 - struct workqueue_struct *workqueue; 46 45 struct work_struct work; 47 46 48 47 struct list_head queue; ··· 298 299 299 300 spin_lock_irqsave(&mps->lock, flags); 300 301 list_add_tail(&m->queue, &mps->queue); 301 - queue_work(mps->workqueue, &mps->work); 302 + schedule_work(&mps->work); 302 303 spin_unlock_irqrestore(&mps->lock, flags); 303 304 304 305 return 0; ··· 424 425 INIT_WORK(&mps->work, mpc52xx_psc_spi_work); 425 426 INIT_LIST_HEAD(&mps->queue); 426 427 427 - mps->workqueue = create_singlethread_workqueue( 428 - dev_name(master->dev.parent)); 429 - if (mps->workqueue == NULL) { 430 - ret = -EBUSY; 431 - goto free_irq; 432 - } 433 - 434 428 ret = spi_register_master(master); 435 429 if (ret < 0) 436 - goto unreg_master; 430 + goto free_irq; 437 431 438 432 return ret; 439 433 440 - unreg_master: 441 - destroy_workqueue(mps->workqueue); 442 434 free_irq: 443 435 free_irq(mps->irq, mps); 444 436 free_master: ··· 474 484 struct spi_master *master = spi_master_get(platform_get_drvdata(op)); 475 485 struct mpc52xx_psc_spi *mps = spi_master_get_devdata(master); 476 486 477 - flush_workqueue(mps->workqueue); 478 - destroy_workqueue(mps->workqueue); 487 + flush_work(&mps->work); 479 488 spi_unregister_master(master); 480 489 free_irq(mps->irq, mps); 481 490 if (mps->psc)