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.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,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 71263C07E96 for ; Sun, 11 Jul 2021 14:07:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 35A1161167 for ; Sun, 11 Jul 2021 14:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35A1161167 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lechnology.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=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VNmRn6DtRMzDrhU+FGREea3caCqb1tfypAutYRbeKdc=; b=QxeK2VgMPvBJmZrYiIEYMXOKSO wceeoNCOoqsT9Nu7aF0BvGXg+PKwwxMC/zDNDc9wsfetAsbLJfgwfIhKhCmFTXZrq/QaGSqsNEcT2 1lcFhhvlALlEuQrESwPw3ZXD2fq1X9Tf5NXKF2RHqv4bKUMg9AL+J4aOSPNzjMl9sR59wf9bh/skm mypquz1J8NhRwbmZKq8BLfi31zF5mteoj4sefXS1b37B1gZWAfgzsEnD7arvACx5oxobjt+GH5dqI +PqpNJnJh+lcpcLCTS0+znzyF9CTx+2oMwMY9QvQJ4n7KFwnGVWHRXUq7lJn3e45GrxZV+prYF18E OAgpNt/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2a5c-0059Dm-O6; Sun, 11 Jul 2021 14:05:48 +0000 Received: from vern.gendns.com ([98.142.107.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2a5Y-0059D3-KY for linux-arm-kernel@lists.infradead.org; Sun, 11 Jul 2021 14:05:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=opiyXzz03XSvATCVRQY9c1WK7Xfz/7xyqkaDVHpblnA=; b=fUrBhWtbCVrd2/MswDdJf3BmcI gGdKTBwUzBrOarv9W9KDAElabrY2h4DzMS7WhUpPq0qqVdEICnlwj+hPFRRK2jDDWfg9xDV9FmASi qlUIpSImfp56d28SrY+WB4CrhtDId+3+LGSVDPZmR5powvHKj0EDfGw5j+G1pz/d8mpjXw5y9HF5i oRpK3aeSGWYPLHuP5Tk9HBl8+lDkw3IlkUJUa3qndZxMwyDQJORADABi2+cBXW3CsR1rKp8DJ6BzV jQlJlfpCfsGsiO/bkNQmylp9UgcW34SykCbPyrhmuQQbrxGYJj48RkRFrdr7rlypLPMJIew1OpD29 4qdDwXDw==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:51930 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1m2a5R-003hqX-91; Sun, 11 Jul 2021 10:05:38 -0400 Subject: Re: [PATCH v12 12/17] tools/counter: Create Counter tools To: William Breathitt Gray Cc: jic23@kernel.org, linux-stm32@st-md-mailman.stormreply.com, kernel@pengutronix.de, a.fatoum@pengutronix.de, kamel.bouhara@bootlin.com, gwendal@chromium.org, alexandre.belloni@bootlin.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, syednwaris@gmail.com, patrick.havelange@essensium.com, fabrice.gasnier@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, o.rempel@pengutronix.de, jarkko.nikula@linux.intel.com, Pavel Machek References: <343a2bd3-38b7-7462-bc52-d3f6493bede0@lechnology.com> From: David Lechner Message-ID: <56fb48ac-335d-f112-6370-38ad35ad72f0@lechnology.com> Date: Sun, 11 Jul 2021 09:05:32 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210711_070544_901835_0EA84C0B X-CRM114-Status: GOOD ( 18.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/11/21 6:28 AM, William Breathitt Gray wrote: > On Sat, Jul 10, 2021 at 11:53:35AM -0500, David Lechner wrote: >> On 7/5/21 3:19 AM, William Breathitt Gray wrote: >>> + { >>> + /* Component data: Count 0 count */ >>> + .component.type = COUNTER_COMPONENT_COUNT, >>> + .component.scope = COUNTER_SCOPE_COUNT, >>> + .component.parent = 0, >>> + /* Event type: Index */ >>> + .event = COUNTER_EVENT_INDEX, >>> + /* Device event channel 0 */ >>> + .channel = 0, >>> + }, >>> + { >>> + /* Component data: Count 1 count */ >>> + .component.type = COUNTER_COMPONENT_COUNT, >>> + .component.scope = COUNTER_SCOPE_COUNT, >>> + .component.parent = 1, >>> + /* Event type: Index */ >>> + .event = COUNTER_EVENT_INDEX, >>> + /* Device event channel 0 */ >>> + .channel = 0, >>> + }, >>> +}; >>> + >>> +int main(void) >>> +{ >>> + int fd; >>> + int ret; >>> + struct counter_event event_data[2]; >>> + >>> + fd = open("/dev/counter0", O_RDWR); >>> + if (fd == -1) { >>> + perror("Unable to open /dev/counter0"); >>> + return -errno; >> >> errno is no longer valid after calling perror(). Since this >> is example code, we can just return 1 instead (exit codes >> positive number between 0 and 255 so -1 would be 255). > > Ack. > >>> + } >>> + >>> + ret = ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches); >>> + if (ret == -1) { >>> + perror("Error adding watches[0]"); >>> + return -errno; >>> + } >>> + ret = ioctl(fd, COUNTER_ADD_WATCH_IOCTL, watches + 1); >>> + if (ret == -1) { >>> + perror("Error adding watches[1]"); >>> + return -errno; >>> + } >>> + ret = ioctl(fd, COUNTER_ENABLE_EVENTS_IOCTL); >>> + if (ret == -1) { >>> + perror("Error enabling events"); >>> + return -errno; >>> + } >>> + >>> + for (;;) { >>> + ret = read(fd, event_data, sizeof(event_data)); >>> + if (ret == -1) { >>> + perror("Failed to read event data"); >>> + return -errno; >>> + } >>> + >>> + if (ret != sizeof(event_data)) { >>> + fprintf(stderr, "Failed to read event data\n"); >>> + return -EIO; >>> + } >>> + >>> + printf("Timestamp 0: %llu\tCount 0: %llu\n" >>> + "Error Message 0: %s\n" >>> + "Timestamp 1: %llu\tCount 1: %llu\n" >>> + "Error Message 1: %s\n", >>> + (unsigned long long)event_data[0].timestamp, >>> + (unsigned long long)event_data[0].value, >>> + strerror(event_data[0].status), >>> + (unsigned long long)event_data[1].timestamp, >>> + (unsigned long long)event_data[1].value, >>> + strerror(event_data[1].status)); >>> + } >> >> Aren't the Count 0 and Count 1 events independent? Why should we expect to >> always get both events at the same time in the same order? > > Watch 0 and Watch 1 are both triggered by the same event: a > COUNTER_EVENT_INDEX event on device event channel 0. If we had set > channel to 1 for Watch 1, then we would have two independent events, but > in this case both Watches have their respective channel set to 0. The thing that jumped out to me is that they have different parents. But I guess I forgot that the event itself always has a scope of device and that the component just says what value to record and is otherwise independent of the event. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel