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=-3.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 A45A4C433E7 for ; Tue, 13 Oct 2020 19:29:49 +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 41430208D5 for ; Tue, 13 Oct 2020 19:29:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UooFqIvr"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pNlUsnGh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41430208D5 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=irAglcga4AI2KFxFfJe/izpdE4PA10vSCh/wRGUwRA4=; b=UooFqIvrI9pf230dwr41ll8xE GwhRC0roBw2zY8Uc+Vf6GWRc6JtXfNRiiBHDn847N60slAzZqEAKdmeCUI0uSeEvVfEhbmadeTx6u 0Onu433L/mXWmvl4RjCtox/rm2OXa8fwv5oGqGI6oa43iABW8vQd54S8gEIz2eEGpaeSgkwzoxQfv HM54E4urbyFyf4YEteLdWaLpbfbLIAuk3WIlB6221IdYJnZJKixjq5n9m6e3IeUhks5gRAYyfY2hz 8R6xLx7YzKsyIlW4nTfF1aQ+mU7ondKrWAACkK+fVYYUntrtkDlrKrId1S9WuqnraSR5X7zTsLyrL 0nRfQjeww==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSPxv-000608-PP; Tue, 13 Oct 2020 19:28:07 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSPxs-0005zN-Nc for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2020 19:28:05 +0000 Received: by mail-qk1-x741.google.com with SMTP id q63so829357qkf.3 for ; Tue, 13 Oct 2020 12:28:04 -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=oH57Aeq7dptpbLJ/Gi2x/xQv7Jn157z+tldkFDsNdQM=; b=pNlUsnGhf+deEhFYlFqDY5WR8rb2vOVydQDO8QwSvlS/iLxpD14Hx6AIEABIJxLn0c M8s9QGsCktIrZqTduAtjIjKlMWJ7DKouhiwdMZs9Tq1+k1NTgNXXmZB3Zexh2vYaBBlA MdsUKxFeSS49DaklCfpQ4PrS66PXsjjGLTEj9JtwZJekjrFh2isHrbeYYNMlDVKl5sHK NJ8xe3e5HbVuM9HyevTdl5om3GHXHRPKoqxYSwgQiDQ7EodoRy4KuWDKkq5TTOEggl28 o10R2OX93CMdmOUws6qi01Iperaqf3lNGaFy2BekOstQ9pb/AN9ye587q0yDa3eZS9+w /Unw== 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=oH57Aeq7dptpbLJ/Gi2x/xQv7Jn157z+tldkFDsNdQM=; b=XSieppwS1wSxaIJmYgnm4T4NgcB/hb7UEkwaRJy53p+KomzWN2YNKBw8s+hVabjeXH pM+f2FPVeFA8FU8TGdPAqQx2PBmHI6hfO1dtLL9opCjFpyi1ytU865ZXwGJoSdPvtjkw GhPfrL9k+jGBivnJyd9RDbyWYH7k2NmZ5VDK0mDH5j0/JZ9zZ/d4pS8q8RZ+ScWu3JZK tlCO3L8JzpZI/Z8VsF4LGi11EbwheivGs1Y9cOiE4t0UpcxlMLTFnCnJgdscx3alKJL7 KejXp3FTELJudZ4NESDUen378fIt5PeKewgkchPEFfhpT3nfO3/0tqp+mapzGJifWldd 46jA== X-Gm-Message-State: AOAM530stK3/5sVhYkhumJi9JccgAM38092/DHSuxF1FNM2ppgrGf7bl kDH2XcNsojbnWUWn555ySVk= X-Google-Smtp-Source: ABdhPJx3RWQ0Ixnkg8H7A0PimPYFPhuFdry/B79ZtoiOA/CSvk9rCJEEn5yfbDMQoseSWKFJdfADhA== X-Received: by 2002:a37:a8a:: with SMTP id 132mr1582931qkk.199.1602617282945; Tue, 13 Oct 2020 12:28:02 -0700 (PDT) Received: from shinobu (072-189-064-225.res.spectrum.com. [72.189.64.225]) by smtp.gmail.com with ESMTPSA id s17sm337542qta.26.2020.10.13.12.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Oct 2020 12:28:02 -0700 (PDT) Date: Tue, 13 Oct 2020 15:27:43 -0400 From: William Breathitt Gray To: David Lechner Subject: Re: [PATCH v5 4/5] docs: counter: Document character device interface Message-ID: <20201013192743.GA33437@shinobu> References: <54190f9875b81b6aa5483a7710b084053a44abb8.1601170670.git.vilhelm.gray@gmail.com> <20201008080909.GA31561@amd> <20201008122845.GA3314@shinobu> <20201013185851.GB32722@shinobu> <09949c56-19da-1937-418b-99a1a9260c4c@lechnology.com> MIME-Version: 1.0 In-Reply-To: <09949c56-19da-1937-418b-99a1a9260c4c@lechnology.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201013_152804_832275_B41930C7 X-CRM114-Status: GOOD ( 29.22 ) 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, mcoquelin.stm32@gmail.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, Pavel Machek , syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com, jic23@kernel.org, alexandre.torgue@st.com Content-Type: multipart/mixed; boundary="===============0812083437202741141==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============0812083437202741141== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ZGiS0Q5IWpPtfppv" Content-Disposition: inline --ZGiS0Q5IWpPtfppv Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 13, 2020 at 02:08:45PM -0500, David Lechner wrote: > On 10/13/20 1:58 PM, William Breathitt Gray wrote: > > On Mon, Oct 12, 2020 at 12:04:10PM -0500, David Lechner wrote: > >> On 10/8/20 7:28 AM, William Breathitt Gray wrote: > >>> On Thu, Oct 08, 2020 at 10:09:09AM +0200, Pavel Machek wrote: > >>>> Hi! > >>>> > >>>>> + int main(void) > >>>>> + { > >>>>> + struct pollfd pfd =3D { .events =3D POLLIN }; > >>>>> + struct counter_event event_data[2]; > >>>>> + > >>>>> + pfd.fd =3D open("/dev/counter0", O_RDWR); > >>>>> + > >>>>> + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches); > >>>>> + ioctl(pfd.fd, COUNTER_SET_WATCH_IOCTL, watches + 1= ); > >>>>> + ioctl(pfd.fd, COUNTER_LOAD_WATCHES_IOCTL); > >>>>> + > >>>>> + for (;;) { > >>>>> + poll(&pfd, 1, -1); > >>>> > >>>> Why do poll, when you are doing blocking read? > >>>> > >>>>> + read(pfd.fd, event_data, sizeof(event_dat= a)); > >>>> > >>>> Does your new chrdev always guarantee returning complete buffer? > >>>> > >>>> If so, should it behave like that? > >>>> > >>>> Best regards, > >>>> Pavel > >>>> --=20 > >>>> (english) http://www.livejournal.com/~pavelmachek > >>>> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/hor= ses/blog.html > >>> > >>> I suppose you're right: a poll() should be redundant now with this > >>> version of the character device implementation because buffers will > >>> always return complete; so a blocking read() should achieve the same > >>> behavior that a poll() with read() would. > >>> > >>> I'll give some more time for additional feedback to come in for this > >>> version of the patchset, and then likely remove support for poll() in > >>> the v6 submission. > >>> > >>> William Breathitt Gray > >>> > >> > >> I hope that you mean that you will just remove it from the example > >> and not from the chardev. Otherwise it won't be possible to > >> integrate this with an event loop. > >=20 > > Would you elaborate a bit further on this? My thought process is that > > because users must set the Counter Events they want to watch, and only > > those Counter Events show up in the character device node, a blocking > > read() would effectively behave the same as poll() with read(); if none > > of the Counter Events occur, the read() just blocks until one does, thus > > making the use of a poll() call redundant. > >=20 > > William Breathitt Gray > >=20 >=20 > If the counter device was the only file descriptor being read, then yes > it wouldn't matter. But if we are using this in combination with other > file descriptors, then it is common to poll all of the file descriptors > using a single syscall to see which one is ready to read rather than > doing a non-blocking read on all of the file descriptors, which would > result in many unnecessary syscalls. Ah, that's a fair point, my original view was somewhat myopic there. I'll leave poll support in the Counter chrdev then and just simplify the documentation example code to not use it. William Breathitt Gray --ZGiS0Q5IWpPtfppv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEk5I4PDJ2w1cDf/bghvpINdm7VJIFAl+F/68ACgkQhvpINdm7 VJL09xAAiV4IcrugWkrx2BL3YYZnD8T2DIOs7rpSZAQhOmnCdYi+RkdpcIkL1BiE m43MgXUDtj+YsRzAVE55mySXUbpDXH3Hp2/ty0p8tzToy+ZI6d2ooRzFwNsxlSdy 4/FIQQQaqCpl6pBBwRwsum2Swe7JrToX+Q+FoN7KZt1STia8FuxlmiWlUC+ZL6L6 rk4/3dMMLcCm8JKGZ4qKqSEJxXyHGKQ/leAm9GTRS4a+RjzNiidBvM4+aNuAy+bC j7x7vzHHfmxT1egmhT4XeyyuWW8C4rd1mQXG8RllaP6PhABi61Zd+KH1LIfMjV1P t/9biiBXbdyh5uytVrI6Z04tu0frQGZi1JglSLljGvkNoKRBnvP8f9ay44y2PrG7 jAYAq0lgig9N0zLNql9c/ZMtanGACNlxQShnO/5MjYo1oBjXPy9I8oOn4vI5OvnG 2ccm6NhZRs+bU5f0dRJZy+DsqQFWaekjXVxmqu/HwG45YbcxUpprSY0qZtbLOe1m U2EuuipT10o/UoJMO+3AlqqgJOfj2cGL2lXMIMSUFb3HQ0TDuHbBq3GPG02Fn9qL TYHt5XoeQWb82gOmVuL0ynXac8mXuGy9PwGrHBYQryfODVvy6kA3nhSXkFncb52q ovI9PDQc8Z3jigrxj17nrlvoDNb6FT+2knKdwSujiKgo8ZWdZUc= =4Gc4 -----END PGP SIGNATURE----- --ZGiS0Q5IWpPtfppv-- --===============0812083437202741141== 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 --===============0812083437202741141==--