Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp2077344imm; Fri, 6 Jul 2018 11:24:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeyPtuK+07sV0C/gkvg/2u6hdkOb4q0ksazNsslBgDYs0Y6FmXCI3fEEClToHpVzFoQwUfX X-Received: by 2002:a63:743:: with SMTP id 64-v6mr10627726pgh.216.1530901494184; Fri, 06 Jul 2018 11:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530901494; cv=none; d=google.com; s=arc-20160816; b=le4Z/rQB39EDDU72Yj8QE+YwYCVhs+upQYyE/pIq1cZARYghrie+uS4IZehR9kIAlz ByZKw7okcm3DLbQgeUsNDJV9HH1+Qnt1k7ZDF7YFAAqojOO51+FfZMRvaTRq5IEZyHkj A0GiyP5VG9yUSp6nbY1SOyWxr+YnX0LKHRfkXrGr3HOyWhrYBjyf/EIZFqG/kEpAVBS/ 8rB0MzNLwSi937LOmtznJqCFoETVmIKSpShmYbBwrP4LDXmfhAHi+LQ/K0KnV7rJWqai +Obe3/w2fODNmdv1a4Jty76O/bltvAyIZf9uvqnhk7N6nBY7Vrof0zAP5jlqZJsSiUq/ aFNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Pa1vm1q+kkQVDnhcNRAsMvEX3GoIyMfiqpgNhPn01Qs=; b=yDE6ie5sTsbEaWmGJ2y19TYIqgUkbVx+vghy49OQW2Ih8XH4/urBeeww14gxRqc4E9 DQ6lwshZxTefGsN9B11afpEoh/InHFHd5QhDB3lBbXyqEn78/NGDm/lZYVRfOXtPEZaL gdV8hqaoRgdgMU63q6751eo191sO0VMxTJvEnw2d71o2C01VbsLYjxzhj57Ai2HMoNk4 1DhKJrcC57SqpVYoof/vVPMmpsL81tBxSbGISklRpMr2ef+uOJNE03wsFnBOLCl6zHAH tQGLEoWQugtwYzF+L65aWsoGYyJtZo4f63REcqmz7IaSrgPOhaPggZpS2U33CcMTqdJV aDzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=pWuoNb9C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g75-v6si5945105pfb.37.2018.07.06.11.24.39; Fri, 06 Jul 2018 11:24:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=pWuoNb9C; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934332AbeGFSXE (ORCPT + 99 others); Fri, 6 Jul 2018 14:23:04 -0400 Received: from vern.gendns.com ([206.190.152.46]:51321 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933999AbeGFSXD (ORCPT ); Fri, 6 Jul 2018 14:23:03 -0400 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=Pa1vm1q+kkQVDnhcNRAsMvEX3GoIyMfiqpgNhPn01Qs=; b=pWuoNb9CB7DjCgs/1+yV6j0jLb 5VE+4nOKzZVuwwrCTsMyRmM9uAqfgk6vtocbonBprM2Ox7N77tCPQOjTS9KTrYT4LehGBkh3EHD4Q dm7NcGAi3g9RsMDZJUb3JDIuUhUx5uVyP4JkAEJ3G681a89T6o1su3vfpqQbg1t6xn5C0JXP2MDYi D15r7/ozy8mle3PO2YNnOjCuvZc2Zv+2O8lYxobtzTvAyuI4S951HkgLw5PRa0WIt/6dtwFIvFdBk pOUTBHTLWaKZHE6JWxSWVV9Dpk/ROeaAyOt2sxjPIJFSUkkEs2l7Za3QnbCFREp+58cZKVoPnvyZD S3SM/V8Q==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:37140 helo=[192.168.0.134]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1fbVNk-00BUi0-7O; Fri, 06 Jul 2018 14:23:00 -0400 Subject: Re: [PATCH v7 00/10] Introduce the Counter subsystem To: Jonathan Cameron , William Breathitt Gray Cc: gregkh@linuxfoundation.org, jic23@kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, fabrice.gasnier@st.com, benjamin.gaignard@st.com, robh+dt@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, mark.rutland@arm.com References: <603b0373-f1e1-5938-fa53-8328c9a5964f@lechnology.com> <20180703024835.GA9493@sophia> <20180706182154.0000002d@huawei.com> From: David Lechner Message-ID: <59b0950e-ef39-4ad4-a32b-316992e1f236@lechnology.com> Date: Fri, 6 Jul 2018 13:22:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180706182154.0000002d@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 - vger.kernel.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: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/06/2018 12:21 PM, Jonathan Cameron wrote: > On Mon, 2 Jul 2018 22:48:35 -0400 > William Breathitt Gray wrote: > >> On Mon, Jul 02, 2018 at 01:13:40PM -0500, David Lechner wrote: >>> On 06/21/2018 04:06 PM, William Breathitt Gray wrote: >>>> I decided to strip down these devices to arrive at the core essence of >>>> what constitutes a "counter device" and therefore design a "generic >>>> counter" abstraction to better represent these devices and prevent the >>>> ambiguity we discovered with the existing IIO Counter interface. This >>>> abstraction became the Generic Counter paradigm, which is explained in >>>> detail within the Documentation/driver-api/generic-counter.rst file >>>> introduced by this patchset. >>> >>> I'm curious if you have given any thought to the time aspect of counters. >>> I am interested in the rate at which the counters are counting (e.g. how >>> many counts per second). I realize that you can calculate this in >>> userspace or in the kernel using the system timer, but it is not very >>> accurate since Linux is not a realtime OS. So, I would like to get the >>> rate directly from the hardware. For example, the TI eQEP[1], like the >>> one found in BeagleBones, has a couple ways of measuring time (see link >>> for details). >>> >>> [1]: http://www.ti.com/lit/ug/sprug05a/sprug05a.pdf > > Cool in eQEP if that is what you are targetting - been wanting to see > nice kernel support implemented for that for a long time, but never > got the spare cycles to do it myself! > >> >> Ah yes, I see you initially attempted adding a frequency channel type to >> the IIO code. I agree with you that this calculation is best kept away >> from the operating system, not just because of the realtime requirement >> considerations, but also because the hardware likely knows best its own >> data, so let's expose it! >> >> Regarding the Generic Counter interface, a frequency attribute can be >> added quite easily in a technical sense, so this discussion should be >> focused more on the warrant for exposing this data. I understand from >> the discussion thread on your initial patch submission that you're >> working with hot-swappable encoder wheels and would like to expose a >> counting rate since you have trouble otherwise knowing the number of >> counts equal to one revolution due to the various possible encoder >> wheels that could be installed -- do I understand this correctly? >> >> Luckily the Generic Counter interface is a more abstract paradigm, so >> the hot-swappable encoder wheels should not be a problem for us as long >> as we nail down a consistent and thorough definition for this attribute. >> To that end, since the Generic Counter paradigm is designed to abstract >> away specifics of counter devices in order to present the final data of >> interest to users (e.g. the count value, the mode of operation, etc.), >> let's make sure frequency is actually what we want to expose and not >> just a middle-step datum on the path to the final result. >> >> What is the real life use-case for this information (are you tracking >> position)? We are attempting to control the speed of the motors well enough to make a balancing (inverted pendulum) robot and also synchronize two motors when driving a robot (e.g. if one gets "stuck", the other slows down and waits for the first to catch up). >> Does the relevant hardware report the number of counts equal >> to one revolution, or are you calculating this from frequency? Not exactly. For the most part, the motors are the same, so we assume that as default, but have a way for changing the parameters from userspace. >> Are you >> using this frequency to simply track the number of revolutions? No, we are using it to calculate the rotational speed of the motor. >> Should >> revolution count also be exposed? I don't think so. The raw count value is good enough. >> Is frequency useful for other >> applications on its own (perhaps velocity of an automobile device >> equipped with an encoder wheel for some reason or other)? Since we are just dealing with counters here, I think we should call it "rate" instead of "frequency". At least that seems to be the common name in industrial automation. Another possible use case for "rate" would be flow meters. Some flow meters generate a pulse every X gallons. Assuming that the counter also has a rate output, then you can scale the rate (e.g. counts/second) into flow in gallons per minute. >> >> Once we figure out how this data is used, we can determine the best >> design and place to introduce it into the Generic Counter interface, >> then move on to integration from there. > > Great - as long as this fits reasonably well in ABI wise (whatever the > details) sounds like we don't need to solve it today. I'm anxious not > to delay merging this counter subsystem for another cycle. Certainly don't delay things on account of me. I'm just trying to get a feel for where things are headed since I missed the earlier discussions. I don't see any major problems with the current state of things. Once this lands, I may have a go at the eQEP and see how it looks.