From patchwork Sat Feb 24 11:29:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Middelschulte X-Patchwork-Id: 205814 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1099933dyb; Sat, 24 Feb 2024 03:29:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZYgKTkv/RRyppWZ6RRjndvfN7HvBCMObLQUbtQZxYZSQOcbsn9jsWDB1eGulj5ANH36BHrEqTV4LXkkVKfQ4HlI97vA== X-Google-Smtp-Source: AGHT+IHDd9e8s3RE/KWxdocSYhhQ5Va+XSo8S7T3JuJn/6dnwjN4Jrd0F6RPT+UjUfql0jGM0PVq X-Received: by 2002:a05:622a:c:b0:42e:7803:6135 with SMTP id x12-20020a05622a000c00b0042e78036135mr528623qtw.17.1708774167713; Sat, 24 Feb 2024 03:29:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708774167; cv=pass; d=google.com; s=arc-20160816; b=s9mOIXgFxDYUB+uVOoyzP9daJ66VTvSvApPN34aVpBeXNupN488G7UwXu2Ph1iJbEn WByH5XiWnXH43MUSiK/wE0Nbljou4h1O6VfsZI1D8IDx5476JNb2ks9xHYnnM/Q62s82 yzSUflQRtx5wLxetYLZ84OOt8gQ7iHZH1b8Vv24jVu2h4eLHnz1O2hL17jBxmzsIXFIf ASpXkeFLCJwLlBrAqRGa/Uv7dP4inCPj90GO0iXrLVTsoohhmqb7rGGdEfk8mFcN7ADO gucVjPc27fYh/YBrOEsMz/n4Oz3BAg0nKJ8uLe8g0GRHx+JrL5VuixVKHhumR+gR6VD0 NJuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JYAho2X90qK7tOrS84lGLoReElvfwN9Vc1VtqG59PbA=; fh=Sty37SHU7Aijum2bk/4LGsaBJUevakYPzgKLPFJ2xZg=; b=wO++KIAiGIpuCTq0jWIu7M0lmgxjZ7Cf0l1zxbKsz8KoFh3oJvatyN0M4QsHVHs9FN hi2huA2t+q0B74ylAninBTQpoT+2SwCCi4UjcSGRXvtF4HcbSqV2UF9GqQuBzwFtkY7O 1ENwq8eILiV0AHpMIhJ8ad6hcWmtUuJrrP0qYweSpz84b+rPFoO7Ve3FTOjQ1vx8GxvW dtffEwKaazXQMnWLnFVRhJYhgIatF3Y+ilESsTh5zEhBQ1+ahUURQqpFFfOhBmiFJluq s3aqdZZ/0zFLnESnvPccrlw9T05ssehAyWMqhaPc8qv2RBb1OKqICOz6VDpUU0bDfbAy cEXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lnITihWZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79586-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v21-20020a05622a189500b0042e5ca702bdsi920658qtc.568.2024.02.24.03.29.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 03:29:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=lnITihWZ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79586-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79586-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7340D1C21725 for ; Sat, 24 Feb 2024 11:29:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 19CDD29437; Sat, 24 Feb 2024 11:29:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lnITihWZ" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF08425565; Sat, 24 Feb 2024 11:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708774153; cv=none; b=UASbM7ixlcXLnMRdW7fuBnLYL+t8UeW/RNsyA84KKj8BtsyfE2ObPEGBDjDmTApRRquuQtBDSnG4R9oo0B90hOWwHEQRRcHmsMbfYOzGq7YEQGxJNHrQArkFb5kZsMF27r1FOAO6v1YHtwtgoDOX5v3pHuPjSduX6bQJ+O32uhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708774153; c=relaxed/simple; bh=8Wmjz1P/B2yK+9hfRLUJbl27WLHSx0xp5D2G5Vt/aLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XnZMXaRHeBCNxS7Yc6ETRsaw/ESC+XYbSdeBa25rt8sRkrNUoA5aEouB4ooFHmXc2hfU5wW1pK0IYA6NaYBj8FRNOAXyiu3BXrrZzBnzm5yXP9TJtm/gIosfkeyxLS6BrMe9w2X78aposIxShpN5daR3V1uOeyDFi/fYlX7fNQM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lnITihWZ; arc=none smtp.client-ip=209.85.218.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3566c0309fso151004666b.1; Sat, 24 Feb 2024 03:29:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708774149; x=1709378949; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JYAho2X90qK7tOrS84lGLoReElvfwN9Vc1VtqG59PbA=; b=lnITihWZyVM8tLIkUE552jG2HVHhER9n8blbPFNfDqHIRArSD31rH1VUaeD2BGP+aB MYCU0lpg5ObZ7e9Odmw3+4MyqCvC5TnNR2xEj/I+fyAMaYaoLvyR5nrf/uuL4DhLlnUX P7z6BjIE0KwWmLCsrs3StImyToOgueBvXALM5r5mPk9OscdNkTkgeaF45zsTvubB5iC5 L9oil7N8OBZ3NQ1VSsf3irRrhBtw0Ve/YfT1bEsew+99KzImf4vAkvC48oNXAezu9vkA +l8gZ/+cAoERGQCuSML/5dh4yHjFcvDyx9BX81Da/t8bSMljF551lqUOLj8mWXHtxczT ZaMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708774149; x=1709378949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JYAho2X90qK7tOrS84lGLoReElvfwN9Vc1VtqG59PbA=; b=TMxtfKDXdyxTeUws2tbzoF2dBk3s0bLfQYfxj3ZsZgjDLTjk9XG5nHhivOKpLb4248 V4Wa66/B3/bp+ZMv5z5wICxXu034ITixqk4YHZ3TJR+RuD3LViAYriK+AtMJjIxKouWQ yZqv1jUYoGOrG1FyIqxF5iJFNBXJMB/2txXLh+Zw5vvPvsrw0kdteEZIZe5ScuHde3HP oZ819OHJkx9dYp0v361oh1EnuRrf9vte1F+lOAE1+TVsde6Nk23zghZsT9arOsHgC4sc aCRRnPJaV9X1zSRLXoaEPphHSfsiKcADbKzjsT1/fGQcQ+qUNklcCu+ToPgtkiWZhHbn e2FA== X-Forwarded-Encrypted: i=1; AJvYcCXk8BUpE9hlgWDNJvZn9gN+3O5Jf6z6IjBt9l1+VJcG6P7G7pX2XP8cK7PMUIk3FHjsb9KVaNoUArATyZv59ZxFscfmkwvJ5LQ99nDIFhyeAWzarl3R/64maXwsftSeFZF2cEuX1UZR X-Gm-Message-State: AOJu0Yy/kBt3CxUuuOgd+vUuejBWyH1thI0yJaRDycKAuby8J5VdS8hZ 2xEA8FgG8IwF63/h9UHu4psfvbTaAjLQkKgNpqQuUiNKTF+lksCsBJpqku1HmNI= X-Received: by 2002:a17:906:2b05:b0:a40:65ea:61 with SMTP id a5-20020a1709062b0500b00a4065ea0061mr1475681ejg.46.1708774148756; Sat, 24 Feb 2024 03:29:08 -0800 (PST) Received: from localhost.localdomain (p5dc68d61.dip0.t-ipconnect.de. [93.198.141.97]) by smtp.gmail.com with ESMTPSA id s1-20020a170906060100b00a3d9e6e9983sm507181ejb.174.2024.02.24.03.29.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 24 Feb 2024 03:29:08 -0800 (PST) From: Leif Middelschulte X-Google-Original-From: Leif Middelschulte To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: Leif Middelschulte , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/2] pwm: imx27: fix race condition .apply,.get_state Date: Sat, 24 Feb 2024 12:29:00 +0100 Message-Id: <20240224112902.55539-1-Leif.Middelschulte@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20230906154215.4ikrrbx4xgx2nmu5@pengutronix.de> References: <20230906154215.4ikrrbx4xgx2nmu5@pengutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1756098382301687616 X-GMAIL-MSGID: 1791779581539585870 From: Leif Middelschulte With CONFIG_PWM_DEBUG=y after writing a value to the PWMSAR register in .apply(), the register is read in .get_state(). Unless a period completed in the meantime, this read yields the previously used duty cycle configuration. As the PWM_DEBUG code applies the read out configuration for testing purposes this effectively undoes the intended effect by rewriting the previous hardware state. Note that this change merely implements a sensible heuristic. The i.MX has a 4 slot FIFO to configure the duty cycle. This FIFO cannot be read back in its entirety. The "write x then read back x from hw" semantics are therefore not easily applicable. With this change, the .get_state() function tries to wait for some stabilization in the FIFO (empty state). In this state it keeps applying the last value written to the sample register. Signed-off-by: Leif Middelschulte --- drivers/pwm/pwm-imx27.c | 55 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index 7d9bc43f12b0..cb564460b79c 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -75,6 +75,7 @@ (x)) + 1) #define MX3_PWM_SWR_LOOP 5 +#define MX3_PWM_FIFOAV_EMPTY_LOOP 4 /* PWMPR register value of 0xffff has the same effect as 0xfffe */ #define MX3_PWMPR_MAX 0xfffe @@ -118,6 +119,31 @@ static void pwm_imx27_clk_disable_unprepare(struct pwm_imx27_chip *imx) clk_disable_unprepare(imx->clk_ipg); } +static int pwm_imx27_wait_fifo_empty(struct pwm_chip *chip, + struct pwm_device *pwm) +{ + struct pwm_imx27_chip *imx = to_pwm_imx27_chip(chip); + struct device *dev = chip->dev; + unsigned int period_ms = DIV_ROUND_UP_ULL(pwm->state.period, NSEC_PER_MSEC); + int tries = MX3_PWM_FIFOAV_EMPTY_LOOP; + int fifoav, previous_fifoav = INT_MAX; + u32 sr; + + while (tries--) { + sr = readl(imx->mmio_base + MX3_PWMSR); + fifoav = FIELD_GET(MX3_PWMSR_FIFOAV, sr); + if (fifoav == MX3_PWMSR_FIFOAV_EMPTY) + return 0; + /* if the FIFO value does not decrease, there is another problem */ + if (previous_fifoav == fifoav) + break; + previous_fifoav = fifoav; + msleep(period_ms); + } + + return -EAGAIN; +} + static int pwm_imx27_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { @@ -161,10 +187,35 @@ static int pwm_imx27_get_state(struct pwm_chip *chip, * PWMSAR can be read only if PWM is enabled. If the PWM is disabled, * use the cached value. */ - if (state->enabled) + if (state->enabled) { + /* + * From the i.MX PWM reference manual: + * "A read on the sample register yields the current FIFO value that + * is being used, or will be used, by the PWM for generation on the + * output signal. Therefore, a write and a subsequent read on the + * sample register may result in different values being obtained." + * Furthermore: + * "When a new value is written, the duty cycle changes after the + * current period is over." + * Note "changes" vs. "changes to the given value"! + * Finally: + * "The PWM will run at the last set duty-cycle setting if all the + * values of the FIFO has been utilized, until the FIFO is reloaded + * or the PWM is disabled." + * Try to be at least a bit more deterministic about which value is + * read by waiting until the FIFO is empty. In this state the last/most + * recently pushed sample (duty cycle) value is continuously applied. + * Beware that this approach is still racy, as a new value could have + * been supplied and a period expired between the call of the wait + * function and the subsequent readl. + */ + ret = pwm_imx27_wait_fifo_empty(chip, pwm); + if (ret) + return ret; val = readl(imx->mmio_base + MX3_PWMSAR); - else + } else { val = imx->duty_cycle; + } tmp = NSEC_PER_SEC * (u64)(val) * prescaler; state->duty_cycle = DIV_ROUND_UP_ULL(tmp, pwm_clk); From patchwork Sat Feb 24 11:29:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Middelschulte X-Patchwork-Id: 205815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1099978dyb; Sat, 24 Feb 2024 03:29:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCULs6roGdglAyDIMUaMpA5RpoNtfd7iDcQUMldTqPoKA9tyymXoOWeNjk27yONycdnB7AY4vDT7KpGhE9aE7NYE0XASZA== X-Google-Smtp-Source: AGHT+IFDwCrUpBgYh9FEqNAqZnnQa1LnvXq7N5cI7Yf2WTvzkDQRJB3E6i50kVKj2aoNfx7qG1VE X-Received: by 2002:ac8:5b8a:0:b0:42e:792b:7e03 with SMTP id a10-20020ac85b8a000000b0042e792b7e03mr154174qta.46.1708774180619; Sat, 24 Feb 2024 03:29:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708774180; cv=pass; d=google.com; s=arc-20160816; b=0giI8wlEpr3bIns/Gg+Inn5PNAHUy8FMa1k7aBsdxPHA13LQTmL8bFtD+YxMEj/c2+ plrl+7wJOc4qVPOYLGB2dEre1jb0xaM/OC21b9/WiaWY8ZOmM2Rtrq7T0P76cSJn5yVj sKHxCde3bhjYXVgE5VFM0bh9cMfQVSV6o0w6HSoydvd50ZgA/vw8g6PedbCY2Cg0ZmrQ p0j9EKwYVl/YcI6R55gfZB/nvgL5zdQySS7ma/4g8ZfQdjNQftMtyV1+jjNCC/E4OaVr NRTQ/JJGuZ4z88DbOCIw7t5bpr9+A/ur/VA6GqxuNK5XYCZckYWIXX7CFc6rn9aGi+gt Qmkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4MmK3Tpm9+5KttJbHDCWPd/7vMZzGKkTnGzOOVkaN4Y=; fh=k5pj6gPi6gDXcZEIB4KnVWwXiviziq6ShGcZ4dHCpME=; b=t/k/MEklMm9/Raq2iQmxdzrP3iXdCSGGq59WGzeKr2euG24zGmaNJeplNc/tTtIufY 8tzPkP/Rmh9fZlUYryjD0vJxRzMqzrcz+Cfi2dHEFTMiOMxnHrVL+a8AsE/CYTe1JLw+ VNeAxiNuXEd6n0Oo2kcLl9+FtjQYKc1dZRX/LlObhCUMzBhw84GAqxFO8V54XIS14fVR bAM0QF5QWTRW+WgM1BV/GvhSSM1PFKqSlYchY6cTKv6M5P18jENub80rsdJ08cFZoEEN 1QoMsMQjOEWgIt/g1c3OOInUIHiylsJTNqxe37IbhH2anuflovzjhLW65AuF1hlG/c9i 8N5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QyTK5cBN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w8-20020ac87e88000000b0042e4f157265si919975qtj.241.2024.02.24.03.29.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 03:29:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QyTK5cBN; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79587-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6AF111C21652 for ; Sat, 24 Feb 2024 11:29:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60553364CF; Sat, 24 Feb 2024 11:29:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QyTK5cBN" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 493BC250EB; Sat, 24 Feb 2024 11:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708774165; cv=none; b=Zf/3FtF6L0BzZi6IFQarlG2m2VA0cWEn6nZx5bWn/BknkUfQyRtQi90xlkP0vBTL95j8G9w/u4N/iODgNKa8nyGwXFWgMz0ZbEy/MZmjJgbC7kHNhFUY1SE9TDAFljnVLSze+yHpEqsoZtcDuFqLaW/PId3SJvVljfoTygNkdhQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708774165; c=relaxed/simple; bh=oLDwwbjlfldA8YTQKnJROMeakHh9GmORvJ1FZwNxLQI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FOGwdlMw0QvT4EAWfH7CLVzHobaLEIljuXoKG4uwcD3oWNCDQk3fKtQSuYdISNibscVexGocorcuU2ZdWVoeGIfPo4jGOJ7HgVicdlyXv5XQjrdK9FhpJ6QgnkbnfDKPxtxPNfBKd4AeSLBSjpd5P7Yhf1thwGyNPxr7iXriEbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QyTK5cBN; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-55a5e7fa471so2116350a12.1; Sat, 24 Feb 2024 03:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708774162; x=1709378962; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4MmK3Tpm9+5KttJbHDCWPd/7vMZzGKkTnGzOOVkaN4Y=; b=QyTK5cBNd+V4/72EdyRSZjyYIQkT0EvAM8EpS03PVsfDyO24mIjDkTMXkiiRuxYO3m 1oWu9ckdD86DH6cFjzTZBCF1V6kT2S0N0mvSqniIV+11BmVNFtBdjlHBxgmw/CSt0cNf PQIb1f0ka/aiBVFDPqGcZCXYHyI94tYD46hsqr4/rpRveQj6vOeV01CVCOSQE7TblzOW GmNGCrKpXSzd4J01HvpF15Jtvhjzr6ZwTQEz5+jiHQhPKftrPsDLwRooSiireOJ5hkw4 Zol9mboP2mxH3kEKYQvQYSz9hKd1Y1ilFP6xBKETs3enqiUacIZF3rBL389sB5EB5f4m 9yUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708774162; x=1709378962; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4MmK3Tpm9+5KttJbHDCWPd/7vMZzGKkTnGzOOVkaN4Y=; b=CTB3TdLsdSidA4RZwAsfRzarZZ3ECbcGJsTpJZ2eHF6wou3db/aFd4/ODGj0Lny7pP N1AAZqVFvXYHSvbw625LRdnmXI++lm9y+FTwvRyut4Ap4PoHKYZruaKb1wx0Sb5cI+8y ACjSGJDqwbmXzr1Z0utdpiLkMiBidRNNO3nxwZ0XZFS000018oSRvmavBaK3sT8x8xZu 9cRn/N5sbpI+a29jyx+933/N16r7MT94eyAlm0Gw7vGDI7tBhTCTnFD0DQZ2H82gsMAs Slwvio6Dxeg8gbrRyu75WIXlx+ifWJ4CsDVlgAMP/NlvHuq6G/Cwex72966lxqsq5kB4 88aQ== X-Forwarded-Encrypted: i=1; AJvYcCXrrztE18pTD05NPJWW/4zUY+2GMw7ZUJrVvwccJ2C7FsTHiMLFcBHe3jqiOx1FqxV8/jq+vfxk8zOeXFHiVTENUPJYrWTOjgnLyOJO997dgkXI998uWQB8J1I/pk47xwBrH2O26UJa X-Gm-Message-State: AOJu0YyYF/v8oFLzq9LEClZcyk6Bo2OI7FNmOtkXX/s9rwiKrO8NYtU+ qyv2OpqCsyG0canakju7+qNkTu2bRPlzyzPzoKCAOU48QlPl5Iwc X-Received: by 2002:a17:906:3449:b0:a41:31ed:acd5 with SMTP id d9-20020a170906344900b00a4131edacd5mr1438285ejb.50.1708774162367; Sat, 24 Feb 2024 03:29:22 -0800 (PST) Received: from localhost.localdomain (p5dc68d61.dip0.t-ipconnect.de. [93.198.141.97]) by smtp.gmail.com with ESMTPSA id s1-20020a170906060100b00a3d9e6e9983sm507181ejb.174.2024.02.24.03.29.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 24 Feb 2024 03:29:21 -0800 (PST) From: Leif Middelschulte X-Google-Original-From: Leif Middelschulte To: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: Leif Middelschulte , linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/2] pwm: imx27: avoid PWM consumer API Date: Sat, 24 Feb 2024 12:29:01 +0100 Message-Id: <20240224112902.55539-2-Leif.Middelschulte@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240224112902.55539-1-Leif.Middelschulte@gmail.com> References: <20230906154215.4ikrrbx4xgx2nmu5@pengutronix.de> <20240224112902.55539-1-Leif.Middelschulte@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791779595197171736 X-GMAIL-MSGID: 1791779595197171736 Access struct members directly. Signed-off-by: Leif Middelschulte --- drivers/pwm/pwm-imx27.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c index cb564460b79c..d00d79a5edb1 100644 --- a/drivers/pwm/pwm-imx27.c +++ b/drivers/pwm/pwm-imx27.c @@ -255,7 +255,7 @@ static void pwm_imx27_wait_fifo_slot(struct pwm_chip *chip, sr = readl(imx->mmio_base + MX3_PWMSR); fifoav = FIELD_GET(MX3_PWMSR_FIFOAV, sr); if (fifoav == MX3_PWMSR_FIFOAV_4WORDS) { - period_ms = DIV_ROUND_UP_ULL(pwm_get_period(pwm), + period_ms = DIV_ROUND_UP_ULL(pwm->state.period, NSEC_PER_MSEC); msleep(period_ms);