Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp274356ybz; Tue, 21 Apr 2020 20:44:56 -0700 (PDT) X-Google-Smtp-Source: APiQypLqyRWu48Kc8yr4RCrAdsBGX5c/98/7h+bTsMOTyDAtuafw+IV9D+8IpjOnqOG0t2WB0/13 X-Received: by 2002:a05:6402:b4c:: with SMTP id bx12mr14970750edb.247.1587527096823; Tue, 21 Apr 2020 20:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587527096; cv=none; d=google.com; s=arc-20160816; b=Q0t7Vo7YdXesQkEsCe+j0sMsgurojKCqwtiGlboqT1vqXS0gR7fPsJPj0+X6kazLxY 1iAQW8UWmX9Kqf/FgwwwoVmJv/D79P+ec3fR5xepzvVb44mkhn5Vx1wvfDiebBCVV1Am X/fxWjqYn4CG3A0ssdfK4T8T1ufXsfjDDae1yun4GBxyYkrWgawouLMh/UM8TsHbeoNk bsNCkXF1vu22EoxksgWm2Y/S3eFMbxe5xXlfpFDVAbF5YIjZ8gfCa4N2cIVDEw6qshCD UjiTbxw3fpm3CMPjmbpwhyzKcjuzM/i+1nE+TfvZsrcyO6ko0GUGu20F9B4ryWY8HnFt g3oQ== 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 :dkim-signature; bh=2pJX7Yg+sQ/AyYD6L8gjHh63yS93sxWkwLxkCvnI+ek=; b=NSJHdCOH8c5dlwBsoG92rTK3yPyVMSMzkL15owORBDPxV1Ld09xj8sGdo3KQl1DwNm vyMtp/jPmtf2sRUmpf4SYzRNxPBCQ75OHHa2/+fDG9DKWhbsa0Vpl+FUcFUuElPXi8Ht yDwGMjUiwgMsDJPQXhz+VLTr2iqAQf6UKwIXeahpaVDQ0bHxc8Jeylte7ABlmv9szuta VsOz002ZIdFPE1aFx00m5q1pmE8O0anf+4iXTAmhYI0fDfsDKniF7JNJtc1Fk/iis/jq SfZY50Tt9kHs37qLyXSQnFKeWwx4yIM+WuaSSZUpNLvesM/bE9IyBzxPAI3IUKR60+i3 QKsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b="SUr/qn7f"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=pEDjSUE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rp4si2927913ejb.205.2020.04.21.20.44.33; Tue, 21 Apr 2020 20:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm2 header.b="SUr/qn7f"; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=pEDjSUE1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgDVDnl (ORCPT + 99 others); Tue, 21 Apr 2020 23:43:41 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:54909 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726294AbgDVDnl (ORCPT ); Tue, 21 Apr 2020 23:43:41 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 12B025C008C; Tue, 21 Apr 2020 23:43:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 21 Apr 2020 23:43:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=2 pJX7Yg+sQ/AyYD6L8gjHh63yS93sxWkwLxkCvnI+ek=; b=SUr/qn7fhubwORw6r 1SR1sDofmVTFUbL2y0aluMDxkSGyAp1JV9NqfoBrmMZEAev+b7/MxxOFbt9w7orK lUq1CGofBI93ZRVKcgJ0X+4czDPtNhntXkWz8azKX7Mq34PtY5GwhgB5ukVTSO94 y83SC6XxnrVsNt9vxoD0DxbwdLOlh0sCGhrxFY/6qndn1uecSkUStY1AxkcH4esY PlxOjFHQVsEytDwCu8IWG8jKNOrRARJ2zU5t+hjIj8OItQZMXbQFKn3959Lf3Knx 7NOxuYQJFsPR8K5mNS4FBrYiKQn/wGSggYfQNHatsjiCLcFFeLXGnjbHJl+XMnTO C6USw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=2pJX7Yg+sQ/AyYD6L8gjHh63yS93sxWkwLxkCvnI+ ek=; b=pEDjSUE1KhTlyS+psV8vjg4C1Tyf6w6G+iTzSvAiQ1Pu/GPPmA/Wpxju4 SkMwqtzAf4viQKZBKvxTYN4EuXT+Kz2lzCCMt74s04/G8tW0aLfqCryiy6/J1WUC yuCprfcsr9Hh7Bye9JhgzEv6qBx3QjMNBq6u31+5pPVLuqr5rKJZC1VzSFv8cI4q SgJ9wc8ZU5DkTJzQ39hfI9feYy2RTSQ4g8VIYx3kQe6lXOAjvSd/fwQECz8B+q2y mWVGYHwM6jkRumlYmRu3/1QFHITmhvBnueLN19+NXkSWmXEwprHM8zpsZ125KPy7 Gv48rfuu8YIG63gWjkYU+IoTsWqGg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrgeeigdejfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucfkph epjedtrddufeehrddugeekrdduhedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Received: from [192.168.50.169] (70-135-148-151.lightspeed.stlsmo.sbcglobal.net [70.135.148.151]) by mail.messagingengine.com (Postfix) with ESMTPA id 5921B3065CB0; Tue, 21 Apr 2020 23:43:38 -0400 (EDT) Subject: Re: [linux-sunxi] [RFC PATCH 4/4] pwm: sun4i: Delay after writing the period To: dev@pascalroeleven.nl, Thierry Reding , =?UTF-8?Q?Uwe_Kleine-K=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 Cc: linux-sunxi@googlegroups.com References: <20200317155906.31288-1-dev@pascalroeleven.nl> <20200317155906.31288-5-dev@pascalroeleven.nl> From: Samuel Holland Message-ID: Date: Tue, 21 Apr 2020 22:43:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200317155906.31288-5-dev@pascalroeleven.nl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > if (state->polarity != PWM_POLARITY_NORMAL) > ctrl &= ~BIT_CH(PWM_ACT_STATE, pwm->hwpwm); > else > @@ -320,6 +324,7 @@ static int sun4i_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > return 0; > > /* We need a full period to elapse before disabling the channel. */ > + next_period = jiffies + usecs_to_jiffies(cstate.period / 1000 + 1); > sun4i_pwm_wait(next_period); > > spin_lock(&sun4i_pwm->ctrl_lock); >