Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp345882imu; Thu, 8 Nov 2018 03:00:06 -0800 (PST) X-Google-Smtp-Source: AJdET5ezlaHhDRzwIB8wSGtviZm14dIoggIdPRe/GapCrQWhRH7BtatlqNsXrVqBsaznbocTJ1HS X-Received: by 2002:a17:902:30f:: with SMTP id 15-v6mr4088733pld.155.1541674806414; Thu, 08 Nov 2018 03:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541674806; cv=none; d=google.com; s=arc-20160816; b=XMmtFV574ez5rmhd2y8KJMbf+Wht7lBhOul7GlNf0iHw0PJZLLhiEem1XAyJQufit6 GHv7xtC517Xic/lYemUDDmNL3kxr5PpOEp0Rra1itnk+JAcgjpsm0ogRjdmZ0qo8mmcC u1+jN27cixQi9YIjtCnYk2UJ5FEl++HULHYwAm3ATONjIvPN7DOgfZUyjS3/QhiwKX1+ SyH8jMF41gHnaoLxgtmOlwUs2G049eG1U/i1BOPeURzVOpTZM84hTK7uZgb6+3gooG8P vLltXqxB/JqhL4J6ZITvhjugQaJGJaBy69P0bB5nro7z4EVgvkEwEsjRvpIgW4PdJcfi iqEA== 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=iVTxM1mKE7ZhyVlFnb5nvAoe0kjgIYYogeZnR3frdnQ=; b=uNIJF0Qx9YHR46mGXpwLn7oAKFwM5wqsVxbpHOUY9lW3szBoe8TfXwSaQ3sJfpjk70 V5w8SMff4tERYvWc0Y15+rMlUJFXiM6yNe40/pXanMayDrsaWdfiHdwxQmOfdr8tO1fq 9ldB/SjHPJqEAXa3MzgfQNThpXSgnKsBk+PPUp2XatA17TdRkclYbEmTMexfJXrmv3lp 4Mk1qjtPIKJB+n5rzvccEv1zaTCImhM8PANuF+eNnqhw/z2J7Iy03zFRqcj4HWVfB+Cu s/sf9VloQeweCzVRxAPsCDizCUxIfc3r/uyr8LmXHuzbYsHNbN5jN5j5GQhi/smuJHxk uNeA== 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 y207-v6si3929191pfb.59.2018.11.08.02.59.50; Thu, 08 Nov 2018 03:00:06 -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; 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 S1727180AbeKHUeU (ORCPT + 99 others); Thu, 8 Nov 2018 15:34:20 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:57103 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbeKHUeU (ORCPT ); Thu, 8 Nov 2018 15:34:20 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKi1z-0007QT-5y; Thu, 08 Nov 2018 11:59:23 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gKi1y-0006IZ-M2; Thu, 08 Nov 2018 11:59:22 +0100 Date: Thu, 8 Nov 2018 11:59:22 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: =?iso-8859-1?Q?Cl=E9ment_P=E9ron?= Cc: Thierry Reding , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, Suji Velupillai , Tim Kryger Subject: Re: [PATCH 2/2] pwm: bcm-kona: apply pwm settings on enable Message-ID: <20181108105922.p557jxrebjlhnsho@pengutronix.de> References: <20181107093613.26734-1-peron.clem@gmail.com> <20181107093613.26734-2-peron.clem@gmail.com> <20181107162908.tejzekhc35pbknut@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::c0 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 Hello, adding Tim Kryger as the initial author of the bcm-kona driver to Cc:. Maybe he can shed some light to the questions below? On Thu, Nov 08, 2018 at 11:47:17AM +0100, Cl?ment P?ron wrote: > On Wed, 7 Nov 2018 at 17:29, Uwe Kleine-K?nig > wrote: > > On Wed, Nov 07, 2018 at 10:36:13AM +0100, Cl?ment P?ron wrote: > > > From: Suji Velupillai > > > > > > When pwm_bl framework calls enable, a call to pwm_is_enabled(pwm) still > > > return false, this prevents the backlight being turn on at boot time. > > > > > > Signed-off-by: Suji Velupillai > > > Signed-off-by: Cl?ment P?ron > > > --- > > > drivers/pwm/pwm-bcm-kona.c | 16 +++++++++++----- > > > 1 file changed, 11 insertions(+), 5 deletions(-) > > > > > > diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c > > > index 09a95aeb3a70..d991d53c4b38 100644 > > > --- a/drivers/pwm/pwm-bcm-kona.c > > > +++ b/drivers/pwm/pwm-bcm-kona.c > > > @@ -108,8 +108,8 @@ static void kona_pwmc_apply_settings(struct kona_pwmc *kp, unsigned int chan) > > > ndelay(400); > > > } > > > > > > -static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > > > - int duty_ns, int period_ns) > > > +static int __pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > > > + int duty_ns, int period_ns, bool pwmc_enabled) > > > { > > > struct kona_pwmc *kp = to_kona_pwmc(chip); > > > u64 val, div, rate; > > > @@ -155,7 +155,7 @@ static int kona_pwmc_config(struct pwm_chip *chip, struct pwm_device *pwm, > > > * always calculated above to ensure the new values are > > > * validated immediately instead of on enable. > > > */ > > > - if (pwm_is_enabled(pwm)) { > > > + if (pwm_is_enabled(pwm) || pwmc_enabled) { > > > > Having pwm-API-calls in hw-drivers is ugly. Apart from not giving the > > intended return code this function should IMHO be reserved to pwm > > consumers. The underlaying problem is that pwm-bl does: > > > > pwm_config(pwm, duty_cycle, period); > > pwm_enable(pwm); > > > > and expects that the duty_cycle and period is used then. Doesn't > > everything works just fine if the if-block is always executed? > > Tested and works fine for me. But I only have a Cygnus proc. > Maybe there is some issue with Kona as explained by the comment (even > if I don't understand it well). > > * Don't apply settings if disabled. The period and duty cycle are > * always calculated above to ensure the new values are > * validated immediately instead of on enable. I wouldn't understand that as "If you apply settings on a disabled PWM a kitten dies". I think it only means: At the current point in time duty_cycle and period are not important as the hardware is off. So don't bother to write these values to the hardware. @Tim: Do you think (or can test if) there is a problem when doing - if (pwm_is_enabled(pwm)) { + if (1) { in kona_pwmc_config? (For sure the comment needs adaption and the if (1) shouldn't make it into the driver, just used that as shorthand for the change I want to suggest.) But still better than dropping the check is to convert the driver to the atomic API. With that this problem would simply not occur. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |