Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1499422/?format=api
{ "id": 1499422, "url": "http://patchwork.ozlabs.org/api/patches/1499422/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20210701072927.328254-3-u.kleine-koenig@pengutronix.de/", "project": { "id": 38, "url": "http://patchwork.ozlabs.org/api/projects/38/?format=api", "name": "Linux PWM development", "link_name": "linux-pwm", "list_id": "linux-pwm.vger.kernel.org", "list_email": "linux-pwm@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20210701072927.328254-3-u.kleine-koenig@pengutronix.de>", "list_archive_url": null, "date": "2021-07-01T07:29:26", "name": "[2/3] pwm: Prevent a glitch for legacy drivers", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9378807f32982fde2ac02afd02941c294c894c20", "submitter": { "id": 1476, "url": "http://patchwork.ozlabs.org/api/people/1476/?format=api", "name": "Uwe Kleine-König", "email": "u.kleine-koenig@pengutronix.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pwm/patch/20210701072927.328254-3-u.kleine-koenig@pengutronix.de/mbox/", "series": [ { "id": 251456, "url": "http://patchwork.ozlabs.org/api/series/251456/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pwm/list/?series=251456", "date": "2021-07-01T07:29:25", "name": "pwm: Some improvements for legacy drivers", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/251456/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1499422/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1499422/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-pwm-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=23.128.96.18; helo=vger.kernel.org;\n envelope-from=linux-pwm-owner@vger.kernel.org; receiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [23.128.96.18])\n\tby ozlabs.org (Postfix) with ESMTP id 4GFqbh6Hqtz9sVb\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 1 Jul 2021 17:29:36 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n id S234635AbhGAHcE (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n Thu, 1 Jul 2021 03:32:04 -0400", "from lindbergh.monkeyblade.net ([23.128.96.19]:52746 \"EHLO\n lindbergh.monkeyblade.net\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n with ESMTP id S234824AbhGAHcE (ORCPT\n <rfc822;linux-pwm@vger.kernel.org>); Thu, 1 Jul 2021 03:32:04 -0400", "from metis.ext.pengutronix.de (metis.ext.pengutronix.de\n [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33])\n by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28B6CC0617AD\n for <linux-pwm@vger.kernel.org>; Thu, 1 Jul 2021 00:29:33 -0700 (PDT)", "from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0])\n by metis.ext.pengutronix.de with esmtps\n (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1lyr8c-00038z-Ou; Thu, 01 Jul 2021 09:29:30 +0200", "from ukl by ptx.hi.pengutronix.de with local (Exim 4.92)\n (envelope-from <ukl@pengutronix.de>)\n id 1lyr8b-0006y4-V8; Thu, 01 Jul 2021 09:29:29 +0200" ], "From": "=?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>", "To": "Thierry Reding <thierry.reding@gmail.com>,\n Lee Jones <lee.jones@linaro.org>", "Cc": "linux-pwm@vger.kernel.org, kernel@pengutronix.de,\n Geert Uytterhoeven <geert@linux-m68k.org>", "Subject": "[PATCH 2/3] pwm: Prevent a glitch for legacy drivers", "Date": "Thu, 1 Jul 2021 09:29:26 +0200", "Message-Id": "<20210701072927.328254-3-u.kleine-koenig@pengutronix.de>", "X-Mailer": "git-send-email 2.30.2", "In-Reply-To": "<20210701072927.328254-1-u.kleine-koenig@pengutronix.de>", "References": "<20210701072927.328254-1-u.kleine-koenig@pengutronix.de>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "X-Patch-Hashes": "v=1; h=sha256; i=3jp+KNgBvhQphIgkyTxKed1TpNAQoyExL9GSbIVWWQw=;\n m=rP85FNWtFgXD27m7WY/IxRngNXRoyZYDgl17dsyh6Vo=;\n p=L5ZhrPYspHz4XDsRRnjWAFPVp9jL9aqm3h/Sc7WnMiw=;\n g=6b0f80e136ce6a82845a5ee3ecc159fe1446a3b4", "X-Patch-Sig": "m=pgp; i=uwe@kleine-koenig.org;\n s=0x0D2511F322BFAB1C1580266BE2DCDD9132669BD6;\n b=iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmDdbqkACgkQwfwUeK3K7AnCegf/cwR\n Jz9bOUzVELWnBWpzAOr57vKCfJH298VRn5JLVuZm2lYPrVQwlJ2EgLolq6UZsCIj5CYl41FI0jALc\n JLQON5qHOQF3y+wV3i4gwPOwQDvT6AdAF/HYUcj+RIiceqvRyVoc6L8ehwth6YYrEe36IvOIOTvpD\n h/pcOqaMMLIgd/aJmsIc0WZpFJMaGObCIn8fMiVJzUbBsHgSru752Qix+ShzGB21P8cmvenWoPwAe\n P0GVHVXNSiYDKvTXWPTVfpo/qp7Qqh8mSpGRz1e57zpuMaWTNLcIg1gn8+RTqBjGpgqmWsRKfyecy\n qPK+XoKq8+o5FgsZISUVwpaxrv5QOEA==", "Content-Transfer-Encoding": "8bit", "X-SA-Exim-Connect-IP": "2001:67c:670:100:1d::c0", "X-SA-Exim-Mail-From": "ukl@pengutronix.de", "X-SA-Exim-Scanned": "No (on metis.ext.pengutronix.de);\n SAEximRunCond expanded to false", "X-PTX-Original-Recipient": "linux-pwm@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-pwm.vger.kernel.org>", "X-Mailing-List": "linux-pwm@vger.kernel.org" }, "content": "If a running PWM is reconfigured to disabled calling the ->config()\ncallback before disabling the hardware might result in a glitch where\nthe (maybe) new period and duty_cycle are visible on the output before\ndisabling the hardware.\n\nSo handle disabling before calling ->config(). Also exit early in this case\nwhich is possible because period and duty_cycle don't matter for disabled PWMs.\nIn return however ->config has to be called even if state->period ==\npwm->state.period && state->duty_cycle != pwm->state.duty_cycle because setting\nthese might have been skipped in the previous call.\n\nSigned-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>\n---\n drivers/pwm/core.c | 41 ++++++++++++++++++++++++-----------------\n 1 file changed, 24 insertions(+), 17 deletions(-)", "diff": "diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c\nindex 3c72f8963073..20afe6d0bc5e 100644\n--- a/drivers/pwm/core.c\n+++ b/drivers/pwm/core.c\n@@ -568,26 +568,33 @@ static int pwm_apply_legacy(struct pwm_chip *chip, struct pwm_device *pwm,\n \t\tpwm->state.polarity = state->polarity;\n \t}\n \n-\tif (state->period != pwm->state.period ||\n-\t state->duty_cycle != pwm->state.duty_cycle) {\n-\t\terr = chip->ops->config(pwm->chip, pwm,\n-\t\t\t\t\tstate->duty_cycle,\n-\t\t\t\t\tstate->period);\n-\t\tif (err)\n-\t\t\treturn err;\n+\tif (!state->enabled) {\n+\t\tif (pwm->state.enabled)\n+\t\t\tchip->ops->disable(chip, pwm);\n \n-\t\tpwm->state.period = state->period;\n-\t\tpwm->state.duty_cycle = state->duty_cycle;\n+\t\treturn 0;\n \t}\n \n-\tif (state->enabled != pwm->state.enabled) {\n-\t\tif (!pwm->state.enabled) {\n-\t\t\terr = chip->ops->enable(chip, pwm);\n-\t\t\tif (err)\n-\t\t\t\treturn err;\n-\t\t} else {\n-\t\t\tchip->ops->disable(chip, pwm);\n-\t\t}\n+\t/*\n+\t * We cannot skip calling ->config even if state->period ==\n+\t * pwm->state.period && state->duty_cycle == pwm->state.duty_cycle\n+\t * because we might have exited early in the last call to\n+\t * pwm_apply_state because of !state->enabled and so the two values in\n+\t * pwm->state might not be configured in hardware.\n+\t */\n+\terr = chip->ops->config(pwm->chip, pwm,\n+\t\t\t\tstate->duty_cycle,\n+\t\t\t\tstate->period);\n+\tif (err)\n+\t\treturn err;\n+\n+\tpwm->state.period = state->period;\n+\tpwm->state.duty_cycle = state->duty_cycle;\n+\n+\tif (!pwm->state.enabled) {\n+\t\terr = chip->ops->enable(chip, pwm);\n+\t\tif (err)\n+\t\t\treturn err;\n \t}\n \n \treturn 0;\n", "prefixes": [ "2/3" ] }