2003-03-01 17:35:05

by Amit Shah

[permalink] [raw]
Subject: [PATCH] taskqueue to workqueue update for riscom8 driver

This patch updates the Riscom8 driver with the workqueue interface. It applies to the 2.5.63 kernel. Please apply.

diff -Naur -X /home/Amit/lib/dontdiff a/drivers/char/riscom8.c b/drivers/char/riscom8.c
--- a/drivers/char/riscom8.c Fri Feb 28 19:49:11 2003
+++ b/drivers/char/riscom8.c Sat Mar 1 16:59:35 2003
@@ -29,6 +29,9 @@
* ChangeLog:
* Arnaldo Carvalho de Melo <[email protected]> - 27-Jun-2001
* - get rid of check_region and several cleanups
+ *
+ * Amit Shah <[email protected]> - 1-Mar-2003
+ * - update all the task queues to work queues.
*/

#include <linux/module.h>
@@ -81,8 +84,6 @@

#define RS_EVENT_WRITE_WAKEUP 0

-static DECLARE_TASK_QUEUE(tq_riscom);
-
#define RISCOM_TYPE_NORMAL 1
#define RISCOM_TYPE_CALLOUT 2

@@ -346,10 +347,11 @@
* serving for all serial drivers.
* For now I must introduce another one - RISCOM8_BH.
* Still hope this will be changed in near future.
- */
+ *
+ * FIXME: update this comment for the workqueue interface.
+ */
set_bit(event, &port->event);
- queue_task(&port->tqueue, &tq_riscom);
- mark_bh(RISCOM8_BH);
+ schedule_work(&port->work);
}

static inline struct riscom_port * rc_get_port(struct riscom_board const * bp,
@@ -432,7 +434,7 @@

*tty->flip.char_buf_ptr++ = ch;
tty->flip.count++;
- queue_task(&tty->flip.tqueue, &tq_timer);
+ schedule_delayed_work(&tty->flip.work, 1);
}

static inline void rc_receive(struct riscom_board const * bp)
@@ -463,7 +465,7 @@
*tty->flip.flag_buf_ptr++ = 0;
tty->flip.count++;
}
- queue_task(&tty->flip.tqueue, &tq_timer);
+ schedule_delayed_work(&tty->flip.work, 1);
}

static inline void rc_transmit(struct riscom_board const * bp)
@@ -553,7 +555,7 @@
else if (!((port->flags & ASYNC_CALLOUT_ACTIVE) &&
(port->flags & ASYNC_CALLOUT_NOHUP))) {
MOD_INC_USE_COUNT;
- if (schedule_task(&port->tqueue_hangup) == 0)
+ if (schedule_work(&port->work_hangup) == 0)
MOD_DEC_USE_COUNT;
}
}
@@ -1660,11 +1662,11 @@
}

/*
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred. The path of
- * hangup processing is:
+ * This routine is called from the scheduler work queue when the
+ * interrupt routine has signalled that a hangup has occurred. The
+ * path of hangup processing is:
*
- * serial interrupt routine -> (scheduler tqueue) ->
+ * serial interrupt routine -> (scheduler workqueue) ->
* do_rc_hangup() -> tty->hangup() -> rc_hangup()
*
*/
@@ -1720,11 +1722,6 @@
}
}

-static void do_riscom_bh(void)
-{
- run_task_queue(&tq_riscom);
-}
-
static void do_softint(void *private_)
{
struct riscom_port *port = (struct riscom_port *) private_;
@@ -1751,7 +1748,6 @@
printk(KERN_ERR "rc: Couldn't get free page.\n");
return 1;
}
- init_bh(RISCOM8_BH, do_riscom_bh);
memset(IRQ_to_board, 0, sizeof(IRQ_to_board));
memset(&riscom_driver, 0, sizeof(riscom_driver));
riscom_driver.magic = TTY_DRIVER_MAGIC;
@@ -1811,10 +1807,10 @@
rc_port[i].callout_termios = riscom_callout_driver.init_termios;
rc_port[i].normal_termios = riscom_driver.init_termios;
rc_port[i].magic = RISCOM8_MAGIC;
- rc_port[i].tqueue.routine = do_softint;
- rc_port[i].tqueue.data = &rc_port[i];
- rc_port[i].tqueue_hangup.routine = do_rc_hangup;
- rc_port[i].tqueue_hangup.data = &rc_port[i];
+
+ INIT_WORK(&rc_port[i].work, do_softint, &rc_port[i]);
+ INIT_WORK(&rc_port[i].work_hangup, do_rc_hangup, &rc_port[i]);
+
rc_port[i].close_delay = 50 * HZ/100;
rc_port[i].closing_wait = 3000 * HZ/100;
init_waitqueue_head(&rc_port[i].open_wait);
@@ -1830,7 +1826,6 @@

save_flags(flags);
cli();
- remove_bh(RISCOM8_BH);
free_page((unsigned long)tmp_buf);
tty_unregister_driver(&riscom_driver);
tty_unregister_driver(&riscom_callout_driver);
diff -Naur -X /home/Amit/lib/dontdiff a/drivers/char/riscom8.h b/drivers/char/riscom8.h
--- a/drivers/char/riscom8.h Wed Feb 19 15:45:10 2003
+++ b/drivers/char/riscom8.h Sat Mar 1 16:59:17 2003
@@ -85,8 +85,8 @@
struct termios callout_termios;
wait_queue_head_t open_wait;
wait_queue_head_t close_wait;
- struct work_struct tqueue;
- struct work_struct tqueue_hangup;
+ struct work_struct work;
+ struct work_struct work_hangup;
short wakeup_chars;
short break_length;
unsigned short closing_wait;

--
Amit Shah
http://amitshah.nav.to/

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
-- Isaac Asimov




2003-03-02 04:27:41

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH] taskqueue to workqueue update for riscom8 driver


No, this driver needs to be converted to the new serial core. It's still
using cli(), for example.

--
"It's not Hollywood. War is real, war is primarily not about defeat or
victory, it is about death. I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

2003-03-02 12:09:07

by Amit Shah

[permalink] [raw]
Subject: Re: [PATCH] taskqueue to workqueue update for riscom8 driver

On Sunday 02 March 2003 10:08, Matthew Wilcox wrote:
> No, this driver needs to be converted to the new serial core. It's still
> using cli(), for example.

That's a different issue, isn't it? This patch was just meant to get the
drivers in a compilable state... I'll look into the cli() issue, but I don't
have any hardware to test...

--
Amit Shah
http://amitshah.nav.to/

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
-- Isaac Asimov


2003-03-02 16:24:04

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH] taskqueue to workqueue update for riscom8 driver

On Sun, Mar 02, 2003 at 05:51:01PM +0530, Amit Shah wrote:
> On Sunday 02 March 2003 10:08, Matthew Wilcox wrote:
> > No, this driver needs to be converted to the new serial core. It's still
> > using cli(), for example.
>
> That's a different issue, isn't it? This patch was just meant to get the
> drivers in a compilable state... I'll look into the cli() issue, but I don't
> have any hardware to test...

So it only compiles on UP. Not terribly interesting.

BTW, I wouldn't necessarily expect it to work. Work queues run in
process context; the code you replaced ran in bottom half context.
If you're going to do this kind of lame hack, it should be converted
to a tasklet, not a work queue.

--
"It's not Hollywood. War is real, war is primarily not about defeat or
victory, it is about death. I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk

2003-03-03 07:25:19

by Amit Shah

[permalink] [raw]
Subject: Re: [PATCH] taskqueue to workqueue update for riscom8 driver

On Sunday 02 Mar 2003 22:04, Matthew Wilcox wrote:
> So it only compiles on UP. Not terribly interesting.
>
> BTW, I wouldn't necessarily expect it to work. Work queues run in
> process context; the code you replaced ran in bottom half context.
> If you're going to do this kind of lame hack, it should be converted
> to a tasklet, not a work queue.

A simple grep for cli() in drivers/char reveals that many of those drivers
still use cli(), which means even they haven't yet been converted to the new
framework.

As for the patch, other drivers, like cyclades, for example, too have been
modified in the same manner.... on digging, I found that the original patch
that converted the taskqueues to workqueues had also done it the same way.

Amit.

--
Amit Shah
http://amitshah.nav.to/

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
-- Isaac Asimov

2003-03-03 08:02:13

by Matthew Wilcox

[permalink] [raw]
Subject: Re: [PATCH] taskqueue to workqueue update for riscom8 driver

On Mon, Mar 03, 2003 at 01:05:22PM +0530, Amit Shah wrote:
> A simple grep for cli() in drivers/char reveals that many of those drivers
> still use cli(), which means even they haven't yet been converted to the new
> framework.

Yes. Serial drivers still in drivers/char have not been converted to
the new serial core. Part of the conversion process moves the drivers
to drivers/serial.

--
"It's not Hollywood. War is real, war is primarily not about defeat or
victory, it is about death. I've seen thousands and thousands of dead bodies.
Do you think I want to have an academic debate on this subject?" -- Robert Fisk