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=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 AF23AC433E0 for ; Mon, 22 Feb 2021 10:13:03 +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 64B6364E25 for ; Mon, 22 Feb 2021 10:13:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64B6364E25 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ucw.cz 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=rPBYZusIHYSsars9FppEa7SX3f+4rPFMqnJmbgpZEN0=; b=BuDQivjJMXJqs+jPDc4/JTb9t Hy6LxcvSQKuFbx4OH/ZOH1mEF9G/PKZJVORG1Ss0bnYMR27GY0k3FrAx3NiGWzZ0GGfmznF/fxL9C 9u02xwMhNc4kL+3gF3kS0owPnZ/Y0178pBbylJH79jaydbAxolYB4zpmvCNZQN2AepmOpEBhUdeby X6L7UHAS8K9Sd5S3sifiWYmk9DhtvYYVvyufd+YM/PcO43YQzQRO/oJxdGcEzEVxWBcTxV+M9uwrn 9iejMgyNvZF90N8ASquPioCNy6AecQ0YSF7ITWn5xQGcCYPoMdoRFg1EIgta1W7Ob4WvwijL2oY39 ht9db/0IA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lE8Bs-0005fR-MS; Mon, 22 Feb 2021 10:11:44 +0000 Received: from jabberwock.ucw.cz ([46.255.230.98]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lE8Bo-0005eJ-Vx for linux-arm-kernel@lists.infradead.org; Mon, 22 Feb 2021 10:11:42 +0000 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 8B3741C0B7F; Mon, 22 Feb 2021 11:11:34 +0100 (CET) Date: Mon, 22 Feb 2021 11:11:33 +0100 From: Pavel Machek To: Jonathan Cameron Subject: Re: [PATCH v8 18/22] docs: counter: Document character device interface Message-ID: <20210222101133.GB14587@amd> References: <350cafba81d3220b64efdb019bd76c08eb1e5d10.1613131238.git.vilhelm.gray@gmail.com> <20210214174819.6757e2b0@archlinux> MIME-Version: 1.0 In-Reply-To: <20210214174819.6757e2b0@archlinux> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210222_051141_180673_2F96B931 X-CRM114-Status: GOOD ( 18.90 ) 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, a.fatoum@pengutronix.de, david@lechnology.com, alexandre.belloni@bootlin.com, linux-iio@vger.kernel.org, patrick.havelange@essensium.com, William Breathitt Gray , mcoquelin.stm32@gmail.com, linux-kernel@vger.kernel.org, o.rempel@pengutronix.de, 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 Content-Type: multipart/mixed; boundary="===============6723648252581197768==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============6723648252581197768== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MfFXiAuoTsnnDAfZ" Content-Disposition: inline --MfFXiAuoTsnnDAfZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > +* COUNTER_ENABLE_EVENTS_IOCTL: > > + Enables monitoring the events specified by the Counter watches that > > + were queued by ``COUNTER_ADD_WATCH_IOCTL``. If events are already > > + enabled, the new set of watches replaces the old one. Calling this > > + ioctl also has the effect of clearing the queue of watches added by > > + ``COUNTER_ADD_WATCH_IOCTL``. > > + > > +* COUNTER_DISABLE_EVENTS_IOCTL: > > + Stops monitoring the previously enabled events. >=20 > Is there a way to remove a watch?=20 Is there a way to eat all kernel memory and crash the system by adding too many watches? > > +For example, the following userspace code opens ``/dev/counter0``, > > +configures the ``COUNTER_EVENT_INDEX`` event channel 0 to gather Count= 0 > > +and Count 1, and prints out the data as it becomes available on the > > +character device node:: > > + >=20 > Consider adding an example program under tools/ >=20 > > + #include > > + #include > > + #include > > + #include > > + #include > > + #include > > + > > + struct counter_watch watches[2] =3D { > > + { > > + .component.type =3D COUNTER_COMPONENT_COUNT, > > + .component.scope =3D COUNTER_SCOPE_COUNT, > > + .component.parent =3D 0, >=20 > Good to add comments on what these elements actually are? > > + fd =3D open("/dev/counter0", O_RDWR); > > + > > + ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches); > > + ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches + 1); > > + ioctl(fd, COUNTER_ENABLE_EVENTS_IOCTL); > > + for (;;) { > > + read(fd, event_data, sizeof(event_data)); If this goes to tools it really should have error handling and handling of short read. Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --MfFXiAuoTsnnDAfZ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmAzg1UACgkQMOfwapXb+vJsaACffCOe28RqjxELfyTkP8K3Wy+h SeYAn26EGcT9n9wUACiesQqsPDqCDl31 =ku3H -----END PGP SIGNATURE----- --MfFXiAuoTsnnDAfZ-- --===============6723648252581197768== 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 --===============6723648252581197768==--