From: Greg KH <gregkh@linuxfoundation.org>
To: Saurabh Sengar <ssengar@linux.microsoft.com>
Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, mikelley@microsoft.com,
linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org
Subject: Re: [PATCH 1/5] uio: Add hv_vmbus_client driver
Date: Sun, 4 Jun 2023 09:09:57 +0200 [thread overview]
Message-ID: <2023060421-unclothed-hungry-cb3e@gregkh> (raw)
In-Reply-To: <1685692629-31351-2-git-send-email-ssengar@linux.microsoft.com>
On Fri, Jun 02, 2023 at 12:57:05AM -0700, Saurabh Sengar wrote:
> + * Since the driver does not declare any device ids, you must allocate
> + * id and bind the device to the driver yourself. For example:
> + * driverctl -b vmbus set-override <dev uuid> uio_hv_vmbus_client
Shouldn't this be documented somewhere?
> + */
> +
> +#include <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/uio_driver.h>
> +#include <linux/hyperv.h>
> +#include <linux/vmalloc.h>
> +#include <linux/sysfs.h>
> +
> +#define DRIVER_VERSION "0.0.1"
Why this number? Why not "1"?
The whole "driver version" thing doesn't really make sense here, we
should just drop it from the uio later, right?
> +#define DRIVER_AUTHOR "Saurabh Sengar <ssengar@microsoft.com>"
> +#define DRIVER_DESC "Generic UIO driver for low speed VMBus devices"
> +
> +#define DEFAULT_HV_RING_SIZE VMBUS_RING_SIZE(3 * HV_HYP_PAGE_SIZE)
> +static int ring_size = DEFAULT_HV_RING_SIZE;
> +
> +struct uio_hv_vmbus_dev {
> + struct uio_info info;
> + struct hv_device *device;
> + atomic_t refcnt;
Why is this refcnt needed?
Have you seen the other threads about how attempting to block multiple
opens in UIO drivers really does not work at all? Please drop all of
that logic, it is not correct.
> +static ssize_t ring_size_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + return scnprintf(buf, PAGE_SIZE, "%d\n", ring_size);
Did you use checkpatch?
It should have said to use sysfs_emit(), right?
> + ret = sysfs_create_file(&dev->device.kobj, &dev_attr_ring_size.attr);
If you ever have to use a sysfs_* call in a driver, that's a huge hint
something is wrong. Please fix this to not race with userspace and
loose.
> + if (ret)
> + dev_notice(&dev->device, "sysfs create ring size file failed; %d\n", ret);
Why not just use dev_err() for this and other errors? Why "notice"?
> +MODULE_VERSION(DRIVER_VERSION);
This means nothing, please drop.
thanks,
greg k-h
next prev parent reply other threads:[~2023-06-04 7:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 7:57 [PATCH 0/5] UIO driver for low speed Hyper-V devices Saurabh Sengar
2023-06-02 7:57 ` [PATCH 1/5] uio: Add hv_vmbus_client driver Saurabh Sengar
2023-06-04 2:05 ` kernel test robot
2023-06-04 7:09 ` Greg KH [this message]
2023-06-05 3:00 ` [EXTERNAL] " Saurabh Singh Sengar
2023-06-02 7:57 ` [PATCH 2/5] tools: hv: Add vmbus_bufring Saurabh Sengar
2023-06-02 7:57 ` [PATCH 3/5] tools: hv: Add new fcopy application based on uio driver Saurabh Sengar
2023-06-02 7:57 ` [PATCH 4/5] tools: hv: Remove hv_fcopy_daemon Saurabh Sengar
2023-06-02 7:57 ` [PATCH 5/5] Drivers: hv: Remove fcopy driver Saurabh Sengar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2023060421-unclothed-hungry-cb3e@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=ssengar@linux.microsoft.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).