[PATCH 08/10] uio_hv_generic: check that host supports monitor page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In order for userspace application to signal host, it needs the
host to support the monitor page property. Check for the flag
and fail if this is not supported.

Signed-off-by: Stephen Hemminger <sthemmin@xxxxxxxxxxxxx>
---
 drivers/uio/uio_hv_generic.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/uio/uio_hv_generic.c b/drivers/uio/uio_hv_generic.c
index 18735731206e..b5fe0db844a7 100644
--- a/drivers/uio/uio_hv_generic.c
+++ b/drivers/uio/uio_hv_generic.c
@@ -158,6 +158,13 @@ hv_uio_probe(struct hv_device *dev,
 	if (ret)
 		goto fail;
 
+	/* Communicating with host has to be via shared memory not hypercall */
+	if (!dev->channel->offermsg.monitor_allocated) {
+		dev_err(&dev->device, "vmbus channel requires hypercall\n");
+		ret = -ENOTSUPP;
+		goto fail_close;
+	}
+
 	dev->channel->inbound.ring_buffer->interrupt_mask = 1;
 	set_channel_read_mode(dev->channel, HV_CALL_ISR);
 
@@ -192,13 +199,13 @@ hv_uio_probe(struct hv_device *dev,
 		pdata->recv_buf = vzalloc(buf_size);
 		if (pdata->recv_buf == NULL) {
 			ret = -ENOMEM;
-			goto fail_close;
+			goto fail_cleanup;
 		}
 
 		ret = vmbus_establish_gpadl(dev->channel, pdata->recv_buf,
 					    buf_size, &pdata->recv_gpadl);
 		if (ret)
-			goto fail_close;
+			goto fail_cleanup;
 
 		/* put Global Physical Address Label in name */
 		snprintf(pdata->recv_name, sizeof(pdata->recv_name),
@@ -215,13 +222,13 @@ hv_uio_probe(struct hv_device *dev,
 		pdata->send_buf = vzalloc(buf_size);
 		if (pdata->send_buf == NULL) {
 			ret = -ENOMEM;
-			goto fail_close;
+			goto fail_cleanup;
 		}
 
 		ret = vmbus_establish_gpadl(dev->channel, pdata->send_buf,
 					    buf_size, &pdata->send_gpadl);
 		if (ret)
-			goto fail_close;
+			goto fail_cleanup;
 
 		snprintf(pdata->send_name, sizeof(pdata->send_name),
 			 "send:%u", pdata->send_gpadl);
@@ -238,15 +245,16 @@ hv_uio_probe(struct hv_device *dev,
 	ret = uio_register_device(&dev->device, &pdata->info);
 	if (ret) {
 		dev_err(&dev->device, "hv_uio register failed\n");
-		goto fail_close;
+		goto fail_cleanup;
 	}
 
 	hv_set_drvdata(dev, pdata);
 
 	return 0;
 
-fail_close:
+fail_cleanup:
 	hv_uio_cleanup(dev, pdata);
+fail_close:
 	vmbus_close(dev->channel);
 fail:
 	kfree(pdata);
-- 
2.15.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux