From: Greg KH <gregkh@linuxfoundation.org>
To: "Chen, Mike Ximing" <mike.ximing.chen@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"arnd@arndb.de" <arnd@arndb.de>,
"Williams, Dan J" <dan.j.williams@intel.com>,
"pierre-louis.bossart@linux.intel.com"
<pierre-louis.bossart@linux.intel.com>
Subject: Re: [PATCH v8 04/20] dlb: add device ioctl layer and first three ioctls
Date: Sat, 9 Jan 2021 09:33:53 +0100 [thread overview]
Message-ID: <X/lqcaLVb+PbbmWg@kroah.com> (raw)
In-Reply-To: <SA2PR11MB5018670AEC81EA93598E1212D9AD0@SA2PR11MB5018.namprd11.prod.outlook.com>
On Sat, Jan 09, 2021 at 07:49:24AM +0000, Chen, Mike Ximing wrote:
> > > +static int dlb_ioctl_arg_size[NUM_DLB_CMD] = {
> > > + sizeof(struct dlb_get_device_version_args),
> > > + sizeof(struct dlb_create_sched_domain_args),
> > > + sizeof(struct dlb_get_num_resources_args)
> >
> > That list.
> >
> > Ugh, no. that's no way to write maintainable code that you will be able
> > to understand in 2 years.
> >
>
> dlb_ioctl() was implemented with switch-case and real function calls previously.
> We changed to the table/list implementation during a code restructure. I will move
> back to the old implementation.
Who said to change this? And why did they say that? Please go back to
those developers and point them at this thread so that doesn't happen
again...
> > > +{
> > > + struct dlb *dlb;
> > > + dlb_ioctl_fn_t fn;
> > > + u32 cmd_nr;
> > > + void *karg;
> > > + int size;
> > > + int ret;
> > > +
> > > + dlb = f->private_data;
> > > +
> > > + if (!dlb) {
> > > + pr_err("dlb: [%s()] Invalid DLB data\n", __func__);
> > > + return -EFAULT;
> >
> > This error value is only allowed if you really do have a memory fault.
> >
> > Hint, you do not here.
> >
> > How can that value ever be NULL?
> >
>
> It is targeted at some very rare cases, in which an ioctl command are called immediately after a device unbind (by a different process/application).
And how can that happen? If it really can happen, where is the lock
that you are holding to keep that pointer from becoming "stale" right
after you assign it?
So either this never can happen, or your logic here for this type of
thing is totally wrong. Please work to determine which it is.
> > > +#define DLB_DEVICE_VERSION(x) (((x) >> 8) & 0xFF)
> > > +#define DLB_DEVICE_REVISION(x) ((x) & 0xFF)
> > > +
> > > +enum dlb_revisions {
> > > + DLB_REV_A0 = 0,
> >
> > What is a "revision" and why do you care about it?
>
> This is for different revisions of hardware. Each revision of hardware may have a slight different configuration/feature.
So what does this mean? What are you going to do based on it?
> > > +/*
> > > + * DLB_CMD_GET_DEVICE_VERSION: Query the DLB device version.
> > > + *
> > > + * Each DLB device version has its own unique ioctl API, but all share
> > > + * this as the first command in their interface, which tells user-space
> > > + * which API to use. The device revision is provided in case of any
> > > + * hardware errata.
> > > + *
> > > + * Output parameters:
> > > + * - response.status: Detailed error code. In certain cases, such as if the
> > > + * ioctl request arg is invalid, the driver won't set status.
> > > + * - response.id[7:0]: Device revision.
> > > + * - response.id[15:8]: Device version.
> >
> > So userspace has to do different things depending on what the hardware
> > type is? Why not make a totally different driver for new hardware
> > types if things are going to change in the future?
> >
>
> This comment is not correct (sorry about this). There will be different
> versions of DLB hardware (of the same type). All DLB devices will have the same ioctl
> API and userspace interface.
Good, please fix then :)
thanks,
greg k-h
next prev parent reply other threads:[~2021-01-09 8:34 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-05 2:58 [PATCH v8 00/20] dlb: introduce DLB device driver Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 01/20] dlb: add skeleton for DLB driver Mike Ximing Chen
2021-01-07 19:35 ` Greg KH
2021-01-09 6:09 ` Chen, Mike Ximing
2021-01-05 2:58 ` [PATCH v8 02/20] dlb: initialize device Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 03/20] dlb: add resource and device initialization Mike Ximing Chen
2021-01-07 19:40 ` Greg KH
2021-01-10 17:22 ` Chen, Mike Ximing
2021-01-05 2:58 ` [PATCH v8 04/20] dlb: add device ioctl layer and first three ioctls Mike Ximing Chen
2021-01-07 19:41 ` Greg KH
2021-01-09 6:17 ` Chen, Mike Ximing
2021-01-07 19:41 ` Greg KH
2021-01-09 7:55 ` Chen, Mike Ximing
2021-01-07 19:50 ` Greg KH
2021-01-09 7:49 ` Chen, Mike Ximing
2021-01-09 8:33 ` Greg KH [this message]
2021-01-09 21:49 ` Dan Williams
2021-01-10 15:07 ` Greg KH
2021-01-12 21:03 ` Dan Williams
2021-01-13 9:57 ` Greg KH
2021-01-21 23:14 ` Dan Williams
2021-01-10 4:30 ` Chen, Mike Ximing
2021-01-05 2:58 ` [PATCH v8 05/20] dlb: add scheduling domain configuration Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 06/20] dlb: add domain software reset Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 07/20] dlb: add low-level register reset operations Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 08/20] dlb: add runtime power-management support Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 09/20] dlb: add queue create, reset, get-depth ioctls Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 10/20] dlb: add register operations for queue management Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 11/20] dlb: add ioctl to configure ports and query poll mode Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 12/20] dlb: add register operations for port management Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 13/20] dlb: add port mmap support Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 14/20] dlb: add start domain ioctl Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 15/20] dlb: add queue map, unmap, and pending unmap operations Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 16/20] dlb: add port map/unmap state machine Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 17/20] dlb: add static queue map register operations Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 18/20] dlb: add dynamic " Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 19/20] dlb: add queue unmap " Mike Ximing Chen
2021-01-05 2:58 ` [PATCH v8 20/20] dlb: queue map/unmap workqueue Mike Ximing Chen
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=X/lqcaLVb+PbbmWg@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.ximing.chen@intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
/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