From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB8D7C433E7 for ; Wed, 14 Oct 2020 19:07:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4872C2078A for ; Wed, 14 Oct 2020 19:07:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YGufI2aZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C4cJ+6ik" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4872C2078A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8CyC/WCeVp0gO9IUDqzPmcD0xlq1shmfVGbiCVhrcb4=; b=YGufI2aZuqZncy44QEPns+6mr 23SJd0FUDtFn7eEuvItfBwDVd9Ytklj2UVrkDhG5o6abcY1R+Q27NFqBMG2Sjk7I14E7mxD9gmpI4 f1NFMpq/90rcb91JIUIIW6bmQXKi6/cEpCqK5dcFOBfd92L5uP/jREOuqM7HJ7ckDebwUIBuMmdxH lca3zmj47V77cg1h+gOmuFJahJ9LcQ2HXn0gaQNAreHiwyCTCxwwYQfrTl18h7+8HEHB/IdPwRp07 k/97WcELwoyP97teSB2iwv6QtjrkvTrfj2GTSqiOWqBpZfFsrvqMdImuWhBZPJZ2eEFqeZ3GiZBOg hl/Y7p9ew==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSm5t-0008T9-TR; Wed, 14 Oct 2020 19:05:49 +0000 Received: from mail-qk1-x742.google.com ([2607:f8b0:4864:20::742]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSm5q-0008RJ-31 for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2020 19:05:47 +0000 Received: by mail-qk1-x742.google.com with SMTP id q63so412127qkf.3 for ; Wed, 14 Oct 2020 12:05:43 -0700 (PDT) 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=6wjqxwtbzgIHiDQg99WolaTB10lGIX9ridUr1LerSto=; b=C4cJ+6ikED4y7sddfCSWORNVTWuC5T2E3whaMK6+cusw1l8WOeKtareV0Byt1OQtyk z2Gb2+3ge3KpfVTMHbAiiPsAR2O1n9HsO1EZ9tlgCaQf4HXgwLoDnWK9vNrkBQA5MGlO /4JFHF7Prlrc1a3zs26OMnayCe7V6fG1ZMh3uxT2JZfiwhmeR9sSpP1ZiCRkHkhUF9Ug ldlxUnytAhsdqz5mHhxIRRHa/+lGCRUNX6bOTeRAW+scdQdLyf1nSMDRFwFXjjnkRmLS tANYv3DYEOm07stB54QrMNQ60nzuKDFeeU7evQOo5HlH2c1ietMjAmNmbT4hLpSgTE+1 7Aqw== 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=6wjqxwtbzgIHiDQg99WolaTB10lGIX9ridUr1LerSto=; b=SZFdY3bvAE8W0nV6BC2WzNN6ENm21c+IUeXrAQOtgy+GNYKd2qoFTftGLWgSeurIsM lv+O6AaIAcaL6pbOTzCOrgT/fkp5Xxtmlq/G44sMbLtWDRcJb7wETi7Q7bNT7SbQgnmE hvaKZCQ+G8qGd4ol2G7pRXxnHZX3feNX0YdiDkrFf7PNc3NAS9l4lnrJGF45qNW28iXj 0yh4Dre0pXeYzrLfPZLmm7ViiTgppwDct1BIqxgtaoiwiN5MFT6d+4+hOeRdMXK1dJZu AVunmeS88cHbJ0zdZ4u3sMS9Iw/EPfOH3FIoGFCUAOrttaNl1Xq1golM1Zj57LWWUKXw /xfg== X-Gm-Message-State: AOAM530ySoJ0qGAwtX22/kLa+cu3SyLZd0wr1NdQZKuFu7E/XX55W/Ri 0AmcI0Zrb52En9G1E3y+AM8= X-Google-Smtp-Source: ABdhPJxtNMA2dHYbfdwX/cS1+k4VNViVtwLuSPBAgvxVBiNRGxKjZbeYrm37jqFJYa3DXkpMUa+hDw== X-Received: by 2002:a05:620a:152:: with SMTP id e18mr465193qkn.365.1602702341697; Wed, 14 Oct 2020 12:05:41 -0700 (PDT) Received: from shinobu (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id u4sm238508qkh.106.2020.10.14.12.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 12:05:40 -0700 (PDT) Date: Wed, 14 Oct 2020 15:05:26 -0400 From: William Breathitt Gray To: David Lechner Subject: Re: [PATCH v5 3/5] counter: Add character device interface Message-ID: <20201014190526.GA13439@shinobu> References: <00be1fccc672c5207f3b04fe4cc09c29e22641f4.1601170670.git.vilhelm.gray@gmail.com> <67a0290e-731b-822a-5113-30b56bde6c88@lechnology.com> MIME-Version: 1.0 In-Reply-To: <67a0290e-731b-822a-5113-30b56bde6c88@lechnology.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201014_150546_237845_622A8388 X-CRM114-Status: GOOD ( 29.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.torgue@st.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com, syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, jic23@kernel.org Content-Type: multipart/mixed; boundary="===============7964901317102881945==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============7964901317102881945== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 14, 2020 at 12:43:08PM -0500, David Lechner wrote: > On 9/26/20 9:18 PM, William Breathitt Gray wrote: > > diff --git a/drivers/counter/counter-chrdev.c b/drivers/counter/counter= -chrdev.c > > new file mode 100644 > > index 000000000000..2be3846e4105 > > --- /dev/null > > +++ b/drivers/counter/counter-chrdev.c >=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. > > + * > > + * RETURNS: > > + * 0 on success, negative error number on failure. > > + */ > > +int 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; > > + int err; > > + > > + ev.timestamp =3D ktime_get_ns(); > > + ev.watch.event =3D event; > > + ev.watch.channel =3D channel; > > + > > + raw_spin_lock_irqsave(&counter->events_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; > > + > > + /* Read and queue relevant comp for userspace */ > > + list_for_each_entry(comp_node, &event_node->comp_list, l) { > > + err =3D counter_get_data(counter, comp_node, &ev.value_u8); >=20 > Currently all counter devices are memory mapped devices so calling > counter_get_data() here with interrupts disabled is probably OK, but > if any counter drivers are added that use I2C/SPI/etc. that will take > a long time to read, it would cause problems leaving interrupts > disabled here. >=20 > Brainstorming: Would it make sense to separate the event from the > component value being read? As I mentioned in one of my previous > reviews, I think there are some cases where we would just want to > know when an event happened and not read any additional data anyway. > In the case of a slow communication bus, this would also let us > queue the event in the kfifo and notify poll right away and then > defer the reads in a workqueue for later. I don't see any problems with reporting just an event without any component value attached (e.g. userspace could handle the component reads via sysfs at a later point). We would just need a way to inform userspace that the struct counter_component in the struct counter_watch returned should be ignored. Perhaps we can add an additional member to struct counter_watch indicating whether it's an empty watch; or alternatively, add a new component scope define to differentiate between an actual component and an empty one (e.g. COUNTER_SCOPE_EVENT). What do you think? William Breathitt Gray --tKW2IUtsqtDRztdT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAl+HS+wACgkQhvpINdm7 VJLA6w/8C/7Kk5FVs4czCH9uMX3PWTVzLg32XilvtRndujXVCml9iLMADLvFVyIA dEX7rmXz/bWYSzG99VkZyHCWCeQX8+roYFDhmqbD8hQyEkqQlhHFWGdAPqGPAYeH cesBwsFdkB3yoc28HahJfV6c3HtuO3pLtsu7qKORwbhOupqzz6BBg/imzx04+8hh LicqVk0uFKT/v5E9o5AfOV+9cbHgZWm+TusLYTwKZCrvDVmrWkxdppPC581ftd9Q mrW/2qfj3ltcO4VoJ6JVZpKjcXJSak8V0l+A7dV2Hbp8dBGEhC+iODBfhhAUxTz5 NM/cw+L90slS7Yli2mf1aY4lYLNv+Ob17alTK4P1Gc1ekJ9yofNevJlb8xp55KxC jY8rUWxEkS1y1h8K7wrPzwhMwk6Ab4psdUB+9+DClArQI5ZnimG1nJlSph9p1C24 VjR6Vi8qSyUlSKrr5vK1ac1s/EDoAxwJoMr+e3rbRqrz3kktAvSN0S0sPD+xoV87 iPjdASJa3YvBkS4v2o34XoNQnsVpdzUW3emUQ56qLf2yWVqbP8PkG5xhBRtfHvtI 3VRYrSJ2dgv1u2xvrFhFhr2g7DRA9XMDOgc/aiqRnD18MHWT57GBLakOIZAYG9g3 qbtBe6fEcVlUumDSKscRfWe6bsFhldy3v5FCMiY2JGZh689pwPM= =EhIu -----END PGP SIGNATURE----- --tKW2IUtsqtDRztdT-- --===============7964901317102881945== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============7964901317102881945==--