@@ -542,11 +542,10 @@ static struct qeth_reply *qeth_alloc_reply(struct qeth_card *card)
542
542
{
543
543
struct qeth_reply * reply ;
544
544
545
- reply = kzalloc (sizeof (struct qeth_reply ), GFP_ATOMIC );
545
+ reply = kzalloc (sizeof (* reply ), GFP_KERNEL );
546
546
if (reply ) {
547
547
refcount_set (& reply -> refcnt , 1 );
548
- atomic_set (& reply -> received , 0 );
549
- init_waitqueue_head (& reply -> wait_q );
548
+ init_completion (& reply -> received );
550
549
}
551
550
return reply ;
552
551
}
@@ -578,8 +577,7 @@ static void qeth_dequeue_reply(struct qeth_card *card, struct qeth_reply *reply)
578
577
579
578
static void qeth_notify_reply (struct qeth_reply * reply )
580
579
{
581
- atomic_inc (& reply -> received );
582
- wake_up (& reply -> wait_q );
580
+ complete (& reply -> received );
583
581
}
584
582
585
583
static void qeth_issue_ipa_msg (struct qeth_ipa_cmd * cmd , int rc ,
@@ -704,6 +702,7 @@ static struct qeth_cmd_buffer *__qeth_get_buffer(struct qeth_channel *channel)
704
702
do {
705
703
if (channel -> iob [index ].state == BUF_STATE_FREE ) {
706
704
channel -> iob [index ].state = BUF_STATE_LOCKED ;
705
+ channel -> iob [index ].timeout = QETH_TIMEOUT ;
707
706
channel -> io_buf_no = (channel -> io_buf_no + 1 ) %
708
707
QETH_CMD_BUFFER_NO ;
709
708
memset (channel -> iob [index ].data , 0 , QETH_BUFSIZE );
@@ -1786,8 +1785,7 @@ static int qeth_idx_activate_get_answer(struct qeth_card *card,
1786
1785
iob -> callback = reply_cb ;
1787
1786
qeth_setup_ccw (channel -> ccw , CCW_CMD_READ , QETH_BUFSIZE , iob -> data );
1788
1787
1789
- wait_event (card -> wait_q ,
1790
- atomic_cmpxchg (& channel -> irq_pending , 0 , 1 ) == 0 );
1788
+ wait_event (card -> wait_q , qeth_trylock_channel (channel ));
1791
1789
QETH_DBF_TEXT (SETUP , 6 , "noirqpnd" );
1792
1790
spin_lock_irq (get_ccwdev_lock (channel -> ccwdev ));
1793
1791
rc = ccw_device_start_timeout (channel -> ccwdev , channel -> ccw ,
@@ -1855,8 +1853,7 @@ static int qeth_idx_activate_channel(struct qeth_card *card,
1855
1853
temp = (card -> info .cula << 8 ) + card -> info .unit_addr2 ;
1856
1854
memcpy (QETH_IDX_ACT_QDIO_DEV_REALADDR (iob -> data ), & temp , 2 );
1857
1855
1858
- wait_event (card -> wait_q ,
1859
- atomic_cmpxchg (& channel -> irq_pending , 0 , 1 ) == 0 );
1856
+ wait_event (card -> wait_q , qeth_trylock_channel (channel ));
1860
1857
QETH_DBF_TEXT (SETUP , 6 , "noirqpnd" );
1861
1858
spin_lock_irq (get_ccwdev_lock (channel -> ccwdev ));
1862
1859
rc = ccw_device_start_timeout (channel -> ccwdev , channel -> ccw ,
@@ -2034,9 +2031,9 @@ static int qeth_send_control_data(struct qeth_card *card, int len,
2034
2031
void * reply_param )
2035
2032
{
2036
2033
struct qeth_channel * channel = iob -> channel ;
2034
+ long timeout = iob -> timeout ;
2037
2035
int rc ;
2038
2036
struct qeth_reply * reply = NULL ;
2039
- unsigned long timeout , event_timeout ;
2040
2037
struct qeth_ipa_cmd * cmd = NULL ;
2041
2038
2042
2039
QETH_CARD_TEXT (card , 2 , "sendctl" );
@@ -2057,27 +2054,30 @@ static int qeth_send_control_data(struct qeth_card *card, int len,
2057
2054
qeth_get_reply (reply );
2058
2055
iob -> reply = reply ;
2059
2056
2060
- while (atomic_cmpxchg (& channel -> irq_pending , 0 , 1 )) ;
2057
+ timeout = wait_event_interruptible_timeout (card -> wait_q ,
2058
+ qeth_trylock_channel (channel ),
2059
+ timeout );
2060
+ if (timeout <= 0 ) {
2061
+ qeth_put_reply (reply );
2062
+ qeth_release_buffer (channel , iob );
2063
+ return (timeout == - ERESTARTSYS ) ? - EINTR : - ETIME ;
2064
+ }
2061
2065
2062
2066
if (IS_IPA (iob -> data )) {
2063
2067
cmd = __ipa_cmd (iob );
2064
2068
cmd -> hdr .seqno = card -> seqno .ipa ++ ;
2065
2069
reply -> seqno = cmd -> hdr .seqno ;
2066
- event_timeout = QETH_IPA_TIMEOUT ;
2067
2070
} else {
2068
2071
reply -> seqno = QETH_IDX_COMMAND_SEQNO ;
2069
- event_timeout = QETH_TIMEOUT ;
2070
2072
}
2071
2073
qeth_prepare_control_data (card , len , iob );
2072
2074
2073
2075
qeth_enqueue_reply (card , reply );
2074
2076
2075
- timeout = jiffies + event_timeout ;
2076
-
2077
2077
QETH_CARD_TEXT (card , 6 , "noirqpnd" );
2078
2078
spin_lock_irq (get_ccwdev_lock (channel -> ccwdev ));
2079
2079
rc = ccw_device_start_timeout (channel -> ccwdev , channel -> ccw ,
2080
- (addr_t ) iob , 0 , 0 , event_timeout );
2080
+ (addr_t ) iob , 0 , 0 , timeout );
2081
2081
spin_unlock_irq (get_ccwdev_lock (channel -> ccwdev ));
2082
2082
if (rc ) {
2083
2083
QETH_DBF_MESSAGE (2 , "qeth_send_control_data on device %x: ccw_device_start rc = %i\n" ,
@@ -2091,30 +2091,16 @@ static int qeth_send_control_data(struct qeth_card *card, int len,
2091
2091
return rc ;
2092
2092
}
2093
2093
2094
- /* we have only one long running ipassist, since we can ensure
2095
- process context of this command we can sleep */
2096
- if (cmd && cmd -> hdr .command == IPA_CMD_SETIP &&
2097
- cmd -> hdr .prot_version == QETH_PROT_IPV4 ) {
2098
- if (!wait_event_timeout (reply -> wait_q ,
2099
- atomic_read (& reply -> received ), event_timeout ))
2100
- goto time_err ;
2101
- } else {
2102
- while (!atomic_read (& reply -> received )) {
2103
- if (time_after (jiffies , timeout ))
2104
- goto time_err ;
2105
- cpu_relax ();
2106
- }
2107
- }
2094
+ timeout = wait_for_completion_interruptible_timeout (& reply -> received ,
2095
+ timeout );
2096
+ if (timeout <= 0 )
2097
+ rc = (timeout == - ERESTARTSYS ) ? - EINTR : - ETIME ;
2108
2098
2109
2099
qeth_dequeue_reply (card , reply );
2110
- rc = reply -> rc ;
2100
+ if (!rc )
2101
+ rc = reply -> rc ;
2111
2102
qeth_put_reply (reply );
2112
2103
return rc ;
2113
-
2114
- time_err :
2115
- qeth_dequeue_reply (card , reply );
2116
- qeth_put_reply (reply );
2117
- return - ETIME ;
2118
2104
}
2119
2105
2120
2106
static int qeth_cm_enable_cb (struct qeth_card * card , struct qeth_reply * reply ,
@@ -2810,6 +2796,8 @@ void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
2810
2796
u16 total_length = IPA_PDU_HEADER_SIZE + cmd_length ;
2811
2797
u8 prot_type = qeth_mpc_select_prot_type (card );
2812
2798
2799
+ iob -> timeout = QETH_IPA_TIMEOUT ;
2800
+
2813
2801
memcpy (iob -> data , IPA_PDU_HEADER , IPA_PDU_HEADER_SIZE );
2814
2802
memcpy (QETH_IPA_PDU_LEN_TOTAL (iob -> data ), & total_length , 2 );
2815
2803
memcpy (QETH_IPA_CMD_PROT_TYPE (iob -> data ), & prot_type , 1 );
0 commit comments