lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ulthwqifylgh5ufrhu43nsboq3a3gykq4isgmrb23g67n2fzs6@4tt5afd73pnm>
Date: Mon, 23 Jun 2025 11:53:49 +0200
From: Uwe Kleine-König <ukleinek@...nel.org>
To: Christian Marangi <ansuelsmth@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-pwm@...r.kernel.org, 
	Benjamin Larsson <benjamin.larsson@...exis.eu>, 
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, Lorenzo Bianconi <lorenzo@...nel.org>
Subject: Re: [PATCH v14] pwm: airoha: Add support for EN7581 SoC

Hello Christian,

On Mon, Jun 16, 2025 at 10:15:24PM +0200, Christian Marangi wrote:
> +static int airoha_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> +			    const struct pwm_state *state)
> +{
> +	struct airoha_pwm *pc = pwmchip_get_drvdata(chip);
> +	u64 duty_ns = state->duty_cycle;
> +	u64 period_ns = state->period;
> +
> +	if (!state->enabled) {
> +		airoha_pwm_disable(pc, pwm);
> +		return 0;
> +	}
> +
> +	/* Only normal polarity is supported */
> +	if (state->polarity == PWM_POLARITY_INVERSED)
> +		return -EINVAL;
> +
> +	/* Exit early if period is less than minimum supported */
> +	if (period_ns < AIROHA_PWM_PERIOD_TICK_NS)
> +		return -EINVAL;
> +
> +	/*
> +	 * Period goes at 4ns step, normalize it to check if we can
> +	 * share a generator.
> +	 */
> +	period_ns = rounddown(period_ns, AIROHA_PWM_PERIOD_TICK_NS);

I guess this is the one that triggered the exception on m68k (though I
couldn't reproduce it). If you do the clamping first, period_ns can be
an unsigned int and the issue should be fixed.

> +	/*
> +	 * Duty goes at 255 step, normalize it to check if we can
> +	 * share a generator.
> +	 */
> +	duty_ns = DIV_U64_ROUND_UP(duty_ns * AIROHA_PWM_DUTY_FULL,
> +				   AIROHA_PWM_DUTY_FULL);
> +
> +	/* Clamp period to MAX supported value */
> +	if (period_ns > AIROHA_PWM_PERIOD_MAX_NS) {
> +		period_ns = AIROHA_PWM_PERIOD_MAX_NS;
> +
> +		if (duty_ns > period_ns)
> +			duty_ns = period_ns;
> +	}
> +
> +	return airoha_pwm_config(pc, pwm, duty_ns, period_ns);
> +}
> [...]
> +static struct platform_driver airoha_pwm_driver = {
> +	.driver = {
> +		.name = "pwm-airoha",

Given that there must be another revision anyhow, please add

		.probe_type = PROBE_PREFER_ASYNCHRONOUS,

here.

> +		.of_match_table = airoha_pwm_of_match,
> +	},
> +	.probe = airoha_pwm_probe,
> +};
> +module_platform_driver(airoha_pwm_driver);

Best regards
Uwe

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ