Skip to content

media: pwm-ir-tx: Correct timer calculation - #7680

Draft
6by9 wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-ir
Draft

6by9 wants to merge 1 commit into
raspberrypi:rpi-6.18.yfrom
6by9:rpi-6.18.y-ir

Conversation

@6by9

@6by9 6by9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Commit 44d7fb8 ("media: pwm-ir-tx: Avoid direct access to hrtimer clockbase") converted a loop conditional from
now = timer->base->get_time();
} while (hrtimer_get_expires_tv64(timer) < now);
to
while (hrtimer_expires_remaining(timer) > 0);

hrtimer_expires_remaining returns (expires - now), so the change has inverted the condition.

Correct the > to < to restore the old behaviour

#7678

Fixes: 44d7fb8 ("media: pwm-ir-tx: Avoid direct access to hrtimer clockbase")

@6by9

6by9 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Draft PR for reporter to test.

@popcornmix

Copy link
Copy Markdown
Collaborator

@t-8ch - I think this wants fixing upstream.

@t-8ch

t-8ch commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

@t-8ch - I think this wants fixing upstream.

Yes, agreed.

@6by9 Can you submit this upstream?
Also add Cc: stable@vger.kernel.org.

Maybe it should change to this:

} while (hrtimer_get_expires(timer) < hrtimer_cb_get_time(timer));

This is closer to the original logic and IMO easier to understand.
Case in point: I got confused by my own change here...

@6by9

6by9 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

Yup, happy to submit it upstream, making your suggested change first.

I'll update this PR too so hopefully we'll avoid merge conflicts when it does merge back through stable.

Commit 44d7fb8 ("media: pwm-ir-tx: Avoid direct access to
hrtimer clockbase") converted a loop conditional from
               now = timer->base->get_time();
       } while (hrtimer_get_expires_tv64(timer) < now);
to
       while (hrtimer_expires_remaining(timer) > 0);

hrtimer_expires_remaining returns (expires - now), so the
change has inverted the condition.

Convert back to follow the original pattern, but using the
proper API call.

Fixes: 44d7fb8 ("media: pwm-ir-tx: Avoid direct access to hrtimer clockbase")
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9

6by9 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

PR updated based on suggested option.
I've asked on #7678 for them to retest, and I'll send upstream once confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants