Commit 56c642e2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull Hyper-V fixes from Sasha Levin:
 "Two fixes from Dexuan Cui:

   - Fix a (harmless) warning when building vmbus without
     CONFIG_PM_SLEEP

   - Fix for a memory leak (and optimization) in the hyperv mouse code"

* tag 'hyperv-fixes-signed' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
  Drivers: hv: vmbus: Fix harmless building warnings without CONFIG_PM_SLEEP
  HID: hyperv: Use in-place iterator API in the channel callback
parents b9918bdc 83b50f83
Loading
Loading
Loading
Loading
+10 −46
Original line number Diff line number Diff line
@@ -314,31 +314,10 @@ static void mousevsc_on_receive(struct hv_device *device,

static void mousevsc_on_channel_callback(void *context)
{
	const int packet_size = 0x100;
	int ret;
	struct hv_device *device = context;
	u32 bytes_recvd;
	u64 req_id;
	struct vmpacket_descriptor *desc;
	unsigned char	*buffer;
	int	bufferlen = packet_size;

	buffer = kmalloc(bufferlen, GFP_ATOMIC);
	if (!buffer)
		return;

	do {
		ret = vmbus_recvpacket_raw(device->channel, buffer,
					bufferlen, &bytes_recvd, &req_id);

		switch (ret) {
		case 0:
			if (bytes_recvd <= 0) {
				kfree(buffer);
				return;
			}
			desc = (struct vmpacket_descriptor *)buffer;

	foreach_vmbus_pkt(desc, device->channel) {
		switch (desc->type) {
		case VM_PKT_COMP:
			break;
@@ -348,26 +327,11 @@ static void mousevsc_on_channel_callback(void *context)
			break;

		default:
				pr_err("unhandled packet type %d, tid %llx len %d\n",
					desc->type, req_id, bytes_recvd);
			pr_err("Unhandled packet type %d, tid %llx len %d\n",
			       desc->type, desc->trans_id, desc->len8 * 8);
			break;
		}

			break;

		case -ENOBUFS:
			kfree(buffer);
			/* Handle large packet */
			bufferlen = bytes_recvd;
			buffer = kmalloc(bytes_recvd, GFP_ATOMIC);

			if (!buffer)
				return;

			break;
	}
	} while (1);

}

static int mousevsc_connect_to_vsp(struct hv_device *device)
+6 −0
Original line number Diff line number Diff line
@@ -912,6 +912,7 @@ static void vmbus_shutdown(struct device *child_device)
		drv->shutdown(dev);
}

#ifdef CONFIG_PM_SLEEP
/*
 * vmbus_suspend - Suspend a vmbus device
 */
@@ -949,6 +950,7 @@ static int vmbus_resume(struct device *child_device)

	return drv->resume(dev);
}
#endif /* CONFIG_PM_SLEEP */

/*
 * vmbus_device_release - Final callback release of the vmbus child device
@@ -1070,6 +1072,7 @@ msg_handled:
	vmbus_signal_eom(msg, message_type);
}

#ifdef CONFIG_PM_SLEEP
/*
 * Fake RESCIND_CHANNEL messages to clean up hv_sock channels by force for
 * hibernation, because hv_sock connections can not persist across hibernation.
@@ -1105,6 +1108,7 @@ static void vmbus_force_channel_rescinded(struct vmbus_channel *channel)
		      vmbus_connection.work_queue,
		      &ctx->work);
}
#endif /* CONFIG_PM_SLEEP */

/*
 * Direct callback for channels using other deferred processing
@@ -2125,6 +2129,7 @@ acpi_walk_err:
	return ret_val;
}

#ifdef CONFIG_PM_SLEEP
static int vmbus_bus_suspend(struct device *dev)
{
	struct vmbus_channel *channel, *sc;
@@ -2247,6 +2252,7 @@ static int vmbus_bus_resume(struct device *dev)

	return 0;
}
#endif /* CONFIG_PM_SLEEP */

static const struct acpi_device_id vmbus_acpi_device_ids[] = {
	{"VMBUS", 0},