From: gregkh <gregkh@linuxfoundation.org>
To: "Eads, Gage" <gage.eads@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>,
"Topel, Bjorn" <bjorn.topel@intel.com>
Subject: Re: [PATCH 04/20] dlb2: add device ioctl layer and first 4 ioctls
Date: Wed, 5 Aug 2020 17:17:50 +0200 [thread overview]
Message-ID: <20200805151750.GB2403607@kroah.com> (raw)
In-Reply-To: <SN6PR11MB2574EE40D3120F92F1BFEEAAF64B0@SN6PR11MB2574.namprd11.prod.outlook.com>
On Wed, Aug 05, 2020 at 03:07:50PM +0000, Eads, Gage wrote:
>
>
> > -----Original Message-----
> > From: gregkh <gregkh@linuxfoundation.org>
> > Sent: Wednesday, August 5, 2020 1:46 AM
> > To: Eads, Gage <gage.eads@intel.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>; linux-kernel@vger.kernel.org;
> > Karlsson, Magnus <magnus.karlsson@intel.com>; Topel, Bjorn
> > <bjorn.topel@intel.com>
> > Subject: Re: [PATCH 04/20] dlb2: add device ioctl layer and first 4 ioctls
> >
> > On Tue, Aug 04, 2020 at 10:20:47PM +0000, Eads, Gage wrote:
> > > > > +/* [7:0]: device revision, [15:8]: device version */
> > > > > +#define DLB2_SET_DEVICE_VERSION(ver, rev) (((ver) << 8) | (rev))
> > > > > +
> > > > > +static int dlb2_ioctl_get_device_version(struct dlb2_dev *dev,
> > > > > + unsigned long user_arg,
> > > > > + u16 size)
> > > > > +{
> > > > > + struct dlb2_get_device_version_args arg;
> > > > > + struct dlb2_cmd_response response;
> > > > > + int ret;
> > > > > +
> > > > > + dev_dbg(dev->dlb2_device, "Entering %s()\n", __func__);
> > > > > +
> > > > > + response.status = 0;
> > > > > + response.id = DLB2_SET_DEVICE_VERSION(2, DLB2_REV_A0);
> > > > > +
> > > > > + ret = dlb2_copy_from_user(dev, user_arg, size, &arg,
> > sizeof(arg));
> > > > > + if (ret)
> > > > > + return ret;
> > > > > +
> > > > > + ret = dlb2_copy_resp_to_user(dev, arg.response, &response);
> > > >
> > > > Better avoid any indirect pointers. As you always return a constant
> > > > here, I think the entire ioctl command can be removed until you
> > > > actually need it. If you have an ioctl command that needs both
> > > > input and output, use _IOWR() to define it and put all arguments
> > > > into the same structure.
> > >
> > > I should've caught this in my earlier response, sorry. The device version
> > > command is intentionally the first in the user interface enum. My
> > > goal is for all device versions (e.g. DLB 1.0 in the future) to be accessible
> > > through a /dev/dlb%d node. To allow this, all drivers would support the
> > same
> > > device-version command as command 0, then the subsequent commands
> > can be
> > > tailored to that particular device. User-space would query the version first
> > > to determine which set of ioctl commands it needs to use.
> > >
> > > So even though the response is constant (for now), it must occupy
> > command 0 for
> > > this design to work.
> >
> > "versions" for ioctls just do not work, please don't go down that path,
> > they should not be needed. See the many different discussions about
> > this topic on lkml for other subsystem submissions if you are curious.
> >
>
> This approach is based on VFIO's modular ioctl design, which has a different
> API for Type1 vs. SPAPR IOMMUs. Similarly a DLB driver could have a different
> API for each device version (but each API would be fixed, not versioned). I
> didn't see any concerns on lkml over VFIO when it was originally submitted -- though
> that was 8 years ago, perhaps the community's feelings have changed since then.
Fixed apis for device types is usually the better way to go. See the
review comments on the nitro_enclaves driver submission a few weeks ago
for the full details.
greg k-h
next prev parent reply other threads:[~2020-08-05 20:15 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 13:43 [PATCH 00/20] dlb2: introduce DLB 2.0 device driver Gage Eads
2020-07-12 13:43 ` [PATCH 01/20] dlb2: add skeleton for DLB 2.0 driver Gage Eads
2020-07-12 15:56 ` Greg KH
2020-07-17 18:19 ` Eads, Gage
2020-07-18 6:46 ` Greg KH
2020-07-12 15:58 ` Greg KH
2020-07-17 18:18 ` Eads, Gage
2020-07-18 6:46 ` Greg KH
2020-07-20 19:02 ` Eads, Gage
2020-07-20 19:19 ` Greg KH
2020-07-24 21:00 ` Eads, Gage
2020-07-12 13:43 ` [PATCH 02/20] dlb2: initialize PF device Gage Eads
2020-07-12 13:43 ` [PATCH 03/20] dlb2: add resource and device initialization Gage Eads
2020-07-12 13:43 ` [PATCH 04/20] dlb2: add device ioctl layer and first 4 ioctls Gage Eads
2020-07-12 14:42 ` Randy Dunlap
2020-07-17 18:20 ` Eads, Gage
2020-07-12 14:53 ` Randy Dunlap
2020-07-17 18:20 ` Eads, Gage
2020-07-12 15:28 ` Arnd Bergmann
2020-07-17 18:19 ` Eads, Gage
2020-07-17 18:56 ` Arnd Bergmann
2020-07-17 20:05 ` Eads, Gage
2020-07-18 6:48 ` gregkh
2020-08-04 22:20 ` Eads, Gage
2020-08-05 6:46 ` gregkh
2020-08-05 15:07 ` Eads, Gage
2020-08-05 15:17 ` gregkh [this message]
2020-08-05 15:39 ` Eads, Gage
2020-07-12 13:43 ` [PATCH 05/20] dlb2: add sched domain config and reset support Gage Eads
2020-07-12 13:43 ` [PATCH 06/20] dlb2: add ioctl to get sched domain fd Gage Eads
2020-07-12 13:43 ` [PATCH 07/20] dlb2: add runtime power-management support Gage Eads
2020-07-12 13:43 ` [PATCH 08/20] dlb2: add queue create and queue-depth-get ioctls Gage Eads
2020-07-12 13:43 ` [PATCH 09/20] dlb2: add ioctl to configure ports, query poll mode Gage Eads
2020-07-12 15:34 ` Arnd Bergmann
2020-07-17 18:19 ` Eads, Gage
2020-07-12 13:43 ` [PATCH 10/20] dlb2: add port mmap support Gage Eads
2020-07-12 13:43 ` [PATCH 11/20] dlb2: add start domain ioctl Gage Eads
2020-07-12 13:43 ` [PATCH 12/20] dlb2: add queue map and unmap ioctls Gage Eads
2020-07-12 13:43 ` [PATCH 13/20] dlb2: add port enable/disable ioctls Gage Eads
2020-07-12 13:43 ` [PATCH 14/20] dlb2: add CQ interrupt support Gage Eads
2020-07-12 13:43 ` [PATCH 15/20] dlb2: add domain alert support Gage Eads
2020-07-12 13:43 ` [PATCH 16/20] dlb2: add sequence-number management ioctls Gage Eads
2020-07-12 13:43 ` [PATCH 17/20] dlb2: add cos bandwidth get/set ioctls Gage Eads
2020-07-12 13:43 ` [PATCH 18/20] dlb2: add device FLR support Gage Eads
2020-07-12 13:43 ` [PATCH 19/20] dlb2: add basic PF sysfs interfaces Gage Eads
2020-07-12 13:43 ` [PATCH 20/20] dlb2: add ingress error handling Gage Eads
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=20200805151750.GB2403607@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arnd@arndb.de \
--cc=bjorn.topel@intel.com \
--cc=gage.eads@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=magnus.karlsson@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
all inboxes | Powered by JetHome®