Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp807278pxa; Wed, 5 Aug 2020 13:16:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGhS7iPKIPbJ3oh9/rLuUgiwWodiTpiW2fbRrXHVMaKfLrXo5Vhzm7HahS1tqNMAfoycbU X-Received: by 2002:a17:907:36b:: with SMTP id rs11mr1051169ejb.544.1596658561854; Wed, 05 Aug 2020 13:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596658561; cv=none; d=google.com; s=arc-20160816; b=LyFqiUcqjj8yYT7IZ+BWaG28atytFlbcUdrUhG2cxgDuSKWLH9ALrEt2GtB6cExPP7 DcB6/pE7HdASVXc8G1G95TdH4qHlnoxLVSo9ZAa88Yn2O3DktoQhHv7Ua9wlQwvtkdtw 8nGk5jUPDhjQKL7xerH0oLEhehHyUMgeFFeYFYxCg5xTcDxqBzYMxxf0vl1qUkENRsZG 0FJ7vpoMjHJvE7WnFlOy0qYDk9p2uVRcBSknX54H8EU1c4sbSNeqWCQI1lGuZr1uP353 Id+tKwsjEoBigCfA3uOScps3mr5bs8FlTPLJSkf+mjndECdbjDTVP9Bm1i01IZD2mOyR bxvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=t4liwyRwt8e4DIscbHWZxWaJ6VG4otdmSEtDutyffwc=; b=YE6sztOHwQHn9cBkTpxO/E0ckBMioVHCiLbUN4c18+0gwLHQ6S5A6SxXYEb6LmIcBp TKqsF2vmFup0JreTySf92uF4NaveFjwADOnAU3GrAaMPjkpZrDyS9Po+Yd48hf0JmA9B 0toYIZGKNxsRwvvnbBPzmY9HtmSlvZFdRSYlayuy9YgReSxCaj62wZs7s8CNsNPbwHOK R4nJescPhecvvJt8H/skyNgB2AwHWSP1QdP2E4OzAM3Z9ewm4aag582ZqKrb251Glw3s bkJwcV33K0YLb/I1vruSPZXZbgTUHx2gCbPWO6zJiRZNQvTwiKGB4lH2VwFgNMAz4IqY p2Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BLrph8iP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si1913758edr.231.2020.08.05.13.15.39; Wed, 05 Aug 2020 13:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BLrph8iP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbgHEUPg (ORCPT + 99 others); Wed, 5 Aug 2020 16:15:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:48132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726490AbgHEQUR (ORCPT ); Wed, 5 Aug 2020 12:20:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BCD5206B6; Wed, 5 Aug 2020 15:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596640653; bh=gBmY82YJchlC5eNJ+4SoP6WaPlkBBETLWW2SZmQNfJs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BLrph8iPoGj6bvjObc8NNwkLm5v3s4RbLkhEZ5CiXq8rFbP1BrNHK0N41jM118DvI TyTRSBwmehDb8aQZwh1n97tVH8Yk2MhhvqwYkZ3lk8UTbzwA/31QEoAl4IjOZQpCBs MFv1a5+jxYiasNVEcbSw9OFjapiq72wVXDb+pbcw= Date: Wed, 5 Aug 2020 17:17:50 +0200 From: gregkh To: "Eads, Gage" Cc: Arnd Bergmann , "linux-kernel@vger.kernel.org" , "Karlsson, Magnus" , "Topel, Bjorn" Subject: Re: [PATCH 04/20] dlb2: add device ioctl layer and first 4 ioctls Message-ID: <20200805151750.GB2403607@kroah.com> References: <20200712134331.8169-1-gage.eads@intel.com> <20200712134331.8169-5-gage.eads@intel.com> <20200805064622.GA608152@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 05, 2020 at 03:07:50PM +0000, Eads, Gage wrote: > > > > -----Original Message----- > > From: gregkh > > Sent: Wednesday, August 5, 2020 1:46 AM > > To: Eads, Gage > > Cc: Arnd Bergmann ; linux-kernel@vger.kernel.org; > > Karlsson, Magnus ; Topel, Bjorn > > > > 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