linux/drivers/platform/surface
Maximilian Luz 36db2b7099 platform/surface: aggregator: Fix warning when controller is destroyed in probe
[ Upstream commit bc923d594d ]

There is a small window in ssam_serial_hub_probe() where the controller
is initialized but has not been started yet. Specifically, between
ssam_controller_init() and ssam_controller_start(). Any failure in this
window, for example caused by a failure of serdev_device_open(),
currently results in an incorrect warning being emitted.

In particular, any failure in this window results in the controller
being destroyed via ssam_controller_destroy(). This function checks the
state of the controller and, in an attempt to validate that the
controller has been cleanly shut down before we try and deallocate any
resources, emits a warning if that state is not SSAM_CONTROLLER_STOPPED.

However, since we have only just initialized the controller and have not
yet started it, its state is SSAM_CONTROLLER_INITIALIZED. Note that this
is the only point at which the controller has this state, as it will
change after we start the controller with ssam_controller_start() and
never revert back. Further, at this point no communication has taken
place and the sender and receiver threads have not been started yet (and
we may not even have an open serdev device either).

Therefore, it is perfectly safe to call ssam_controller_destroy() with a
state of SSAM_CONTROLLER_INITIALIZED. This, however, means that the
warning currently being emitted is incorrect. Fix it by extending the
check.

Fixes: c167b9c7e3 ("platform/surface: Add Surface Aggregator subsystem")
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Link: https://lore.kernel.org/r/20240811124645.246016-1-luzmaximilian@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2024-08-29 17:30:42 +02:00
..
aggregator platform/surface: aggregator: Fix warning when controller is destroyed in probe 2024-08-29 17:30:42 +02:00
Kconfig platform/surface: aggregator: Move subsystem hub drivers to their own module 2022-07-02 11:23:25 +02:00
Makefile platform/surface: aggregator: Move subsystem hub drivers to their own module 2022-07-02 11:23:25 +02:00
surface3-wmi.c platform/surface: surface3-wmi: Simplify resource management 2022-02-03 11:56:04 +01:00
surface3_power.c platform-drivers-x86 for v6.1-1 2022-10-05 10:38:24 -07:00
surface_acpi_notify.c platform/surface: Split memcpy() of struct ssam_event flexible array 2022-09-27 15:14:53 +02:00
surface_aggregator_cdev.c platform/surface: Update copyright year of various drivers 2022-07-02 11:23:30 +02:00
surface_aggregator_hub.c platform/surface: aggregator: Move subsystem hub drivers to their own module 2022-07-02 11:23:25 +02:00
surface_aggregator_registry.c platform/surface: aggregator_registry: Add support for Surface Laptop 5 2022-11-16 08:43:36 +01:00
surface_aggregator_tabletsw.c platform/surface: aggregator_tabletsw: Add support for book mode in KIP subsystem 2023-06-14 11:15:15 +02:00
surface_dtx.c platform/surface: Update copyright year of various drivers 2022-07-02 11:23:30 +02:00
surface_gpe.c platform/surface: gpe: Add support for 13" Intel version of Surface Laptop 4 2022-07-28 20:40:40 +02:00
surface_hotplug.c platform/surface: Update copyright year of various drivers 2022-07-02 11:23:30 +02:00
surface_platform_profile.c platform/surface: platform_profile: Propagate error if profile registration fails 2023-10-25 12:03:15 +02:00
surfacepro3_button.c platform: x86: ACPI: Get rid of ACPICA message printing 2021-03-08 11:33:39 +01:00