From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 871D51DDF5; Thu, 15 Aug 2024 13:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723728593; cv=none; b=iYOWgNhDlf8QxUGTD2IQo+YfPhCfY9RIbitmJUsNPu1UKqFDns78RLJ4Xv46GDunFW/4T7tcQaoYjkOntFmclYnszE1gwW+zzam7fgS/8nz5hq1qLXQoovi6lMhfGHouIJKAaE1Dnbz97lK77HDPgZdzSXvvQr6xH6JZ7o/+Evo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723728593; c=relaxed/simple; bh=te8P9VU8nAMiZ93UK1mzYYSBgZ0TXpxGJWpgMaiEYwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L6xLheAgFWXZ8M9kzxNfmbpBBWfrECKD2wZRcFl/uO1E24RkU7SmiTGzAx1oH6XyAeG9hZY5ysK4IqTIPZv1gI35wD1M0yVIqBOhQ7G+eW3lbFHa4s06baSbElzlYI3TAGXmAnv6yNZgQboIzDPvEe5bR9xA0QnrZSusVaA1QnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=s3N1Y5/t; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="s3N1Y5/t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BADBC4AF0E; Thu, 15 Aug 2024 13:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723728593; bh=te8P9VU8nAMiZ93UK1mzYYSBgZ0TXpxGJWpgMaiEYwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3N1Y5/tNWvB22dUJKkkeYcYjGvkrJdOIKq1vXEeUAQziL3i1FPiiyg/xwjFt6vAl SpckQxPlgnnlR2mOZNcIUFJyv4O1tFQ5g5VaBPtvdXwy5wHnBePbNgivgWHFHbDfEx 50fPRgnwFNDvXzkJJiyUt7rbMaxqmuFyMS3Pb2nA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Sasha Levin Subject: [PATCH 4.19 008/196] pwm: stm32: Always do lazy disabling Date: Thu, 15 Aug 2024 15:22:05 +0200 Message-ID: <20240815131852.392340189@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131852.063866671@linuxfoundation.org> References: <20240815131852.063866671@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Uwe Kleine-König [ Upstream commit 7346e7a058a2c9aa9ff1cc699c7bf18a402d9f84 ] When the state changes from enabled to disabled, polarity, duty_cycle and period are not configured in hardware and TIM_CCER_CCxE is just cleared. However if the state changes from one disabled state to another, all parameters are written to hardware because the early exit from stm32_pwm_apply() is only taken if the pwm is currently enabled. This yields surprises like: Applying { .period = 1, .duty_cycle = 0, .enabled = false } succeeds if the pwm is initially on, but fails if it's already off because 1 is a too small period. Update the check for lazy disable to always exit early if the target state is disabled, no matter what is currently configured. Fixes: 7edf7369205b ("pwm: Add driver for STM32 plaftorm") Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20240703110010.672654-2-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König Signed-off-by: Sasha Levin --- drivers/pwm/pwm-stm32.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c index ee7197b8e4ef7..5325e804ca24f 100644 --- a/drivers/pwm/pwm-stm32.c +++ b/drivers/pwm/pwm-stm32.c @@ -451,8 +451,9 @@ static int stm32_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, enabled = pwm->state.enabled; - if (enabled && !state->enabled) { - stm32_pwm_disable(priv, pwm->hwpwm); + if (!state->enabled) { + if (enabled) + stm32_pwm_disable(priv, pwm->hwpwm); return 0; } -- 2.43.0