channel_mgmt.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. /*
  2. * Copyright (c) 2009, Microsoft Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  15. * Place - Suite 330, Boston, MA 02111-1307 USA.
  16. *
  17. * Authors:
  18. * Haiyang Zhang <haiyangz@microsoft.com>
  19. * Hank Janssen <hjanssen@microsoft.com>
  20. */
  21. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  22. #include <linux/kernel.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/sched.h>
  25. #include <linux/wait.h>
  26. #include <linux/mm.h>
  27. #include <linux/slab.h>
  28. #include <linux/list.h>
  29. #include <linux/module.h>
  30. #include <linux/completion.h>
  31. #include <linux/delay.h>
  32. #include <linux/hyperv.h>
  33. #include <asm/mshyperv.h>
  34. #include "hyperv_vmbus.h"
  35. static void init_vp_index(struct vmbus_channel *channel, u16 dev_type);
  36. static const struct vmbus_device vmbus_devs[] = {
  37. /* IDE */
  38. { .dev_type = HV_IDE,
  39. HV_IDE_GUID,
  40. .perf_device = true,
  41. },
  42. /* SCSI */
  43. { .dev_type = HV_SCSI,
  44. HV_SCSI_GUID,
  45. .perf_device = true,
  46. },
  47. /* Fibre Channel */
  48. { .dev_type = HV_FC,
  49. HV_SYNTHFC_GUID,
  50. .perf_device = true,
  51. },
  52. /* Synthetic NIC */
  53. { .dev_type = HV_NIC,
  54. HV_NIC_GUID,
  55. .perf_device = true,
  56. },
  57. /* Network Direct */
  58. { .dev_type = HV_ND,
  59. HV_ND_GUID,
  60. .perf_device = true,
  61. },
  62. /* PCIE */
  63. { .dev_type = HV_PCIE,
  64. HV_PCIE_GUID,
  65. .perf_device = false,
  66. },
  67. /* Synthetic Frame Buffer */
  68. { .dev_type = HV_FB,
  69. HV_SYNTHVID_GUID,
  70. .perf_device = false,
  71. },
  72. /* Synthetic Keyboard */
  73. { .dev_type = HV_KBD,
  74. HV_KBD_GUID,
  75. .perf_device = false,
  76. },
  77. /* Synthetic MOUSE */
  78. { .dev_type = HV_MOUSE,
  79. HV_MOUSE_GUID,
  80. .perf_device = false,
  81. },
  82. /* KVP */
  83. { .dev_type = HV_KVP,
  84. HV_KVP_GUID,
  85. .perf_device = false,
  86. },
  87. /* Time Synch */
  88. { .dev_type = HV_TS,
  89. HV_TS_GUID,
  90. .perf_device = false,
  91. },
  92. /* Heartbeat */
  93. { .dev_type = HV_HB,
  94. HV_HEART_BEAT_GUID,
  95. .perf_device = false,
  96. },
  97. /* Shutdown */
  98. { .dev_type = HV_SHUTDOWN,
  99. HV_SHUTDOWN_GUID,
  100. .perf_device = false,
  101. },
  102. /* File copy */
  103. { .dev_type = HV_FCOPY,
  104. HV_FCOPY_GUID,
  105. .perf_device = false,
  106. },
  107. /* Backup */
  108. { .dev_type = HV_BACKUP,
  109. HV_VSS_GUID,
  110. .perf_device = false,
  111. },
  112. /* Dynamic Memory */
  113. { .dev_type = HV_DM,
  114. HV_DM_GUID,
  115. .perf_device = false,
  116. },
  117. /* Unknown GUID */
  118. { .dev_type = HV_UNKNOWN,
  119. .perf_device = false,
  120. },
  121. };
  122. static const struct {
  123. uuid_le guid;
  124. } vmbus_unsupported_devs[] = {
  125. { HV_AVMA1_GUID },
  126. { HV_AVMA2_GUID },
  127. { HV_RDV_GUID },
  128. };
  129. /*
  130. * The rescinded channel may be blocked waiting for a response from the host;
  131. * take care of that.
  132. */
  133. static void vmbus_rescind_cleanup(struct vmbus_channel *channel)
  134. {
  135. struct vmbus_channel_msginfo *msginfo;
  136. unsigned long flags;
  137. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  138. channel->rescind = true;
  139. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  140. msglistentry) {
  141. if (msginfo->waiting_channel == channel) {
  142. complete(&msginfo->waitevent);
  143. break;
  144. }
  145. }
  146. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  147. }
  148. static bool is_unsupported_vmbus_devs(const uuid_le *guid)
  149. {
  150. int i;
  151. for (i = 0; i < ARRAY_SIZE(vmbus_unsupported_devs); i++)
  152. if (!uuid_le_cmp(*guid, vmbus_unsupported_devs[i].guid))
  153. return true;
  154. return false;
  155. }
  156. static u16 hv_get_dev_type(const struct vmbus_channel *channel)
  157. {
  158. const uuid_le *guid = &channel->offermsg.offer.if_type;
  159. u16 i;
  160. if (is_hvsock_channel(channel) || is_unsupported_vmbus_devs(guid))
  161. return HV_UNKNOWN;
  162. for (i = HV_IDE; i < HV_UNKNOWN; i++) {
  163. if (!uuid_le_cmp(*guid, vmbus_devs[i].guid))
  164. return i;
  165. }
  166. pr_info("Unknown GUID: %pUl\n", guid);
  167. return i;
  168. }
  169. /**
  170. * vmbus_prep_negotiate_resp() - Create default response for Hyper-V Negotiate message
  171. * @icmsghdrp: Pointer to msg header structure
  172. * @icmsg_negotiate: Pointer to negotiate message structure
  173. * @buf: Raw buffer channel data
  174. *
  175. * @icmsghdrp is of type &struct icmsg_hdr.
  176. * Set up and fill in default negotiate response message.
  177. *
  178. * The fw_version and fw_vercnt specifies the framework version that
  179. * we can support.
  180. *
  181. * The srv_version and srv_vercnt specifies the service
  182. * versions we can support.
  183. *
  184. * Versions are given in decreasing order.
  185. *
  186. * nego_fw_version and nego_srv_version store the selected protocol versions.
  187. *
  188. * Mainly used by Hyper-V drivers.
  189. */
  190. bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
  191. u8 *buf, const int *fw_version, int fw_vercnt,
  192. const int *srv_version, int srv_vercnt,
  193. int *nego_fw_version, int *nego_srv_version)
  194. {
  195. int icframe_major, icframe_minor;
  196. int icmsg_major, icmsg_minor;
  197. int fw_major, fw_minor;
  198. int srv_major, srv_minor;
  199. int i, j;
  200. bool found_match = false;
  201. struct icmsg_negotiate *negop;
  202. icmsghdrp->icmsgsize = 0x10;
  203. negop = (struct icmsg_negotiate *)&buf[
  204. sizeof(struct vmbuspipe_hdr) +
  205. sizeof(struct icmsg_hdr)];
  206. icframe_major = negop->icframe_vercnt;
  207. icframe_minor = 0;
  208. icmsg_major = negop->icmsg_vercnt;
  209. icmsg_minor = 0;
  210. /*
  211. * Select the framework version number we will
  212. * support.
  213. */
  214. for (i = 0; i < fw_vercnt; i++) {
  215. fw_major = (fw_version[i] >> 16);
  216. fw_minor = (fw_version[i] & 0xFFFF);
  217. for (j = 0; j < negop->icframe_vercnt; j++) {
  218. if ((negop->icversion_data[j].major == fw_major) &&
  219. (negop->icversion_data[j].minor == fw_minor)) {
  220. icframe_major = negop->icversion_data[j].major;
  221. icframe_minor = negop->icversion_data[j].minor;
  222. found_match = true;
  223. break;
  224. }
  225. }
  226. if (found_match)
  227. break;
  228. }
  229. if (!found_match)
  230. goto fw_error;
  231. found_match = false;
  232. for (i = 0; i < srv_vercnt; i++) {
  233. srv_major = (srv_version[i] >> 16);
  234. srv_minor = (srv_version[i] & 0xFFFF);
  235. for (j = negop->icframe_vercnt;
  236. (j < negop->icframe_vercnt + negop->icmsg_vercnt);
  237. j++) {
  238. if ((negop->icversion_data[j].major == srv_major) &&
  239. (negop->icversion_data[j].minor == srv_minor)) {
  240. icmsg_major = negop->icversion_data[j].major;
  241. icmsg_minor = negop->icversion_data[j].minor;
  242. found_match = true;
  243. break;
  244. }
  245. }
  246. if (found_match)
  247. break;
  248. }
  249. /*
  250. * Respond with the framework and service
  251. * version numbers we can support.
  252. */
  253. fw_error:
  254. if (!found_match) {
  255. negop->icframe_vercnt = 0;
  256. negop->icmsg_vercnt = 0;
  257. } else {
  258. negop->icframe_vercnt = 1;
  259. negop->icmsg_vercnt = 1;
  260. }
  261. if (nego_fw_version)
  262. *nego_fw_version = (icframe_major << 16) | icframe_minor;
  263. if (nego_srv_version)
  264. *nego_srv_version = (icmsg_major << 16) | icmsg_minor;
  265. negop->icversion_data[0].major = icframe_major;
  266. negop->icversion_data[0].minor = icframe_minor;
  267. negop->icversion_data[1].major = icmsg_major;
  268. negop->icversion_data[1].minor = icmsg_minor;
  269. return found_match;
  270. }
  271. EXPORT_SYMBOL_GPL(vmbus_prep_negotiate_resp);
  272. /*
  273. * alloc_channel - Allocate and initialize a vmbus channel object
  274. */
  275. static struct vmbus_channel *alloc_channel(void)
  276. {
  277. struct vmbus_channel *channel;
  278. channel = kzalloc(sizeof(*channel), GFP_ATOMIC);
  279. if (!channel)
  280. return NULL;
  281. spin_lock_init(&channel->lock);
  282. init_completion(&channel->rescind_event);
  283. INIT_LIST_HEAD(&channel->sc_list);
  284. INIT_LIST_HEAD(&channel->percpu_list);
  285. tasklet_init(&channel->callback_event,
  286. vmbus_on_event, (unsigned long)channel);
  287. return channel;
  288. }
  289. /*
  290. * free_channel - Release the resources used by the vmbus channel object
  291. */
  292. static void free_channel(struct vmbus_channel *channel)
  293. {
  294. tasklet_kill(&channel->callback_event);
  295. kobject_put(&channel->kobj);
  296. }
  297. static void percpu_channel_enq(void *arg)
  298. {
  299. struct vmbus_channel *channel = arg;
  300. struct hv_per_cpu_context *hv_cpu
  301. = this_cpu_ptr(hv_context.cpu_context);
  302. list_add_tail_rcu(&channel->percpu_list, &hv_cpu->chan_list);
  303. }
  304. static void percpu_channel_deq(void *arg)
  305. {
  306. struct vmbus_channel *channel = arg;
  307. list_del_rcu(&channel->percpu_list);
  308. }
  309. static void vmbus_release_relid(u32 relid)
  310. {
  311. struct vmbus_channel_relid_released msg;
  312. int ret;
  313. memset(&msg, 0, sizeof(struct vmbus_channel_relid_released));
  314. msg.child_relid = relid;
  315. msg.header.msgtype = CHANNELMSG_RELID_RELEASED;
  316. ret = vmbus_post_msg(&msg, sizeof(struct vmbus_channel_relid_released),
  317. true);
  318. trace_vmbus_release_relid(&msg, ret);
  319. }
  320. void hv_process_channel_removal(u32 relid)
  321. {
  322. unsigned long flags;
  323. struct vmbus_channel *primary_channel, *channel;
  324. BUG_ON(!mutex_is_locked(&vmbus_connection.channel_mutex));
  325. /*
  326. * Make sure channel is valid as we may have raced.
  327. */
  328. channel = relid2channel(relid);
  329. if (!channel)
  330. return;
  331. BUG_ON(!channel->rescind);
  332. if (channel->target_cpu != get_cpu()) {
  333. put_cpu();
  334. smp_call_function_single(channel->target_cpu,
  335. percpu_channel_deq, channel, true);
  336. } else {
  337. percpu_channel_deq(channel);
  338. put_cpu();
  339. }
  340. if (channel->primary_channel == NULL) {
  341. list_del(&channel->listentry);
  342. primary_channel = channel;
  343. } else {
  344. primary_channel = channel->primary_channel;
  345. spin_lock_irqsave(&primary_channel->lock, flags);
  346. list_del(&channel->sc_list);
  347. primary_channel->num_sc--;
  348. spin_unlock_irqrestore(&primary_channel->lock, flags);
  349. }
  350. /*
  351. * We need to free the bit for init_vp_index() to work in the case
  352. * of sub-channel, when we reload drivers like hv_netvsc.
  353. */
  354. if (channel->affinity_policy == HV_LOCALIZED)
  355. cpumask_clear_cpu(channel->target_cpu,
  356. &primary_channel->alloced_cpus_in_node);
  357. vmbus_release_relid(relid);
  358. free_channel(channel);
  359. }
  360. void vmbus_free_channels(void)
  361. {
  362. struct vmbus_channel *channel, *tmp;
  363. list_for_each_entry_safe(channel, tmp, &vmbus_connection.chn_list,
  364. listentry) {
  365. /* hv_process_channel_removal() needs this */
  366. channel->rescind = true;
  367. vmbus_device_unregister(channel->device_obj);
  368. }
  369. }
  370. /*
  371. * vmbus_process_offer - Process the offer by creating a channel/device
  372. * associated with this offer
  373. */
  374. static void vmbus_process_offer(struct vmbus_channel *newchannel)
  375. {
  376. struct vmbus_channel *channel;
  377. bool fnew = true;
  378. unsigned long flags;
  379. u16 dev_type;
  380. int ret;
  381. /* Make sure this is a new offer */
  382. mutex_lock(&vmbus_connection.channel_mutex);
  383. /*
  384. * Now that we have acquired the channel_mutex,
  385. * we can release the potentially racing rescind thread.
  386. */
  387. atomic_dec(&vmbus_connection.offer_in_progress);
  388. list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
  389. if (!uuid_le_cmp(channel->offermsg.offer.if_type,
  390. newchannel->offermsg.offer.if_type) &&
  391. !uuid_le_cmp(channel->offermsg.offer.if_instance,
  392. newchannel->offermsg.offer.if_instance)) {
  393. fnew = false;
  394. break;
  395. }
  396. }
  397. if (fnew)
  398. list_add_tail(&newchannel->listentry,
  399. &vmbus_connection.chn_list);
  400. mutex_unlock(&vmbus_connection.channel_mutex);
  401. if (!fnew) {
  402. /*
  403. * Check to see if this is a sub-channel.
  404. */
  405. if (newchannel->offermsg.offer.sub_channel_index != 0) {
  406. /*
  407. * Process the sub-channel.
  408. */
  409. newchannel->primary_channel = channel;
  410. spin_lock_irqsave(&channel->lock, flags);
  411. list_add_tail(&newchannel->sc_list, &channel->sc_list);
  412. channel->num_sc++;
  413. spin_unlock_irqrestore(&channel->lock, flags);
  414. } else {
  415. goto err_free_chan;
  416. }
  417. }
  418. dev_type = hv_get_dev_type(newchannel);
  419. init_vp_index(newchannel, dev_type);
  420. if (newchannel->target_cpu != get_cpu()) {
  421. put_cpu();
  422. smp_call_function_single(newchannel->target_cpu,
  423. percpu_channel_enq,
  424. newchannel, true);
  425. } else {
  426. percpu_channel_enq(newchannel);
  427. put_cpu();
  428. }
  429. /*
  430. * This state is used to indicate a successful open
  431. * so that when we do close the channel normally, we
  432. * can cleanup properly
  433. */
  434. newchannel->state = CHANNEL_OPEN_STATE;
  435. if (!fnew) {
  436. struct hv_device *dev
  437. = newchannel->primary_channel->device_obj;
  438. if (vmbus_add_channel_kobj(dev, newchannel))
  439. goto err_free_chan;
  440. if (channel->sc_creation_callback != NULL)
  441. channel->sc_creation_callback(newchannel);
  442. newchannel->probe_done = true;
  443. return;
  444. }
  445. /*
  446. * Start the process of binding this offer to the driver
  447. * We need to set the DeviceObject field before calling
  448. * vmbus_child_dev_add()
  449. */
  450. newchannel->device_obj = vmbus_device_create(
  451. &newchannel->offermsg.offer.if_type,
  452. &newchannel->offermsg.offer.if_instance,
  453. newchannel);
  454. if (!newchannel->device_obj)
  455. goto err_deq_chan;
  456. newchannel->device_obj->device_id = dev_type;
  457. /*
  458. * Add the new device to the bus. This will kick off device-driver
  459. * binding which eventually invokes the device driver's AddDevice()
  460. * method.
  461. */
  462. ret = vmbus_device_register(newchannel->device_obj);
  463. if (ret != 0) {
  464. pr_err("unable to add child device object (relid %d)\n",
  465. newchannel->offermsg.child_relid);
  466. kfree(newchannel->device_obj);
  467. goto err_deq_chan;
  468. }
  469. newchannel->probe_done = true;
  470. return;
  471. err_deq_chan:
  472. mutex_lock(&vmbus_connection.channel_mutex);
  473. list_del(&newchannel->listentry);
  474. mutex_unlock(&vmbus_connection.channel_mutex);
  475. if (newchannel->target_cpu != get_cpu()) {
  476. put_cpu();
  477. smp_call_function_single(newchannel->target_cpu,
  478. percpu_channel_deq, newchannel, true);
  479. } else {
  480. percpu_channel_deq(newchannel);
  481. put_cpu();
  482. }
  483. vmbus_release_relid(newchannel->offermsg.child_relid);
  484. err_free_chan:
  485. free_channel(newchannel);
  486. }
  487. /*
  488. * We use this state to statically distribute the channel interrupt load.
  489. */
  490. static int next_numa_node_id;
  491. /*
  492. * Starting with Win8, we can statically distribute the incoming
  493. * channel interrupt load by binding a channel to VCPU.
  494. * We distribute the interrupt loads to one or more NUMA nodes based on
  495. * the channel's affinity_policy.
  496. *
  497. * For pre-win8 hosts or non-performance critical channels we assign the
  498. * first CPU in the first NUMA node.
  499. */
  500. static void init_vp_index(struct vmbus_channel *channel, u16 dev_type)
  501. {
  502. u32 cur_cpu;
  503. bool perf_chn = vmbus_devs[dev_type].perf_device;
  504. struct vmbus_channel *primary = channel->primary_channel;
  505. int next_node;
  506. struct cpumask available_mask;
  507. struct cpumask *alloced_mask;
  508. if ((vmbus_proto_version == VERSION_WS2008) ||
  509. (vmbus_proto_version == VERSION_WIN7) || (!perf_chn)) {
  510. /*
  511. * Prior to win8, all channel interrupts are
  512. * delivered on cpu 0.
  513. * Also if the channel is not a performance critical
  514. * channel, bind it to cpu 0.
  515. */
  516. channel->numa_node = 0;
  517. channel->target_cpu = 0;
  518. channel->target_vp = hv_cpu_number_to_vp_number(0);
  519. return;
  520. }
  521. /*
  522. * Based on the channel affinity policy, we will assign the NUMA
  523. * nodes.
  524. */
  525. if ((channel->affinity_policy == HV_BALANCED) || (!primary)) {
  526. while (true) {
  527. next_node = next_numa_node_id++;
  528. if (next_node == nr_node_ids) {
  529. next_node = next_numa_node_id = 0;
  530. continue;
  531. }
  532. if (cpumask_empty(cpumask_of_node(next_node)))
  533. continue;
  534. break;
  535. }
  536. channel->numa_node = next_node;
  537. primary = channel;
  538. }
  539. alloced_mask = &hv_context.hv_numa_map[primary->numa_node];
  540. if (cpumask_weight(alloced_mask) ==
  541. cpumask_weight(cpumask_of_node(primary->numa_node))) {
  542. /*
  543. * We have cycled through all the CPUs in the node;
  544. * reset the alloced map.
  545. */
  546. cpumask_clear(alloced_mask);
  547. }
  548. cpumask_xor(&available_mask, alloced_mask,
  549. cpumask_of_node(primary->numa_node));
  550. cur_cpu = -1;
  551. if (primary->affinity_policy == HV_LOCALIZED) {
  552. /*
  553. * Normally Hyper-V host doesn't create more subchannels
  554. * than there are VCPUs on the node but it is possible when not
  555. * all present VCPUs on the node are initialized by guest.
  556. * Clear the alloced_cpus_in_node to start over.
  557. */
  558. if (cpumask_equal(&primary->alloced_cpus_in_node,
  559. cpumask_of_node(primary->numa_node)))
  560. cpumask_clear(&primary->alloced_cpus_in_node);
  561. }
  562. while (true) {
  563. cur_cpu = cpumask_next(cur_cpu, &available_mask);
  564. if (cur_cpu >= nr_cpu_ids) {
  565. cur_cpu = -1;
  566. cpumask_copy(&available_mask,
  567. cpumask_of_node(primary->numa_node));
  568. continue;
  569. }
  570. if (primary->affinity_policy == HV_LOCALIZED) {
  571. /*
  572. * NOTE: in the case of sub-channel, we clear the
  573. * sub-channel related bit(s) in
  574. * primary->alloced_cpus_in_node in
  575. * hv_process_channel_removal(), so when we
  576. * reload drivers like hv_netvsc in SMP guest, here
  577. * we're able to re-allocate
  578. * bit from primary->alloced_cpus_in_node.
  579. */
  580. if (!cpumask_test_cpu(cur_cpu,
  581. &primary->alloced_cpus_in_node)) {
  582. cpumask_set_cpu(cur_cpu,
  583. &primary->alloced_cpus_in_node);
  584. cpumask_set_cpu(cur_cpu, alloced_mask);
  585. break;
  586. }
  587. } else {
  588. cpumask_set_cpu(cur_cpu, alloced_mask);
  589. break;
  590. }
  591. }
  592. channel->target_cpu = cur_cpu;
  593. channel->target_vp = hv_cpu_number_to_vp_number(cur_cpu);
  594. }
  595. static void vmbus_wait_for_unload(void)
  596. {
  597. int cpu;
  598. void *page_addr;
  599. struct hv_message *msg;
  600. struct vmbus_channel_message_header *hdr;
  601. u32 message_type;
  602. /*
  603. * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was
  604. * used for initial contact or to CPU0 depending on host version. When
  605. * we're crashing on a different CPU let's hope that IRQ handler on
  606. * the cpu which receives CHANNELMSG_UNLOAD_RESPONSE is still
  607. * functional and vmbus_unload_response() will complete
  608. * vmbus_connection.unload_event. If not, the last thing we can do is
  609. * read message pages for all CPUs directly.
  610. */
  611. while (1) {
  612. if (completion_done(&vmbus_connection.unload_event))
  613. break;
  614. for_each_online_cpu(cpu) {
  615. struct hv_per_cpu_context *hv_cpu
  616. = per_cpu_ptr(hv_context.cpu_context, cpu);
  617. page_addr = hv_cpu->synic_message_page;
  618. msg = (struct hv_message *)page_addr
  619. + VMBUS_MESSAGE_SINT;
  620. message_type = READ_ONCE(msg->header.message_type);
  621. if (message_type == HVMSG_NONE)
  622. continue;
  623. hdr = (struct vmbus_channel_message_header *)
  624. msg->u.payload;
  625. if (hdr->msgtype == CHANNELMSG_UNLOAD_RESPONSE)
  626. complete(&vmbus_connection.unload_event);
  627. vmbus_signal_eom(msg, message_type);
  628. }
  629. mdelay(10);
  630. }
  631. /*
  632. * We're crashing and already got the UNLOAD_RESPONSE, cleanup all
  633. * maybe-pending messages on all CPUs to be able to receive new
  634. * messages after we reconnect.
  635. */
  636. for_each_online_cpu(cpu) {
  637. struct hv_per_cpu_context *hv_cpu
  638. = per_cpu_ptr(hv_context.cpu_context, cpu);
  639. page_addr = hv_cpu->synic_message_page;
  640. msg = (struct hv_message *)page_addr + VMBUS_MESSAGE_SINT;
  641. msg->header.message_type = HVMSG_NONE;
  642. }
  643. }
  644. /*
  645. * vmbus_unload_response - Handler for the unload response.
  646. */
  647. static void vmbus_unload_response(struct vmbus_channel_message_header *hdr)
  648. {
  649. /*
  650. * This is a global event; just wakeup the waiting thread.
  651. * Once we successfully unload, we can cleanup the monitor state.
  652. */
  653. complete(&vmbus_connection.unload_event);
  654. }
  655. void vmbus_initiate_unload(bool crash)
  656. {
  657. struct vmbus_channel_message_header hdr;
  658. /* Pre-Win2012R2 hosts don't support reconnect */
  659. if (vmbus_proto_version < VERSION_WIN8_1)
  660. return;
  661. init_completion(&vmbus_connection.unload_event);
  662. memset(&hdr, 0, sizeof(struct vmbus_channel_message_header));
  663. hdr.msgtype = CHANNELMSG_UNLOAD;
  664. vmbus_post_msg(&hdr, sizeof(struct vmbus_channel_message_header),
  665. !crash);
  666. /*
  667. * vmbus_initiate_unload() is also called on crash and the crash can be
  668. * happening in an interrupt context, where scheduling is impossible.
  669. */
  670. if (!crash)
  671. wait_for_completion(&vmbus_connection.unload_event);
  672. else
  673. vmbus_wait_for_unload();
  674. }
  675. /*
  676. * vmbus_onoffer - Handler for channel offers from vmbus in parent partition.
  677. *
  678. */
  679. static void vmbus_onoffer(struct vmbus_channel_message_header *hdr)
  680. {
  681. struct vmbus_channel_offer_channel *offer;
  682. struct vmbus_channel *newchannel;
  683. offer = (struct vmbus_channel_offer_channel *)hdr;
  684. trace_vmbus_onoffer(offer);
  685. /* Allocate the channel object and save this offer. */
  686. newchannel = alloc_channel();
  687. if (!newchannel) {
  688. vmbus_release_relid(offer->child_relid);
  689. atomic_dec(&vmbus_connection.offer_in_progress);
  690. pr_err("Unable to allocate channel object\n");
  691. return;
  692. }
  693. /*
  694. * Setup state for signalling the host.
  695. */
  696. newchannel->sig_event = VMBUS_EVENT_CONNECTION_ID;
  697. if (vmbus_proto_version != VERSION_WS2008) {
  698. newchannel->is_dedicated_interrupt =
  699. (offer->is_dedicated_interrupt != 0);
  700. newchannel->sig_event = offer->connection_id;
  701. }
  702. memcpy(&newchannel->offermsg, offer,
  703. sizeof(struct vmbus_channel_offer_channel));
  704. newchannel->monitor_grp = (u8)offer->monitorid / 32;
  705. newchannel->monitor_bit = (u8)offer->monitorid % 32;
  706. vmbus_process_offer(newchannel);
  707. }
  708. /*
  709. * vmbus_onoffer_rescind - Rescind offer handler.
  710. *
  711. * We queue a work item to process this offer synchronously
  712. */
  713. static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
  714. {
  715. struct vmbus_channel_rescind_offer *rescind;
  716. struct vmbus_channel *channel;
  717. struct device *dev;
  718. rescind = (struct vmbus_channel_rescind_offer *)hdr;
  719. trace_vmbus_onoffer_rescind(rescind);
  720. /*
  721. * The offer msg and the corresponding rescind msg
  722. * from the host are guranteed to be ordered -
  723. * offer comes in first and then the rescind.
  724. * Since we process these events in work elements,
  725. * and with preemption, we may end up processing
  726. * the events out of order. Given that we handle these
  727. * work elements on the same CPU, this is possible only
  728. * in the case of preemption. In any case wait here
  729. * until the offer processing has moved beyond the
  730. * point where the channel is discoverable.
  731. */
  732. while (atomic_read(&vmbus_connection.offer_in_progress) != 0) {
  733. /*
  734. * We wait here until any channel offer is currently
  735. * being processed.
  736. */
  737. msleep(1);
  738. }
  739. mutex_lock(&vmbus_connection.channel_mutex);
  740. channel = relid2channel(rescind->child_relid);
  741. mutex_unlock(&vmbus_connection.channel_mutex);
  742. if (channel == NULL) {
  743. /*
  744. * We failed in processing the offer message;
  745. * we would have cleaned up the relid in that
  746. * failure path.
  747. */
  748. return;
  749. }
  750. /*
  751. * Before setting channel->rescind in vmbus_rescind_cleanup(), we
  752. * should make sure the channel callback is not running any more.
  753. */
  754. vmbus_reset_channel_cb(channel);
  755. /*
  756. * Now wait for offer handling to complete.
  757. */
  758. vmbus_rescind_cleanup(channel);
  759. while (READ_ONCE(channel->probe_done) == false) {
  760. /*
  761. * We wait here until any channel offer is currently
  762. * being processed.
  763. */
  764. msleep(1);
  765. }
  766. /*
  767. * At this point, the rescind handling can proceed safely.
  768. */
  769. if (channel->device_obj) {
  770. if (channel->chn_rescind_callback) {
  771. channel->chn_rescind_callback(channel);
  772. return;
  773. }
  774. /*
  775. * We will have to unregister this device from the
  776. * driver core.
  777. */
  778. dev = get_device(&channel->device_obj->device);
  779. if (dev) {
  780. vmbus_device_unregister(channel->device_obj);
  781. put_device(dev);
  782. }
  783. }
  784. if (channel->primary_channel != NULL) {
  785. /*
  786. * Sub-channel is being rescinded. Following is the channel
  787. * close sequence when initiated from the driveri (refer to
  788. * vmbus_close() for details):
  789. * 1. Close all sub-channels first
  790. * 2. Then close the primary channel.
  791. */
  792. mutex_lock(&vmbus_connection.channel_mutex);
  793. if (channel->state == CHANNEL_OPEN_STATE) {
  794. /*
  795. * The channel is currently not open;
  796. * it is safe for us to cleanup the channel.
  797. */
  798. hv_process_channel_removal(rescind->child_relid);
  799. } else {
  800. complete(&channel->rescind_event);
  801. }
  802. mutex_unlock(&vmbus_connection.channel_mutex);
  803. }
  804. }
  805. void vmbus_hvsock_device_unregister(struct vmbus_channel *channel)
  806. {
  807. BUG_ON(!is_hvsock_channel(channel));
  808. /* We always get a rescind msg when a connection is closed. */
  809. while (!READ_ONCE(channel->probe_done) || !READ_ONCE(channel->rescind))
  810. msleep(1);
  811. vmbus_device_unregister(channel->device_obj);
  812. }
  813. EXPORT_SYMBOL_GPL(vmbus_hvsock_device_unregister);
  814. /*
  815. * vmbus_onoffers_delivered -
  816. * This is invoked when all offers have been delivered.
  817. *
  818. * Nothing to do here.
  819. */
  820. static void vmbus_onoffers_delivered(
  821. struct vmbus_channel_message_header *hdr)
  822. {
  823. }
  824. /*
  825. * vmbus_onopen_result - Open result handler.
  826. *
  827. * This is invoked when we received a response to our channel open request.
  828. * Find the matching request, copy the response and signal the requesting
  829. * thread.
  830. */
  831. static void vmbus_onopen_result(struct vmbus_channel_message_header *hdr)
  832. {
  833. struct vmbus_channel_open_result *result;
  834. struct vmbus_channel_msginfo *msginfo;
  835. struct vmbus_channel_message_header *requestheader;
  836. struct vmbus_channel_open_channel *openmsg;
  837. unsigned long flags;
  838. result = (struct vmbus_channel_open_result *)hdr;
  839. trace_vmbus_onopen_result(result);
  840. /*
  841. * Find the open msg, copy the result and signal/unblock the wait event
  842. */
  843. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  844. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  845. msglistentry) {
  846. requestheader =
  847. (struct vmbus_channel_message_header *)msginfo->msg;
  848. if (requestheader->msgtype == CHANNELMSG_OPENCHANNEL) {
  849. openmsg =
  850. (struct vmbus_channel_open_channel *)msginfo->msg;
  851. if (openmsg->child_relid == result->child_relid &&
  852. openmsg->openid == result->openid) {
  853. memcpy(&msginfo->response.open_result,
  854. result,
  855. sizeof(
  856. struct vmbus_channel_open_result));
  857. complete(&msginfo->waitevent);
  858. break;
  859. }
  860. }
  861. }
  862. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  863. }
  864. /*
  865. * vmbus_ongpadl_created - GPADL created handler.
  866. *
  867. * This is invoked when we received a response to our gpadl create request.
  868. * Find the matching request, copy the response and signal the requesting
  869. * thread.
  870. */
  871. static void vmbus_ongpadl_created(struct vmbus_channel_message_header *hdr)
  872. {
  873. struct vmbus_channel_gpadl_created *gpadlcreated;
  874. struct vmbus_channel_msginfo *msginfo;
  875. struct vmbus_channel_message_header *requestheader;
  876. struct vmbus_channel_gpadl_header *gpadlheader;
  877. unsigned long flags;
  878. gpadlcreated = (struct vmbus_channel_gpadl_created *)hdr;
  879. trace_vmbus_ongpadl_created(gpadlcreated);
  880. /*
  881. * Find the establish msg, copy the result and signal/unblock the wait
  882. * event
  883. */
  884. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  885. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  886. msglistentry) {
  887. requestheader =
  888. (struct vmbus_channel_message_header *)msginfo->msg;
  889. if (requestheader->msgtype == CHANNELMSG_GPADL_HEADER) {
  890. gpadlheader =
  891. (struct vmbus_channel_gpadl_header *)requestheader;
  892. if ((gpadlcreated->child_relid ==
  893. gpadlheader->child_relid) &&
  894. (gpadlcreated->gpadl == gpadlheader->gpadl)) {
  895. memcpy(&msginfo->response.gpadl_created,
  896. gpadlcreated,
  897. sizeof(
  898. struct vmbus_channel_gpadl_created));
  899. complete(&msginfo->waitevent);
  900. break;
  901. }
  902. }
  903. }
  904. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  905. }
  906. /*
  907. * vmbus_ongpadl_torndown - GPADL torndown handler.
  908. *
  909. * This is invoked when we received a response to our gpadl teardown request.
  910. * Find the matching request, copy the response and signal the requesting
  911. * thread.
  912. */
  913. static void vmbus_ongpadl_torndown(
  914. struct vmbus_channel_message_header *hdr)
  915. {
  916. struct vmbus_channel_gpadl_torndown *gpadl_torndown;
  917. struct vmbus_channel_msginfo *msginfo;
  918. struct vmbus_channel_message_header *requestheader;
  919. struct vmbus_channel_gpadl_teardown *gpadl_teardown;
  920. unsigned long flags;
  921. gpadl_torndown = (struct vmbus_channel_gpadl_torndown *)hdr;
  922. trace_vmbus_ongpadl_torndown(gpadl_torndown);
  923. /*
  924. * Find the open msg, copy the result and signal/unblock the wait event
  925. */
  926. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  927. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  928. msglistentry) {
  929. requestheader =
  930. (struct vmbus_channel_message_header *)msginfo->msg;
  931. if (requestheader->msgtype == CHANNELMSG_GPADL_TEARDOWN) {
  932. gpadl_teardown =
  933. (struct vmbus_channel_gpadl_teardown *)requestheader;
  934. if (gpadl_torndown->gpadl == gpadl_teardown->gpadl) {
  935. memcpy(&msginfo->response.gpadl_torndown,
  936. gpadl_torndown,
  937. sizeof(
  938. struct vmbus_channel_gpadl_torndown));
  939. complete(&msginfo->waitevent);
  940. break;
  941. }
  942. }
  943. }
  944. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  945. }
  946. /*
  947. * vmbus_onversion_response - Version response handler
  948. *
  949. * This is invoked when we received a response to our initiate contact request.
  950. * Find the matching request, copy the response and signal the requesting
  951. * thread.
  952. */
  953. static void vmbus_onversion_response(
  954. struct vmbus_channel_message_header *hdr)
  955. {
  956. struct vmbus_channel_msginfo *msginfo;
  957. struct vmbus_channel_message_header *requestheader;
  958. struct vmbus_channel_version_response *version_response;
  959. unsigned long flags;
  960. version_response = (struct vmbus_channel_version_response *)hdr;
  961. trace_vmbus_onversion_response(version_response);
  962. spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
  963. list_for_each_entry(msginfo, &vmbus_connection.chn_msg_list,
  964. msglistentry) {
  965. requestheader =
  966. (struct vmbus_channel_message_header *)msginfo->msg;
  967. if (requestheader->msgtype ==
  968. CHANNELMSG_INITIATE_CONTACT) {
  969. memcpy(&msginfo->response.version_response,
  970. version_response,
  971. sizeof(struct vmbus_channel_version_response));
  972. complete(&msginfo->waitevent);
  973. }
  974. }
  975. spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
  976. }
  977. /* Channel message dispatch table */
  978. const struct vmbus_channel_message_table_entry
  979. channel_message_table[CHANNELMSG_COUNT] = {
  980. { CHANNELMSG_INVALID, 0, NULL },
  981. { CHANNELMSG_OFFERCHANNEL, 0, vmbus_onoffer },
  982. { CHANNELMSG_RESCIND_CHANNELOFFER, 0, vmbus_onoffer_rescind },
  983. { CHANNELMSG_REQUESTOFFERS, 0, NULL },
  984. { CHANNELMSG_ALLOFFERS_DELIVERED, 1, vmbus_onoffers_delivered },
  985. { CHANNELMSG_OPENCHANNEL, 0, NULL },
  986. { CHANNELMSG_OPENCHANNEL_RESULT, 1, vmbus_onopen_result },
  987. { CHANNELMSG_CLOSECHANNEL, 0, NULL },
  988. { CHANNELMSG_GPADL_HEADER, 0, NULL },
  989. { CHANNELMSG_GPADL_BODY, 0, NULL },
  990. { CHANNELMSG_GPADL_CREATED, 1, vmbus_ongpadl_created },
  991. { CHANNELMSG_GPADL_TEARDOWN, 0, NULL },
  992. { CHANNELMSG_GPADL_TORNDOWN, 1, vmbus_ongpadl_torndown },
  993. { CHANNELMSG_RELID_RELEASED, 0, NULL },
  994. { CHANNELMSG_INITIATE_CONTACT, 0, NULL },
  995. { CHANNELMSG_VERSION_RESPONSE, 1, vmbus_onversion_response },
  996. { CHANNELMSG_UNLOAD, 0, NULL },
  997. { CHANNELMSG_UNLOAD_RESPONSE, 1, vmbus_unload_response },
  998. { CHANNELMSG_18, 0, NULL },
  999. { CHANNELMSG_19, 0, NULL },
  1000. { CHANNELMSG_20, 0, NULL },
  1001. { CHANNELMSG_TL_CONNECT_REQUEST, 0, NULL },
  1002. };
  1003. /*
  1004. * vmbus_onmessage - Handler for channel protocol messages.
  1005. *
  1006. * This is invoked in the vmbus worker thread context.
  1007. */
  1008. void vmbus_onmessage(void *context)
  1009. {
  1010. struct hv_message *msg = context;
  1011. struct vmbus_channel_message_header *hdr;
  1012. int size;
  1013. hdr = (struct vmbus_channel_message_header *)msg->u.payload;
  1014. size = msg->header.payload_size;
  1015. trace_vmbus_on_message(hdr);
  1016. if (hdr->msgtype >= CHANNELMSG_COUNT) {
  1017. pr_err("Received invalid channel message type %d size %d\n",
  1018. hdr->msgtype, size);
  1019. print_hex_dump_bytes("", DUMP_PREFIX_NONE,
  1020. (unsigned char *)msg->u.payload, size);
  1021. return;
  1022. }
  1023. if (channel_message_table[hdr->msgtype].message_handler)
  1024. channel_message_table[hdr->msgtype].message_handler(hdr);
  1025. else
  1026. pr_err("Unhandled channel message type %d\n", hdr->msgtype);
  1027. }
  1028. /*
  1029. * vmbus_request_offers - Send a request to get all our pending offers.
  1030. */
  1031. int vmbus_request_offers(void)
  1032. {
  1033. struct vmbus_channel_message_header *msg;
  1034. struct vmbus_channel_msginfo *msginfo;
  1035. int ret;
  1036. msginfo = kmalloc(sizeof(*msginfo) +
  1037. sizeof(struct vmbus_channel_message_header),
  1038. GFP_KERNEL);
  1039. if (!msginfo)
  1040. return -ENOMEM;
  1041. msg = (struct vmbus_channel_message_header *)msginfo->msg;
  1042. msg->msgtype = CHANNELMSG_REQUESTOFFERS;
  1043. ret = vmbus_post_msg(msg, sizeof(struct vmbus_channel_message_header),
  1044. true);
  1045. trace_vmbus_request_offers(ret);
  1046. if (ret != 0) {
  1047. pr_err("Unable to request offers - %d\n", ret);
  1048. goto cleanup;
  1049. }
  1050. cleanup:
  1051. kfree(msginfo);
  1052. return ret;
  1053. }
  1054. /*
  1055. * Retrieve the (sub) channel on which to send an outgoing request.
  1056. * When a primary channel has multiple sub-channels, we try to
  1057. * distribute the load equally amongst all available channels.
  1058. */
  1059. struct vmbus_channel *vmbus_get_outgoing_channel(struct vmbus_channel *primary)
  1060. {
  1061. struct list_head *cur, *tmp;
  1062. int cur_cpu;
  1063. struct vmbus_channel *cur_channel;
  1064. struct vmbus_channel *outgoing_channel = primary;
  1065. int next_channel;
  1066. int i = 1;
  1067. if (list_empty(&primary->sc_list))
  1068. return outgoing_channel;
  1069. next_channel = primary->next_oc++;
  1070. if (next_channel > (primary->num_sc)) {
  1071. primary->next_oc = 0;
  1072. return outgoing_channel;
  1073. }
  1074. cur_cpu = hv_cpu_number_to_vp_number(smp_processor_id());
  1075. list_for_each_safe(cur, tmp, &primary->sc_list) {
  1076. cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
  1077. if (cur_channel->state != CHANNEL_OPENED_STATE)
  1078. continue;
  1079. if (cur_channel->target_vp == cur_cpu)
  1080. return cur_channel;
  1081. if (i == next_channel)
  1082. return cur_channel;
  1083. i++;
  1084. }
  1085. return outgoing_channel;
  1086. }
  1087. EXPORT_SYMBOL_GPL(vmbus_get_outgoing_channel);
  1088. static void invoke_sc_cb(struct vmbus_channel *primary_channel)
  1089. {
  1090. struct list_head *cur, *tmp;
  1091. struct vmbus_channel *cur_channel;
  1092. if (primary_channel->sc_creation_callback == NULL)
  1093. return;
  1094. list_for_each_safe(cur, tmp, &primary_channel->sc_list) {
  1095. cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
  1096. primary_channel->sc_creation_callback(cur_channel);
  1097. }
  1098. }
  1099. void vmbus_set_sc_create_callback(struct vmbus_channel *primary_channel,
  1100. void (*sc_cr_cb)(struct vmbus_channel *new_sc))
  1101. {
  1102. primary_channel->sc_creation_callback = sc_cr_cb;
  1103. }
  1104. EXPORT_SYMBOL_GPL(vmbus_set_sc_create_callback);
  1105. bool vmbus_are_subchannels_present(struct vmbus_channel *primary)
  1106. {
  1107. bool ret;
  1108. ret = !list_empty(&primary->sc_list);
  1109. if (ret) {
  1110. /*
  1111. * Invoke the callback on sub-channel creation.
  1112. * This will present a uniform interface to the
  1113. * clients.
  1114. */
  1115. invoke_sc_cb(primary);
  1116. }
  1117. return ret;
  1118. }
  1119. EXPORT_SYMBOL_GPL(vmbus_are_subchannels_present);
  1120. void vmbus_set_chn_rescind_callback(struct vmbus_channel *channel,
  1121. void (*chn_rescind_cb)(struct vmbus_channel *))
  1122. {
  1123. channel->chn_rescind_callback = chn_rescind_cb;
  1124. }
  1125. EXPORT_SYMBOL_GPL(vmbus_set_chn_rescind_callback);