Received: by 10.223.148.5 with SMTP id 5csp6947050wrq; Wed, 17 Jan 2018 22:14:45 -0800 (PST) X-Google-Smtp-Source: ACJfBouXJrGJnB+4Eih7q7HJXuUvlFUU1h/EoPyFb9j18K2vRpyEcnJgV90APIkLUGclAwwFcwsq X-Received: by 10.99.5.69 with SMTP id 66mr28167462pgf.80.1516256085212; Wed, 17 Jan 2018 22:14:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516256085; cv=none; d=google.com; s=arc-20160816; b=eS/EI5Csm102TYT8BEcnkfHGlciVscw16NWdat5UWvmEtrAeU4B3rZ5RDZl68V+UDq 1tpwXeHijX3e5zqgTrXjOpJQ/zE6mATrpPeCjwr1wHA/D1Sjux9jgFTSPhNyvXFCj0u5 a+0qLpzObNZ8U2NfE3tHogS3TRTNr8Xgne0UNtsKPBIeawzYCSDTfnkA0VgYG/GgKed1 DqkzhWbqdp/anU0lvvt7PqzURIk2/GVM5CeoSzgCIp9teQZbi7+EroSYtmMY4aBzhwfL LX7lMIuuQ5nYYeMVkP8+4IGWNIyOFIcMLj/HDMhQ3DYR+PHRxKPCH212Oc5BW5LtsO5U tNAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=MFYwozPxJuUKvNOmkmIhpMsmztbpwRc8/fgdhBSQ9kY=; b=L2Ylpg4WjJUw7F0RvFdZ2rYPH3Kw5HH1yxq4ZlUpJ7P0w1fhcYWNcx71iQ3BxNhaQz o0IEkbsA7F1VS6YnKVbXZ24u0EA+WtOfJ5x0hvpS/yIXq9RSOarqpfDz4wKWmt0efouK wyWaTG96ndndlaEijEtCghsE1uE5cDrDbm0E4AnUEKNmLwnz6Qo970VhlW53Mng/ApcQ Xj4ol0ARLinI3VNjNsn7klh0L9+diPQTqXalmu+CpGS7EUHdYeg99vWjO5qq0yufBeRW YnxLN8wyMVrvIGA7dApDJz+H4SStqnwoF76rwDldE0PyquLe8cvLbZjlojHHsvJpCLHe 1IRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Zii9UMmm; 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 z1si6334260pll.427.2018.01.17.22.14.30; Wed, 17 Jan 2018 22:14:45 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=Zii9UMmm; 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 S1754098AbeARGOG (ORCPT + 99 others); Thu, 18 Jan 2018 01:14:06 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34156 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbeARGOE (ORCPT ); Thu, 18 Jan 2018 01:14:04 -0500 Received: by mail-pf0-f176.google.com with SMTP id e76so13576099pfk.1; Wed, 17 Jan 2018 22:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MFYwozPxJuUKvNOmkmIhpMsmztbpwRc8/fgdhBSQ9kY=; b=Zii9UMmmwyXCUnKFs/Y6y7FAIQ5WI2kDDnzYuDY9x5OQn3TLB9CMkSUwamrrbTugRE odSjOB7YYfD3cYCPRm5jcp5t44DZGqZPiXCqeut2moeuCsbeEi89/+DYB/zAl8IHSC42 iB90DASAaPKN8RO7yNZKjytw6dMgwW/56lE+ekIA2Cl7NGkC7XER9uESQAJAIUB2sl00 D7GJsyk8AKvfUXgpnuTlJaEcBlQP0740gJ26vHfVRiQ8cdQEWIl9c1JKmFsWJodp3/1U pe3EtgW4U9c7s0M4XaLLPArLlydG0EeI5ZopGnVIn59aMQ21LGkrGEzwyqCL2qOTtvVp n0rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=MFYwozPxJuUKvNOmkmIhpMsmztbpwRc8/fgdhBSQ9kY=; b=nSTu//um4SNdeBQt/+rNNfKHFZzu6lZAgpivPND9RbUPyyityWpuwahIb1vs9ZSfTj Z6tTfH8dAtvKjQFhjCqC1ANaX0WU4NMso62dYt3AnuIROCKNNozk+rEDl6+vEwiHtX5W nABBGUkDaYFzi7rhDU0XsjAk7wGRXSY14SwYFSmaBPqCNFkqS54AT6IqlomrXZefcyq1 m1oFdzgS4hkzJHoO8EWcYbsAF0JToMhJ5qBqYNXLcBRIWT3f+ZgRj9nfT4phxCfG8prh nwRgdcPlVMaNxLidoAVMaz7w3eSqafNvy3b0oyn8dK8K/kna/ddhvSR4n336hEZT43oG xrvg== X-Gm-Message-State: AKwxytcgeoqzQe3i4wo6kXCkdxj8+ku9r/MiId2Ko/YsyFujAQEZ7Fy0 IeVcvz0fhOp0LRvrOlOLyOg= X-Received: by 10.99.147.70 with SMTP id w6mr184680pgm.410.1516256043522; Wed, 17 Jan 2018 22:14:03 -0800 (PST) Received: from pi.iht.com.au ([203.87.124.230]) by smtp.gmail.com with ESMTPSA id b68sm8978105pfg.159.2018.01.17.22.14.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 22:14:00 -0800 (PST) X-Google-Original-Sender: Received: from johan by pi.iht.com.au with local (Exim 4.89) (envelope-from ) id 1ec3Rq-0007O3-Ur; Thu, 18 Jan 2018 17:13:14 +1100 Date: Thu, 18 Jan 2018 17:13:14 +1100 From: Johan Hovold To: "H. Nikolaus Schaller" Cc: Johan Hovold , Mark Rutland , DTML , Discussions about the Letux Kernel , Arnd Bergmann , Tony Lindgren , Greg Kroah-Hartman , kernel@pyra-handheld.com, Russell King , Linux Kernel Mailing List , linux-omap , Rob Herring , Linux ARM , =?iso-8859-1?Q?Beno=EEt?= Cousson , Kevin Hilman , Andreas Kemnade , Thierry Reding , Andreas =?iso-8859-1?Q?F=E4rber?= , Jonathan Cameron Subject: Re: [PATCH v5 3/5] misc serdev: Add w2sg0004 (gps receiver) power control driver Message-ID: <20180118061314.GG3286@localhost> References: <5494ad34b39a6c62601e3747440268dfb3be7d5a.1512114576.git.hns@goldelico.com> <20171222124427.GI3374@localhost> <91850CC3-B280-4701-9D07-96AFF3A79A6F@goldelico.com> <90F9A8E4-035A-4A9E-8AAB-757491D63E69@goldelico.com> <20180112153903.GB5992@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 12, 2018 at 06:59:59PM +0100, H. Nikolaus Schaller wrote: > Hi Johan, > > > Am 12.01.2018 um 16:39 schrieb Johan Hovold : > > > >> Let's restart this discussion and focus on the main roadblock (others > >> are minor details which can be sorted out later). > >> > >> If it feels like a hack, the key issue seems to me to be the choice of > >> the API to present the GPS data to user space. Right? > > > > Or even more fundamentally, does this belong in the kernel at all? > > Yes, that can be questioned of course. It was questioned and discussed > several times and I thought the answer was a clear yes. But let's reiterate. > > > Also it seems at least part of your specific problem is that you have > > failed to wire up the WAKEUP pin of the W2SG0004/84 properly, > > The w2sg0004 has no wakeup pin. At least I can't find one in the data sheet. I should have said w2sg0084 above, which is the only datasheet I have found. > The two pins you refer to from the 0084 data sheet are called BootSelect0/1 > in the 0004 and have a different function. > > To be clear, we did not fail to wire it up. We did the design before the > 0084 was announced and available. We just had to swap in the 0084 into > existing PCBs during production because the 0004 became EOL. Otherwise > we would probably still use the 0004 without WAKEUP output. > > To make it worse, we have no documentation for an individual board if > an 0004 or 0084 chip is installed and there is no means how a software > can find out which one it is talking to (especially before properly > powering on). Therefore we can not even provide two different device > trees or drivers or whatever, unless we ask people to open their device > and look on the chip. Quite crazy wrt. user-friendlyness of software > installation in 2018... > > Therefore, a driver must be capable to handle both chips in the same way, > with minimalistic assumptions, even if the 0084 could provide a direct > signal to make it easier than using serdev to monitor the data stream. Fair enough. > > which then > > forces you to look at the data stream to determine the power state of > > the chip. Judging from a quick look at the GTA04 schematics it seems > > you've even connected the WAKEUP output to the 1V8_OUT output?! > > No. You failed to see that this is an optional 0R, which is not installed. > The 0R on pin 7 (BootSelect1) to GND was removed when we did switch from > 0004 to 0084. Pin 6 (BootSelect0/WAKEUP) was never connected. Ok. > > The kernel is probably not the place to be working around issues like > > that, > > even if serdev at least allows for such hacks to be fairly > > isolated in drivers (unlike some of the earlier proposals touching core > > code). > > Please tell me why there are so many hacks for hardware issues in certain > drivers. Any why those are good and this one (if it is one at all) is not. Hacks are never good, but sometimes needed. But we should try to keep them contained in drivers rather than allow them to spread to core code, was what I was trying to say above. > What I can learn from your discussion is that it might be considerable > to add an optional gpio for the 0084 WAKEUP and add some logic to > support users who have or will have that pin connected. > > But even then we would need a driver to handle this gpio and issue > an on/off impulse on the other to switch states. It would be a different > driver (variant - maybe some CONFIG option or handled by code), but not > "no driver". Having a WAKEUP signal would allow for a more straight-forward implementation, be it in the kernel or in user space. > >> I see three reasonable options how this presentation can be done: > >> > >> 1. char device > >> 2. tty device > >> 3. some new gps interface API (similar to network, bluetooth interfaces) > >> 4. no driver and use the UART tty directly > >> > >> Pros and cons: > > > >> 4. no driver and use UART directly > >> + a non-solution seems to be attractive > >> - must turn on/off chip by gpio hacks from user-space > > > > I'm not sure that would amount to more of hack then doing it in the > > kernel would. > > It might not be big effort in the user-space code/scripts. > > But much effort to convince all the plethora of user-space client maintainers > to integrate something. And have them roll out. And have distributions take it. > And have users upgrade to it. 5 years later... > > Do you think it is easier to convince them than you? They usually assume a > power management issue should be solved by the kernel driver. > > That is what Andreas did remark as motivation: provide a solution > for *existing* user spaces. I understand that this is what you want, but that in itself is not a sufficient reason to put something in the kernel. > >> - can not guarantee (!) to power off the chip if the last user-space > >> process using it is killed (which is essential for power-management of > >> a handheld, battery operated device) > > > > That depends on how you implement things (extending gpsd, wrapper > > script, pty daemon, ...). > > No. You can of course cover all standard cases but there is one fundamental > issue which is IMHO a problem of any user-space implementation: > > How can you guarantee that the chip is powered off if no > user-space process is using it or if the last process doing > this is killed by *whatever* reason? > > E.g. after a kill -9. Or if someone deinstalls gpsd or whatever and assumes > (and wants a guarantee) that GPS is now turned off and never turned on drawing > precious milliamps from the battery for no use. Have something run at init to put the device in a low power state. > As it is well known, a user-space process can't protect itself against kill -9. > Or has this recently been changed and I am not aware of? > > This is the fundamental reason why we need a kernel driver to provide > reliable, repeatable and trustable power management of this chip. > > It is equally fundamental as a hard disk should spin down after the last > file is closed. Even if this process ends by a kill -9. > > A second almost equally fundamental aspect to be considered is how you want > to automatically and reliably turn off the chip by pure user-space code when > entering suspend. Suspend is initiated by user space, so just power down the device before doing so. > >> If not, I want to suggest to accept the second-best choice 2. for now and we > >> will update the driver as soon as 3. appears. IMHO it would be a good test case > >> for a new subsystem. > > > > Getting the interface right from the start is quite important, as > > otherwise we may end up having to support a superseded one for a long > > time. > > This seems to contradict your argument that user-space can very easily > adapt to everything. If the latter were true there would be no need to > keep old interfaces supported for a long time. You probably know that we try hard never to change an interface that would break user space, and that's why we need to get it right. > So can you agree to that a battery powered portable device must have > reliable and trustable power management? And if it provable can't be > implemented in user-space (a single counter example suffices) it must > be a kernel driver? Having a kernel driver would make things easier for user space, sure, but again, that's not a sufficient reason to merge just any kernel implementation. Johan