Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp359858pxk; Wed, 23 Sep 2020 05:21:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN/uOcSWUOPSGxqZR1pAITYy/et0HNspSZgsqzrlREWeG8xjk7pYyrYjCDXGJ61JltJm7D X-Received: by 2002:a17:906:6884:: with SMTP id n4mr10161206ejr.50.1600863665372; Wed, 23 Sep 2020 05:21:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600863665; cv=none; d=google.com; s=arc-20160816; b=DGYYHCDVKLFXds7qg5cogV3famwIiLGIqPd3NppxKwoPRd7UvPrl+vBmiROAHfu+XH UEsG2x0e9w3rBvB7Ufag+7z6lygLpBplIb5RSCqotX6lnXJsTo/9czJD14IXPtUWkJas 9RfzmZ5+29snFFI3klOn2L3GZj+lmL97y9fcGy1I/rdPdjCR/4fqqK21B5ok2pPw6UIj kB3P0EHqWvnYZyBL5/bnvSsg6hlFZ+1xB8+rNBK9bSYyopuz67bv0Uj/XI6E3g6kLiYY NFOotzaTM5fmJIn4h4Pdkphg4owV8bJeeLmH572Z7RzLg21lUfJ5MwLAr/B6y4RYvHwP hKdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=iM6DEYjVfGhf6Ba3td38B9+A6A9MEpV0/vPp+Igi9cE=; b=M5GcG0t1bR12Bk+mV82vOlUxCkuyLyotj6mWVzsOKE7p0ofbTszu9Vg34NT7vbTgQH SDP0PRoGOPnRkom8lxA8EBNAsllQ7Gd0gVnroCHf0wVVn3zRhLHLAGUO5sy4C7K7L7Nr FSIY/uyz35wLoX96ipVX17YTcbwK4kxJC+a0jyZ1LyBEZh5wO7e8e7Oof++vm1ESqJkd yRYWBm2ggonBG+6nNSzzB22yJhsCmx5aNVT0VqqWfXbmzKl1MHtsint3N0hwRgUxh29v c5qjOGarHrNSsD2yxPIi6i0czpBR7U0DG5jZF1C5OiYeWxbQyA4PZI1WxJjce0tpXo3f +s4A== ARC-Authentication-Results: i=1; mx.google.com; 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 mf3si12432847ejb.27.2020.09.23.05.20.41; Wed, 23 Sep 2020 05:21:05 -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; 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 S1726587AbgIWMTM (ORCPT + 99 others); Wed, 23 Sep 2020 08:19:12 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:57553 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgIWMTM (ORCPT ); Wed, 23 Sep 2020 08:19:12 -0400 Received: from mail-qk1-f171.google.com ([209.85.222.171]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPSA (Nemesis) id 1M42Ss-1kL3jp38CG-00073t; Wed, 23 Sep 2020 14:19:09 +0200 Received: by mail-qk1-f171.google.com with SMTP id 16so22527011qkf.4; Wed, 23 Sep 2020 05:19:09 -0700 (PDT) X-Gm-Message-State: AOAM532lY0TkymKkkfGsxfS4qTG1PdcKRfkG5QkUgpBHUq8ChOlGlXLc B6vjfPxlRSuU7XoOGfGR3qS6XK4xTdmFQNL4MEA= X-Received: by 2002:a37:a483:: with SMTP id n125mr9513561qke.286.1600863548470; Wed, 23 Sep 2020 05:19:08 -0700 (PDT) MIME-Version: 1.0 References: <20200922023151.387447-1-warthog618@gmail.com> <20200922023151.387447-5-warthog618@gmail.com> <20200923103031.GA579645@sol> In-Reply-To: From: Arnd Bergmann Date: Wed, 23 Sep 2020 14:18:53 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 04/20] gpio: uapi: define uAPI v2 To: Andy Shevchenko Cc: Kent Gibson , Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Bartosz Golaszewski , Linus Walleij Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:KbD3LuXs/BYv76mIwRu51/92ImObZCetcHiM9pdlE77vH2rIxR6 WqISgVkbB+YrZkdaXmVy04xPfz9w1LiUSwKRD+T7kCsa451KvM2gwqwYbfBArHkANwRD+BG Ea3QzX7o575LtWkIqDEEmXyv/INesS5WMV1UbKEJw4Fejo2SddChiV2ioOgwJkbvk2RPpbP 89+9j945JabixBucHgOmA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:x5PEMy+/OtI=:xEmdLQaDYoO9jmchcXcFGI lp2odA/uQiK3FVREIRNK2Gnw7PvCmxUTiQcg/hdqOD0oS+6GUqW7B4Wm6W0C+BxYbNUPufTkE JTs5+EzzxEBFm2aUptH1+XzJ+sD+O1VQwl6mqGmWkabztnHgsleY6T2hlLyyWI4hKQCXxNbbc FE+4cFz3I5N4OZGluJ75WJe7ST3Gj+7ROelfhM5RpA6CiXYeCzhwp1L1aSPzxKuCPwHw1YCww 79AWrqwle+W10djzz69QZIhTFTus1MahyTrl+5MdlQ1qJsNie/5PNtqD5Sd94w3YUJeeI9I0h g1oP+p1HKZfwpc4NSOG5ZQIUKT6d315EQL7LqN4hPN6ne7DI7wCeiiu7xDY9eXUQIFqYiqMDN lC5UKs+vHXAWjqT4toFEtt8ds7jSjQgShvisfcqt8MveSnNjH4EBdBYEyQacbbTKkTSMqk/jv 5bXzibO0baP72Di1tIv55gAH7FPUHhMevRfcUZZQP4ZezNNz3exBBC1vzss0gREkHffFxWWR/ 1CSk0VpJXRJu6XEiNBmG6L/7kqvKYbTPjtIxSCk3GOF7hdK8jtM93qz8dnn3rPdom9h8a+gFp qrPCbiANFLGJxuVuT/9H7Rjv8o0FRmkCXuQz8LF9UPFxDByvM3yYbidscVxNBcNE5AKtdE7Wr mOBE9uiu+nO0ANyJFdHjg7M5euFLEk1g4Vk97QppA3HNKpzGPtMDsBZS4Nf/DXTIXQ0o+r28l 5CDRi/Eg3AfEVPXDTX8zqSsCJe1hJA+YrYt2HMa8s4zoya29TNHLhLFnVke46sosnolbBIjk0 yXaAkp3lA8dN5hO4ZTFm+DjUIM5T6tPop9yIKTQ2e6ZBjhSuq6nhhzO0EdpDKK0RXVbG8bD Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 23, 2020 at 1:16 PM Andy Shevchenko wrote: > On Wed, Sep 23, 2020 at 1:30 PM Kent Gibson wrote: > > On Wed, Sep 23, 2020 at 01:04:05PM +0300, Andy Shevchenko wrote: > > > On Tue, Sep 22, 2020 at 5:34 AM Kent Gibson wrote: > > > > There is also some minor renaming of fields for consistency compared to > > > > their v1 counterparts, e.g. offset rather than lineoffset or line_offset, > > > > and consumer rather than consumer_label. > > > > > > > > Additionally, v1 GPIOHANDLES_MAX becomes GPIO_V2_LINES_MAX in v2 for > > > > clarity, and the gpiohandle_data __u8 array becomes a bitmap in > > > > gpio_v2_line_values. > > > > > > > > The v2 uAPI is mostly a reorganisation and extension of v1, so userspace > > > > code, particularly libgpiod, should readily port to it. > > > > > > ... > > > > > > > +struct gpio_v2_line_config { > > > > + __aligned_u64 flags; > > > > + __u32 num_attrs; > > > > > > > + /* Pad to fill implicit padding and reserve space for future use. */ > > > > + __u32 padding[5]; > > > > > > Probably I somehow missed the answer, but why do we need 5 here and not 1? > > > > > > > Sorry, I got tired of repeating myself, and just acked that we disagree > > on the approach here. > > > > Your suggestion to use the size for version would result in an > > explosion of ioctl signatures - every time we add a field we have to add > > a new ioctl and handle it separately in gpio_ioctl() or linereq_ioctl(). > > No, you just add > __u32 version; // implies sizeof() check as well. > > Look for examples of existing ABIs (e.g. perf ABI). Please don't ever add a version field to an ioctl structure, this has been shown to cause more problems than it solves many times in the past... Having some reserved fields can be helpful, as long as the kernel returns an error in case any of the unknown fields are nonzero. I'd also prefer fewer than five reserved fields, but that is not as important, just use as many as are likely to be used in the future, but not more: It's easy to add one more ioctl command in case the expectations are wrong, but I agree you wouldn't want a new command every time another field gets added if the past has shown that this happens a lot. Arnd