Skip to contentSkip to conversation

Drivers: hv: vmbus: Miscellaneous fixes

PATCH In review [email protected] 4 participants 8 messages Nov 14, 2017 – Dec 11, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Drivers: hv: vmbus: Miscellaneous fixes

From: K. Y. Srinivasan <[email protected]>

Miscellaneous fixes.

Dexuan Cui (1):
vmbus: unregister device_obj->channels_kset

K. Y. Srinivasan (1):
Drivers: hv: vmbus: Fix a rescind issue

 drivers/hv/channel.c      |   10 ++++++++--
 drivers/hv/channel_mgmt.c |    7 ++++---
 drivers/hv/vmbus_drv.c    |    2 ++
 include/linux/hyperv.h    |    1 +
 4 files changed, 15 insertions(+), 5 deletions(-)
#7 lore raw

PATCH 2/2 Drivers: hv: vmbus: Fix a rescind issue

From: K. Y. Srinivasan <[email protected]>

The current rescind processing code will not correctly handle the case where the host immediately rescinds a channel that has been offerred. In this case, we could be blocked in the open call and since the channel is rescinded, the host will not respond and we could be blocked forever in the vmbus open call.i Fix this problem.

---
 drivers/hv/channel.c      |   10 ++++++++--
 drivers/hv/channel_mgmt.c |    7 ++++---
 include/linux/hyperv.h    |    1 +
 3 files changed, 13 insertions(+), 5 deletions(-)
drivers/hv/channel.c +8 -2
index 19f0cf3..ba0a092 100644
@@ -659,22 +659,28 @@ void vmbus_close(struct vmbus_channel *channel)
 		 */
 		return;
 	}
-	mutex_lock(&vmbus_connection.channel_mutex);
 	/*
 	 * Close all the sub-channels first and then close the
 	 * primary channel.
 	 */
 	list_for_each_safe(cur, tmp, &channel->sc_list) {
 		cur_channel = list_entry(cur, struct vmbus_channel, sc_list);
-		vmbus_close_internal(cur_channel);
 		if (cur_channel->rescind) {
+			wait_for_completion(&cur_channel->rescind_event);
+			mutex_lock(&vmbus_connection.channel_mutex);
+			vmbus_close_internal(cur_channel);
 			hv_process_channel_removal(
 					   cur_channel->offermsg.child_relid);
+		} else {
+			mutex_lock(&vmbus_connection.channel_mutex);
+			vmbus_close_internal(cur_channel);
 		}
+		mutex_unlock(&vmbus_connection.channel_mutex);
 	}
 	/*
 	 * Now close the primary.
 	 */
+	mutex_lock(&vmbus_connection.channel_mutex);
 	vmbus_close_internal(channel);
 	mutex_unlock(&vmbus_connection.channel_mutex);
 }
drivers/hv/channel_mgmt.c +4 -3
index ec5454f..c21020b 100644
@@ -333,6 +333,7 @@ bool vmbus_prep_negotiate_resp(struct icmsg_hdr *icmsghdrp,
 		return NULL;
 
 	spin_lock_init(&channel->lock);
+	init_completion(&channel->rescind_event);
 
 	INIT_LIST_HEAD(&channel->sc_list);
 	INIT_LIST_HEAD(&channel->percpu_list);
@@ -898,6 +899,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 	/*
 	 * Now wait for offer handling to complete.
 	 */
+	vmbus_rescind_cleanup(channel);
 	while (READ_ONCE(channel->probe_done) == false) {
 		/*
 		 * We wait here until any channel offer is currently
@@ -913,7 +915,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 	if (channel->device_obj) {
 		if (channel->chn_rescind_callback) {
 			channel->chn_rescind_callback(channel);
-			vmbus_rescind_cleanup(channel);
 			return;
 		}
 		/*
@@ -922,7 +923,6 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 		 */
 		dev = get_device(&channel->device_obj->device);
 		if (dev) {
-			vmbus_rescind_cleanup(channel);
 			vmbus_device_unregister(channel->device_obj);
 			put_device(dev);
 		}
@@ -936,13 +936,14 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr)
 		 * 2. Then close the primary channel.
 		 */
 		mutex_lock(&vmbus_connection.channel_mutex);
-		vmbus_rescind_cleanup(channel);
 		if (channel->state == CHANNEL_OPEN_STATE) {
 			/*
 			 * The channel is currently not open;
 			 * it is safe for us to cleanup the channel.
 			 */
 			hv_process_channel_removal(rescind->child_relid);
+		} else {
+			complete(&channel->rescind_event);
 		}
 		mutex_unlock(&vmbus_connection.channel_mutex);
 	}
include/linux/hyperv.h +1 -0
index f3e97c5..6c93366 100644
@@ -708,6 +708,7 @@ struct vmbus_channel {
 	u8 monitor_bit;
 
 	bool rescind; /* got rescind msg */
+	struct completion rescind_event;
 
 	u32 ringbuffer_gpadlhandle;
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/2 vmbus: unregister device_obj->channels_kset

In reply to [email protected]

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

---
 drivers/hv/vmbus_drv.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/hv/vmbus_drv.c +2 -0
index 6a86746..4f3faf5 100644
@@ -1378,6 +1378,8 @@ void vmbus_device_unregister(struct hv_device *device_obj)
 	pr_debug("child device %s unregistered\n",
 		dev_name(&device_obj->device));
 
+	kset_unregister(device_obj->channels_kset);
+
 	/*
 	 * Kick off the process of unregistering the device.
 	 * This will call vmbus_remove() and eventually vmbus_device_release()
Signature · 1 line
1.7.1
maintainer
#2 lore raw

Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 11 lines · On Tue, Nov 14, 2017 at 06:53:32AM -0700, [email protected] wrote:

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

Why is this marked for stable when the patch it "fixes" is in 4.15-rc1?

#3 lore raw

Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 9 lines · On Tue, 28 Nov 2017 16:56:05 +0100 Greg KH <[email protected]> wrote:
Quoted 8 lines · On Tue, Nov 14, 2017 at 06:53:32AM -0700, [email protected] wrote:

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

Quoted 5 lines
Quoted 3 lines

Why is this marked for stable when the patch it "fixes" is in 4.15-rc1?

It doesn't need to go to stable.

maintainer
#4 lore raw

RE: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 24 lines

From: devel [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, November 28, 2017 9:30 AM
To: Greg KH <[email protected]>
Cc: [email protected]; Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 1 line · On Tue, 28 Nov 2017 16:56:05 +0100 Greg KH <[email protected]> wrote:

On Tue, Nov 14, 2017 at 06:53:32AM -0700, [email protected]

Quoted 8 lines · wrote:
Quoted 8 lines

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Why is this marked for stable when the patch it "fixes" is in 4.15-rc1?

It doesn't need to go to stable.

Hi Greg,
May I know the status of the patch?

Thanks,
-- Dexuan

maintainer
#5 lore raw

Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 28 lines · Dexuan Cui
Quoted 28 lines

From: devel [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, November 28, 2017 9:30 AM
To: Greg KH <[email protected]>
Cc: [email protected]; Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 1 line · On Tue, 28 Nov 2017 16:56:05 +0100 Greg KH <[email protected]> wrote:

On Tue, Nov 14, 2017 at 06:53:32AM -0700, [email protected]

Quoted 12 lines · wrote:
Quoted 11 lines

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Why is this marked for stable when the patch it "fixes" is in 4.15-rc1?

It doesn't need to go to stable.

Hi Greg,
May I know the status of the patch?

It's still in my "to-apply" queue. As it's only a 4.15-final thing, don't worry, it will get there...

thanks,

greg k-h

maintainer
#6 lore raw

RE: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 48 lines

From: Greg KH [mailto:[email protected]]
Sent: Monday, December 11, 2017 12:59 PM
To: Dexuan Cui <[email protected]>
Cc: Stephen Hemminger <[email protected]>; [email protected]; Stephen Hemminger <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 6 lines · Dexuan Cui
Quoted 6 lines

From: devel [mailto:[email protected]] On Behalf Of Stephen Hemminger
Sent: Tuesday, November 28, 2017 9:30 AM
To: Greg KH <[email protected]>
Cc: [email protected]; Stephen Hemminger <[email protected]>; [email protected]; [email protected];

[email protected];

Quoted 9 lines
Quoted 9 lines

[email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/2] vmbus: unregister device_obj->channels_kset

Quoted 1 line · On Tue, 28 Nov 2017 16:56:05 +0100 Greg KH <[email protected]> wrote:

On Tue, Nov 14, 2017 at 06:53:32AM -0700,

[email protected]

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines · wrote:
Quoted 11 lines

From: Dexuan Cui <[email protected]>

Fixes c2e5df616e1a ("vmbus: add per-channel sysfs info")

Without the patch, a device can't be thoroughly destroyed, because vmbus_device_register() -> kset_create_and_add() still holds a reference to the hv_device's device.kobj.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Why is this marked for stable when the patch it "fixes" is in 4.15-rc1?

It doesn't need to go to stable.

Hi Greg,
May I know the status of the patch?

Quoted 6 lines

It's still in my "to-apply" queue. As it's only a 4.15-final thing, don't worry, it will get there...

thanks,

greg k-h

Thanks a lot, Greg!

-- Dexuan