Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp282469pxx; Wed, 28 Oct 2020 04:58:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6cA6bx1cgDqyOBPHDL120RbTMYLdCn/JZOleLjtuqM12NHfIcElM64cRYqHjPUezFb2hD X-Received: by 2002:a17:906:d1ce:: with SMTP id bs14mr6964113ejb.548.1603886319650; Wed, 28 Oct 2020 04:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603886319; cv=none; d=google.com; s=arc-20160816; b=kpNN8pOa+Z9EBy3pb7Z9rVulA3BCO8PBuLURzUjT4OlazHwYkDX7bAgQiyaE/FOA6l ceevugPC+/BdRUW30SasGC/kt/b/OqeU1q386e3xg7u8hyBP106QQRSqE76KJs8DfJTZ jEr4cpK+IeSMx+D6u+q34ErPuHga/ddHjspnXs1+0N+AKovbHr8CIlh1Neh2Ko3V7ocY DG54t6K5Pl1bZ+IBeGPA5vhkG78ymW6/ALQnYgttfZqzXZPoite1GNM5853ei4MoSNbp GsaaY53otkyQIEZMJiY6jpBiskhzwNr7qYfK9Qf61RGEELghbgXg+aEvy6SiWlsbUakQ 81DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9UIePexAGNg/dGuEuwjY73LGxOKFnS2HoGAYBpXfTME=; b=LJwevsusxeWPVEMSHbg09WqQPl8HJHz5w1JgrsKWiaIyvcjV3pM88VKR6J73/9WzIo GSKnocFVp2fP40zZEhI/KV+3tnM1iWkcag1NaRya9L1aX04nmSpstJVLzCMyDe+tQ684 zikpoFehY8ifZ4N6At7HDiadeqgV0ZnyUgyg2SCJct9Zb+RBST6iiGcooUby4lQuPKZH utH63Rj0FtCq1OTtKw5zVlpvFD0ld6Og9unm04fkB/g91CyW9V/FQ5nxyxghXt1qM3Iu 1t3yoUo4BoNalf067mB9gHfVAJDspx9uBu1GJ3RJupSbnajMhrX52kpirpSlmNR1qoni jZxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dnl1VywC; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si2524555edb.466.2020.10.28.04.58.16; Wed, 28 Oct 2020 04:58:39 -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=@kernel.org header.s=default header.b=Dnl1VywC; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794918AbgJ0POW (ORCPT + 99 others); Tue, 27 Oct 2020 11:14:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:43538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1793798AbgJ0PIV (ORCPT ); Tue, 27 Oct 2020 11:08:21 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EAAE5206E5; Tue, 27 Oct 2020 15:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811300; bh=jBNNwsIKnn0W5z4A48N5P+kQ4x2eqUrJssaQKKdLJdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dnl1VywCfEIEGUtZunvDdvqUPGwCF/f8zp1BOiRTaXtShrkAQIon6f8Hf75v83RkA 3d0wN6w4xLplN4bg+AjPtv7wvuEXb+YQ2x7D7qRbRNlBP7ethmjazpuvbwQQ3LL3nf ljQJ0sizS8oyr5EWWxaczjXNUg0Yv3PTBesMowws= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Simon South , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Heiko Stuebner , Thierry Reding , Sasha Levin Subject: [PATCH 5.8 443/633] pwm: rockchip: Keep enabled PWMs running while probing Date: Tue, 27 Oct 2020 14:53:06 +0100 Message-Id: <20201027135543.498231956@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon South [ Upstream commit 457f74abbed060a0395f75ab5297f2d76cada516 ] Following commit cfc4c189bc70 ("pwm: Read initial hardware state at request time") the Rockchip PWM driver can no longer assume a device's pwm_state structure has been populated after a call to pwmchip_add(). Consequently, the test in rockchip_pwm_probe() intended to prevent the driver from stopping PWM devices already enabled by the bootloader no longer functions reliably and this can lead to the kernel hanging during startup, particularly on devices like the Pinebook Pro that use a PWM-controlled backlight for their display. Avoid this by querying the device directly at probe time to determine whether or not it is enabled. Fixes: cfc4c189bc70 ("pwm: Read initial hardware state at request time") Signed-off-by: Simon South Reviewed-by: Uwe Kleine-König Reviewed-by: Heiko Stuebner Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/pwm/pwm-rockchip.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index eb8c9cb645a6c..098e94335cb5b 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -288,6 +288,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) const struct of_device_id *id; struct rockchip_pwm_chip *pc; struct resource *r; + u32 enable_conf, ctrl; int ret, count; id = of_match_device(rockchip_pwm_dt_ids, &pdev->dev); @@ -362,7 +363,9 @@ static int rockchip_pwm_probe(struct platform_device *pdev) } /* Keep the PWM clk enabled if the PWM appears to be up and running. */ - if (!pwm_is_enabled(pc->chip.pwms)) + enable_conf = pc->data->enable_conf; + ctrl = readl_relaxed(pc->base + pc->data->regs.ctrl); + if ((ctrl & enable_conf) != enable_conf) clk_disable(pc->clk); return 0; -- 2.25.1