[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABQX2QO_2zFyz-P0N7PAd=FP9EBi4X5cdCQo9GsOATOotuOLNA@mail.gmail.com>
Date: Thu, 31 Oct 2024 11:59:35 -0400
From: Zack Rusin <zack.rusin@...adcom.com>
To: Nam Cao <namcao@...utronix.de>
Cc: Anna-Maria Behnsen <anna-maria@...utronix.de>, Frederic Weisbecker <frederic@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Miguel Ojeda <ojeda@...nel.org>, Kees Cook <kees@...nel.org>,
linux-kernel@...r.kernel.org, Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>, "Rafael J. Wysocki" <rafael@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>, Sebastian Reichel <sre@...nel.org>, Will Deacon <will@...nel.org>,
Jon Mason <jdmason@...zu.us>, Jaehoon Chung <jh80.chung@...sung.com>,
Hans Verkuil <hverkuil-cisco@...all.nl>, Jassi Brar <jassisinghbrar@...il.com>,
Pavel Machek <pavel@....cz>, Dmitry Torokhov <dmitry.torokhov@...il.com>,
Jonathan Cameron <jic23@...nel.org>, Andi Shyti <andi.shyti@...nel.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Alex Deucher <alexander.deucher@....com>, Jani Nikula <jani.nikula@...ux.intel.com>,
Rob Clark <robdclark@...il.com>, Lucas De Marchi <lucas.demarchi@...el.com>,
"Michael S. Tsirkin" <mst@...hat.com>, Jason Gunthorpe <jgg@...pe.ca>, Uwe Kleine-König <ukleinek@...nel.org>,
Takashi Iwai <tiwai@...e.com>
Subject: Re: [PATCH 00/44] hrtimers: Switch to new hrtimer interface functions (4/5)
On Mon, Oct 28, 2024 at 3:35 AM Nam Cao <namcao@...utronix.de> wrote:
>
> This is the forth part of a 5-part series (split for convenience). All 5
> parts are:
>
> Part 1: https://lore.kernel.org/lkml/cover.1729864615.git.namcao@linutronix.de
> Part 2: https://lore.kernel.org/lkml/cover.1729864823.git.namcao@linutronix.de
> Part 3: https://lore.kernel.org/lkml/cover.1729865232.git.namcao@linutronix.de
> Part 4: https://lore.kernel.org/lkml/cover.1729865485.git.namcao@linutronix.de
> Part 5: https://lore.kernel.org/lkml/cover.1729865740.git.namcao@linutronix.de
>
> To use hrtimer, hrtimer_init() (or one of its variant) must be called, and
> also the timer's callfack function must be setup separately.
>
> That can cause misuse of hrtimer. For example, because:
> - The callback function is not setup
> - The callback function is setup while it is not safe to do so
>
> To prevent misuse of hrtimer, this series:
> - Introduce new functions hrtimer_setup*(). These new functions are
> similar to hrtimer_init*(), except that they also sanity-check and
> initialize the callback function.
> - Introduce hrtimer_update_function() which checks that it is safe to
> change the callback function. The 'function' field of hrtimer is then
> made private.
> - Convert all users to use the new functions.
> - Some minor cleanups on the way.
>
> Most conversion patches were created using Coccinelle with the sematic
> patch below; except for tricky cases that Coccinelle cannot handle, or for
> some cases where a Coccinelle's bug regarding 100 column limit is
> triggered. Any patches not mentioning Coccinelle were done manually.
>
> virtual patch
> @@ expression timer, clock, mode, func; @@
> - hrtimer_init(timer, clock, mode);
> ...
> - timer->function = func;
> + hrtimer_setup(timer, func, clock, mode);
>
> @@ expression timer, clock, mode, func; @@
> - hrtimer_init(&timer, clock, mode);
> ...
> - timer.function = func;
> + hrtimer_setup(&timer, func, clock, mode);
>
> @@ expression timer, clock, mode, func; @@
> - hrtimer_init_on_stack(&timer, clock, mode);
> ...
> - timer.function = func;
> + hrtimer_setup_on_stack(&timer, func, clock, mode);
>
> @@ expression timer, clock, mode; @@
> - hrtimer_init_sleeper_on_stack(timer, clock, mode);
> + hrtimer_setup_sleeper_on_stack(timer, clock, mode);
>
> Signed-off-by: Nam Cao <namcao@...utronix.de>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: "Martin K. Petersen" <martin.petersen@...cle.com>
> Cc: Alexandre Belloni <alexandre.belloni@...tlin.com>
> Cc: "Rafael J. Wysocki" <rafael@...nel.org>
> Cc: Linus Walleij <linus.walleij@...aro.org>
> Cc: Sebastian Reichel <sre@...nel.org>
> Cc: Will Deacon <will@...nel.org>
> Cc: Jon Mason <jdmason@...zu.us>
> Cc: Jaehoon Chung <jh80.chung@...sung.com>
> Cc: Hans Verkuil <hverkuil-cisco@...all.nl>
> Cc: Jassi Brar <jassisinghbrar@...il.com>
> Cc: Pavel Machek <pavel@....cz>
> Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
> Cc: Jonathan Cameron <jic23@...nel.org>
> Cc: Andi Shyti <andi.shyti@...nel.org>
> Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> Cc: Alex Deucher <alexander.deucher@....com>
> Cc: Jani Nikula <jani.nikula@...ux.intel.com>
> Cc: Rob Clark <robdclark@...il.com>
> Cc: Lucas De Marchi <lucas.demarchi@...el.com>
> Cc: Zack Rusin <zack.rusin@...adcom.com>
> Cc: "Michael S. Tsirkin" <mst@...hat.com>
> Cc: Jason Gunthorpe <jgg@...pe.ca>
> Cc: "Uwe Kleine-König" <ukleinek@...nel.org>
> Cc: Takashi Iwai <tiwai@...e.com>
>
> Nam Cao (44):
> USB: chipidea: Switch to use hrtimer_setup()
> usb: dwc2: Switch to use hrtimer_setup()
> usb: fotg210-hcd: Switch to use hrtimer_setup()
> usb: gadget: Switch to use hrtimer_setup()
> usb: ehci: Switch to use hrtimer_setup()
> usb: musb: cppi41: Switch to use hrtimer_setup()
> usb: typec: tcpm: Switch to use hrtimer_setup()
> serial: 8250: Switch to use hrtimer_setup()
> serial: imx: Switch to use hrtimer_setup()
> serial: sh-sci: Switch to use hrtimer_setup()
> serial: xilinx_uartps: Switch to use hrtimer_setup()
> scsi: Switch to use hrtimer_setup()
> rtc: class: Switch to use hrtimer_setup()
> pps: generators: pps_gen_parport: Switch to use hrtimer_setup()
> powercap: Switch to use hrtimer_setup()
> power: supply: ab8500_chargalg: Switch to use hrtimer_setup()
> power: reset: ltc2952-poweroff: Switch to use hrtimer_setup()
> drivers: perf: Switch to use hrtimer_setup()
> ntb: ntb_pingpong: Switch to use hrtimer_setup()
> mmc: dw_mmc: Switch to use hrtimer_setup()
> misc: vcpu_stall_detector: Switch to use hrtimer_setup()
> media: Switch to use hrtimer_setup()
> mailbox: Switch to use hrtimer_setup()
> leds: trigger: pattern: Switch to use hrtimer_setup()
> Input: Switch to use hrtimer_setup()
> iio: Switch to use hrtimer_setup()
> i2c: Switch to use hrtimer_setup()
> stm class: heartbeat: Switch to use hrtimer_setup()
> drm/amdgpu: Switch to use hrtimer_setup()
> drm/i915/huc: Switch to use hrtimer_setup()
> drm/i915/gvt: Switch to use hrtimer_setup()
> drm/i915/perf: Switch to use hrtimer_setup()
> drm/i915/pmu: Switch to use hrtimer_setup()
> drm/i915/uncore: Switch to use hrtimer_setup()
> drm/i915/request: Switch to use hrtimer_setup()
> drm/msm: Switch to use hrtimer_setup()
> drm/vkms: Switch to use hrtimer_setup()
> drm/xe/oa: Switch to use hrtimer_setup()
> drm/vmwgfx: Switch to use hrtimer_setup()
Acked-by: Zack Rusin <zack.rusin@...adcom.com>
FWIW, even if there's no current errors in those paths, that's a nice
change. I remember looking at the hrtimer initialization code the
first time and thinking that setting the function member of the struct
after initialization must be a bug or some hack... Now it will
instinctively make sense to anyone reading it for the first time.
z
Powered by blists - more mailing lists