All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Kosina <jkosina@suse.cz>
To: Tejun Heo <tj@kernel.org>
Cc: laijs@cn.fujitsu.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/9] floppy: don't use PREPARE_[DELAYED_]WORK
Date: Fri, 21 Feb 2014 10:37:01 +0100 (CET)	[thread overview]
Message-ID: <alpine.LNX.2.00.1402211036410.1192@pobox.suse.cz> (raw)
In-Reply-To: <1392929071-16555-4-git-send-email-tj@kernel.org>

On Thu, 20 Feb 2014, Tejun Heo wrote:

> PREPARE_[DELAYED_]WORK() are being phased out.  They have few users
> and a nasty surprise in terms of reentrancy guarantee as workqueue
> considers work items to be different if they don't have the same work
> function.
> 
> floppy has been multiplexing floppy_work and fd_timer with multiple
> work functions.  Introduce floppy_work_workfn() and fd_timer_workfn()
> which invoke floppy_work_fn and fd_timer_fn respectively and always
> use the two functions as the work functions and update the users to
> set floppy_work_fn and fd_timer_fn instead of overriding work
> functions using PREPARE_[DELAYED_]WORK().
> 
> It would probably be best to route this with other related updates
> through the workqueue tree.
> 
> Lightly tested using qemu.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>

Acked-by: Jiri Kosina <jkosina@suse.cz>

Thanks.

> ---
>  drivers/block/floppy.c | 42 ++++++++++++++++++++++++++++--------------
>  1 file changed, 28 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 2023043..8f5565b 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -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)
> -- 
> 1.8.5.3
> 

-- 
Jiri Kosina
SUSE Labs

  reply	other threads:[~2014-02-21  9:37 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20 20:44 [PATCHSET wq/for-3.15] workqueue: remove PREPARE_[DELAYED_]WORK() Tejun Heo
2014-02-20 20:44 ` [PATCH 1/9] wireless/rt2x00: don't use PREPARE_WORK in rt2800usb.c Tejun Heo
2014-03-07 15:26   ` Tejun Heo
2014-02-20 20:44 ` [PATCH 2/9] ps3-vuart: don't use PREPARE_WORK Tejun Heo
2014-02-20 20:44   ` Tejun Heo
2014-02-21 23:19   ` Geoff Levand
2014-02-21 23:19     ` Geoff Levand
2014-02-20 20:44 ` [PATCH 3/9] floppy: don't use PREPARE_[DELAYED_]WORK Tejun Heo
2014-02-21  9:37   ` Jiri Kosina [this message]
2014-02-20 20:44 ` [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK Tejun Heo
2014-02-20 20:44   ` Tejun Heo
2014-02-21  1:44   ` Peter Hurley
2014-02-21  1:59     ` Tejun Heo
2014-02-21  2:07       ` Peter Hurley
2014-02-21  2:07         ` Peter Hurley
2014-02-21  2:13         ` Tejun Heo
2014-02-21  5:13           ` Peter Hurley
2014-02-21 10:03             ` Tejun Heo
2014-02-21 12:51               ` Peter Hurley
2014-02-21 12:51                 ` Peter Hurley
2014-02-21 13:06                 ` Tejun Heo
2014-02-21 16:53                   ` Peter Hurley
2014-02-21 16:57                     ` Tejun Heo
2014-02-21 23:01                       ` Peter Hurley
2014-02-21 23:18                         ` Tejun Heo
2014-02-21 23:46                           ` Peter Hurley
2014-02-22 14:38                             ` Tejun Heo
2014-02-22 14:38                               ` Tejun Heo
2014-02-22 14:48                               ` Peter Hurley
2014-02-22 18:43                         ` James Bottomley
2014-02-22 18:48                           ` Peter Hurley
2014-02-22 18:48                             ` Peter Hurley
2014-02-22 18:52                             ` James Bottomley
2014-02-22 19:03                               ` Peter Hurley
2014-02-22 19:03                                 ` Peter Hurley
2014-02-23  1:23                                 ` memory-barriers.txt again (was Re: [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK) Stefan Richter
2014-02-23 16:37                                   ` Paul E. McKenney
2014-02-23 16:37                                     ` Paul E. McKenney
2014-02-23 20:35                                     ` Peter Hurley
2014-02-23 23:50                                       ` Paul E. McKenney
2014-02-24  0:09                                         ` Peter Hurley
2014-02-24 16:26                                           ` Paul E. McKenney
2014-02-24 16:26                                             ` Paul E. McKenney
2014-02-24  0:32                                         ` Stefan Richter
2014-02-24 16:27                                           ` Paul E. McKenney
2014-02-23 20:05                                 ` [PATCH 4/9] firewire: don't use PREPARE_DELAYED_WORK James Bottomley
2014-02-23 22:32                                   ` Peter Hurley
2014-02-21 20:45   ` Stefan Richter
2014-02-21 20:45     ` Stefan Richter
2014-03-05 21:34     ` Stefan Richter
2014-03-07 15:18       ` Tejun Heo
2014-03-07 15:26   ` [PATCH UPDATED " Tejun Heo
2014-03-07 15:26     ` Tejun Heo
2014-02-20 20:44 ` [PATCH 5/9] usb: " Tejun Heo
2014-02-20 20:59   ` Greg Kroah-Hartman
2014-02-21 15:06     ` Alan Stern
2014-02-21 15:07       ` Tejun Heo
2014-02-22 14:59   ` [PATCH v2 " Tejun Heo
2014-02-22 15:14     ` Alan Stern
2014-02-22 15:20       ` Peter Hurley
2014-02-22 15:37       ` Tejun Heo
2014-02-22 23:03         ` Alan Stern
2014-02-23  4:29           ` Tejun Heo
2014-02-20 20:44 ` [PATCH 6/9] nvme: don't use PREPARE_WORK Tejun Heo
2014-02-20 20:44   ` Tejun Heo
2014-03-07 15:26   ` Tejun Heo
2014-03-07 15:26     ` Tejun Heo
2014-02-20 20:44 ` [PATCH 7/9] afs: " Tejun Heo
2014-03-07 15:27   ` Tejun Heo
2014-02-20 20:44 ` [PATCH 8/9] staging/fwserial: " Tejun Heo
2014-02-21 15:13   ` Peter Hurley
2014-02-20 20:44 ` [PATCH 9/9] workqueue: remove PREPARE_[DELAYED_]WORK() Tejun Heo
2014-03-07 15:27   ` Tejun Heo
2014-02-20 22:00 ` [PATCH 7/9] afs: don't use PREPARE_WORK David Howells
2014-02-20 22:46   ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1402211036410.1192@pobox.suse.cz \
    --to=jkosina@suse.cz \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.