To abtract the lock and unlock operations on the requestor spin lock. The helpers will come in handy in hv_pci. No functional change.
Unified · Split
| @@ -1252,12 +1252,12 @@ u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr) · 1251 unmodified lines | ||
| 1252 | 1252 | if (!channel->rqstor_size) |
| 1253 | 1253 | return VMBUS_NO_RQSTOR; |
| 1254 | 1254 | |
| 1255 | − spin_lock_irqsave(&rqstor->req_lock, flags); | |
| 1255 | + lock_requestor(channel, flags); | |
| 1256 | 1256 | current_id = rqstor->next_request_id; |
| 1257 | 1257 | |
| 1258 | 1258 | /* Requestor array is full */ |
| 1259 | 1259 | if (current_id >= rqstor->size) { |
| 1260 | − spin_unlock_irqrestore(&rqstor->req_lock, flags); | |
| 1260 | + unlock_requestor(channel, flags); | |
| 1261 | 1261 | return VMBUS_RQST_ERROR; |
| 1262 | 1262 | } |
| 1263 | 1263 | |
| @@ -1267,7 +1267,7 @@ u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr) · 3 unmodified lines | ||
| 1267 | 1267 | /* The already held spin lock provides atomicity */ |
| 1268 | 1268 | bitmap_set(rqstor->req_bitmap, current_id, 1); |
| 1269 | 1269 | |
| 1270 | − spin_unlock_irqrestore(&rqstor->req_lock, flags); | |
| 1270 | + unlock_requestor(channel, flags); | |
| 1271 | 1271 | |
| 1272 | 1272 | /* |
| 1273 | 1273 | * Cannot return an ID of 0, which is reserved for an unsolicited |
| @@ -1327,13 +1327,12 @@ EXPORT_SYMBOL_GPL(__vmbus_request_addr_match); · 53 unmodified lines | ||
| 1327 | 1327 | u64 vmbus_request_addr_match(struct vmbus_channel *channel, u64 trans_id, |
| 1328 | 1328 | u64 rqst_addr) |
| 1329 | 1329 | { |
| 1330 | − struct vmbus_requestor *rqstor = &channel->requestor; | |
| 1331 | 1330 | unsigned long flags; |
| 1332 | 1331 | u64 req_addr; |
| 1333 | 1332 | |
| 1334 | − spin_lock_irqsave(&rqstor->req_lock, flags); | |
| 1333 | + lock_requestor(channel, flags); | |
| 1335 | 1334 | req_addr = __vmbus_request_addr_match(channel, trans_id, rqst_addr); |
| 1336 | − spin_unlock_irqrestore(&rqstor->req_lock, flags); | |
| 1335 | + unlock_requestor(channel, flags); | |
| 1337 | 1336 | |
| 1338 | 1337 | return req_addr; |
| 1339 | 1338 | } |
| @@ -1042,6 +1042,21 @@ struct vmbus_channel { · 1041 unmodified lines | ||
| 1042 | 1042 | u32 max_pkt_size; |
| 1043 | 1043 | }; |
| 1044 | 1044 | |
| 1045 | +#define lock_requestor(channel, flags) \ | |
| 1046 | +do { \ | |
| 1047 | + struct vmbus_requestor *rqstor = &(channel)->requestor; \ | |
| 1048 | + \ | |
| 1049 | + spin_lock_irqsave(&rqstor->req_lock, flags); \ | |
| 1050 | +} while (0) | |
| 1051 | + | |
| 1052 | +static __always_inline void unlock_requestor(struct vmbus_channel *channel, | |
| 1053 | + unsigned long flags) | |
| 1054 | +{ | |
| 1055 | + struct vmbus_requestor *rqstor = &channel->requestor; | |
| 1056 | + | |
| 1057 | + spin_unlock_irqrestore(&rqstor->req_lock, flags); | |
| 1058 | +} | |
| 1059 | + | |
| 1045 | 1060 | u64 vmbus_next_request_id(struct vmbus_channel *channel, u64 rqst_addr); |
| 1046 | 1061 | u64 __vmbus_request_addr_match(struct vmbus_channel *channel, u64 trans_id, |
| 1047 | 1062 | u64 rqst_addr); |