Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5362075pxb; Mon, 15 Feb 2021 17:55:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrY7HwvYAWGu+u3JEtDrwu6XHy/71YlYPJteYrjjhl2bgQv0SAcJ03GeGD4G6JemQe8ZUj X-Received: by 2002:a17:906:e18:: with SMTP id l24mr17993989eji.500.1613440556699; Mon, 15 Feb 2021 17:55:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613440556; cv=none; d=google.com; s=arc-20160816; b=PlDulBNQp/vkdmCmqBz3Q2exwqPlEa3u2TGGF2shv+6SGtgek3VF7U4oSJ0CVtRFwb VrSvMlKNc8S3F9FUWL1zZ9CBMXm57F9G5Te+LqEVTqQuOom0iOrHeiQ1q0SbjgO4FBYn wX5JYMxSZbSuBxuRZ27w5LDq0fmczhO2lNW78u3wokELZ3d4KFrABE7dYAXF0yEIljdB jbdLnl0F03t09gVjL4M1vFIleQnkw4P6T+IdCc58yu7pEjIwlthJTzYo2dP4T+lWkqTd XbbaFjUfdm/4j+JNqv+B7Fi3Am9ErXpBsMHYKj3L5c8jbjUODe8nlbgC9JzlUiv26OVm 9p0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Z9fQxyTq8wZx7TxGYyTLeA7qeXg7RbpnEvNBDuqSeU=; b=Hp1UMO6aeYOI3cxLXsVsh0VnYFvPbE+gbDakstGBPckgzpONa3tZFRNdmcDmOMZUyO uNmsuMDcC+KlOrk/5bnlFdtu13yKWRxxgZ8/0IZ1cxH9uxs0b2zv83LbKCIqY7Wd1zVI f5UhHBL7TJADeIrXW549sx+na1WOr+QpOTEBj61uIQi3Jjjm3aLsrPxv1V79SlXG+z3z GV7oLW63JJUQlUFxkm4sre2aCONgHbxGNupiGkQdH4QNIOe+USLWLqEiI8Lo/jwUqZdr YtFnoSk4QeIm+Vf/Tt7OyQ8/RytbHSVRJPP9ljipMP4QeQpM2E+0FLdIko3eFvd6VYpe wfeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B6H+rtng; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm8si11926597ejc.748.2021.02.15.17.55.33; Mon, 15 Feb 2021 17:55:56 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=B6H+rtng; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbhBPBx4 (ORCPT + 99 others); Mon, 15 Feb 2021 20:53:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbhBPBxz (ORCPT ); Mon, 15 Feb 2021 20:53:55 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DB9BC061574; Mon, 15 Feb 2021 17:53:15 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id f8so3077819plg.5; Mon, 15 Feb 2021 17:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3Z9fQxyTq8wZx7TxGYyTLeA7qeXg7RbpnEvNBDuqSeU=; b=B6H+rtngp5Ub6P7PakgDyMgHLMSFW3CXCwi7xKpx+HOjYnyvKM7HSlwfA95mkNKG4p H6+ziozELER4v/UR2ZoBPLf+kJdhsgYeHVCxbqGHZX53Lu/iglnQ2LsDkxH1SUBQknOW lnoIq4mgym/IU63GuzQtLykc/x/mW3NFDRhyOmr/+Af23Qu77unqcAppvFqaq3XYDsB+ 0s3iWUlvx3hmeITiQ5mat6MQ1wlL8ZIwBmgsvqk+IL6WMtu2tnOj9rUU8jy7DGfgcfLw iL/+WuBuHzJEVj+JYCStZAKIufq+25xZlYspAyYuSISJvC9ce+SRhGbnd4FEiu2ctoCC ONYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3Z9fQxyTq8wZx7TxGYyTLeA7qeXg7RbpnEvNBDuqSeU=; b=CR4xWRp+5zxX75I0QKFBIjJ82G6qoBraZKdlW4OvKxM728J1CCeV7Pbp+1tZ4SNgAZ 2zAuDHlqeJNxhdzo+S+JI7kMVKDoaHzKkByGuau//nzGJ4k0MQgKTVrfAmJT5SZXzeQZ LivoNGWNR92JIivzD2MzjA5OlD3L8JXkF9fYBkOx3s/S+1sUzfmyaxueVUzDJBdNAXF+ D4MAxqoULmaQdpe0EVJ2iHgrP/BPI+gjZVH84TgNothjib8gPWqNoCo9J1KdVczbMIuq KrSEWXoknB9pCycwnNf0W+xHYuwmeOWyWV44eGH5GTGjEjWHnT8O+hTcA09bz0OL/wgw sxHA== X-Gm-Message-State: AOAM531cNK+as8f6xvPKLqTHgzBKr4NjNXS3rKtG+Z1KU16UEtoHVBLn dmBgypDNKhzdX69UGVEra4A= X-Received: by 2002:a17:902:e847:b029:e1:52b9:d81b with SMTP id t7-20020a170902e847b02900e152b9d81bmr17553849plg.82.1613440394610; Mon, 15 Feb 2021 17:53:14 -0800 (PST) Received: from shinobu ([156.146.35.76]) by smtp.gmail.com with ESMTPSA id ga22sm691114pjb.34.2021.02.15.17.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 17:53:13 -0800 (PST) Date: Tue, 16 Feb 2021 10:53:07 +0900 From: William Breathitt Gray To: Oleksij Rempel Cc: jic23@kernel.org, kamel.bouhara@bootlin.com, gwendal@chromium.org, a.fatoum@pengutronix.de, david@lechnology.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org, Dan Carpenter , kernel@pengutronix.de, fabrice.gasnier@st.com, syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, alexandre.torgue@st.com Subject: Re: [PATCH v8 17/22] counter: Add character device interface Message-ID: References: <720278e3aaf3f249657ec18d158eca3f962baf8e.1613131238.git.vilhelm.gray@gmail.com> <20210215092412.ptbngqge7m7nyivp@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EWkdL/PqLMg68rsd" Content-Disposition: inline In-Reply-To: <20210215092412.ptbngqge7m7nyivp@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EWkdL/PqLMg68rsd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 15, 2021 at 10:24:12AM +0100, Oleksij Rempel wrote: > Hi William, >=20 > On Fri, Feb 12, 2021 at 09:13:41PM +0900, William Breathitt Gray wrote: > > This patch introduces a character device interface for the Counter > > subsystem. Device data is exposed through standard character device read > > operations. Device data is gathered when a Counter event is pushed by > > the respective Counter device driver. Configuration is handled via ioctl > > operations on the respective Counter character device node. >=20 > ..... >=20 > > +/** > > + * counter_push_event - queue event for userspace reading > > + * @counter: pointer to Counter structure > > + * @event: triggered event > > + * @channel: event channel > > + * > > + * Note: If no one is watching for the respective event, it is silently > > + * discarded. > > + */ > > +void counter_push_event(struct counter_device *const counter, const u8= event, > > + const u8 channel) > > +{ > > + struct counter_event ev =3D {0}; > > + unsigned int copied =3D 0; > > + unsigned long flags; > > + struct counter_event_node *event_node; > > + struct counter_comp_node *comp_node; > > + > > + ev.timestamp =3D ktime_get_ns(); > > + ev.watch.event =3D event; > > + ev.watch.channel =3D channel; > > + > > + /* Could be in an interrupt context, so use a raw spin lock */ > > + raw_spin_lock_irqsave(&counter->events_list_lock, flags); > > + > > + /* Search for event in the list */ > > + list_for_each_entry(event_node, &counter->events_list, l) > > + if (event_node->event =3D=3D event && > > + event_node->channel =3D=3D channel) > > + break; > > + > > + /* If event is not in the list */ > > + if (&event_node->l =3D=3D &counter->events_list) > > + goto exit_early; >=20 > To cover my "interrupt-counter" use case, I added following line here to > convert the tail drop fifo to the head drop fifo: >=20 > + list_for_each_entry(comp_node, &event_node->comp_list, l) > + to_copy +=3D sizeof(ev); > + > + while (kfifo_avail(&counter->events) < to_copy) > + kfifo_skip(&counter->events); >=20 > May be it make sense to make it optional and integrate in to you patches > before it goes mainline? >=20 > Regards, > Oleksij > --=20 > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | Hello Oleksij, I appreciate your suggestion, and I'm excited about your interrupt-counter driver -- it looks like the Counter character device interface will be central for that driver. However, I want to hold off on adding further functionality to this patchset so that we can stablize it enough to merge. Once the Counter character device interface is merged, please send your changes again as a patch and we can review it further then. Thank you, William Breathitt Gray --EWkdL/PqLMg68rsd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAmArJYMACgkQhvpINdm7 VJKmiRAA4DZryRZBEwsPxRbFl4Mq1+SDKR8yQSfXW6ddho5xEp8qj+fGp6RaimIm Zz9YLNH7/VQvEDeX5o6swntVlq3HT+C8VSp2sNPEIKIduNy114kx4qTE0L238nGq cSOiY7rO78BKcbZ1zGfg1waRZWXuAsTu0F8xC5zrjYbjN+OEohUjmzMYsJoNbmq8 pVMuSiwbx2V4sBysgnKffP5ZfEsNVJocVbt7u3NPsadMMn9CVswtqqY6RVn8GdF9 KSTSomqzlL8OnnbodjuFM5CjvECVp3HVMUYd5R9hJAAQOCMds3j4nq1dD/qY78RB UeD7+SuQBAPWi517V/tTezbal7HloM7AYNwwG9oyu27DEy+t49fd+p/cahBRhhHi YY97IZyTk0WeJh7sX4Z2kNkgEj5KQljlxy6iX6UnToDaM1AF0Ezx+v6f+lUsRZ8c l/zFYc74ZoVbP4TcO535pbyh6AleOkeZRBxJYsu1N+c96JzcrftFAhk0Gkbo52rA DKSdh2qvELlJlYQf77EQh39yLvnluacqm3oUoHpXnp2hrIZMyZGo0/82eFlM+Ue+ xoeQCy2FiKOmkE9s1l0S7JvqkPTLpALDvFWm7FGWhBqpAZm/gdSRph/RumyccYIE 3fHlmlJOh4aa712C+b+K2zkKEXMhD/Bn1y4i8XZv7N8qq4cbyLQ= =JYlU -----END PGP SIGNATURE----- --EWkdL/PqLMg68rsd--