Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d919e8d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull workqueue changes from Tejun Heo:
 "PREPARE_[DELAYED_]WORK() were used to change the work function of work
  items without fully reinitializing it; however, this makes workqueue
  consider the work item as a different one from before and allows the
  work item to start executing before the previous instance is finished
  which can lead to extremely subtle issues which are painful to debug.

  The interface has never been popular.  This pull request contains
  patches to remove existing usages and kill the interface.  As one of
  the changes was routed during the last devel cycle and another
  depended on a pending change in nvme, for-3.15 contains a couple merge
  commits.

  In addition, interfaces which were deprecated quite a while ago -
  __cancel_delayed_work() and WQ_NON_REENTRANT - are removed too"

* 'for-3.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: remove deprecated WQ_NON_REENTRANT
  workqueue: Spelling s/instensive/intensive/
  workqueue: remove PREPARE_[DELAYED_]WORK()
  staging/fwserial: don't use PREPARE_WORK
  afs: don't use PREPARE_WORK
  nvme: don't use PREPARE_WORK
  usb: don't use PREPARE_DELAYED_WORK
  floppy: don't use PREPARE_[DELAYED_]WORK
  ps3-vuart: don't use PREPARE_WORK
  wireless/rt2x00: don't use PREPARE_WORK in rt2800usb.c
  workqueue: Remove deprecated __cancel_delayed_work()
parents cf6fafcf 59ff3eb6
Loading
Loading
Loading
Loading
+28 −14
Original line number Diff line number Diff line
@@ -961,17 +961,31 @@ static void empty(void)
{
}

static DECLARE_WORK(floppy_work, NULL);
static void (*floppy_work_fn)(void);

static void floppy_work_workfn(struct work_struct *work)
{
	floppy_work_fn();
}

static DECLARE_WORK(floppy_work, floppy_work_workfn);

static void schedule_bh(void (*handler)(void))
{
	WARN_ON(work_pending(&floppy_work));

	PREPARE_WORK(&floppy_work, (work_func_t)handler);
	floppy_work_fn = handler;
	queue_work(floppy_wq, &floppy_work);
}

static DECLARE_DELAYED_WORK(fd_timer, NULL);
static void (*fd_timer_fn)(void) = NULL;

static void fd_timer_workfn(struct work_struct *work)
{
	fd_timer_fn();
}

static DECLARE_DELAYED_WORK(fd_timer, fd_timer_workfn);

static void cancel_activity(void)
{
@@ -982,7 +996,7 @@ static void cancel_activity(void)

/* this function makes sure that the disk stays in the drive during the
 * transfer */
static void fd_watchdog(struct work_struct *arg)
static void fd_watchdog(void)
{
	debug_dcl(DP->flags, "calling disk change from watchdog\n");

@@ -993,7 +1007,7 @@ static void fd_watchdog(struct work_struct *arg)
		reset_fdc();
	} else {
		cancel_delayed_work(&fd_timer);
		PREPARE_DELAYED_WORK(&fd_timer, fd_watchdog);
		fd_timer_fn = fd_watchdog;
		queue_delayed_work(floppy_wq, &fd_timer, HZ / 10);
	}
}
@@ -1005,7 +1019,8 @@ static void main_command_interrupt(void)
}

/* waits for a delay (spinup or select) to pass */
static int fd_wait_for_completion(unsigned long expires, work_func_t function)
static int fd_wait_for_completion(unsigned long expires,
				  void (*function)(void))
{
	if (FDCS->reset) {
		reset_fdc();	/* do the reset during sleep to win time
@@ -1016,7 +1031,7 @@ static int fd_wait_for_completion(unsigned long expires, work_func_t function)

	if (time_before(jiffies, expires)) {
		cancel_delayed_work(&fd_timer);
		PREPARE_DELAYED_WORK(&fd_timer, function);
		fd_timer_fn = function;
		queue_delayed_work(floppy_wq, &fd_timer, expires - jiffies);
		return 1;
	}
@@ -1334,8 +1349,7 @@ static int fdc_dtr(void)
	 * Pause 5 msec to avoid trouble. (Needs to be 2 jiffies)
	 */
	FDCS->dtr = raw_cmd->rate & 3;
	return fd_wait_for_completion(jiffies + 2UL * HZ / 100,
				      (work_func_t)floppy_ready);
	return fd_wait_for_completion(jiffies + 2UL * HZ / 100, floppy_ready);
}				/* fdc_dtr */

static void tell_sector(void)
@@ -1440,7 +1454,7 @@ static void setup_rw_floppy(void)
	int flags;
	int dflags;
	unsigned long ready_date;
	work_func_t function;
	void (*function)(void);

	flags = raw_cmd->flags;
	if (flags & (FD_RAW_READ | FD_RAW_WRITE))
@@ -1454,9 +1468,9 @@ static void setup_rw_floppy(void)
		 */
		if (time_after(ready_date, jiffies + DP->select_delay)) {
			ready_date -= DP->select_delay;
			function = (work_func_t)floppy_start;
			function = floppy_start;
		} else
			function = (work_func_t)setup_rw_floppy;
			function = setup_rw_floppy;

		/* wait until the floppy is spinning fast enough */
		if (fd_wait_for_completion(ready_date, function))
@@ -1486,7 +1500,7 @@ static void setup_rw_floppy(void)
		inr = result();
		cont->interrupt();
	} else if (flags & FD_RAW_NEED_DISK)
		fd_watchdog(NULL);
		fd_watchdog();
}

static int blind_seek;
@@ -1863,7 +1877,7 @@ static int start_motor(void (*function)(void))

	/* wait_for_completion also schedules reset if needed. */
	return fd_wait_for_completion(DRS->select_date + DP->select_delay,
				      (work_func_t)function);
				      function);
}

static void floppy_ready(void)
+12 −6
Original line number Diff line number Diff line
@@ -993,7 +993,7 @@ static void nvme_abort_cmd(int cmdid, struct nvme_queue *nvmeq)
		dev_warn(&dev->pci_dev->dev,
			"I/O %d QID %d timeout, reset controller\n", cmdid,
								nvmeq->qid);
		PREPARE_WORK(&dev->reset_work, nvme_reset_failed_dev);
		dev->reset_workfn = nvme_reset_failed_dev;
		queue_work(nvme_workq, &dev->reset_work);
		return;
	}
@@ -1696,8 +1696,7 @@ static int nvme_kthread(void *data)
				list_del_init(&dev->node);
				dev_warn(&dev->pci_dev->dev,
					"Failed status, reset controller\n");
				PREPARE_WORK(&dev->reset_work,
							nvme_reset_failed_dev);
				dev->reset_workfn = nvme_reset_failed_dev;
				queue_work(nvme_workq, &dev->reset_work);
				continue;
			}
@@ -2406,7 +2405,7 @@ static int nvme_dev_resume(struct nvme_dev *dev)
		return ret;
	if (ret == -EBUSY) {
		spin_lock(&dev_list_lock);
		PREPARE_WORK(&dev->reset_work, nvme_remove_disks);
		dev->reset_workfn = nvme_remove_disks;
		queue_work(nvme_workq, &dev->reset_work);
		spin_unlock(&dev_list_lock);
	}
@@ -2435,6 +2434,12 @@ static void nvme_reset_failed_dev(struct work_struct *ws)
	nvme_dev_reset(dev);
}

static void nvme_reset_workfn(struct work_struct *work)
{
	struct nvme_dev *dev = container_of(work, struct nvme_dev, reset_work);
	dev->reset_workfn(work);
}

static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
	int result = -ENOMEM;
@@ -2453,7 +2458,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
		goto free;

	INIT_LIST_HEAD(&dev->namespaces);
	INIT_WORK(&dev->reset_work, nvme_reset_failed_dev);
	dev->reset_workfn = nvme_reset_failed_dev;
	INIT_WORK(&dev->reset_work, nvme_reset_workfn);
	dev->pci_dev = pdev;
	pci_set_drvdata(pdev, dev);
	result = nvme_set_instance(dev);
@@ -2553,7 +2559,7 @@ static int nvme_resume(struct device *dev)
	struct nvme_dev *ndev = pci_get_drvdata(pdev);

	if (nvme_dev_resume(ndev) && !work_busy(&ndev->reset_work)) {
		PREPARE_WORK(&ndev->reset_work, nvme_reset_failed_dev);
		ndev->reset_workfn = nvme_reset_failed_dev;
		queue_work(nvme_workq, &ndev->reset_work);
	}
	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -2607,7 +2607,7 @@ int dw_mci_probe(struct dw_mci *host)

	tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host);
	host->card_workqueue = alloc_workqueue("dw-mci-card",
			WQ_MEM_RECLAIM | WQ_NON_REENTRANT, 1);
			WQ_MEM_RECLAIM, 1);
	if (!host->card_workqueue) {
		ret = -ENOMEM;
		goto err_dmaunmap;
+1 −1
Original line number Diff line number Diff line
@@ -764,7 +764,7 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
	/*
	 * Overwrite TX done handler
	 */
	PREPARE_WORK(&rt2x00dev->txdone_work, rt2800usb_work_txdone);
	INIT_WORK(&rt2x00dev->txdone_work, rt2800usb_work_txdone);

	return 0;
}
+1 −3
Original line number Diff line number Diff line
@@ -699,8 +699,6 @@ int ps3_vuart_read_async(struct ps3_system_bus_device *dev, unsigned int bytes)

	BUG_ON(!bytes);

	PREPARE_WORK(&priv->rx_list.work.work, ps3_vuart_work);

	spin_lock_irqsave(&priv->rx_list.lock, flags);
	if (priv->rx_list.bytes_held >= bytes) {
		dev_dbg(&dev->core, "%s:%d: schedule_work %xh bytes\n",
@@ -1052,7 +1050,7 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)
	INIT_LIST_HEAD(&priv->rx_list.head);
	spin_lock_init(&priv->rx_list.lock);

	INIT_WORK(&priv->rx_list.work.work, NULL);
	INIT_WORK(&priv->rx_list.work.work, ps3_vuart_work);
	priv->rx_list.work.trigger = 0;
	priv->rx_list.work.dev = dev;

Loading