Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp752370yba; Sun, 31 Mar 2019 11:48:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqL8abCd71TLG/G4FtTjYh8s+8GpLT+s8KRywm1utDp54Q7QijYj2JMHC3cB4S+AcOrOia X-Received: by 2002:a63:36ce:: with SMTP id d197mr7529365pga.180.1554058104056; Sun, 31 Mar 2019 11:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554058104; cv=none; d=google.com; s=arc-20160816; b=km8rfg2fDS3GqQAwmevKxfuiqHZ5RErQbUMkrfwjxExEHSBy0l2uF+wZ9lr7oDMp3J uDgqOr3xZUeQoGZgxsOs2zsso7x5tfvEfOiYfC8cvvrnvbY4N3CWQKd/MHYbGPLuY5Qm /xCJMMARODnFU4ewsiz4VYjC5pZ1RD5k8hzqlrVpKM6ffWBmJQuw/MlsCwdYl2XwzzA+ 14kiOtkbm/wpD8ELrJGwR3bwHZeCmTZvHJs7kSkn4H7a+fxRw/rL1j1QbzHHnJkA5nPH uYPNmABLPhCtg3H6plC9BWGGaRiyncLo8ExGvEv0rxDnpw7HmX7Vgo5nPPXGdkUNXNcX 2jsw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=jyU0WEMq/7Kq+a9fJMxpBnxkczURpEILtZqSQshysoU=; b=zin3SVfXP1V+d+QCqfC5iTH27FUyw9kuoaVVgoQhHzEtld+HGxpd5aYECklugV8UKg 6t6YRGITi/F7SdLNQas9HvuXLptmhWayfN26OjDj2KoKLwN5UQTcUyp98fZTuyjgC7rq Prk8KrZXXh8cEbCgBqM59XVdOpwx4U7uC3hNMZx6bC9+JqC7z50an7iOnW5lICuTQ6/w j9JBxWlBzQPsGIQ6C7wamxyzTFy8HldxjBn+Qplj+9rdCXmhrqEojxaAEuF7/Ug2p7uo n2usanWCiZe3tacIefXHOXoV9qTP5bcGGTawIxWS3buWwcge6J03Lc0staoxIKNvUupU GKLw== ARC-Authentication-Results: i=1; mx.google.com; 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 c10si6844960plo.216.2019.03.31.11.48.08; Sun, 31 Mar 2019 11:48:24 -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; 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 S1731353AbfCaSrd (ORCPT + 99 others); Sun, 31 Mar 2019 14:47:33 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:34881 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731241AbfCaSrd (ORCPT ); Sun, 31 Mar 2019 14:47:33 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hAfUR-0007FK-3o; Sun, 31 Mar 2019 20:47:31 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1hAfUQ-0001eS-E9; Sun, 31 Mar 2019 20:47:30 +0200 Date: Sun, 31 Mar 2019 20:47:30 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Martin Blumenstingl Cc: linux-pwm@vger.kernel.org, Neil Armstrong , linux-kernel@vger.kernel.org, thierry.reding@gmail.com, kernel@pengutronix.de, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, jbrunet@baylibre.com Subject: Re: [PATCH 0/1] pwm: meson: fix scheduling while atomic issue Message-ID: <20190331184730.y767dxhblffxj3om@pengutronix.de> References: <20190324220217.15813-1-martin.blumenstingl@googlemail.com> <20190325084153.l44pzfewcqlkoaoe@pengutronix.de> <20190325200730.cx73jgxfexz6ybzq@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 30, 2019 at 08:29:35PM +0100, Martin Blumenstingl wrote: > Hello Uwe, > > On Mon, Mar 25, 2019 at 9:07 PM Uwe Kleine-K?nig > wrote: > [...] > > > > - Does stopping the PWM (i.e. clearing MISC_{A,B}_EN in the MISC_AB > > > > register) freeze the output, or is the currently running period > > > > completed first? (The latter is the right behaviour.) > > > I don't know, I would have to measure this with a logic analyzer. > > > > In practise you can do this with a multimeter, too. Just do something > > like: > > > > pwm_apply_state({ .enabled = true, .period = 5s, .duty_cycle = 5s, .polarity = PWM_POLARITY_NORMAL }); > > pwm_apply_state({ .enabled = false, .period = 5s, .duty_cycle = 5s, .polarity = PWM_POLARITY_NORMAL }); > > > > (assuming the PWM supports periods that long). The expectation is that > > the last command takes nearly 5 s to complete and while it waits the > > output is high and on return it's low. If that isn't the case, there is > > a bug somewhere. > the longest supported period (using the 24MHz crystal as input, which > is the slowest input clock and thus gives the longest possible > duration) is 349514407ns (that's approx. 0.35 seconds). my multimeter > isn't fast enough to measure this so I'm using my logic analyzer with > puleseview instead: [0] > > I added the following code to meson_pwm_request: > struct pwm_state enable = { > .enabled = true, > .period = 349514407U, > .duty_cycle = 349514407U, > .polarity = PWM_POLARITY_NORMAL }; > struct pwm_state disable = { > .enabled = false, > .period = 349514407U, > .duty_cycle = 349514407U, > .polarity = PWM_POLARITY_NORMAL }; > pwm_apply_state(pwm, &enable); > pwm_apply_state(pwm, &disable); > > this returns immediately. my logic analyzer doesn't see signal change > (I'm sampling at 1MHz). > > can you please confirm that my test code and measurement procedure is correct? > if it is then my observation is that disabling the PWM does so > immediately, without waiting for the current period to complete Ack, with the above two pwm_apply_state the output must be high when the first pwm_apply_state returns. Then it must stay high for n * 349514407 ns (for an natural n >= 1) and then go low. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |