Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182159
b: refs/heads/master
c: b4563e8
h: refs/heads/master
i:
  182157: 9e9cd90
  182155: 45196fa
  182151: 6e7f6d1
  182143: 4459327
v: v3
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Feb 26, 2010
1 parent 63181e4 commit d282ed9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 879acca58a904c25487c89ab11e23eb556fb13d3
refs/heads/master: b4563e891a043fe521e62f6f621b928641474ff3
1 change: 1 addition & 0 deletions trunk/arch/s390/include/asm/crw.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef void (*crw_handler_t)(struct crw *, struct crw *, int);
extern int crw_register_handler(int rsc, crw_handler_t handler);
extern void crw_unregister_handler(int rsc);
extern void crw_handle_channel_report(void);
void crw_wait_for_channel_report(void);

#define NR_RSCS 16

Expand Down
29 changes: 15 additions & 14 deletions trunk/drivers/s390/cio/crw.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
* Heiko Carstens <heiko.carstens@de.ibm.com>,
*/

#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/kthread.h>
#include <linux/init.h>
#include <linux/wait.h>
#include <asm/crw.h>

static struct semaphore crw_semaphore;
static DEFINE_MUTEX(crw_handler_mutex);
static crw_handler_t crw_handlers[NR_RSCS];
static atomic_t crw_nr_req = ATOMIC_INIT(0);
static DECLARE_WAIT_QUEUE_HEAD(crw_handler_wait_q);

/**
* crw_register_handler() - register a channel report word handler
Expand Down Expand Up @@ -59,12 +60,14 @@ void crw_unregister_handler(int rsc)
static int crw_collect_info(void *unused)
{
struct crw crw[2];
int ccode;
int ccode, signal;
unsigned int chain;
int ignore;

repeat:
ignore = down_interruptible(&crw_semaphore);
signal = wait_event_interruptible(crw_handler_wait_q,
atomic_read(&crw_nr_req) > 0);
if (unlikely(signal))
atomic_inc(&crw_nr_req);
chain = 0;
while (1) {
crw_handler_t handler;
Expand Down Expand Up @@ -122,25 +125,23 @@ static int crw_collect_info(void *unused)
/* chain is always 0 or 1 here. */
chain = crw[chain].chn ? chain + 1 : 0;
}
if (atomic_dec_and_test(&crw_nr_req))
wake_up(&crw_handler_wait_q);
goto repeat;
return 0;
}

void crw_handle_channel_report(void)
{
up(&crw_semaphore);
atomic_inc(&crw_nr_req);
wake_up(&crw_handler_wait_q);
}

/*
* Separate initcall needed for semaphore initialization since
* crw_handle_channel_report might be called before crw_machine_check_init.
*/
static int __init crw_init_semaphore(void)
void crw_wait_for_channel_report(void)
{
init_MUTEX_LOCKED(&crw_semaphore);
return 0;
crw_handle_channel_report();
wait_event(crw_handler_wait_q, atomic_read(&crw_nr_req) == 0);
}
pure_initcall(crw_init_semaphore);

/*
* Machine checks for the channel subsystem must be enabled
Expand Down

0 comments on commit d282ed9

Please sign in to comment.