Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3069982ybl; Fri, 20 Dec 2019 03:27:15 -0800 (PST) X-Google-Smtp-Source: APXvYqzgg8uN57CWUU9XtixV3kLNpKmrM3Qiv7VN0n9gAGoHJ8kN4pdbXgOZdqAuXmfnKxGqbF6X X-Received: by 2002:a9d:3425:: with SMTP id v34mr13820705otb.142.1576841235021; Fri, 20 Dec 2019 03:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576841235; cv=none; d=google.com; s=arc-20160816; b=o1GR2Ru++Vjgp5P5VZ2no250/249H5wdzVXQ7YqC7xln1JdkXD7GJDAl26Bhc3Cwak esFgLHICCdLjMPDex/RRzCB/0vQCNxAVRcgUfSczmbyN+syoHHZ3LVKtWp4weYi1h7xq WzyLDaSeAYpc6KLXWqLZQtc0u4LGZxHs+rLBIrLQSiQisvF2ZU6umvAO7B7vnFgKiK56 geKBHuxQ/bci3qXuRjGs6kepraLD4R6rZFenV5sKpEhS6wDTGvasGDvsMc7wP1xDPUlk FXShBZdjNku34FSnVi0Wg20Ttgg/R/5tnGQ5w4+b33jhhs+q2kXczxvbEuBdchqAQgLS hzSg== 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=k8kYT/giIfGkzEyDaTLw5uWSWD/PKdfRcdySeHBbOIc=; b=VHqTatpX8hbtWup+WLu1kxRz8JHdU/EgOupzy7wMmr2S9Kq+RcetYvdQdTGlAeOyDk JHRI8BBJMiw7aRiULiENS9v13d0Jpr3I3dVigipLLq6ExEpoWmfxg5qXxtZbYNMSm0Ij E5SsEXdCr4WgllAFP7ECvpZM8w8h/xGNp4DYZf+UW96F9MiLXNn1YI4p1uXWapvMmCaS Zmr5ANj2ufI1YXlEfYWKhdqfFYmj6HZTWPaWijp96w/jjTkIp9VzJ634QGO7GtFlMUHR W24U6pn2z7UDAPePbCu0w8VHMXgt6ibsBLhRwIuaVH5y7YpradA2/ySq0FMye8SwmeKU zo6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0X653SLf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si2102147otn.220.2019.12.20.03.27.02; Fri, 20 Dec 2019 03:27:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0X653SLf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfLTL0L (ORCPT + 99 others); Fri, 20 Dec 2019 06:26:11 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:33797 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbfLTL0L (ORCPT ); Fri, 20 Dec 2019 06:26:11 -0500 Received: by mail-qk1-f196.google.com with SMTP id j9so7709513qkk.1 for ; Fri, 20 Dec 2019 03:26:10 -0800 (PST) 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=k8kYT/giIfGkzEyDaTLw5uWSWD/PKdfRcdySeHBbOIc=; b=0X653SLfZNSEO/Z0hHuv1zWsbliVSJtZtWdOa+Ry7XnYv7DIc2ZmpunTfkv0OUH1tN 7PGiHeNQqkzBha5MSgH9+CocziAqShdM8hEUIDqvaN9dqUOl+qV4DxxXxNkEYsmPVWFf pXyj5qP6i1t2JDQkRKPevT76mlTYWmF5vRd7mTPMnbqLHA2umw+jO1kyk4Ti5LeFdx90 Bz/AV+xllb4m7jIefbgvzcCRg6EDthPUsYP6j/9+qWD2MwYKi0wScSRVKBwSbM0sMsEY GWRklvcHAFfZ9BuIMEHGxBvut6Yb3XiX2eMnyYIgqr7+qsURt8NEkRaRzEIVY053unM/ 5J+A== 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=k8kYT/giIfGkzEyDaTLw5uWSWD/PKdfRcdySeHBbOIc=; b=WJCA/IzqmAKjM8iNXzDcx7uEnHlFb5/9i/JubcmTv9Q3dwC/8+tNy/tOZperyS8bqn 82/OOyW+yuI5gRxvzL6CxNJHMwhKaWMxOmHgCr/OOIyhXmNWXx0fPfuXhlfQKdb60ekU eQXSxIa6+aNIY45VJ+b9AfemE6hWEA2zXc4BmYGHy3Cp+vdInDm5Fn7izUzzdvYn2eKb enQYRIyxXir3oczzhGOkR1j4qusA40Z7OO/XUI3h+HTKw+Z4LqOiaT0wGu1BjpBni39N 9M+DEe3lqjllSkUqcjOSOM0iIwyKKjWm3WAX/3JByyqGimw9MYfMX1/ya/Z+sHtSUqUF HLbw== X-Gm-Message-State: APjAAAUgUpRd0B0PLUCvSY4gWyK0LRpoeLtGyreviFU2oZZi4TKMnEAh h9BTAOqSrEHpZ6NOi5Yg/el7ctR4SY/sJ6cuphckPA== X-Received: by 2002:a37:744:: with SMTP id 65mr12553936qkh.323.1576841170045; Fri, 20 Dec 2019 03:26:10 -0800 (PST) MIME-Version: 1.0 References: <20191219171528.6348-1-brgl@bgdev.pl> <20191219171528.6348-13-brgl@bgdev.pl> In-Reply-To: From: Bartosz Golaszewski Date: Fri, 20 Dec 2019 12:25:59 +0100 Message-ID: Subject: Re: [PATCH v3 12/13] gpiolib: add new ioctl() for monitoring changes in line info To: Andy Shevchenko Cc: Bartosz Golaszewski , Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List 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 czw., 19 gru 2019 o 19:17 Andy Shevchenko napisa=C5=82(a): > > On Thu, Dec 19, 2019 at 7:17 PM Bartosz Golaszewski wrote= : > > > > From: Bartosz Golaszewski > > > > Currently there is no way for user-space to be informed about changes > > in status of GPIO lines e.g. when someone else requests the line or its > > config changes. We can only periodically re-read the line-info. This > > is fine for simple one-off user-space tools, but any daemon that provid= es > > a centralized access to GPIO chips would benefit hugely from an event > > driven line info synchronization. > > > > This patch adds a new ioctl() that allows user-space processes to reuse > > the file descriptor associated with the character device for watching > > any changes in line properties. Every such event contains the updated > > line information. > > > > Currently the events are generated on three types of status changes: wh= en > > a line is requested, when it's released and when its config is changed. > > The first two are self-explanatory. For the third one: this will only > > happen when another user-space process calls the new SET_CONFIG ioctl() > > as any changes that can happen from within the kernel (i.e. > > set_transitory() or set_debounce()) are of no interest to user-space. > > > - } else if (cmd =3D=3D GPIO_GET_LINEINFO_IOCTL) { > > + } else if (cmd =3D=3D GPIO_GET_LINEINFO_IOCTL || > > + cmd =3D=3D GPIO_GET_LINEINFO_WATCH_IOCTL) { > > Wouldn't be better for maintenance to have them separated from the day 1? > Sure. Will fix in v4. > ... > > > + if (test_bit(desc_to_gpio(desc), priv->watched_lines)) { > > if (!test_bit(...)) > return NOTIFY_DONE; > > ? > > > + pr_debug_ratelimited( > > + "%s: lineinfo event FIFO is full - even= t dropped\n", > > > + __func__); > > This is in 99.9% cases redundant in *_dbg() calls. > > > + ret =3D NOTIFY_OK; > > + } > > + > > + return ret; > > return NOTIFY_OK; Yeah, makes sense. > ? > > > +} > > ... > > > @@ -3111,6 +3285,7 @@ static int gpio_set_bias(struct gpio_chip *chip, = struct gpio_desc *desc) > > if (ret !=3D -ENOTSUPP) > > return ret; > > } > > + > > return 0; > > } > > > > This hunk doesn't belong to this patch. > Ha! Of course it doesn't. :) > ... > > > +/** > > + * struct gpioline_info_changed - Information about a change in status > > + * of a GPIO line > > + * @info: updated line information > > + * @timestamp: estimate of time of status change occurrence, in nanose= conds > > + * and GPIOLINE_CHANGED_CONFIG > > + * @event_type: one of GPIOLINE_CHANGED_REQUESTED, GPIOLINE_CHANGED_RE= LEASED > > + */ > > +struct gpioline_info_changed { > > > + struct gpioline_info info; > > Is this guaranteed to be always 8 byte aligned? > I'm expecting to see some comments there and / or here about it. > struct gpioline_info alone is 32-bit aligned but its size is 72 bytes which works for 64-bit alignment. This new structure's biggest element in 64-bit, so it's 64-bit aligned on 64-bit arch. We have 72 bytes of gpioline_info, 8 bytes of timestamp, 32 bytes of event type and 5 * 32 bytes of padding. Should be fine, but I'll add comments to the header. Bart > > + __u64 timestamp; > > + __u32 event_type; > > + __u32 padding[5]; /* for future use */ > > +}; > > -- > With Best Regards, > Andy Shevchenko