Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1438585ybs; Mon, 25 May 2020 16:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOPdsXvdqEkr/Dr38ImQN8NYEToiravCH5o7HlkoLkpvLQRpmipj2dWyCP4LHtO4VGIcoV X-Received: by 2002:a17:906:660f:: with SMTP id b15mr19756058ejp.113.1590449244653; Mon, 25 May 2020 16:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590449244; cv=none; d=google.com; s=arc-20160816; b=aX859kif9tJECwFKm3JgBfvGeOJs5r4GwXmdef4j2uWevOTg6Ne+RLDWz6wp8MMp62 m+gtbqsLfAWS1g59d/fBiEHE8CPGobwBS+Fu0O+JxOFyuLEVYCND7cbKzNQe9X7awE/n qZS3t04vP2PruchCzKb8C7+xGhhNxcMyuvL/KKMS53/OcwKeyQcUG6GFbnGkDXu9E/On vff7sncG5hL73TFY0x1O6nzQCxkY3uhfoBHEMdCoUhXIKx2ozNtlIEM9Yb5kPWAX6oGt wn5uvYX3rfaOBZAdUM/SfU5PZf8EYG4nvIEyYoPfy77GtuUrxDVyU1/371Op8buS0okU VTVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KS0a12ZGAlis5FGjzq3oVpbX/YM5oeodYRXZXqWm+i8=; b=zBvaWRpPH5U/AJJSMY/OvxCRSZc8Bc+o52tInmxY8UippaWnnU99usN5Vqt3r4V9G0 5E4HnenkuSlwsuJZQPV41UJsrcjpG1OcSTszRsBv9LPZ1HbtzxmuVXYhtyoPKCrRBKWZ 61zW+kxwrc/T4iq5efcTMz2qajIU0+DF6zKPCxII5q+6K0Uf2QbkhJnx7J3kb8evEa23 GPRZwNNbtp0euKN6vBe8DVTdNWlukTjaLm2mvKt9D7RPKE5YCnvgH0LeBfelugsLL3pF VNRPor0xWIcHwoZy9/0IsFcqPGmZN/Rs8GnDc0PmbTn0rp5pSnNSb0belUX5rZKPW7va QM5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=RlvVOG4o; 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 j14si10807001ejy.206.2020.05.25.16.27.01; Mon, 25 May 2020 16:27:24 -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=RlvVOG4o; 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 S1731437AbgEYQYR (ORCPT + 99 others); Mon, 25 May 2020 12:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729338AbgEYQYR (ORCPT ); Mon, 25 May 2020 12:24:17 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA5EC061A0E for ; Mon, 25 May 2020 09:24:15 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id x12so14066661qts.9 for ; Mon, 25 May 2020 09:24:15 -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:content-transfer-encoding; bh=KS0a12ZGAlis5FGjzq3oVpbX/YM5oeodYRXZXqWm+i8=; b=RlvVOG4oquelW/QHisprTnJ5+AE3nog67eWlbiiRX9LiPSKxC/6WMrf4vBwM2ErSEA uGKS5APVknW5P/Eg7MNjU54ZkvnfNQuwclevWvDHkRjNzv894NaIgXAMlbKgPzA71l3c a6MuKd+gpTBCLRNLEkltvuJ1CT4jW5xM6g88pj36tRDQ4X2CsVs1yTVdtZ2XkFiq5WwK 42M8ef7/aC02RxBECMt7j8ZDHCGmqRgSgOauDfgM3qr76a9cdAsOwTb/o2x8+ePIvCHd FAgs3MxfFbcrL5J3KwW7D3Xk2eBr1ydZzVVYI0K5LhnslAgzFRhFJTuy/gV+xQPG1Ib6 zCsA== 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:content-transfer-encoding; bh=KS0a12ZGAlis5FGjzq3oVpbX/YM5oeodYRXZXqWm+i8=; b=HTrBuA2Hs4rwm2Kme2RMi1uoCLjfV5RNmtIA40whDXID6GxSmDsIj3OuJqcV9Td/yA pUxq4OVDRmllqyR9ta6YxlhDxDtKENVTEcQ4grlyhsWocGuYGxnY2gXGvOTa/3N8fV1I gAy3xJGAnqifX9ZlyQJv4O89ahM8hbdXz4zVWkXaaswVHc229VvnzbiCHdoNkfz2y9mI am6vMwsODAaYQjRb2HGJ3wudIwOJbq+cugeM4B+isnOPMLg9wGgRv7r94GwPBfIAg+iL 1ryjBQV+S5QQWCoPLj40UTO7bha7ylyf7yPm2Xh68TxX2OhIHmuVCFz7aqBfkMRvWUoX MpPA== X-Gm-Message-State: AOAM530mAsnxA5emoAGm9wijaJY2bZtzq7nejYQnSYiPgZ1raY+24MTm S3l7OA1a9vaJW00qwT86IrQ6i0fx/a/FXubU+K3LRQ== X-Received: by 2002:ac8:2242:: with SMTP id p2mr19187641qtp.27.1590423855112; Mon, 25 May 2020 09:24:15 -0700 (PDT) MIME-Version: 1.0 References: <20200516064507.19058-1-warthog618@gmail.com> In-Reply-To: <20200516064507.19058-1-warthog618@gmail.com> From: Bartosz Golaszewski Date: Mon, 25 May 2020 18:24:04 +0200 Message-ID: Subject: Re: [RFC PATCH] gpio: uapi: v2 proposal To: Kent Gibson Cc: LKML , linux-gpio , Linus Walleij Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sob., 16 maj 2020 o 08:45 Kent Gibson napisa=C5=82(a= ): > > Add a new version of the uAPI to address existing 32/64bit alignment > issues, add support for debounce, and provide some future proofing by > adding padding reserved for future use. > > Signed-off-by: Kent Gibson > > --- > > This patch is a proposal to replace the majority of the uAPI, so some > background and justification is in order. > > The alignment issue relates to the gpioevent_data, which packs to differe= nt > sizes on 32bit and 64bit platforms. That creates problems for 32bit apps > running on 64bit kernels. The patch addresses that particular issue, and > the problem more generally, by adding pad fields that explicitly pad > structs out to 64bit 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 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 reserved padding in all > structs for future features. Specifically, the line request, > config and info structs get updated versions and ioctls. > > I haven't added any padding to gpiochip_info, as I haven't seen any calls > for new features for the corresponding ioctl, but I'm open to updating th= at > as well. > > As the majority of the structs and ioctls were being replaced, it seemed > opportune to rework some of the other aspects of the uAPI. > > Firstly, I've reworked the flags field throughout. v1 has three differen= t > flags fields, each with their own separate bit definitions. In v2 that i= s > collapsed to one. Further, the bits of the v2 flags field are used > as feature enable flags, with any other necessary configuration fields en= coded > separately. This is simpler and clearer, while also providing a foundati= on > for adding features in the future. > > I've also merged the handle and event requests into a single request, the > line request, as the two requests where 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 re= quest. > > This means there are now only two types of file handle to be concerned wi= th, > 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 t= heir > v1 counterparts, e.g. offset rather than lineoffset or line_offset, and > consumer rather than consumer_label. > > And v1 GPIOHANDLES_MAX and gpiohandle_data become GPIOLINES_MAX and > gpioline_values for v2 - the only change being the renaming for clarity. > > The v2 uAPI is mostly just a reorganisation of v1, so userspace code, > particularly libgpiod, should easily port to it. > > This patch is obviously only one patch in a much bigger series that > will actually implement it, but I would appreciate a review and any feedb= ack, > as it is foundational to the rest of that series. > > Thanks, > Kent. > Hi Kent, Thanks for posting this. I like the general direction a lot. I'll review this in detail later this week. Seeing the speed at which you make progress I think I won't be implementing support for the v1 of the watch ioctl() in libgpiod after all. Once the v2 is live I will probably bump the API version in libgpiod to v2.0.0 and make some non-compatible changes anyway. Bart