Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp681006pxa; Tue, 11 Aug 2020 12:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Ky1vVm6RbE9lmOjsTK+0ZmQlw5fBrkuCkpeDR+MtjKGZghHQVK2R9sxxP6sIR0chCxyL X-Received: by 2002:a17:906:2749:: with SMTP id a9mr27647333ejd.28.1597173323916; Tue, 11 Aug 2020 12:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597173323; cv=none; d=google.com; s=arc-20160816; b=IMj312/LmJaJdL4SvH4ijKQCjaI9U80PUIcA2z55UGCLFnV1PlpU0H/EOBz4w90qnz y5dPE+scuqMdoOcNV7CoFMMB5P32HcFn5cxRrIOcUJlWmfvzy5hvuAdPMyHLVtoY1FBd KK/HN1JkgJxmjWkQ5JVClvqwoyZS6c4CI/fKnK0kJ4TE2C66TBrqSKbnI1MKmHEqOG50 +pyoVsiMuAwTugBFmcaFSi+sX8SVQ0ISKM15Xn934Hlkn9K3AxBCgd1kmE6gN94fodiM 48zfNtZaCQfQronbYFqCH1cVXX6VSEwfxdtigC7vYZAE9xn2MW58BeGV1S4+SBLRHx4x zvjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pLatoOn79pYJ/DuOSj6cLvAVzQZnxlbGJi91nLHmWxM=; b=UmPLdsIWbSG8O7ly5GUGKIe7NcdpzeZ4JMIztPpwbTk/KGN2j+1q3TBLNq2VBEzphq WlYG1sVJZ+rvzM0ZQ735ZgrZsRKDhsyqM7pQIoU4pwfFzfAyOdOCbeNShVuSDTD4uoAP GNgLqfLHztwSdjy1fxGlrchaG44RfXsYL8SHpw82L43hV8r3imWEFBf9amTzu2rDr0yx 5NeV7UpRO0aGjlsqlYcnmBczxLUpoUTZWHdJrZV6udP6M5QpFZr6iKNhQv6jGDB1KkzW rPzeT1atciNw6ivd4MwvsolIXpEjK/iCe9GgXVf7TEZJGdvPvKU3T0e+nf1UWd2UklaI AmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fbMx3780; 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 t4si13131491ejt.506.2020.08.11.12.15.00; Tue, 11 Aug 2020 12:15:23 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=fbMx3780; 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 S1726424AbgHKTLx (ORCPT + 99 others); Tue, 11 Aug 2020 15:11:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbgHKTLx (ORCPT ); Tue, 11 Aug 2020 15:11:53 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36051C06174A for ; Tue, 11 Aug 2020 12:11:53 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id j10so6513646qvo.13 for ; Tue, 11 Aug 2020 12:11:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pLatoOn79pYJ/DuOSj6cLvAVzQZnxlbGJi91nLHmWxM=; b=fbMx3780UeiwoaK7tuSdafEpSCzt2QSHEE1/+ByVUmkAE+hSHgf3oW7Kw9luwn/bGk u6kcshS5/siw0+AdKcgPIXz05yzhKR/moxZm+Z53BlEZKybm6wcvZZNOb8yoDcyApwBo XNuNqoGVhcajRdB5mIN1cspaFlnL2h2oBAjCV8LKG+CTr1z8rRWsdTo5Axty2xciXgdL 1rJKcrugyV9FCIxqVf9lrT+uHiWbkp32Y4S8zCNHg++NnG5yjflYqd+nOEpysOGYHfbD Xkb7J8MdsmMB8Ccr8Mjm86xw4hmVRa7R7vej56eNeTjX123T6UDvr6lzyhrAhMx1SYdk PFVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pLatoOn79pYJ/DuOSj6cLvAVzQZnxlbGJi91nLHmWxM=; b=gEE2D5Wk9cB33oP/DDiszVoegH3W17JMmWmbY0RKi1nChJ3MRKOJVReI+sgn7ZS3W8 QlBbBkYnYPPvlJd1EVqTvDQWypop+v6/C/IwBqjSlh2fWX5DlfsnMcaBvHgYgCuEdZzS QJO1SQODLYRkEnwDug7WADbDR9P1dGwdeT8G5idTmFNp7Kwi7ymM8cHUffmc/vOtEd1j JoKb0neUErZn9T4BbnVsXQR9VaYXNwHGbo/1LaTcfSVdLR4/KQFift5KTLWkDfuBvSSq GLz3EnuVPVk4v2+393ZIjWhf9tnGddI7MVIhiivzsyW0vGoPuEtqjXAPgCwkTBFbmK4j lwlA== X-Gm-Message-State: AOAM530OyUaprxBxnrocO+ZalSM5SDDSEdRIUA2uiW8urRx2PeiCd3yM TRiACZsCBZrVUEMhN6Bli6WCL0fYWLKCs/R+AXIepQ== X-Received: by 2002:a0c:ff06:: with SMTP id w6mr2973554qvt.61.1597173112408; Tue, 11 Aug 2020 12:11:52 -0700 (PDT) MIME-Version: 1.0 References: <20200809132529.264312-1-warthog618@gmail.com> <20200809132529.264312-3-warthog618@gmail.com> In-Reply-To: <20200809132529.264312-3-warthog618@gmail.com> From: Bartosz Golaszewski Date: Tue, 11 Aug 2020 21:11:41 +0200 Message-ID: Subject: Re: [PATCH v3 02/18] gpio: uapi: define uAPI v2 To: Kent Gibson , Andy Shevchenko Cc: LKML , linux-gpio , Linus Walleij Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 9, 2020 at 3:26 PM Kent Gibson wrote: > > Add a new version of the uAPI to address existing 32/64-bit alignment > issues, add support for debounce and event sequence numbers, allow > requested lines with different configurations, and provide some future > proofing by adding padding reserved for future use. > > The alignment issue relates to the gpioevent_data, which packs to different > sizes on 32-bit and 64-bit platforms. That creates problems for 32-bit apps > running on 64-bit kernels. uAPI v2 addresses that particular issue, and > the problem more generally, by adding pad fields that explicitly pad > structs out to 64-bit boundaries, so they will pack to the same size now, > and even if some of the reserved padding is used for __u64 fields in the > future. > > The new structs have been analysed with pahole to ensure that they > are sized as expected and contain no implicit padding. > > The lack of future proofing in v1 makes it impossible to, for example, > add the debounce feature that is included in v2. > The future proofing is addressed by providing configurable attributes in > line config and reserved padding in all structs for future features. > Specifically, the line request, config, info, info_changed and event > structs receive updated versions and new ioctls. > > As the majority of the structs and ioctls were being replaced, it is > opportune to rework some of the other aspects of the uAPI: > > v1 has three different flags fields, each with their own separate > bit definitions. In v2 that is collapsed to one - gpio_v2_line_flag. > > The handle and event requests are merged into a single request, the line > request, as the two requests were mostly the same other than the edge > detection provided by event requests. As a byproduct, the v2 uAPI allows > for multiple lines producing edge events on the same line handle. > This is a new capability as v1 only supports a single line in an event > request. > > As a consequence, there are now only two types of file handle to be > concerned with, the chip and the line, and it is clearer which ioctls > apply to which type of handle. > > 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. > > Signed-off-by: Kent Gibson > --- This now looks good for me. Just a small nit below. Andy: would you mind taking a look as well? > > +/* > + * Maximum number of requested lines. > + * > + * Must be no greater than 64 as bitmaps are limited to 64-bits, and a > + * multiple of 2 to ensure 32/64-bit alignment of structs. > + */ > +#define GPIO_V2_LINES_MAX 64 > + If we refer to bitmaps for which helpers are defined in include/linux/bitmap.h then they're not limited to 64-bits. I'd just say here that we want to fit into 64-bit integers for simplicity. [snip] Bartosz