Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2962952rwd; Mon, 29 May 2023 03:49:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ik2fz6FceLXLFeIPZ7jJYS+hFtfy6rEv4gXckFyzRwjrf2ZMB99PjQsZ6O4U6C2mvOUVM X-Received: by 2002:a05:6a21:7895:b0:10f:1e5d:9045 with SMTP id bf21-20020a056a21789500b0010f1e5d9045mr9129255pzc.45.1685357387230; Mon, 29 May 2023 03:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685357387; cv=none; d=google.com; s=arc-20160816; b=UNz/IqsIC/tXarYhSjREV9xxKuzzOY26eEUbdJYhf8HU3UbJTpfrlp+qOUSNslszuN I64n9wS29n1tup8LjWDGBxnaLDodpVjys8CKbfID1XXvxGLfzkdzFMOzCGUquGU4kE1g EQCAwjMDnkh7SsDFrwVJ5wNBD0EUakLYuIul1nN/2InNz3ib6R4OU2eQlC4n1TXKLpC2 Fdkhn7Au5OFajLQEN2QvEAy5wmeMXbGYzhxnjyxvl9bu4ri1TqjkWDza58AXe9PLTc1w Q3cZZTccbQMDAySsoOWy4T5mAGr8HR9NJpG7ajE1TQkLwI9jPcaNl3s3GZw6zh0iffVG XOyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=TlXsffIo/L+kqdH7G4cgKFcqeg5Ddsyfs99NjT62XR0=; b=iRV83rZ1xwO/rcCB7ZY7TwTACN48C9LPWs1fGH5XA2t3Nq2nY0n7b2i34/R5B8F17I IxkMib3i/JKBARmhCqlMiCgHRiqh5tVorKCWUWz1cugC/eWrSQAL5uoCEe8rEHyj+Zut i+dECkOtc/fVMWdcUzVpMBerDfva3pIV9U1qQdiGplEHt1T1VXeqSZ1q6xOdjizFPoCt d1gigS5ltw7QYynBNrOYN38Gy5D7F1U8jtD/9SeDOHoOgd+zYvKU2sjrGV9TrN1vsSmD ZQVwuVqecFBfmmNgwjYvvihGp2aqdtU2x+iZzxJZgZBOutw+3TlNnQZfkSd4jGIjs9BY jqlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EnvTo00w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j26-20020a634a5a000000b005300dbf81d5si9416552pgl.496.2023.05.29.03.49.32; Mon, 29 May 2023 03:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EnvTo00w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231986AbjE2Kna (ORCPT + 99 others); Mon, 29 May 2023 06:43:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231847AbjE2Kn2 (ORCPT ); Mon, 29 May 2023 06:43:28 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D20C2; Mon, 29 May 2023 03:43:27 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f6e1393f13so20458705e9.0; Mon, 29 May 2023 03:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685357006; x=1687949006; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TlXsffIo/L+kqdH7G4cgKFcqeg5Ddsyfs99NjT62XR0=; b=EnvTo00wkAKLMtoqFGLvi4W/YB7706/2c8SCT0SwMNQ3+pkfme8KI4yEiYWFlVqCAq d945IbI9mN7zA8SlLc/zgkBmLP5haKZIgMBg82pOiGMzYcOw099B1l3X8v7APSYbaeDo 31foG6mi/PrfAShYbpKynBiEIdG3vjBrLtjskeW7619fwiOIBJSbpgFrGp2PzFFh8lF7 hhS+r7Q3GOUARarEoG71NOf9mFEHZ0tqBl5yEEPFBhpl3lM174god86ZZz4JgxvRgFLY 0sav5dPH69qTaUyDsS9uOCY4XvjIezh1mmql9jHAUlIdq8jvOolQqahEgdQqKK6VGsds TIfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685357006; x=1687949006; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TlXsffIo/L+kqdH7G4cgKFcqeg5Ddsyfs99NjT62XR0=; b=TzEUstQpSSpHWN+SMTkE++iWB+elAxaU7p5oPto94B0Ye9uRjs+B5LhgSONZPqssow KsT8hxZ2JoOaS8/y2ZpC0okb9ifuDllhLJRhERbrJliqFOyzeMOKCkQ17ah3J+gWglHA 22OVt++MDr/mPhtm1FYS30NhXtTNrasqSx7VSKwyNoE2ZfTXNyHdexU6HV1YkR2ozesZ tBEi94eWIsWauwswt76+F2r62LPi/CeQ9yj1+IhrJxzcJl10l1iV/QGPeovqFgynbZK2 NmyU772vzZBiHIByZKkuaEND86r3a+UmtGEzFRwH+nfoeA70A1mx57IAVn1n0xFfMQSM D7hA== X-Gm-Message-State: AC+VfDz/gjVDGE3p0TT6zUR+xKSfTmhClU9VSgTai9dmyM3PFC0It402 4QvqM75nLCuGcEWeszZAaqQ= X-Received: by 2002:a5d:5086:0:b0:309:1532:8287 with SMTP id a6-20020a5d5086000000b0030915328287mr8940723wrt.19.1685357005863; Mon, 29 May 2023 03:43:25 -0700 (PDT) Received: from [192.168.2.177] ([207.188.167.132]) by smtp.gmail.com with ESMTPSA id r6-20020adff706000000b0030903371ef9sm13399824wrp.22.2023.05.29.03.43.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 May 2023 03:43:24 -0700 (PDT) Message-ID: <0ff74fff-9e48-e2a6-617c-13d4cfc2e157@gmail.com> Date: Mon, 29 May 2023 12:43:22 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2] pwm: mtk_disp: Fix the disable flow of disp_pwm Content-Language: en-US, ca-ES, es-ES To: Shuijing Li , thierry.reding@gmail.com, u.kleine-koenig@pengutronix.de, angelogioacchino.delregno@collabora.com Cc: devicetree@vger.kernel.org, linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Project_Global_Chrome_Upstream_Group@mediatek.com, jitao.shi@mediatek.com References: <20230518115258.14320-1-shuijing.li@mediatek.com> From: Matthias Brugger In-Reply-To: <20230518115258.14320-1-shuijing.li@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/05/2023 13:52, Shuijing Li wrote: > There is a flow error in the original mtk_disp_pwm_apply() function. > If this function is called when the clock is disabled, there will be a > chance to operate the disp_pwm register, resulting in disp_pwm exception. > Fix this accordingly. > > Signed-off-by: Shuijing Li We are missing a fixes tag here. Fixes: 888a623db5d0 ("pwm: mtk-disp: Implement atomic API .apply()") with that: Reviewed-by: Matthias Brugger > --- > Changes in v2: > Use > if (A && B) { > something(); > } > instead of > if (A) { > if (B) { > something(); > } > } > per suggestion from the previous thread: > https://lore.kernel.org/lkml/20230515140346.bxeu6xewi6a446nd@pengutronix.de/ > --- > drivers/pwm/pwm-mtk-disp.c | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/drivers/pwm/pwm-mtk-disp.c b/drivers/pwm/pwm-mtk-disp.c > index 79e321e96f56..2401b6733241 100644 > --- a/drivers/pwm/pwm-mtk-disp.c > +++ b/drivers/pwm/pwm-mtk-disp.c > @@ -79,14 +79,11 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, > if (state->polarity != PWM_POLARITY_NORMAL) > return -EINVAL; > > - if (!state->enabled) { > - mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, mdp->data->enable_mask, > - 0x0); > - > - if (mdp->enabled) { > - clk_disable_unprepare(mdp->clk_mm); > - clk_disable_unprepare(mdp->clk_main); > - } > + if (!state->enabled && mdp->enabled) { > + mtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, > + mdp->data->enable_mask, 0x0); > + clk_disable_unprepare(mdp->clk_mm); > + clk_disable_unprepare(mdp->clk_main); > > mdp->enabled = false; > return 0;