12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later 28c3e34a4SDavid Howells /* RxRPC individual remote procedure call handling 38c3e34a4SDavid Howells * 48c3e34a4SDavid Howells * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. 58c3e34a4SDavid Howells * Written by David Howells (dhowells@redhat.com) 68c3e34a4SDavid Howells */ 78c3e34a4SDavid Howells 88c3e34a4SDavid Howells #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 98c3e34a4SDavid Howells 108c3e34a4SDavid Howells #include <linux/slab.h> 118c3e34a4SDavid Howells #include <linux/module.h> 128c3e34a4SDavid Howells #include <linux/circ_buf.h> 138c3e34a4SDavid Howells #include <linux/spinlock_types.h> 148c3e34a4SDavid Howells #include <net/sock.h> 158c3e34a4SDavid Howells #include <net/af_rxrpc.h> 168c3e34a4SDavid Howells #include "ar-internal.h" 178c3e34a4SDavid Howells 188c3e34a4SDavid Howells const char *const rxrpc_call_states[NR__RXRPC_CALL_STATES] = { 19999b69f8SDavid Howells [RXRPC_CALL_UNINITIALISED] = "Uninit ", 20999b69f8SDavid Howells [RXRPC_CALL_CLIENT_AWAIT_CONN] = "ClWtConn", 218c3e34a4SDavid Howells [RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq", 228c3e34a4SDavid Howells [RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl", 238c3e34a4SDavid Howells [RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl", 2400e90712SDavid Howells [RXRPC_CALL_SERVER_PREALLOC] = "SvPrealc", 258c3e34a4SDavid Howells [RXRPC_CALL_SERVER_SECURING] = "SvSecure", 268c3e34a4SDavid Howells [RXRPC_CALL_SERVER_RECV_REQUEST] = "SvRcvReq", 278c3e34a4SDavid Howells [RXRPC_CALL_SERVER_ACK_REQUEST] = "SvAckReq", 288c3e34a4SDavid Howells [RXRPC_CALL_SERVER_SEND_REPLY] = "SvSndRpl", 298c3e34a4SDavid Howells [RXRPC_CALL_SERVER_AWAIT_ACK] = "SvAwtACK", 308c3e34a4SDavid Howells [RXRPC_CALL_COMPLETE] = "Complete", 31f5c17aaeSDavid Howells }; 32f5c17aaeSDavid Howells 33f5c17aaeSDavid Howells const char *const rxrpc_call_completions[NR__RXRPC_CALL_COMPLETIONS] = { 34f5c17aaeSDavid Howells [RXRPC_CALL_SUCCEEDED] = "Complete", 358c3e34a4SDavid Howells [RXRPC_CALL_REMOTELY_ABORTED] = "RmtAbort", 368c3e34a4SDavid Howells [RXRPC_CALL_LOCALLY_ABORTED] = "LocAbort", 37f5c17aaeSDavid Howells [RXRPC_CALL_LOCAL_ERROR] = "LocError", 388c3e34a4SDavid Howells [RXRPC_CALL_NETWORK_ERROR] = "NetError", 398c3e34a4SDavid Howells }; 408c3e34a4SDavid Howells 418c3e34a4SDavid Howells struct kmem_cache *rxrpc_call_jar; 428c3e34a4SDavid Howells 43b7a7d674SDavid Howells static struct semaphore rxrpc_call_limiter = 44b7a7d674SDavid Howells __SEMAPHORE_INITIALIZER(rxrpc_call_limiter, 1000); 45b7a7d674SDavid Howells static struct semaphore rxrpc_kernel_call_limiter = 46b7a7d674SDavid Howells __SEMAPHORE_INITIALIZER(rxrpc_kernel_call_limiter, 1000); 47b7a7d674SDavid Howells 4815f661dcSDavid Howells void rxrpc_poke_call(struct rxrpc_call *call, enum rxrpc_call_poke_trace what) 4915f661dcSDavid Howells { 50f3441d41SDavid Howells struct rxrpc_local *local = call->local; 5115f661dcSDavid Howells bool busy; 5215f661dcSDavid Howells 5315f661dcSDavid Howells if (call->state < RXRPC_CALL_COMPLETE) { 5415f661dcSDavid Howells spin_lock_bh(&local->lock); 5515f661dcSDavid Howells busy = !list_empty(&call->attend_link); 5615f661dcSDavid Howells trace_rxrpc_poke_call(call, busy, what); 5715f661dcSDavid Howells if (!busy) { 5815f661dcSDavid Howells rxrpc_get_call(call, rxrpc_call_get_poke); 5915f661dcSDavid Howells list_add_tail(&call->attend_link, &local->call_attend_q); 6015f661dcSDavid Howells } 6115f661dcSDavid Howells spin_unlock_bh(&local->lock); 6215f661dcSDavid Howells rxrpc_wake_up_io_thread(local); 6315f661dcSDavid Howells } 6415f661dcSDavid Howells } 6515f661dcSDavid Howells 66e99e88a9SKees Cook static void rxrpc_call_timer_expired(struct timer_list *t) 67248f219cSDavid Howells { 68e99e88a9SKees Cook struct rxrpc_call *call = from_timer(call, t, timer); 69248f219cSDavid Howells 70248f219cSDavid Howells _enter("%d", call->debug_id); 71248f219cSDavid Howells 72a158bdd3SDavid Howells if (call->state < RXRPC_CALL_COMPLETE) { 73334dfbfcSDavid Howells trace_rxrpc_timer_expired(call, jiffies); 745e6ef4f1SDavid Howells rxrpc_poke_call(call, rxrpc_call_poke_timer); 75fc7ab6d2SDavid Howells } 76248f219cSDavid Howells } 778c3e34a4SDavid Howells 784a7f62f9SDavid Howells void rxrpc_reduce_call_timer(struct rxrpc_call *call, 794a7f62f9SDavid Howells unsigned long expire_at, 804a7f62f9SDavid Howells unsigned long now, 814a7f62f9SDavid Howells enum rxrpc_timer_trace why) 824a7f62f9SDavid Howells { 834a7f62f9SDavid Howells trace_rxrpc_timer(call, why, now); 843feda9d6SDavid Howells timer_reduce(&call->timer, expire_at); 854a7f62f9SDavid Howells } 864a7f62f9SDavid Howells 879faaff59SDavid Howells static struct lock_class_key rxrpc_call_user_mutex_lock_class_key; 888c3e34a4SDavid Howells 893feda9d6SDavid Howells static void rxrpc_destroy_call(struct work_struct *); 903feda9d6SDavid Howells 918c3e34a4SDavid Howells /* 928c3e34a4SDavid Howells * find an extant server call 938c3e34a4SDavid Howells * - called in process context with IRQs enabled 948c3e34a4SDavid Howells */ 958c3e34a4SDavid Howells struct rxrpc_call *rxrpc_find_call_by_user_ID(struct rxrpc_sock *rx, 968c3e34a4SDavid Howells unsigned long user_call_ID) 978c3e34a4SDavid Howells { 988c3e34a4SDavid Howells struct rxrpc_call *call; 998c3e34a4SDavid Howells struct rb_node *p; 1008c3e34a4SDavid Howells 1018c3e34a4SDavid Howells _enter("%p,%lx", rx, user_call_ID); 1028c3e34a4SDavid Howells 1038c3e34a4SDavid Howells read_lock(&rx->call_lock); 1048c3e34a4SDavid Howells 1058c3e34a4SDavid Howells p = rx->calls.rb_node; 1068c3e34a4SDavid Howells while (p) { 1078c3e34a4SDavid Howells call = rb_entry(p, struct rxrpc_call, sock_node); 1088c3e34a4SDavid Howells 1098c3e34a4SDavid Howells if (user_call_ID < call->user_call_ID) 1108c3e34a4SDavid Howells p = p->rb_left; 1118c3e34a4SDavid Howells else if (user_call_ID > call->user_call_ID) 1128c3e34a4SDavid Howells p = p->rb_right; 1138c3e34a4SDavid Howells else 1148c3e34a4SDavid Howells goto found_extant_call; 1158c3e34a4SDavid Howells } 1168c3e34a4SDavid Howells 1178c3e34a4SDavid Howells read_unlock(&rx->call_lock); 1188c3e34a4SDavid Howells _leave(" = NULL"); 1198c3e34a4SDavid Howells return NULL; 1208c3e34a4SDavid Howells 1218c3e34a4SDavid Howells found_extant_call: 122cb0fc0c9SDavid Howells rxrpc_get_call(call, rxrpc_call_get_sendmsg); 1238c3e34a4SDavid Howells read_unlock(&rx->call_lock); 124a0575429SDavid Howells _leave(" = %p [%d]", call, refcount_read(&call->ref)); 1258c3e34a4SDavid Howells return call; 1268c3e34a4SDavid Howells } 1278c3e34a4SDavid Howells 1288c3e34a4SDavid Howells /* 1298c3e34a4SDavid Howells * allocate a new call 1308c3e34a4SDavid Howells */ 131a25e21f0SDavid Howells struct rxrpc_call *rxrpc_alloc_call(struct rxrpc_sock *rx, gfp_t gfp, 132a25e21f0SDavid Howells unsigned int debug_id) 1338c3e34a4SDavid Howells { 1348c3e34a4SDavid Howells struct rxrpc_call *call; 135d3be4d24SDavid Howells struct rxrpc_net *rxnet = rxrpc_net(sock_net(&rx->sk)); 1368c3e34a4SDavid Howells 1378c3e34a4SDavid Howells call = kmem_cache_zalloc(rxrpc_call_jar, gfp); 1388c3e34a4SDavid Howells if (!call) 1398c3e34a4SDavid Howells return NULL; 1408c3e34a4SDavid Howells 141540b1c48SDavid Howells mutex_init(&call->user_mutex); 1429faaff59SDavid Howells 1439faaff59SDavid Howells /* Prevent lockdep reporting a deadlock false positive between the afs 1449faaff59SDavid Howells * filesystem and sys_sendmsg() via the mmap sem. 1459faaff59SDavid Howells */ 1469faaff59SDavid Howells if (rx->sk.sk_kern_sock) 1479faaff59SDavid Howells lockdep_set_class(&call->user_mutex, 1489faaff59SDavid Howells &rxrpc_call_user_mutex_lock_class_key); 1499faaff59SDavid Howells 150e99e88a9SKees Cook timer_setup(&call->timer, rxrpc_call_timer_expired, 0); 1513feda9d6SDavid Howells INIT_WORK(&call->destroyer, rxrpc_destroy_call); 152999b69f8SDavid Howells INIT_LIST_HEAD(&call->link); 15345025bceSDavid Howells INIT_LIST_HEAD(&call->chan_wait_link); 1548c3e34a4SDavid Howells INIT_LIST_HEAD(&call->accept_link); 155248f219cSDavid Howells INIT_LIST_HEAD(&call->recvmsg_link); 156248f219cSDavid Howells INIT_LIST_HEAD(&call->sock_link); 15715f661dcSDavid Howells INIT_LIST_HEAD(&call->attend_link); 158cf37b598SDavid Howells INIT_LIST_HEAD(&call->tx_sendmsg); 159a4ea4c47SDavid Howells INIT_LIST_HEAD(&call->tx_buffer); 1605d7edbc9SDavid Howells skb_queue_head_init(&call->recvmsg_queue); 1615d7edbc9SDavid Howells skb_queue_head_init(&call->rx_oos_queue); 16245025bceSDavid Howells init_waitqueue_head(&call->waitq); 16320acbd9aSDavid Howells spin_lock_init(&call->notify_lock); 164a4ea4c47SDavid Howells spin_lock_init(&call->tx_lock); 1658c3e34a4SDavid Howells rwlock_init(&call->state_lock); 166a0575429SDavid Howells refcount_set(&call->ref, 1); 167a25e21f0SDavid Howells call->debug_id = debug_id; 168e754eba6SDavid Howells call->tx_total_len = -1; 169a158bdd3SDavid Howells call->next_rx_timo = 20 * HZ; 170a158bdd3SDavid Howells call->next_req_timo = 1 * HZ; 1715d7edbc9SDavid Howells atomic64_set(&call->ackr_window, 0x100000001ULL); 1728c3e34a4SDavid Howells 1738c3e34a4SDavid Howells memset(&call->sock_node, 0xed, sizeof(call->sock_node)); 1748c3e34a4SDavid Howells 17575e42126SDavid Howells call->rx_winsize = rxrpc_rx_window_size; 176248f219cSDavid Howells call->tx_winsize = 16; 17757494343SDavid Howells 1781fc4fa2aSDavid Howells if (RXRPC_TX_SMSS > 2190) 17957494343SDavid Howells call->cong_cwnd = 2; 1801fc4fa2aSDavid Howells else if (RXRPC_TX_SMSS > 1095) 1811fc4fa2aSDavid Howells call->cong_cwnd = 3; 1821fc4fa2aSDavid Howells else 1831fc4fa2aSDavid Howells call->cong_cwnd = 4; 184a4ea4c47SDavid Howells call->cong_ssthresh = RXRPC_TX_MAX_WINDOW; 185d3be4d24SDavid Howells 186d3be4d24SDavid Howells call->rxnet = rxnet; 1874700c4d8SDavid Howells call->rtt_avail = RXRPC_CALL_RTT_AVAIL_MASK; 188d3be4d24SDavid Howells atomic_inc(&rxnet->nr_calls); 1898c3e34a4SDavid Howells return call; 1908c3e34a4SDavid Howells } 1918c3e34a4SDavid Howells 1928c3e34a4SDavid Howells /* 193999b69f8SDavid Howells * Allocate a new client call. 1948c3e34a4SDavid Howells */ 1959faaff59SDavid Howells static struct rxrpc_call *rxrpc_alloc_client_call(struct rxrpc_sock *rx, 1969faaff59SDavid Howells struct sockaddr_rxrpc *srx, 197f3441d41SDavid Howells struct rxrpc_conn_parameters *cp, 198f3441d41SDavid Howells struct rxrpc_call_params *p, 199a25e21f0SDavid Howells gfp_t gfp, 200a25e21f0SDavid Howells unsigned int debug_id) 2018c3e34a4SDavid Howells { 2028c3e34a4SDavid Howells struct rxrpc_call *call; 20357494343SDavid Howells ktime_t now; 204f3441d41SDavid Howells int ret; 2058c3e34a4SDavid Howells 2068c3e34a4SDavid Howells _enter(""); 2078c3e34a4SDavid Howells 208a25e21f0SDavid Howells call = rxrpc_alloc_call(rx, gfp, debug_id); 2098c3e34a4SDavid Howells if (!call) 2108c3e34a4SDavid Howells return ERR_PTR(-ENOMEM); 21157494343SDavid Howells now = ktime_get_real(); 21257494343SDavid Howells call->acks_latest_ts = now; 21357494343SDavid Howells call->cong_tstamp = now; 214f3441d41SDavid Howells call->state = RXRPC_CALL_CLIENT_AWAIT_CONN; 215f3441d41SDavid Howells call->dest_srx = *srx; 216f3441d41SDavid Howells call->interruptibility = p->interruptibility; 217f3441d41SDavid Howells call->tx_total_len = p->tx_total_len; 218f3441d41SDavid Howells call->key = key_get(cp->key); 219f3441d41SDavid Howells call->local = rxrpc_get_local(cp->local, rxrpc_local_get_call); 220fdb99487SDavid Howells call->security_level = cp->security_level; 221f3441d41SDavid Howells if (p->kernel) 222f3441d41SDavid Howells __set_bit(RXRPC_CALL_KERNEL, &call->flags); 223f3441d41SDavid Howells if (cp->upgrade) 224f3441d41SDavid Howells __set_bit(RXRPC_CALL_UPGRADE, &call->flags); 225f3441d41SDavid Howells if (cp->exclusive) 226f3441d41SDavid Howells __set_bit(RXRPC_CALL_EXCLUSIVE, &call->flags); 227f3441d41SDavid Howells 228f3441d41SDavid Howells ret = rxrpc_init_client_call_security(call); 229f3441d41SDavid Howells if (ret < 0) { 230f3441d41SDavid Howells __rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR, 0, ret); 231f3441d41SDavid Howells rxrpc_put_call(call, rxrpc_call_put_discard_error); 232f3441d41SDavid Howells return ERR_PTR(ret); 233f3441d41SDavid Howells } 234f3441d41SDavid Howells 235f3441d41SDavid Howells trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 236f3441d41SDavid Howells p->user_call_ID, rxrpc_call_new_client); 237999b69f8SDavid Howells 238999b69f8SDavid Howells _leave(" = %p", call); 239999b69f8SDavid Howells return call; 240999b69f8SDavid Howells } 241999b69f8SDavid Howells 242999b69f8SDavid Howells /* 243248f219cSDavid Howells * Initiate the call ack/resend/expiry timer. 244999b69f8SDavid Howells */ 245248f219cSDavid Howells static void rxrpc_start_call_timer(struct rxrpc_call *call) 246999b69f8SDavid Howells { 247a158bdd3SDavid Howells unsigned long now = jiffies; 248a158bdd3SDavid Howells unsigned long j = now + MAX_JIFFY_OFFSET; 249999b69f8SDavid Howells 250530403d9SDavid Howells call->delay_ack_at = j; 251bd1fdf8cSDavid Howells call->ack_lost_at = j; 252a158bdd3SDavid Howells call->resend_at = j; 253a158bdd3SDavid Howells call->ping_at = j; 2545e6ef4f1SDavid Howells call->keepalive_at = j; 255a158bdd3SDavid Howells call->expect_rx_by = j; 256a158bdd3SDavid Howells call->expect_req_by = j; 257a158bdd3SDavid Howells call->expect_term_by = j; 258a158bdd3SDavid Howells call->timer.expires = now; 2598c3e34a4SDavid Howells } 2608c3e34a4SDavid Howells 2618c3e34a4SDavid Howells /* 262b7a7d674SDavid Howells * Wait for a call slot to become available. 263b7a7d674SDavid Howells */ 264b7a7d674SDavid Howells static struct semaphore *rxrpc_get_call_slot(struct rxrpc_call_params *p, gfp_t gfp) 265b7a7d674SDavid Howells { 266b7a7d674SDavid Howells struct semaphore *limiter = &rxrpc_call_limiter; 267b7a7d674SDavid Howells 268b7a7d674SDavid Howells if (p->kernel) 269b7a7d674SDavid Howells limiter = &rxrpc_kernel_call_limiter; 270b7a7d674SDavid Howells if (p->interruptibility == RXRPC_UNINTERRUPTIBLE) { 271b7a7d674SDavid Howells down(limiter); 272b7a7d674SDavid Howells return limiter; 273b7a7d674SDavid Howells } 274b7a7d674SDavid Howells return down_interruptible(limiter) < 0 ? NULL : limiter; 275b7a7d674SDavid Howells } 276b7a7d674SDavid Howells 277b7a7d674SDavid Howells /* 278b7a7d674SDavid Howells * Release a call slot. 279b7a7d674SDavid Howells */ 280b7a7d674SDavid Howells static void rxrpc_put_call_slot(struct rxrpc_call *call) 281b7a7d674SDavid Howells { 282b7a7d674SDavid Howells struct semaphore *limiter = &rxrpc_call_limiter; 283b7a7d674SDavid Howells 284b7a7d674SDavid Howells if (test_bit(RXRPC_CALL_KERNEL, &call->flags)) 285b7a7d674SDavid Howells limiter = &rxrpc_kernel_call_limiter; 286b7a7d674SDavid Howells up(limiter); 287b7a7d674SDavid Howells } 288b7a7d674SDavid Howells 289b7a7d674SDavid Howells /* 290540b1c48SDavid Howells * Set up a call for the given parameters. 291540b1c48SDavid Howells * - Called with the socket lock held, which it must release. 292540b1c48SDavid Howells * - If it returns a call, the call's lock will need releasing by the caller. 2938c3e34a4SDavid Howells */ 2948c3e34a4SDavid Howells struct rxrpc_call *rxrpc_new_client_call(struct rxrpc_sock *rx, 29519ffa01cSDavid Howells struct rxrpc_conn_parameters *cp, 296999b69f8SDavid Howells struct sockaddr_rxrpc *srx, 29748124178SDavid Howells struct rxrpc_call_params *p, 298a25e21f0SDavid Howells gfp_t gfp, 299a25e21f0SDavid Howells unsigned int debug_id) 300540b1c48SDavid Howells __releases(&rx->sk.sk_lock.slock) 30188f2a825SDavid Howells __acquires(&call->user_mutex) 3028c3e34a4SDavid Howells { 3038c3e34a4SDavid Howells struct rxrpc_call *call, *xcall; 304d3be4d24SDavid Howells struct rxrpc_net *rxnet; 305b7a7d674SDavid Howells struct semaphore *limiter; 3068c3e34a4SDavid Howells struct rb_node *parent, **pp; 307999b69f8SDavid Howells int ret; 3088c3e34a4SDavid Howells 30948124178SDavid Howells _enter("%p,%lx", rx, p->user_call_ID); 3108c3e34a4SDavid Howells 311b7a7d674SDavid Howells limiter = rxrpc_get_call_slot(p, gfp); 312b0f571ecSDavid Howells if (!limiter) { 313b0f571ecSDavid Howells release_sock(&rx->sk); 314b7a7d674SDavid Howells return ERR_PTR(-ERESTARTSYS); 315b0f571ecSDavid Howells } 316b7a7d674SDavid Howells 317f3441d41SDavid Howells call = rxrpc_alloc_client_call(rx, srx, cp, p, gfp, debug_id); 3188c3e34a4SDavid Howells if (IS_ERR(call)) { 319540b1c48SDavid Howells release_sock(&rx->sk); 320b7a7d674SDavid Howells up(limiter); 3218c3e34a4SDavid Howells _leave(" = %ld", PTR_ERR(call)); 3228c3e34a4SDavid Howells return call; 3238c3e34a4SDavid Howells } 3248c3e34a4SDavid Howells 325540b1c48SDavid Howells /* We need to protect a partially set up call against the user as we 326540b1c48SDavid Howells * will be acting outside the socket lock. 327540b1c48SDavid Howells */ 328540b1c48SDavid Howells mutex_lock(&call->user_mutex); 329540b1c48SDavid Howells 330999b69f8SDavid Howells /* Publish the call, even though it is incompletely set up as yet */ 3318c3e34a4SDavid Howells write_lock(&rx->call_lock); 3328c3e34a4SDavid Howells 3338c3e34a4SDavid Howells pp = &rx->calls.rb_node; 3348c3e34a4SDavid Howells parent = NULL; 3358c3e34a4SDavid Howells while (*pp) { 3368c3e34a4SDavid Howells parent = *pp; 3378c3e34a4SDavid Howells xcall = rb_entry(parent, struct rxrpc_call, sock_node); 3388c3e34a4SDavid Howells 33948124178SDavid Howells if (p->user_call_ID < xcall->user_call_ID) 3408c3e34a4SDavid Howells pp = &(*pp)->rb_left; 34148124178SDavid Howells else if (p->user_call_ID > xcall->user_call_ID) 3428c3e34a4SDavid Howells pp = &(*pp)->rb_right; 3438c3e34a4SDavid Howells else 344357f5ef6SDavid Howells goto error_dup_user_ID; 3458c3e34a4SDavid Howells } 3468c3e34a4SDavid Howells 347248f219cSDavid Howells rcu_assign_pointer(call->socket, rx); 34848124178SDavid Howells call->user_call_ID = p->user_call_ID; 349357f5ef6SDavid Howells __set_bit(RXRPC_CALL_HAS_USERID, &call->flags); 350cb0fc0c9SDavid Howells rxrpc_get_call(call, rxrpc_call_get_userid); 3518c3e34a4SDavid Howells rb_link_node(&call->sock_node, parent, pp); 3528c3e34a4SDavid Howells rb_insert_color(&call->sock_node, &rx->calls); 353248f219cSDavid Howells list_add(&call->sock_link, &rx->sock_calls); 354248f219cSDavid Howells 3558c3e34a4SDavid Howells write_unlock(&rx->call_lock); 3568c3e34a4SDavid Howells 357d3be4d24SDavid Howells rxnet = call->rxnet; 3583dd9c8b5SDavid Howells spin_lock(&rxnet->call_lock); 359ad25f5cbSDavid Howells list_add_tail_rcu(&call->link, &rxnet->calls); 3603dd9c8b5SDavid Howells spin_unlock(&rxnet->call_lock); 3618c3e34a4SDavid Howells 362540b1c48SDavid Howells /* From this point on, the call is protected by its own lock. */ 363540b1c48SDavid Howells release_sock(&rx->sk); 364540b1c48SDavid Howells 365248f219cSDavid Howells /* Set up or get a connection record and set the protocol parameters, 366248f219cSDavid Howells * including channel number and call ID. 367248f219cSDavid Howells */ 3685e33a23bSDavid Howells ret = rxrpc_connect_call(rx, call, cp, srx, gfp); 369999b69f8SDavid Howells if (ret < 0) 37065550098SDavid Howells goto error_attached_to_socket; 371999b69f8SDavid Howells 372cb0fc0c9SDavid Howells rxrpc_see_call(call, rxrpc_call_see_connected); 373a84a46d7SDavid Howells 374248f219cSDavid Howells rxrpc_start_call_timer(call); 375248f219cSDavid Howells 3768c3e34a4SDavid Howells _leave(" = %p [new]", call); 3778c3e34a4SDavid Howells return call; 3788c3e34a4SDavid Howells 3798c3e34a4SDavid Howells /* We unexpectedly found the user ID in the list after taking 3808c3e34a4SDavid Howells * the call_lock. This shouldn't happen unless the user races 3818c3e34a4SDavid Howells * with itself and tries to add the same user ID twice at the 3828c3e34a4SDavid Howells * same time in different threads. 3838c3e34a4SDavid Howells */ 384357f5ef6SDavid Howells error_dup_user_ID: 3858c3e34a4SDavid Howells write_unlock(&rx->call_lock); 386540b1c48SDavid Howells release_sock(&rx->sk); 387357f5ef6SDavid Howells __rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR, 38865550098SDavid Howells RX_CALL_DEAD, -EEXIST); 389cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 0, 390cb0fc0c9SDavid Howells rxrpc_call_see_userid_exists); 391357f5ef6SDavid Howells rxrpc_release_call(rx, call); 392540b1c48SDavid Howells mutex_unlock(&call->user_mutex); 393cb0fc0c9SDavid Howells rxrpc_put_call(call, rxrpc_call_put_userid_exists); 39465550098SDavid Howells _leave(" = -EEXIST"); 39565550098SDavid Howells return ERR_PTR(-EEXIST); 39665550098SDavid Howells 39765550098SDavid Howells /* We got an error, but the call is attached to the socket and is in 39865550098SDavid Howells * need of release. However, we might now race with recvmsg() when 39965550098SDavid Howells * completing the call queues it. Return 0 from sys_sendmsg() and 40065550098SDavid Howells * leave the error to recvmsg() to deal with. 40165550098SDavid Howells */ 40265550098SDavid Howells error_attached_to_socket: 403cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), ret, 404cb0fc0c9SDavid Howells rxrpc_call_see_connect_failed); 40565550098SDavid Howells set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); 40665550098SDavid Howells __rxrpc_set_call_completion(call, RXRPC_CALL_LOCAL_ERROR, 40765550098SDavid Howells RX_CALL_DEAD, ret); 40865550098SDavid Howells _leave(" = c=%08x [err]", call->debug_id); 40965550098SDavid Howells return call; 4108c3e34a4SDavid Howells } 4118c3e34a4SDavid Howells 4128c3e34a4SDavid Howells /* 413248f219cSDavid Howells * Set up an incoming call. call->conn points to the connection. 414248f219cSDavid Howells * This is called in BH context and isn't allowed to fail. 4158c3e34a4SDavid Howells */ 416248f219cSDavid Howells void rxrpc_incoming_call(struct rxrpc_sock *rx, 417248f219cSDavid Howells struct rxrpc_call *call, 41842886ffeSDavid Howells struct sk_buff *skb) 4198c3e34a4SDavid Howells { 420248f219cSDavid Howells struct rxrpc_connection *conn = call->conn; 42142886ffeSDavid Howells struct rxrpc_skb_priv *sp = rxrpc_skb(skb); 422248f219cSDavid Howells u32 chan; 4238c3e34a4SDavid Howells 424248f219cSDavid Howells _enter(",%d", call->conn->debug_id); 4258c3e34a4SDavid Howells 426248f219cSDavid Howells rcu_assign_pointer(call->socket, rx); 427248f219cSDavid Howells call->call_id = sp->hdr.callNumber; 428f3441d41SDavid Howells call->dest_srx.srx_service = sp->hdr.serviceId; 429248f219cSDavid Howells call->cid = sp->hdr.cid; 430248f219cSDavid Howells call->state = RXRPC_CALL_SERVER_SECURING; 43157494343SDavid Howells call->cong_tstamp = skb->tstamp; 4328c3e34a4SDavid Howells 433*a343b174SDavid Howells __set_bit(RXRPC_CALL_EXPOSED, &call->flags); 434*a343b174SDavid Howells 4355e6ef4f1SDavid Howells spin_lock(&conn->state_lock); 4365e6ef4f1SDavid Howells 4375e6ef4f1SDavid Howells switch (conn->state) { 4385e6ef4f1SDavid Howells case RXRPC_CONN_SERVICE_UNSECURED: 4395e6ef4f1SDavid Howells case RXRPC_CONN_SERVICE_CHALLENGING: 4405e6ef4f1SDavid Howells call->state = RXRPC_CALL_SERVER_SECURING; 4415e6ef4f1SDavid Howells break; 4425e6ef4f1SDavid Howells case RXRPC_CONN_SERVICE: 4435e6ef4f1SDavid Howells call->state = RXRPC_CALL_SERVER_RECV_REQUEST; 4445e6ef4f1SDavid Howells break; 4455e6ef4f1SDavid Howells 4465e6ef4f1SDavid Howells case RXRPC_CONN_REMOTELY_ABORTED: 4475e6ef4f1SDavid Howells __rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED, 4485e6ef4f1SDavid Howells conn->abort_code, conn->error); 4495e6ef4f1SDavid Howells break; 4505e6ef4f1SDavid Howells case RXRPC_CONN_LOCALLY_ABORTED: 4515e6ef4f1SDavid Howells __rxrpc_abort_call("CON", call, 1, 4525e6ef4f1SDavid Howells conn->abort_code, conn->error); 4535e6ef4f1SDavid Howells break; 4545e6ef4f1SDavid Howells default: 4555e6ef4f1SDavid Howells BUG(); 4565e6ef4f1SDavid Howells } 4575e6ef4f1SDavid Howells 4585040011dSDavid Howells rxrpc_get_call(call, rxrpc_call_get_io_thread); 4595040011dSDavid Howells 460248f219cSDavid Howells /* Set the channel for this call. We don't get channel_lock as we're 461248f219cSDavid Howells * only defending against the data_ready handler (which we're called 462248f219cSDavid Howells * from) and the RESPONSE packet parser (which is only really 463248f219cSDavid Howells * interested in call_counter and can cope with a disagreement with the 464248f219cSDavid Howells * call pointer). 4658c3e34a4SDavid Howells */ 466248f219cSDavid Howells chan = sp->hdr.cid & RXRPC_CHANNELMASK; 467248f219cSDavid Howells conn->channels[chan].call_counter = call->call_id; 468248f219cSDavid Howells conn->channels[chan].call_id = call->call_id; 469a1399f8bSDavid Howells rcu_assign_pointer(conn->channels[chan].call, call); 4705e6ef4f1SDavid Howells spin_unlock(&conn->state_lock); 4718c3e34a4SDavid Howells 4722cc80086SDavid Howells spin_lock(&conn->peer->lock); 47329fb4ec3SDavid Howells hlist_add_head(&call->error_link, &conn->peer->error_targets); 4742cc80086SDavid Howells spin_unlock(&conn->peer->lock); 4758c3e34a4SDavid Howells 476248f219cSDavid Howells rxrpc_start_call_timer(call); 477248f219cSDavid Howells _leave(""); 4788c3e34a4SDavid Howells } 4798c3e34a4SDavid Howells 4808c3e34a4SDavid Howells /* 481e34d4234SDavid Howells * Note the re-emergence of a call. 482e34d4234SDavid Howells */ 483cb0fc0c9SDavid Howells void rxrpc_see_call(struct rxrpc_call *call, enum rxrpc_call_trace why) 484e34d4234SDavid Howells { 485e34d4234SDavid Howells if (call) { 486cb0fc0c9SDavid Howells int r = refcount_read(&call->ref); 487e34d4234SDavid Howells 488cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, r, 0, why); 489e34d4234SDavid Howells } 490e34d4234SDavid Howells } 491e34d4234SDavid Howells 4925e6ef4f1SDavid Howells struct rxrpc_call *rxrpc_try_get_call(struct rxrpc_call *call, 4935e6ef4f1SDavid Howells enum rxrpc_call_trace why) 4944a7f62f9SDavid Howells { 495cb0fc0c9SDavid Howells int r; 4964a7f62f9SDavid Howells 4975e6ef4f1SDavid Howells if (!call || !__refcount_inc_not_zero(&call->ref, &r)) 4985e6ef4f1SDavid Howells return NULL; 499cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, r + 1, 0, why); 5005e6ef4f1SDavid Howells return call; 5014a7f62f9SDavid Howells } 5024a7f62f9SDavid Howells 503e34d4234SDavid Howells /* 504e34d4234SDavid Howells * Note the addition of a ref on a call. 505e34d4234SDavid Howells */ 506cb0fc0c9SDavid Howells void rxrpc_get_call(struct rxrpc_call *call, enum rxrpc_call_trace why) 507e34d4234SDavid Howells { 508cb0fc0c9SDavid Howells int r; 509e34d4234SDavid Howells 510cb0fc0c9SDavid Howells __refcount_inc(&call->ref, &r); 511cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, r + 1, 0, why); 512e34d4234SDavid Howells } 513e34d4234SDavid Howells 514e34d4234SDavid Howells /* 515a4ea4c47SDavid Howells * Clean up the Rx skb ring. 516a641fd00SDavid Howells */ 517a641fd00SDavid Howells static void rxrpc_cleanup_ring(struct rxrpc_call *call) 518a641fd00SDavid Howells { 5195d7edbc9SDavid Howells skb_queue_purge(&call->recvmsg_queue); 5205d7edbc9SDavid Howells skb_queue_purge(&call->rx_oos_queue); 521a641fd00SDavid Howells } 522a641fd00SDavid Howells 523a641fd00SDavid Howells /* 524248f219cSDavid Howells * Detach a call from its owning socket. 5258c3e34a4SDavid Howells */ 5268d94aa38SDavid Howells void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) 5278c3e34a4SDavid Howells { 528248f219cSDavid Howells struct rxrpc_connection *conn = call->conn; 529248f219cSDavid Howells bool put = false; 530248f219cSDavid Howells 531a0575429SDavid Howells _enter("{%d,%d}", call->debug_id, refcount_read(&call->ref)); 532248f219cSDavid Howells 533cb0fc0c9SDavid Howells trace_rxrpc_call(call->debug_id, refcount_read(&call->ref), 534cb0fc0c9SDavid Howells call->flags, rxrpc_call_see_release); 5358c3e34a4SDavid Howells 536a84a46d7SDavid Howells ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE); 537e34d4234SDavid Howells 5388c3e34a4SDavid Howells if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags)) 5398c3e34a4SDavid Howells BUG(); 5408c3e34a4SDavid Howells 541b7a7d674SDavid Howells rxrpc_put_call_slot(call); 5423feda9d6SDavid Howells del_timer_sync(&call->timer); 5438c3e34a4SDavid Howells 544248f219cSDavid Howells /* Make sure we don't get any more notifications */ 5453dd9c8b5SDavid Howells write_lock(&rx->recvmsg_lock); 546e653cfe4SDavid Howells 547248f219cSDavid Howells if (!list_empty(&call->recvmsg_link)) { 5488c3e34a4SDavid Howells _debug("unlinking once-pending call %p { e=%lx f=%lx }", 5498c3e34a4SDavid Howells call, call->events, call->flags); 550248f219cSDavid Howells list_del(&call->recvmsg_link); 551248f219cSDavid Howells put = true; 552248f219cSDavid Howells } 553248f219cSDavid Howells 554248f219cSDavid Howells /* list_empty() must return false in rxrpc_notify_socket() */ 555248f219cSDavid Howells call->recvmsg_link.next = NULL; 556248f219cSDavid Howells call->recvmsg_link.prev = NULL; 557248f219cSDavid Howells 5583dd9c8b5SDavid Howells write_unlock(&rx->recvmsg_lock); 559248f219cSDavid Howells if (put) 560cb0fc0c9SDavid Howells rxrpc_put_call(call, rxrpc_call_put_unnotify); 561248f219cSDavid Howells 562248f219cSDavid Howells write_lock(&rx->call_lock); 563248f219cSDavid Howells 564248f219cSDavid Howells if (test_and_clear_bit(RXRPC_CALL_HAS_USERID, &call->flags)) { 5658c3e34a4SDavid Howells rb_erase(&call->sock_node, &rx->calls); 5668c3e34a4SDavid Howells memset(&call->sock_node, 0xdd, sizeof(call->sock_node)); 567cb0fc0c9SDavid Howells rxrpc_put_call(call, rxrpc_call_put_userid_exists); 5688c3e34a4SDavid Howells } 5698c3e34a4SDavid Howells 570248f219cSDavid Howells list_del(&call->sock_link); 571248f219cSDavid Howells write_unlock(&rx->call_lock); 5728c3e34a4SDavid Howells 573248f219cSDavid Howells _debug("RELEASE CALL %p (%d CONN %p)", call, call->debug_id, conn); 5748c3e34a4SDavid Howells 5755273a191SDavid Howells if (conn && !test_bit(RXRPC_CALL_DISCONNECTED, &call->flags)) 576e653cfe4SDavid Howells rxrpc_disconnect_call(call); 57791fcfbe8SDavid Howells if (call->security) 57891fcfbe8SDavid Howells call->security->free_call_crypto(call); 5798c3e34a4SDavid Howells _leave(""); 5808c3e34a4SDavid Howells } 5818c3e34a4SDavid Howells 5828c3e34a4SDavid Howells /* 5838c3e34a4SDavid Howells * release all the calls associated with a socket 5848c3e34a4SDavid Howells */ 5858c3e34a4SDavid Howells void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx) 5868c3e34a4SDavid Howells { 5878c3e34a4SDavid Howells struct rxrpc_call *call; 5888c3e34a4SDavid Howells 5898c3e34a4SDavid Howells _enter("%p", rx); 5908c3e34a4SDavid Howells 5910360da6dSDavid Howells while (!list_empty(&rx->to_be_accepted)) { 5920360da6dSDavid Howells call = list_entry(rx->to_be_accepted.next, 5930360da6dSDavid Howells struct rxrpc_call, accept_link); 5940360da6dSDavid Howells list_del(&call->accept_link); 595*a343b174SDavid Howells rxrpc_propose_abort(call, RX_CALL_DEAD, -ECONNRESET, "SKR"); 596cb0fc0c9SDavid Howells rxrpc_put_call(call, rxrpc_call_put_release_sock_tba); 5970360da6dSDavid Howells } 5980360da6dSDavid Howells 599248f219cSDavid Howells while (!list_empty(&rx->sock_calls)) { 600248f219cSDavid Howells call = list_entry(rx->sock_calls.next, 601248f219cSDavid Howells struct rxrpc_call, sock_link); 602cb0fc0c9SDavid Howells rxrpc_get_call(call, rxrpc_call_get_release_sock); 603*a343b174SDavid Howells rxrpc_propose_abort(call, RX_CALL_DEAD, -ECONNRESET, "SKT"); 6048d94aa38SDavid Howells rxrpc_release_call(rx, call); 605cb0fc0c9SDavid Howells rxrpc_put_call(call, rxrpc_call_put_release_sock); 6068c3e34a4SDavid Howells } 6078c3e34a4SDavid Howells 6088c3e34a4SDavid Howells _leave(""); 6098c3e34a4SDavid Howells } 6108c3e34a4SDavid Howells 6118c3e34a4SDavid Howells /* 6128c3e34a4SDavid Howells * release a call 6138c3e34a4SDavid Howells */ 614cb0fc0c9SDavid Howells void rxrpc_put_call(struct rxrpc_call *call, enum rxrpc_call_trace why) 6158c3e34a4SDavid Howells { 616d3be4d24SDavid Howells struct rxrpc_net *rxnet = call->rxnet; 61748c9e0ecSDavid Howells unsigned int debug_id = call->debug_id; 618a0575429SDavid Howells bool dead; 619cb0fc0c9SDavid Howells int r; 620e34d4234SDavid Howells 6218c3e34a4SDavid Howells ASSERT(call != NULL); 6228c3e34a4SDavid Howells 623cb0fc0c9SDavid Howells dead = __refcount_dec_and_test(&call->ref, &r); 624cb0fc0c9SDavid Howells trace_rxrpc_call(debug_id, r - 1, 0, why); 625a0575429SDavid Howells if (dead) { 626248f219cSDavid Howells ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE); 627e34d4234SDavid Howells 6282baec2c3SDavid Howells if (!list_empty(&call->link)) { 6293dd9c8b5SDavid Howells spin_lock(&rxnet->call_lock); 630248f219cSDavid Howells list_del_init(&call->link); 6313dd9c8b5SDavid Howells spin_unlock(&rxnet->call_lock); 6322baec2c3SDavid Howells } 633e34d4234SDavid Howells 6348d94aa38SDavid Howells rxrpc_cleanup_call(call); 635e34d4234SDavid Howells } 6368c3e34a4SDavid Howells } 6378c3e34a4SDavid Howells 6388c3e34a4SDavid Howells /* 6393feda9d6SDavid Howells * Free up the call under RCU. 640dee46364SDavid Howells */ 6413feda9d6SDavid Howells static void rxrpc_rcu_free_call(struct rcu_head *rcu) 642dee46364SDavid Howells { 6433feda9d6SDavid Howells struct rxrpc_call *call = container_of(rcu, struct rxrpc_call, rcu); 6443feda9d6SDavid Howells struct rxrpc_net *rxnet = READ_ONCE(call->rxnet); 645dee46364SDavid Howells 646dee46364SDavid Howells kmem_cache_free(rxrpc_call_jar, call); 647d3be4d24SDavid Howells if (atomic_dec_and_test(&rxnet->nr_calls)) 6485bb053beSLinus Torvalds wake_up_var(&rxnet->nr_calls); 649dee46364SDavid Howells } 650dee46364SDavid Howells 651dee46364SDavid Howells /* 6523feda9d6SDavid Howells * Final call destruction - but must be done in process context. 653963485d4SDavid Howells */ 6543feda9d6SDavid Howells static void rxrpc_destroy_call(struct work_struct *work) 655963485d4SDavid Howells { 6563feda9d6SDavid Howells struct rxrpc_call *call = container_of(work, struct rxrpc_call, destroyer); 657a4ea4c47SDavid Howells struct rxrpc_txbuf *txb; 658a4ea4c47SDavid Howells 6593feda9d6SDavid Howells del_timer_sync(&call->timer); 6608c3e34a4SDavid Howells 661a641fd00SDavid Howells rxrpc_cleanup_ring(call); 662cf37b598SDavid Howells while ((txb = list_first_entry_or_null(&call->tx_sendmsg, 663cf37b598SDavid Howells struct rxrpc_txbuf, call_link))) { 664cf37b598SDavid Howells list_del(&txb->call_link); 665cf37b598SDavid Howells rxrpc_put_txbuf(txb, rxrpc_txbuf_put_cleaned); 666cf37b598SDavid Howells } 667a4ea4c47SDavid Howells while ((txb = list_first_entry_or_null(&call->tx_buffer, 668a4ea4c47SDavid Howells struct rxrpc_txbuf, call_link))) { 669a4ea4c47SDavid Howells list_del(&txb->call_link); 670a4ea4c47SDavid Howells rxrpc_put_txbuf(txb, rxrpc_txbuf_put_cleaned); 671a4ea4c47SDavid Howells } 6725e6ef4f1SDavid Howells 673a4ea4c47SDavid Howells rxrpc_put_txbuf(call->tx_pending, rxrpc_txbuf_put_cleaned); 6743feda9d6SDavid Howells rxrpc_put_connection(call->conn, rxrpc_conn_put_call); 6753feda9d6SDavid Howells rxrpc_put_peer(call->peer, rxrpc_peer_put_call); 676f3441d41SDavid Howells rxrpc_put_local(call->local, rxrpc_local_put_call); 6773feda9d6SDavid Howells call_rcu(&call->rcu, rxrpc_rcu_free_call); 6783feda9d6SDavid Howells } 6798c3e34a4SDavid Howells 6803feda9d6SDavid Howells /* 6813feda9d6SDavid Howells * clean up a call 6823feda9d6SDavid Howells */ 6833feda9d6SDavid Howells void rxrpc_cleanup_call(struct rxrpc_call *call) 6843feda9d6SDavid Howells { 6853feda9d6SDavid Howells memset(&call->sock_node, 0xcd, sizeof(call->sock_node)); 6863feda9d6SDavid Howells 6873feda9d6SDavid Howells ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE); 6883feda9d6SDavid Howells ASSERT(test_bit(RXRPC_CALL_RELEASED, &call->flags)); 6893feda9d6SDavid Howells 6905e6ef4f1SDavid Howells del_timer(&call->timer); 6913feda9d6SDavid Howells 6925e6ef4f1SDavid Howells if (rcu_read_lock_held()) 6933feda9d6SDavid Howells /* Can't use the rxrpc workqueue as we need to cancel/flush 6943feda9d6SDavid Howells * something that may be running/waiting there. 6953feda9d6SDavid Howells */ 6963feda9d6SDavid Howells schedule_work(&call->destroyer); 6973feda9d6SDavid Howells else 6983feda9d6SDavid Howells rxrpc_destroy_call(&call->destroyer); 6998c3e34a4SDavid Howells } 7008c3e34a4SDavid Howells 7018c3e34a4SDavid Howells /* 7022baec2c3SDavid Howells * Make sure that all calls are gone from a network namespace. To reach this 7032baec2c3SDavid Howells * point, any open UDP sockets in that namespace must have been closed, so any 7042baec2c3SDavid Howells * outstanding calls cannot be doing I/O. 7058c3e34a4SDavid Howells */ 7062baec2c3SDavid Howells void rxrpc_destroy_all_calls(struct rxrpc_net *rxnet) 7078c3e34a4SDavid Howells { 7088c3e34a4SDavid Howells struct rxrpc_call *call; 7098c3e34a4SDavid Howells 7108c3e34a4SDavid Howells _enter(""); 7118d94aa38SDavid Howells 712b1302342SDavid Howells if (!list_empty(&rxnet->calls)) { 7133dd9c8b5SDavid Howells spin_lock(&rxnet->call_lock); 7148c3e34a4SDavid Howells 7152baec2c3SDavid Howells while (!list_empty(&rxnet->calls)) { 716b1302342SDavid Howells call = list_entry(rxnet->calls.next, 717b1302342SDavid Howells struct rxrpc_call, link); 7188c3e34a4SDavid Howells _debug("Zapping call %p", call); 7198c3e34a4SDavid Howells 720cb0fc0c9SDavid Howells rxrpc_see_call(call, rxrpc_call_see_zap); 7218c3e34a4SDavid Howells list_del_init(&call->link); 7228c3e34a4SDavid Howells 723248f219cSDavid Howells pr_err("Call %p still in use (%d,%s,%lx,%lx)!\n", 724a0575429SDavid Howells call, refcount_read(&call->ref), 7258c3e34a4SDavid Howells rxrpc_call_states[call->state], 7268c3e34a4SDavid Howells call->flags, call->events); 7278c3e34a4SDavid Howells 7283dd9c8b5SDavid Howells spin_unlock(&rxnet->call_lock); 7298c3e34a4SDavid Howells cond_resched(); 7303dd9c8b5SDavid Howells spin_lock(&rxnet->call_lock); 7318c3e34a4SDavid Howells } 7328c3e34a4SDavid Howells 7333dd9c8b5SDavid Howells spin_unlock(&rxnet->call_lock); 734b1302342SDavid Howells } 735d3be4d24SDavid Howells 736d3be4d24SDavid Howells atomic_dec(&rxnet->nr_calls); 7375bb053beSLinus Torvalds wait_var_event(&rxnet->nr_calls, !atomic_read(&rxnet->nr_calls)); 7388c3e34a4SDavid Howells } 739