Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2243543ybl; Thu, 19 Dec 2019 10:18:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxXzbHKNvkFm67VPfWw8j6W4pRCwNMmgCayRQsxRfkhXXMCyNfMVAV7m7jW/AFyRw9f5oCH X-Received: by 2002:a9d:630d:: with SMTP id q13mr9645265otk.31.1576779520510; Thu, 19 Dec 2019 10:18:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576779520; cv=none; d=google.com; s=arc-20160816; b=OW8wkhsGKxc7HKdboCaLIgzKTdi2g0srcqwP+BwAAI4jTgP2/DM0hGKWJwDcpnGP3E kjWKJG8lSiYtoEGDwTDGj5NwwNXIPSUUcbveBk9Fy7r5WDLiw9FVw2T7kB+K2+sP7x/H HsI/3IdGqr8hFkrsxOSkXd2JnA3JR8nssBCyXE33Vxnvb/2GZLDphTDoyVkgoGUv6n5j s5U/tHzMRx8pVr8tBcb6WK/CeHKdP+SYDvOHzaREbaBpNYctf4d26nucu7iiT6RHeuHL 0rEjCwMGAOOhITbNL177Hc/381Upo5ij3EYs18fCvUAgek/G0GY2/ctGa1epc+Eh8CXZ dECA== 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=9IKeSaeLtm7vPfFfV60fys8+o5Vf9VVG4sSrLcJnbLg=; b=R5M/1dRlVyrsjomB1hbEbihvz6vMBDg2nxpFPZdt4es/khXFWpXlrDRED+hcNlgJ17 plTgEkzXpVkEoi6+LVbkYnnPoTEdWEmELE8i80zH4e2/GOiJiLaZV6/oraynmidF8+RY wV3JDq7XXFmsiGb4LFuSpKbMYtf1x6myDxhi/R+iM1RPQgQebaSGtFd4WV2mXSxJM+8H EUtBlghObXEoTRZn4eA8VKZ2IeNiO/3KcYpjlUI6Z0r3wo+qgV/I/sTqt5p8nU+x8BBU yDHvUDZTfFMH/GHvbeFta7mTuatJZVuuWR9jp/I/bWLn7piNNh8B51w+PKy8F+EOc51y 4WGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ULrs0SvP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si2815120otj.32.2019.12.19.10.18.25; Thu, 19 Dec 2019 10:18:40 -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=@gmail.com header.s=20161025 header.b=ULrs0SvP; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726873AbfLSSRm (ORCPT + 99 others); Thu, 19 Dec 2019 13:17:42 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42801 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbfLSSRm (ORCPT ); Thu, 19 Dec 2019 13:17:42 -0500 Received: by mail-pl1-f193.google.com with SMTP id p9so2915105plk.9; Thu, 19 Dec 2019 10:17:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9IKeSaeLtm7vPfFfV60fys8+o5Vf9VVG4sSrLcJnbLg=; b=ULrs0SvPCsPJ5z5H89BVhXo7MrrDMFIkP63mnmmlS56bvmxK+d4QpMwoN2KuVUfUiM FW46oiskYuu2Hul4HrnBnoGlYy61FUuBVHchaiXhiX+IElTcFgbYpMCBYBO77uh22FO5 P93uiGBePY/B8Ybui6ZqIMLmHuoqoow/+b4KW8hXPIZASLJXALkXw32xAJI9WFQcxqGP tMRiY2o1C659lso2yKuKsQpvjSoZA7xaCjKy5sp75AkCvonnXBSl+U504BNP3pIzFW9n KjTr+tB0wgTR6RxEY5F4UygnFjgbqeoGMBw1wbmjxQn7m4HZp7GM3UfmZtZAPG30Tfqm Lsfg== 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=9IKeSaeLtm7vPfFfV60fys8+o5Vf9VVG4sSrLcJnbLg=; b=Z5mWQhvu687rU9hbYuttKYT0ljfFe8z+aByl0aljCm3yMnXVlVvwTNva6n+mU/4Cnv bU2tw133SICd4ebHrhCeXbVofePosw7r3F6jrTqqZbJa/3O7v1Hjg7AUmEm9XvbxGNMN ZV19QKt1N9z5kMRkNpBF3lMdxz4SSw17xb1Mnp/9IKbZ3tkuxL7IRJ98iGhg1Pm4orXO vNL64sBn63ciq91R7V/1t/w0aME9ORL1OhVVbcuoIakFi1Sxj0j+wxd+WgXHjjkJ0cqF mg5vLRig0vFxsRYO3AqKpjdCRbFA6vbmiwe0BT6ybaPB8gZdExUPt2imynbLdhkPk2MV ciyQ== X-Gm-Message-State: APjAAAWwzRPG5BEZ34yB/NQti6xrppkESaNPsctTXGgFT42RB0ALPKA8 dVKcyWQw0lv5g72SQXv/f8owieqF+X+qSTlbb2c= X-Received: by 2002:a17:90b:3109:: with SMTP id gc9mr11076004pjb.30.1576779461595; Thu, 19 Dec 2019 10:17:41 -0800 (PST) MIME-Version: 1.0 References: <20191219171528.6348-1-brgl@bgdev.pl> <20191219171528.6348-13-brgl@bgdev.pl> In-Reply-To: <20191219171528.6348-13-brgl@bgdev.pl> From: Andy Shevchenko Date: Thu, 19 Dec 2019 20:17:30 +0200 Message-ID: Subject: Re: [PATCH v3 12/13] gpiolib: add new ioctl() for monitoring changes in line info To: Bartosz Golaszewski Cc: Kent Gibson , Linus Walleij , Andy Shevchenko , Greg Kroah-Hartman , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , Bartosz Golaszewski 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 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 provides > 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: when > 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 == GPIO_GET_LINEINFO_IOCTL) { > + } else if (cmd == GPIO_GET_LINEINFO_IOCTL || > + cmd == GPIO_GET_LINEINFO_WATCH_IOCTL) { Wouldn't be better for maintenance to have them separated from the day 1? ... > + 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 - event dropped\n", > + __func__); This is in 99.9% cases redundant in *_dbg() calls. > + ret = NOTIFY_OK; > + } > + > + return ret; return NOTIFY_OK; ? > +} ... > @@ -3111,6 +3285,7 @@ static int gpio_set_bias(struct gpio_chip *chip, struct gpio_desc *desc) > if (ret != -ENOTSUPP) > return ret; > } > + > return 0; > } > This hunk doesn't belong to this patch. ... > +/** > + * 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 nanoseconds > + * and GPIOLINE_CHANGED_CONFIG > + * @event_type: one of GPIOLINE_CHANGED_REQUESTED, GPIOLINE_CHANGED_RELEASED > + */ > +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. > + __u64 timestamp; > + __u32 event_type; > + __u32 padding[5]; /* for future use */ > +}; -- With Best Regards, Andy Shevchenko