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.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 BFDB4C55189 for ; Wed, 22 Apr 2020 08:40:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91A88206B9 for ; Wed, 22 Apr 2020 08:40:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=pascalroeleven.nl header.i=@pascalroeleven.nl header.b="Ki4mBfA7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726409AbgDVIka (ORCPT ); Wed, 22 Apr 2020 04:40:30 -0400 Received: from web0081.zxcs.nl ([185.104.29.10]:41424 "EHLO web0081.zxcs.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726552AbgDVIk1 (ORCPT ); Wed, 22 Apr 2020 04:40:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pascalroeleven.nl; s=x; h=Message-ID:References:In-Reply-To:Subject:Cc:To: From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version: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=vpGUfuTiVLd2vA91ue4c0K9V/4VZKL+mbW8WcjO/LrA=; b=Ki4mBfA7ZnNAsIT4ktrRzJONzz qGcH4XX8vK9hT0WegeJHXHi9GvfaTzDrFsGGzgrIGxVbAd1awjUtXZFs+hVnKXbXeoLyFQr5KtIhP xlYu37mmaPdqJlz6jaJwzzlIzXOseOphSdyN+fY8h8JEb9IvKQLpMTBV59EIQdTAuW734Vupni4Ew UDtTt1uueJRAdHdKXCAh2bm8uKhnnhxF2mqQyggxYa3shekii9sWDk8UbiHKGeVw2RoqY2QbFUydF O5qgvGJ81fO9ehCniBZrn1P3xFqFjxgkMcwboDpUly3hRVJ2fFevFnkoLglHEQefQwj65hHLEFFDb lkr/7p3w==; Received: from spamrelay.zxcs.nl ([185.104.28.12]:50258 helo=mail-slave01.zxcs.nl) by web0081.zxcs.nl with esmtp (Exim 4.93.0.4) (envelope-from ) id 1jRAvU-002uIq-5s; Wed, 22 Apr 2020 10:40:12 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 22 Apr 2020 10:40:11 +0200 From: Pascal Roeleven To: Samuel Holland Cc: Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K?= =?UTF-8?Q?=C3=B6nig?= , Maxime Ripard , Chen-Yu Tsai , Philipp Zabel , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [linux-sunxi] [RFC PATCH 4/4] pwm: sun4i: Delay after writing the period In-Reply-To: References: <20200317155906.31288-1-dev@pascalroeleven.nl> <20200317155906.31288-5-dev@pascalroeleven.nl> User-Agent: Roundcube Webmail/1.4.2 Message-ID: X-Sender: dev@pascalroeleven.nl Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-22 05:43, Samuel Holland wrote: > Hello Pascal, > > On 3/17/20 10:59 AM, Pascal Roeleven wrote: >> When disabling, ensure the period write is complete before continuing. >> This fixes an issue on some devices when the write isn't complete >> before >> the panel is turned off but the clock gate is still on. >> >> Signed-off-by: Pascal Roeleven >> --- >> drivers/pwm/pwm-sun4i.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c >> index a11d00f96..75250fd4c 100644 >> --- a/drivers/pwm/pwm-sun4i.c >> +++ b/drivers/pwm/pwm-sun4i.c >> @@ -299,6 +299,10 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, >> struct pwm_device *pwm, >> sun4i_pwm_writel(sun4i_pwm, val, PWM_CH_PRD(pwm->hwpwm)); >> next_period = jiffies + usecs_to_jiffies(cstate.period / 1000 + 1); >> >> + /* When disabling, make sure the period register is written first */ >> + if (!state->enabled && cstate.enabled) >> + sun4i_pwm_wait(next_period); >> + > > It is not visible from the context of this patch, but this call to > sun4i_pwm_wait() ends up calling msleep() inside a spinlock, which > isn't > allowed. The spinlock should probably be converted to a mutex, > considering that > sun4i_pwm_apply() already sleeps and takes mutexes. > > Regards, > Samuel > Yes you're right. A different implementation of this patch series is being worked on, in which I'll take this into account. Unfortunately I have other things to work on at the moment, so it might take a while. Regards, Pascal