Hans de Goede [Mon, 15 May 2023 13:40:11 +0000 (14:40 +0100)]
media: atomisp: Move pad linking to atomisp_register_device_nodes()
atomisp_register_device_nodes() already iterates over the ports/sensors
in a loop and that loop already does not include the TPG input.
So we can simply setup the CSI2-port <-> ISP and sensor <-> CSI2-port
mediactl-pad links there instead of repeating the loop in
atomisp_create_pads_links(), which atomisp_register_device_nodes()
used to call later on.
Link: https://lore.kernel.org/r/20230518153733.195306-8-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 14 May 2023 20:08:29 +0000 (21:08 +0100)]
media: atomisp: Delay mapping sensors to inputs till atomisp_register_device_nodes()
Delay mapping sensors to inputs till atomisp_register_device_nodes()
time. There are 2 reasons for this:
1. This guarantees a stable input order independent of the sensor
probe order.
2. This is a preparation patch for v4l2-async sensor probing support.
Link: https://lore.kernel.org/r/20230518153733.195306-7-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 14 May 2023 19:37:00 +0000 (20:37 +0100)]
media: atomisp: Store number of sensor lanes per port in struct atomisp_device
Store number of sensor lanes per port in struct atomisp_device.
This is a preparation patch for adding v4l2-async sensor probing support.
With async probing the inputs will get registered later, but we can
already fill the sensor_lanes array when parsing the fwnodes.
Link: https://lore.kernel.org/r/20230518153733.195306-6-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Tue, 16 May 2023 20:36:14 +0000 (21:36 +0100)]
media: atomisp: Rename __get_mipi_port() to atomisp_port_to_mipi_port()
Rename __get_mipi_port() to atomisp_port_to_mipi_port(), this is not a
private (not static) function so its name should be properly prefixed.
While at is also cleanup the weird handling of ATOMISP_CAMERA_PORT_TERTIARY
this seems to be a left over from when the driver also supported CSI
receivers with only 2 ports, but those are not supported by the current
code base, so this can be cleaned up now.
Link: https://lore.kernel.org/r/20230518153733.195306-5-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Mon, 15 May 2023 18:08:05 +0000 (19:08 +0100)]
media: atomisp: Remove atomisp_video_init() parametrization
Now that we only have a single /dev/video# node it is no longer
necessary for atomisp_video_init() to be parametrized.
Remove its parameters and while at it also change the name
from the single /dev/video# node from "ATOMISP ISP PREVIEW output"
to "ATOMISP video output".
Link: https://lore.kernel.org/r/20230518153733.195306-4-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 14 May 2023 18:59:13 +0000 (19:59 +0100)]
media: atomisp: Remove unused fields from struct atomisp_input_subdev
Remove unused fields from struct atomisp_input_subdev:
1. frame_size is never used at all
2. sensor_index is always 0, just directly pass 0 in the single user.
Link: https://lore.kernel.org/r/20230518153733.195306-3-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 14 May 2023 18:51:28 +0000 (19:51 +0100)]
media: atomisp: Drop MRFLD_PORT_NUM define
The info in the MRFLD_PORT_NUM define is duplicate with
the ATOMISP_CAMERA_NR_PORTS and N_MIPI_PORT_ID enum values.
Drop the MRFLD_PORT_NUM define and switch to N_MIPI_PORT_ID
since the [sensor_]lanes arrays are in enum mipi_port_id order.
Link: https://lore.kernel.org/r/20230518153733.195306-2-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 18 May 2023 14:33:34 +0000 (15:33 +0100)]
media: atomisp: gc0310: Remove gc0310.h
Remove the gc0310.h header file, moving most of its content
into atomisp-gc0310.c and dropping some unused parts.
This brings the gc0310 sensor driver inline with other sensor
regular / non atomisp sensor drivers which usually only are
one single .c file.
Link: https://lore.kernel.org/r/20230518153214.194976-9-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 18 May 2023 14:19:14 +0000 (15:19 +0100)]
media: atomisp: gc0310: Remove gc0310_s_config() function
gc0310_s_config() used to call camera_sensor_platform_data.csi_cfg() back
when the gc0310 driver was still using the atomisp_gmin_platform code
for power-management.
Now it is just a weirdly named wrapper around gc0310_detect(), drop
gc0310_s_config() and make probe() call gc0310_detect() directly.
Link: https://lore.kernel.org/r/20230518153214.194976-8-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 18 May 2023 12:48:34 +0000 (13:48 +0100)]
media: atomisp: gc0310: Cleanup includes
Remove a bunch of unused includes and sort the remainging
includes alphabetically.
Link: https://lore.kernel.org/r/20230518153214.194976-7-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 18 May 2023 14:15:07 +0000 (15:15 +0100)]
media: atomisp: gc0310: Fix double free in gc0310_remove()
gc0310_remove() must not call kfree(dev) since the gc0310_device struct
is devm managed so explicitly freeing it causes a double free.
While at it add a missing mutex_destroy() call for the input_lock.
Link: https://lore.kernel.org/r/20230518153214.194976-6-hdegoede@redhat.com
Fixes:
340b4dd6c183 ("media: atomisp: gc0310: Use devm_kzalloc() for data struct")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 18 May 2023 12:43:45 +0000 (13:43 +0100)]
media: atomisp: gc0310: Drop XXGC0310 ACPI hardware-id
The XXGC0310 ACPI hardware-id does not appear to be used in
the DSDTs of any hardware out there, so drop it.
Link: https://lore.kernel.org/r/20230518153214.194976-5-hdegoede@redhat.com
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Tue, 9 May 2023 20:10:34 +0000 (21:10 +0100)]
media: atomisp: Set asd.subdev.devnode once from isp_subdev_init_entities()
Now that we have only one /dev/video# node we can set asd.subdev.devnode
once from isp_subdev_init_entities(), replacing the hack to set it the
last opened/closed /dev/video# node from atomisp_open() /
atomisp_release().
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 17:31:21 +0000 (18:31 +0100)]
media: atomisp: Remove in_reset argument from atomisp_css_start()
The in_reset argument to atomisp_css_start() is only ever true
in atomisp_assert_recovery_work(), drop the argument and move
the special reset handlig to atomisp_assert_recovery_work().
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 16:27:10 +0000 (17:27 +0100)]
media: atomisp: Remove unused atomisp_get_css_pipe_id() function
Remove no longer user atomisp_get_css_pipe_id() function.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 16:26:11 +0000 (17:26 +0100)]
media: atomisp: Remove unused css_pipe_id argument from atomisp_css_[start|stop]()
The css_pipe_id argument pass to atomisp_css_[start|stop]() is
not used, drop it.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 15:27:46 +0000 (16:27 +0100)]
media: atomisp: Remove atomisp_[sub]dev_users()
The atomisp_[sub]dev_users() functions are not used anymore,
remove them.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 15:24:32 +0000 (16:24 +0100)]
media: atomisp: Allow system suspend to continue with open /dev/video# nodes
Just having a /dev/video# node open is not a reason to block system
suspend. At least when userspace is not streaming.
In that case the worst case scenario is that streams have been created,
but we can just destroy those before powering off the ISP and
recreate the streams on resume.
Fixing suspend when streaming is left as a FIXME item for later.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Fri, 12 May 2023 15:17:54 +0000 (16:17 +0100)]
media: atomisp: Rename atomisp_destroy_pipes_stream_force() to atomisp_destroy_pipes_stream()
There now no longer is a non force version of
atomisp_destroy_pipes_stream_force() so having the _force postfix
no longer makes sense rename it to atomisp_destroy_pipes_stream().
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 18:53:16 +0000 (19:53 +0100)]
media: atomisp: Simplify atomisp_isr() and recovery_work()
Both atomisp_isr() and recovery_work() now have a combination of:
1. "if (!isp->asd.streaming) goto out;" code at the top
2. "if (sp->asd.streaming) {}" blocks in the body which are jumped over
by the goto out.
This means that the "if (sp->asd.streaming) {}" blocks are always
executed if they are not jumped over by the goto.
Remove the unnecessary "if (sp->asd.streaming)" checks and
re-indent the code.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 18:35:43 +0000 (19:35 +0100)]
media: atomisp: Remove atomisp_streaming_count()
atomisp_streaming_count() is just an alias for isp->asd.streaming now,
replace it with directly checking that and remove the helper.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 15:14:21 +0000 (16:14 +0100)]
media: atomisp: Remove no longer used atomisp_css_flush()
Remove the no longer used atomisp_css_flush() function and merge
atomisp_assert_recovery_work() and __atomisp_css_recover() into
a single function.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 17:33:06 +0000 (18:33 +0100)]
media: atomisp: Turn asd->streaming state tracker into a bool
The ATOMISP_DEVICE_STREAMING_STOPPING pipe state comes from when we still
had continuous mode. This would be set when streaming from both capture +
preview devnodes when 1 of the 2 streams has been stopped and the driver
was waiting for the other stream to get stopped too.
With continuous mode gone the stopping state is no longer necessary and
asd->streaming can be changed to a bool.
Note that atomisp_assert_recovery_work() would still temporarily
set streaming to stopping, but it does so with the isp->mutex held and
changes streaming to either enabled or disabled before releasing
the mutex, so none of the consumers which care about the difference
ever see the stopping state.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 17:18:24 +0000 (18:18 +0100)]
media: atomisp: Simplify atomisp_pipe_check()
All switch (pipe->asd->streaming) cases in atomisp_pipe_check()
are either no-ops or never happen:
1. ATOMISP_DEVICE_STREAMING_DISABLED already is a no-op
2. The videobuf2 core guarantees that when we are streaming
vb2_is_busy() returns true. So the ATOMISP_DEVICE_STREAMING_ENABLED case
is already handled by the if above the switch (pipe->asd->streaming).
3. After recent changes pipe->asd->streaming is only ever set to
ATOMISP_DEVICE_STREAMING_STOPPING in atomisp_assert_recovery_work() and
that function holds isp->mutex and always transitions the streaming state
to ATOMISP_DEVICE_STREAMING_DISABLED or ATOMISP_DEVICE_STREAMING_ENABLED
before releasing the mutex. So atomisp_pipe_check() never sees
ATOMISP_DEVICE_STREAMING_STOPPING.
Remove the entire switch-case.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 15:39:37 +0000 (16:39 +0100)]
media: atomisp: Simplify atomisp_open() and atomisp_release()
Now that continuous mode is gone and we only have 1 /dev/video# node,
combined with only allowing 1 open of that /dev/video# node for now,
there is no need to check for other (sub)dev / pipe users.
Remove the unnecessary checks for a nice cleanup.
Note we also don't need to set asd->streaming to disabled since
the vb2_fop_release() call done by atomisp_release() will have called
atomisp_stop_streaming() already at this point (if necessary) and
that will have already done this.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 18:27:24 +0000 (19:27 +0100)]
media: atomisp: Simplify atomisp_css_[start|stop]()
Now that continuous mode is gone and we only have 1 /dev/video# node,
the videobuf2 core guarantees that atomisp_css_[start|stop]() will
only be called one at a time.
So there is no need for atomisp_streaming_count() counts.
When reqbufs has been done then the streams are guaranteed to be created,
and streaming cannot be started without reqbufs so there is no need for
atomisp_css_start() to check if it needs to create the streams.
Use this to clean-up atomisp_css_[start|stop]().
While at it also fix atomisp_css_start() not re-creating the streams
on an error, breaking the guarantee that the streams are always there
after a succesfull reqbufs call.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 15:03:38 +0000 (16:03 +0100)]
media: atomisp: Simplify atomisp_[start|stop]_streaming()
Now that continuous mode is gone and we only have 1 /dev/video# node,
the videobuf2 core guarantees that atomisp_[start|stop]_streaming() will
only be called one at a time.
So there is no need to check for things like the isp is already streaming
when starting, or other streams still being active while stopping.
Remove checks for these from atomisp_[start|stop]_streaming().
While at it also improve the logging a bit:
1. Remove the dev_err(isp->dev, "atomisp_reset") logged on every
stream stop (even though everything is fine.
2. Log a message when starting/stopping the sensor stream fails
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Tue, 9 May 2023 21:12:16 +0000 (22:12 +0100)]
media: atomisp: Remove atomisp_sensor_start_stream()
Now that we no longer have continuous mode we always want to
start the sensor on the first atomisp_start_streaming() call
and stop it on the first atomisp_stop_streaming() call.
Remove atomisp_sensor_start_stream() which returned the number
of streams which should be active before starting the sensor
and always start/stop the sensor directly.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Thu, 11 May 2023 14:51:21 +0000 (15:51 +0100)]
media: atomisp: Remove isp_timeout flag
isp_timeout only ever gets set in __atomisp_css_recover() and then
immediately gets cleared again after calling atomisp_reset().
All this happens with isp->mutex held.
The only consumer of isp->isp_timeout is atomisp_stop_streaming(), which
also holds isp->mutex and which is *not* called by atomisp_reset().
Since both hold isp->mutex and since __atomisp_css_recover() clears
isp_timeout before releasing the mutex, atomisp_stop_streaming() can
never see isp_timeout being true, so just remove the flag.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Wed, 10 May 2023 20:21:51 +0000 (21:21 +0100)]
media: atomisp: Remove unused mipi_frame_size field from atomisp_[sub_]device
Both the atomisp_device and the atomisp_sub_device structs have
an unused mipi_frame_size field, remove the field from both.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 20:21:30 +0000 (21:21 +0100)]
media: atomisp: Remove a bunch of unused atomisp_css_*() functions
Remove various unused atomisp_css_*() functions from
atomisp_compat_css20.c.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 20:19:33 +0000 (21:19 +0100)]
media: atomisp: Remove atomisp_subdev_register_video_nodes() helper
Now that there is only 1 /dev/video# node left there is no need to
do this in a helper. Just make atomisp_register_device_nodes()
call video_register_device() directly.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 20:14:47 +0000 (21:14 +0100)]
media: atomisp: Remove 1 line atomisp_flush_bufs_and_wakeup() helper
After recent changes this now is just a wrapper around
atomisp_flush_video_pipe(). Make its single caller call
atomisp_flush_video_pipe() directly and drop the helper.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 20:11:42 +0000 (21:11 +0100)]
media: atomisp: Remove source_pad parameter from functions and structs
Now that there is only 1 source-pad for an asd there is no need
to have a parameter for this in various places.
Remove the source_pad function parameter and
atomisp_sub_device.capture_pad data member.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 19:42:26 +0000 (20:42 +0100)]
media: atomisp: Rename video_out_preview to video_out
Now that we have only 1 /dev/video# node for output for all different
run-modes (with only 1 run-mode at a time) using video_out_preview for
the remaining atomisp_pipe does not properly reflect that this is
*the* output pipe. Fo the following renames to fix the naming:
s/video_out_preview/video_out/
s/ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW/ATOMISP_SUBDEV_PAD_SOURCE/
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 14:20:22 +0000 (15:20 +0100)]
media: atomisp: Drop atomisp_is_vf_pipe()
Since there only is one /dev/video# node now (no more continuous mode),
there are now no longer separate main capture + view-finder pipes.
We are now always on the main pipe, so atomisp_is_vf_pipe() should
always return false now. Drop any checks using it, replacing them
with the code-path for a false return.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 11:54:26 +0000 (12:54 +0100)]
media: atomisp: Register only 1 /dev/video# node
Now that we no longer support continuous mode and thus no longer support
streaming from 2 /dev/video# nodes at the same time, there is no need
to have a separate /dev/video# node (+ matching v4l2-subdev pads)
for each run-mode.
Keep the video_out_preview /dev/video0 device and remove
the video_out_video_capture / video_out_vf / video_out_capture
video-devices (atomisp_pipe-s) and also remove the matching
ATOMISP_SUBDEV_PAD_SOURCE_VIDEO / ATOMISP_SUBDEV_PAD_SOURCE_VF /
ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE source-pads.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 18:11:48 +0000 (19:11 +0100)]
media: atomisp: Replace source-pad checks with run-mode checks
Currently atomisp behavior is determined by a mix of which /dev/video# node
(which isp-subdev source-pad) is opened + which run-mode is set.
With various combinations not being allowed and likely leading to crashes
due to lack of error checking.
Now that we no longer support continuous mode and thus no longer support
streaming from 2 /dev/video# nodes at the same time, there is no need
to have a separate /dev/video# node for each run-mode. Instead the plan is
to support the 3 different run-modes on a single /dev/video# node.
Since we are moving to a single isp-subdev source-pad, the behavior should
then be solely and consistently be defined by the run-mode.
Replace various source-pad checks with run-mode checks in preparation for
moving to a single source-pad. In some places the new run-mode checks
overlap with existing run-mode checks and the checks are folded together
into a single check.
This removes handling of the ATOMISP_SUBDEV_PAD_SOURCE_VF source-pad,
this source-pad was only useful for continuous mode, for which support has
been removed.
Note that currently the only run-mode which we actually have been able to
get to work is the video-capture with scaler aka preview mode and as such
that is also the only run-mode tested. This patch is intended to preserve
the current (known to not work 100%) behavior of the other run-modes, so
that those maybe can be enabled later.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 17:38:10 +0000 (18:38 +0100)]
media: atomisp: Drop atomisp_get_css_buf_type()
Since continuous mode has been removed, there no longer is the option for
separate capture output + viewfinder output streams at the same time.
So all buffers queued by userspace are now for the normal output stream,
remove atomisp_get_css_buf_type() and always use
IA_CSS_BUFFER_TYPE_OUTPUT_FRAME for buffers queued by userspace.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 15:23:48 +0000 (16:23 +0100)]
media: atomisp: Remove isp->need_gfx_throttle field
Remove the isp->need_gfx_throttle field it is only ever set and
never read.
Also the code setting it is broken, comparing run_mode->val to
ATOMISP_SUBDEV_PAD_SOURCE_VIDEO which are not of the same type /
not part of the same enum.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sun, 7 May 2023 15:16:06 +0000 (16:16 +0100)]
media: atomisp: Remove Continuous capture and SDV run-modes
Since we no longer support Continuous mode, setting the run_mode to
ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE no longer make sense, so remove
this.
While at it, also remove ATOMISP_RUN_MODE_SDV, which was never exposed
to userspace in the first place.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Hans de Goede [Sat, 6 May 2023 18:56:05 +0000 (19:56 +0100)]
media: atomisp: Remove res_overflow parameter from atomisp_try_fmt()
The only remaining caller of atomisp_try_fmt() always passes NULL
for the res_overflow parameter. Drop it and simplify atomisp_try_fmt().
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:32 +0000 (07:26 +0100)]
media: atomisp: sh_css_mipi: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-5-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:31 +0000 (07:26 +0100)]
media: atomisp: sh_css_firmware: determine firmware version at runtime
The firmware version of ISP2401 and 2400 is determined at runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-4-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:30 +0000 (07:26 +0100)]
media: atomisp: sh_css_sp: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 will be determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-3-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:29 +0000 (07:26 +0100)]
media: atomisp: runtime: frame: remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-2-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Kate Hsuan [Mon, 8 May 2023 06:26:28 +0000 (07:26 +0100)]
media: atomisp: sh_css: Remove #ifdef ISP2401
The actions of ISP2401 and 2400 are determined at the runtime.
Link: https://lore.kernel.org/r/20230508062632.34537-1-hpa@redhat.com
Signed-off-by: Kate Hsuan <hpa@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:47:57 +0000 (06:47 +0300)]
media: uvcvideo: Constify descriptor buffers
There is no need to modify the content of UVC descriptor buffers during
parsing. Make all the corresponding pointers const to avoid unintended
modifications.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:47:57 +0000 (06:47 +0300)]
media: uvcvideo: Constify formats, frames and intervals
The formats, frames and intervals stored in the uvc_streaming structure
are not meant to change after being parsed at probe time. Make them
const to prevent unintended modifications, and adapt the probe code
accordingly to use non-const pointers during parsing.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Increment intervals pointer at end of parsing
The intervals pointer is incremented for each interval when parsing the
format descriptor. This doesn't cause any issue as such, but gets in the
way of constifying some pointers. Modify the parsing code to index the
intervals pointer as an array and increment it in one go at end of
parsing.
Careful readers will notice that the maxIntervalIndex variable is set to
1 instead of n - 2 when bFrameIntervalType has a zero value. This is
functionally equivalent, as n is equal to 3 in that case.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Reorganize format descriptor parsing
Format descriptor parsing has grown over time and now mixes parsing of
frame intervals with various quirk handling. Reorganize it to make the
code easier to follow, by parsing frame intervals first, and then
applying fixes and quirks. No functional change is intended.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Fri, 5 May 2023 11:45:24 +0000 (14:45 +0300)]
media: uvcvideo: Use clamp() to replace manual implementation
The kernel has a nice clamp() macro, use it to replace a manual
implementation based on min() and max(). No functional change is
intended.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:33:03 +0000 (06:33 +0300)]
media: uvcvideo: Rename uvc_format 'frame' field to 'frames'
The uvc_format 'frame' field points to an array of frames. Rename it to
'frames' to make this clearer.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Laurent Pinchart [Thu, 20 Apr 2023 03:33:03 +0000 (06:33 +0300)]
media: uvcvideo: Rename uvc_streaming 'format' field to 'formats'
The uvc_streaming 'format' field points to an array of formats. Rename
it to 'formats' to make this clearer.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dmitry Perchanov [Thu, 20 Apr 2023 09:06:55 +0000 (12:06 +0300)]
media: uvcvideo: Enable Intel RealSense metadata for devices
Intel RealSense UVC Depth cameras produce metadata in a
vendor-specific format that is already supported by the uvcvideo driver.
Enable handling of this metadata for 7 additional RealSense devices.
Co-developed-by: Yu MENG <yu1.meng@intel.com>
Co-developed-by: Evgeni Raikhel <evgeni.raikhel@intel.com>
Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dmitry Perchanov [Thu, 1 Jun 2023 16:08:46 +0000 (19:08 +0300)]
media: uapi: v4l: Intel metadata format update
Update metadata structure for Intel RealSense UVC/MIPI cameras.
Compliant to Intel Configuration version 3.
Signed-off-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Sakari Ailus [Fri, 2 Jun 2023 13:19:19 +0000 (16:19 +0300)]
Revert "media: uvcvideo: Limit power line control for Acer EasyCamera"
This reverts commit
5dd0eab84ae9a4b292baf1ad02e1a273c475cd04.
Revert this patch as it has been merged twice. The earlier merged commit
is
81e78a6fc320 ("media: uvcvideo: Limit power line control for Acer
EasyCamera").
Reported-by: Dmitry Perchanov <dmitry.perchanov@intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Sergey Senozhatsky [Fri, 26 May 2023 06:29:34 +0000 (07:29 +0100)]
media: venus: provide ctx queue lock for ioctl synchronization
Video device has to provide a lock so that __video_do_ioctl()
can serialize IOCTL calls. Introduce a dedicated venus_inst
mutex for the purpose of vb2 operations synchronization.
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:48:18 +0000 (07:48 +0100)]
media: venus: return P010 as preferred format for 10 bit decode
If bit depth is detected as 10 bit by firmware, return
P010 as preferred decoder format to the client.
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:48:17 +0000 (07:48 +0100)]
media: venus: add handling of bit depth change from firmware
Set opb format to TP10_UWC and dpb to client set format
when bit depth change to 10 bit is detecting by firmware.
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:48:16 +0000 (07:48 +0100)]
media: venus: update calculation for dpb buffers
Use dpb color format, width and height of output port
for calculating buffer size of dpb buffers.
Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:48:15 +0000 (07:48 +0100)]
media: venus: add support for V4L2_PIX_FMT_P010 color format
add V4L2_PIX_FMT_P010 as supported color format for decoder.
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:17:09 +0000 (07:17 +0100)]
media: venus: replace arrary index with enum for supported formats
Use enums to list supported formats for encoder and decoder
instead of array index which was a error prone design.
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:02:52 +0000 (07:02 +0100)]
media: venus: fix EOS handling in decoder stop command
Use firmware version based check to assign correct
device address for EOS buffer to fix the EOS handling
with different firmware version.
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Tested-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:02:51 +0000 (07:02 +0100)]
media: venus: enable sufficient sequence change support for vp9
VP9 supports resolution change at interframe.
Currenlty, if sequence change is detected at interframe and
resources are sufficient, sequence change event is not raised
by firmware to driver until the next keyframe.
This change add the HFI to notify the sequence change in this
case to driver.
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Tested-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Dikshita Agarwal [Mon, 22 May 2023 06:02:50 +0000 (07:02 +0100)]
media: venus: add firmware version based check
Add firmware version based checks to enable/disable
features for different SOCs.
Tested-by: Nathan Hebert <nhebert@chromium.org>
Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
Signed-off-by: Viswanath Boma <quic_vboma@quicinc.com>
Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Gustavo A. R. Silva [Tue, 16 May 2023 23:14:49 +0000 (00:14 +0100)]
media: venus: hfi_cmds: Use struct_size() helper
Prefer struct_size() over open-coded versions of idiom:
sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count
where count is the max number of items the flexible array is supposed to
contain.
Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Gustavo A. R. Silva [Tue, 16 May 2023 23:14:27 +0000 (00:14 +0100)]
media: venus: hfi_cmds: Replace one-element array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in struct hfi_session_set_buffers_pkt, and refactor the rest of
the code, accordingly.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].
This results in no differences in binary output.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/292
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Gustavo A. R. Silva [Tue, 16 May 2023 20:17:32 +0000 (21:17 +0100)]
media: venus: Replace one-element arrays with flexible-array members
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in multiple structures, and refactor the rest of the code,
accordingly.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].
This results in no differences in binary output.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/291
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Gustavo A. R. Silva [Wed, 17 May 2023 01:03:39 +0000 (02:03 +0100)]
media: venus: hfi_cmds: Replace fake flex-array with flexible-array member
One-element arrays are deprecated, and we are replacing them with flexible
array members instead. So, replace one-element arrays with flexible-array
members in struct hfi_sys_set_resource_pkt, and refactor the rest of
the code, accordingly.
This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [1].
The only binary differences seen before/after changes are the
following:
17ba: mov %rbx,%rdi
17bd: call 17c2 <pkt_sys_set_resource+0x42>
17be: R_X86_64_PLT32 __tsan_write4-0x4
- 17c2: movl $0x14,(%rbx)
+ 17c2: movl $0x10,(%rbx)
17c8: lea 0x4(%rbx),%rdi
17cc: call 17d1 <pkt_sys_set_resource+0x51>
17cd: R_X86_64_PLT32 __tsan_write4-0x4
which is expected once this accounts for the following line of code
at drivers/media/platform/qcom/venus/hfi_cmds.c:73
73 pkt->hdr.size = sizeof(*pkt);
and as *pkt is of type struct hfi_sys_set_resource_pkt, sizeof(*pkt) is
reduced by 4 bytes, due to the flex-array transformation.
Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/293
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Rikard Falkeborn [Sat, 12 Sep 2020 19:03:01 +0000 (20:03 +0100)]
media: venus: helpers: Fix ALIGN() of non power of two
ALIGN() expects its second argument to be a power of 2, otherwise
incorrect results are produced for some inputs. The output can be
both larger or smaller than what is expected.
For example, ALIGN(304, 192) equals 320 instead of 384, and
ALIGN(65, 192) equals 256 instead of 192.
However, nestling two ALIGN() as is done in this case seem to only
produce results equal to or bigger than the expected result if ALIGN()
had handled non powers of two, and that in turn results in framesizes
that are either the correct size or too large.
Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN()
is sufficient.
Fixes:
ab1eda449c6e ("media: venus: vdec: handle 10bit bitstreams")
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Liu Shixin [Mon, 21 Sep 2020 08:24:40 +0000 (09:24 +0100)]
media: venus: simplify the return expression of venus_sys_set_* function
Simplify the return expression.
Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Qinglang Miao [Mon, 21 Sep 2020 13:10:38 +0000 (14:10 +0100)]
media: venus: simplify the return expression of session_process_buf()
Simplify the return expression.
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Stanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Mauro Carvalho Chehab [Fri, 9 Jun 2023 09:12:41 +0000 (10:12 +0100)]
Merge tag 'v6.4-rc5' into media_stage
Linux 6.4-rc5
* tag 'v6.4-rc5': (919 commits)
Linux 6.4-rc5
leds: qcom-lpg: Fix PWM period limits
selftests/ftrace: Choose target function for filter test from samples
KVM: selftests: Add test for race in kvm_recalculate_apic_map()
KVM: x86: Bail from kvm_recalculate_phys_map() if x2APIC ID is out-of-bounds
KVM: x86: Account fastpath-only VM-Exits in vCPU stats
KVM: SVM: vNMI pending bit is V_NMI_PENDING_MASK not V_NMI_BLOCKING_MASK
KVM: x86/mmu: Grab memslot for correct address space in NX recovery worker
tpm, tpm_tis: correct tpm_tis_flags enumeration values
Revert "ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in ext4_mb_check_limits"
media: uvcvideo: Don't expose unsupported formats to userspace
media: v4l2-subdev: Fix missing kerneldoc for client_caps
media: staging: media: imx: initialize hs_settle to avoid warning
media: v4l2-mc: Drop subdev check in v4l2_create_fwnode_links_to_pad()
riscv: Implement missing huge_ptep_get
riscv: Fix huge_ptep_set_wrprotect when PTE is a NAPOT
module/decompress: Fix error checking on zstd decompression
fork, vhost: Use CLONE_THREAD to fix freezer/ps regression
dt-bindings: serial: 8250_omap: add rs485-rts-active-high
selinux: don't use make's grouped targets feature yet
...
Linus Torvalds [Sun, 4 Jun 2023 18:04:27 +0000 (14:04 -0400)]
Linux 6.4-rc5
Linus Torvalds [Sun, 4 Jun 2023 15:57:38 +0000 (11:57 -0400)]
Merge tag 'irq_urgent_for_v6.4_rc5' of git://git./linux/kernel/git/tip/tip
Pull irq fix from Borislav Petkov:
- Fix open firmware quirks validation so that they don't get applied
wrongly
* tag 'irq_urgent_for_v6.4_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
irqchip/gic: Correctly validate OF quirk descriptors
Linus Torvalds [Sun, 4 Jun 2023 13:10:43 +0000 (09:10 -0400)]
Merge tag 'media/v6.4-4' of git://git./linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab:
"Some driver fixes:
- a regression fix for the verisilicon driver
- uvcvideo: don't expose unsupported video formats to userspace
- camss-video: don't zero subdev format after init
- mediatek: some fixes for 4K decoder formats
- fix a Sphinx build warning (missing doc for client_caps)
- some fixes for imx and atomisp staging drivers
And two CEC core fixes:
- don't set last_initiator if TX in progress
- disable adapter in cec_devnode_unregister"
* tag 'media/v6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
media: uvcvideo: Don't expose unsupported formats to userspace
media: v4l2-subdev: Fix missing kerneldoc for client_caps
media: staging: media: imx: initialize hs_settle to avoid warning
media: v4l2-mc: Drop subdev check in v4l2_create_fwnode_links_to_pad()
media: staging: media: atomisp: init high & low vars
media: cec: core: don't set last_initiator if tx in progress
media: cec: core: disable adapter in cec_devnode_unregister
media: mediatek: vcodec: Only apply 4K frame sizes on decoder formats
media: camss: camss-video: Don't zero subdev format again after initialization
media: verisilicon: Additional fix for the crash when opening the driver
Linus Torvalds [Sun, 4 Jun 2023 12:32:30 +0000 (08:32 -0400)]
Merge tag 'char-misc-6.4-rc5' of git://git./linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH:
"Here are a bunch of tiny char/misc/other driver fixes for 6.4-rc5 that
resolve a number of reported issues. Included in here are:
- iio driver fixes
- fpga driver fixes
- test_firmware bugfixes
- fastrpc driver tiny bugfixes
- MAINTAINERS file updates for some subsystems
All of these have been in linux-next this past week with no reported
issues"
* tag 'char-misc-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (34 commits)
test_firmware: fix the memory leak of the allocated firmware buffer
test_firmware: fix a memory leak with reqs buffer
test_firmware: prevent race conditions by a correct implementation of locking
firmware_loader: Fix a NULL vs IS_ERR() check
MAINTAINERS: Vaibhav Gupta is the new ipack maintainer
dt-bindings: fpga: replace Ivan Bornyakov maintainership
MAINTAINERS: update Microchip MPF FPGA reviewers
misc: fastrpc: reject new invocations during device removal
misc: fastrpc: return -EPIPE to invocations on device removal
misc: fastrpc: Reassign memory ownership only for remote heap
misc: fastrpc: Pass proper scm arguments for secure map request
iio: imu: inv_icm42600: fix timestamp reset
iio: adc: ad_sigma_delta: Fix IRQ issue by setting IRQ_DISABLE_UNLAZY flag
dt-bindings: iio: adc: renesas,rcar-gyroadc: Fix adi,ad7476 compatible value
iio: dac: mcp4725: Fix i2c_master_send() return value handling
iio: accel: kx022a fix irq getting
iio: bu27034: Ensure reset is written
iio: dac: build ad5758 driver when AD5758 is selected
iio: addac: ad74413: fix resistance input processing
iio: light: vcnl4035: fixed chip ID check
...
Linus Torvalds [Sun, 4 Jun 2023 12:02:25 +0000 (08:02 -0400)]
Merge tag 'driver-core-6.4-rc5' of git://git./linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH:
"Here are two small driver core cacheinfo fixes for 6.4-rc5 that
resolve a number of reported issues with that file. These changes have
been in linux-next this past week with no reported problems"
* tag 'driver-core-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
drivers: base: cacheinfo: Update cpu_map_populated during CPU Hotplug
drivers: base: cacheinfo: Fix shared_cpu_map changes in event of CPU hotplug
Linus Torvalds [Sun, 4 Jun 2023 11:51:33 +0000 (07:51 -0400)]
Merge tag 'tty-6.4-rc5' of git://git./linux/kernel/git/gregkh/tty
Pull tty/serial driver fixes from Greg KH:
"Here are some small tty/serial driver fixes for 6.4-rc5 that have all
been in linux-next this past week with no reported problems. Included
in here are:
- 8250_tegra driver bugfix
- fsl uart driver bugfixes
- Kconfig fix for dependancy issue
- dt-bindings fix for the 8250_omap driver"
* tag 'tty-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
dt-bindings: serial: 8250_omap: add rs485-rts-active-high
serial: cpm_uart: Fix a COMPILE_TEST dependency
soc: fsl: cpm1: Fix TSA and QMC dependencies in case of COMPILE_TEST
tty: serial: fsl_lpuart: use UARTCTRL_TXINV to send break instead of UARTCTRL_SBK
serial: 8250_tegra: Fix an error handling path in tegra_uart_probe()
Linus Torvalds [Sun, 4 Jun 2023 11:31:48 +0000 (07:31 -0400)]
Merge tag 'usb-6.4-rc5' of git://git./linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH:
"Here are some USB driver and core fixes for 6.4-rc5. Most of these are
tiny driver fixes, including:
- udc driver bugfix
- f_fs gadget driver bugfix
- cdns3 driver bugfix
- typec bugfixes
But the "big" thing in here is a fix yet-again for how the USB buffers
are handled from userspace when dealing with DMA issues. The changes
were discussed a lot, and tested a lot, on the list, and acked by the
relevant mm maintainers and have been in linux-next all this past week
with no reported problems"
* tag 'usb-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usb: typec: tps6598x: Fix broken polling mode after system suspend/resume
mm: page_table_check: Ensure user pages are not slab pages
mm: page_table_check: Make it dependent on EXCLUSIVE_SYSTEM_RAM
usb: usbfs: Use consistent mmap functions
usb: usbfs: Enforce page requirements for mmap
dt-bindings: usb: snps,dwc3: Fix "snps,hsphy_interface" type
usb: gadget: udc: fix NULL dereference in remove()
usb: gadget: f_fs: Add unbind event before functionfs_unbind
usb: cdns3: fix NCM gadget RX speed 20x slow than expection at iMX8QM
Linus Torvalds [Sun, 4 Jun 2023 11:16:53 +0000 (07:16 -0400)]
Merge tag 'for-linus' of git://git./virt/kvm/kvm
Pull kvm fixes from Paolo Bonzini:
"ARM:
- Address some fallout of the locking rework, this time affecting the
way the vgic is configured
- Fix an issue where the page table walker frees a subtree and then
proceeds with walking what it has just freed...
- Check that a given PA donated to the guest is actually memory (only
affecting pKVM)
- Correctly handle MTE CMOs by Set/Way
- Fix the reported address of a watchpoint forwarded to userspace
- Fix the freeing of the root of stage-2 page tables
- Stop creating spurious PMU events to perform detection of the
default PMU and use the existing PMU list instead
x86:
- Fix a memslot lookup bug in the NX recovery thread that could
theoretically let userspace bypass the NX hugepage mitigation
- Fix a s/BLOCKING/PENDING bug in SVM's vNMI support
- Account exit stats for fastpath VM-Exits that never leave the super
tight run-loop
- Fix an out-of-bounds bug in the optimized APIC map code, and add a
regression test for the race"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: selftests: Add test for race in kvm_recalculate_apic_map()
KVM: x86: Bail from kvm_recalculate_phys_map() if x2APIC ID is out-of-bounds
KVM: x86: Account fastpath-only VM-Exits in vCPU stats
KVM: SVM: vNMI pending bit is V_NMI_PENDING_MASK not V_NMI_BLOCKING_MASK
KVM: x86/mmu: Grab memslot for correct address space in NX recovery worker
KVM: arm64: Document default vPMU behavior on heterogeneous systems
KVM: arm64: Iterate arm_pmus list to probe for default PMU
KVM: arm64: Drop last page ref in kvm_pgtable_stage2_free_removed()
KVM: arm64: Populate fault info for watchpoint
KVM: arm64: Reload PTE after invoking walker callback on preorder traversal
KVM: arm64: Handle trap of tagged Set/Way CMOs
arm64: Add missing Set/Way CMO encodings
KVM: arm64: Prevent unconditional donation of unmapped regions from the host
KVM: arm64: vgic: Fix a comment
KVM: arm64: vgic: Fix locking comment
KVM: arm64: vgic: Wrap vgic_its_create() with config_lock
KVM: arm64: vgic: Fix a circular locking issue
Linus Torvalds [Sun, 4 Jun 2023 11:11:13 +0000 (07:11 -0400)]
Merge tag 'powerpc-6.4-4' of git://git./linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman:
- Fix link errors in new aes-gcm-p10 code when built-in with other
drivers
- Limit number of TCEs passed to H_STUFF_TCE hcall as per spec
- Use KSYM_NAME_LEN in xmon array size to avoid possible OOB write
Thanks to Gaurav Batra and Maninder Singh Vishal Chourasia.
* tag 'powerpc-6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/xmon: Use KSYM_NAME_LEN in array size
powerpc/iommu: Limit number of TCEs to 512 for H_STUFF_TCE hcall
powerpc/crypto: Fix aes-gcm-p10 link errors
Paolo Bonzini [Sat, 3 Jun 2023 19:16:58 +0000 (15:16 -0400)]
Merge tag 'kvm-x86-fixes-6.4' of https://github.com/kvm-x86/linux into HEAD
KVM x86 fixes for 6.4
- Fix a memslot lookup bug in the NX recovery thread that could
theoretically let userspace bypass the NX hugepage mitigation
- Fix a s/BLOCKING/PENDING bug in SVM's vNMI support
- Account exit stats for fastpath VM-Exits that never leave the super
tight run-loop
- Fix an out-of-bounds bug in the optimized APIC map code, and add a
regression test for the race.
Paolo Bonzini [Sat, 3 Jun 2023 19:15:49 +0000 (15:15 -0400)]
Merge tag 'kvmarm-fixes-6.4-3' of git://git./linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.4, take #3
- Fix the reported address of a watchpoint forwarded to userspace
- Fix the freeing of the root of stage-2 page tables
- Stop creating spurious PMU events to perform detection of the
default PMU and use the existing PMU list instead.
Paolo Bonzini [Sat, 3 Jun 2023 19:14:18 +0000 (15:14 -0400)]
Merge tag 'kvmarm-fixes-6.4-2' of git://git./linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 fixes for 6.4, take #2
- Address some fallout of the locking rework, this time affecting
the way the vgic is configured
- Fix an issue where the page table walker frees a subtree and
then proceeds with walking what it has just freed...
- Check that a given PA donated to the gues is actually memory
(only affecting pKVM)
- Correctly handle MTE CMOs by Set/Way
Linus Torvalds [Sat, 3 Jun 2023 17:52:24 +0000 (13:52 -0400)]
Merge tag 'scsi-fixes' of git://git./linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley:
"Five fixes, all in drivers.
The most extensive is the target change to fix the hang in the login
code, which involves changing timers from per login to per connection"
* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
scsi: stex: Fix gcc 13 warnings
scsi: qla2xxx: Fix NULL pointer dereference in target mode
scsi: target: iscsi: Prevent login threads from racing between each other
scsi: target: iscsi: Remove unused transport_timer
scsi: target: iscsi: Fix hang in the iSCSI login code
Linus Torvalds [Sat, 3 Jun 2023 17:46:11 +0000 (13:46 -0400)]
Merge tag 'leds-6.4-rc5' of git://git./linux/kernel/git/johan/linux
Pull LED fix from Johan Hovold:
"Here's a fix for a regression in 6.4-rc1 which broke the backlight on
machines such as the Lenovo ThinkPad X13s"
Acked-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/lkml/20230602091928.GR449117@google.com/
* tag 'leds-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/linux:
leds: qcom-lpg: Fix PWM period limits
Bjorn Andersson [Mon, 15 May 2023 16:26:04 +0000 (09:26 -0700)]
leds: qcom-lpg: Fix PWM period limits
The introduction of high resolution PWM support changed the order of the
operations in the calculation of min and max period. The result in both
divisions is in most cases a truncation to 0, which limits the period to
the range of [0, 0].
Both numerators (and denominators) are within 64 bits, so the whole
expression can be put directly into the div64_u64, instead of doing it
partially.
Fixes:
b00d2ed37617 ("leds: rgb: leds-qcom-lpg: Add support for high resolution PWM")
Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>
Tested-by: Steev Klimaszewski <steev@kali.org>
Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
Acked-by: Lee Jones <lee@kernel.org>
Tested-by: Johan Hovold <johan+linaro@kernel.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD
Link: https://lore.kernel.org/r/20230515162604.649203-1-quic_bjorande@quicinc.com
Signed-off-by: Johan Hovold <johan@kernel.org>
Linus Torvalds [Sat, 3 Jun 2023 12:23:16 +0000 (08:23 -0400)]
Merge tag 'probes-fixes-6.4-rc4' of git://git./linux/kernel/git/trace/linux-trace
Pull probes fixes from Masami Hiramatsu:
- Return NULL if the trace_probe list on trace_probe_event is empty
- selftests/ftrace: Choose testing symbol name for filtering feature
from sample data instead of fixed symbol
* tag 'probes-fixes-6.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
selftests/ftrace: Choose target function for filter test from samples
tracing/probe: trace_probe_primary_from_call(): checked list_first_entry
Masami Hiramatsu (Google) [Sun, 19 Mar 2023 02:53:32 +0000 (11:53 +0900)]
selftests/ftrace: Choose target function for filter test from samples
Since the event-filter-function.tc expects the 'exit_mmap()' directly
calls 'kmem_cache_free()', this is vulnerable to code modifications.
Choose the target function for the filter test from the sample
event data so that it can keep test running correctly even if the caller
function name will be changed.
Link: https://lore.kernel.org/linux-trace-kernel/167919441260.1922645.18355804179347364057.stgit@mhiramat.roam.corp.google.com/
Link: https://lore.kernel.org/all/CA+G9fYtF-XEKi9YNGgR=Kf==7iRb2FrmEC7qtwAeQbfyah-UhA@mail.gmail.com/
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Fixes:
7f09d639b8c4 ("tracing/selftests: Add test for event filtering on function name")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Michal Luczaj [Fri, 2 Jun 2023 23:32:50 +0000 (16:32 -0700)]
KVM: selftests: Add test for race in kvm_recalculate_apic_map()
Keep switching between LAPIC_MODE_X2APIC and LAPIC_MODE_DISABLED during
APIC map construction to hunt for TOCTOU bugs in KVM. KVM's optimized map
recalc makes multiple passes over the list of vCPUs, and the calculations
ignore vCPU's whose APIC is hardware-disabled, i.e. there's a window where
toggling LAPIC_MODE_DISABLED is quite interesting.
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Co-developed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20230602233250.1014316-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Sean Christopherson [Fri, 2 Jun 2023 23:32:48 +0000 (16:32 -0700)]
KVM: x86: Bail from kvm_recalculate_phys_map() if x2APIC ID is out-of-bounds
Bail from kvm_recalculate_phys_map() and disable the optimized map if the
target vCPU's x2APIC ID is out-of-bounds, i.e. if the vCPU was added
and/or enabled its local APIC after the map was allocated. This fixes an
out-of-bounds access bug in the !x2apic_format path where KVM would write
beyond the end of phys_map.
Check the x2APIC ID regardless of whether or not x2APIC is enabled,
as KVM's hardcodes x2APIC ID to be the vCPU ID, i.e. it can't change, and
the map allocation in kvm_recalculate_apic_map() doesn't check for x2APIC
being enabled, i.e. the check won't get false postivies.
Note, this also affects the x2apic_format path, which previously just
ignored the "x2apic_id > new->max_apic_id" case. That too is arguably a
bug fix, as ignoring the vCPU meant that KVM would not send interrupts to
the vCPU until the next map recalculation. In practice, that "bug" is
likely benign as a newly present vCPU/APIC would immediately trigger a
recalc. But, there's no functional downside to disabling the map, and
a future patch will gracefully handle the -E2BIG case by retrying instead
of simply disabling the optimized map.
Opportunistically add a sanity check on the xAPIC ID size, along with a
comment explaining why the xAPIC ID is guaranteed to be "good".
Reported-by: Michal Luczaj <mhal@rbox.co>
Fixes:
5b84b0291702 ("KVM: x86: Honor architectural behavior for aliased 8-bit APIC IDs")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230602233250.1014316-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Sean Christopherson [Fri, 2 Jun 2023 01:19:19 +0000 (18:19 -0700)]
KVM: x86: Account fastpath-only VM-Exits in vCPU stats
Increment vcpu->stat.exits when handling a fastpath VM-Exit without
going through any part of the "slow" path. Not bumping the exits stat
can result in wildly misleading exit counts, e.g. if the primary reason
the guest is exiting is to program the TSC deadline timer.
Fixes:
404d5d7bff0d ("KVM: X86: Introduce more exit_fastpath_completion enum values")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230602011920.787844-2-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Maciej S. Szmigiero [Fri, 19 May 2023 11:26:18 +0000 (13:26 +0200)]
KVM: SVM: vNMI pending bit is V_NMI_PENDING_MASK not V_NMI_BLOCKING_MASK
While testing Hyper-V enabled Windows Server 2019 guests on Zen4 hardware
I noticed that with vCPU count large enough (> 16) they sometimes froze at
boot.
With vCPU count of 64 they never booted successfully - suggesting some kind
of a race condition.
Since adding "vnmi=0" module parameter made these guests boot successfully
it was clear that the problem is most likely (v)NMI-related.
Running kvm-unit-tests quickly showed failing NMI-related tests cases, like
"multiple nmi" and "pending nmi" from apic-split, x2apic and xapic tests
and the NMI parts of eventinj test.
The issue was that once one NMI was being serviced no other NMI was allowed
to be set pending (NMI limit = 0), which was traced to
svm_is_vnmi_pending() wrongly testing for the "NMI blocked" flag rather
than for the "NMI pending" flag.
Fix this by testing for the right flag in svm_is_vnmi_pending().
Once this is done, the NMI-related kvm-unit-tests pass successfully and
the Windows guest no longer freezes at boot.
Fixes:
fa4c027a7956 ("KVM: x86: Add support for SVM's Virtual NMI")
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/be4ca192eb0c1e69a210db3009ca984e6a54ae69.1684495380.git.maciej.szmigiero@oracle.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Sean Christopherson [Fri, 2 Jun 2023 01:01:37 +0000 (18:01 -0700)]
KVM: x86/mmu: Grab memslot for correct address space in NX recovery worker
Factor in the address space (non-SMM vs. SMM) of the target shadow page
when recovering potential NX huge pages, otherwise KVM will retrieve the
wrong memslot when zapping shadow pages that were created for SMM. The
bug most visibly manifests as a WARN on the memslot being non-NULL, but
the worst case scenario is that KVM could unaccount the shadow page
without ensuring KVM won't install a huge page, i.e. if the non-SMM slot
is being dirty logged, but the SMM slot is not.
------------[ cut here ]------------
WARNING: CPU: 1 PID: 3911 at arch/x86/kvm/mmu/mmu.c:7015
kvm_nx_huge_page_recovery_worker+0x38c/0x3d0 [kvm]
CPU: 1 PID: 3911 Comm: kvm-nx-lpage-re
RIP: 0010:kvm_nx_huge_page_recovery_worker+0x38c/0x3d0 [kvm]
RSP: 0018:
ffff99b284f0be68 EFLAGS:
00010246
RAX:
0000000000000000 RBX:
ffff99b284edd000 RCX:
0000000000000000
RDX:
0000000000000000 RSI:
0000000000000000 RDI:
0000000000000000
RBP:
ffff9271397024e0 R08:
0000000000000000 R09:
ffff927139702450
R10:
0000000000000000 R11:
0000000000000001 R12:
ffff99b284f0be98
R13:
0000000000000000 R14:
ffff9270991fcd80 R15:
0000000000000003
FS:
0000000000000000(0000) GS:
ffff927f9f640000(0000) knlGS:
0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
CR2:
00007f0aacad3ae0 CR3:
000000088fc2c005 CR4:
00000000003726e0
Call Trace:
<TASK>
__pfx_kvm_nx_huge_page_recovery_worker+0x10/0x10 [kvm]
kvm_vm_worker_thread+0x106/0x1c0 [kvm]
kthread+0xd9/0x100
ret_from_fork+0x2c/0x50
</TASK>
---[ end trace
0000000000000000 ]---
This bug was exposed by commit
edbdb43fc96b ("KVM: x86: Preserve TDP MMU
roots until they are explicitly invalidated"), which allowed KVM to retain
SMM TDP MMU roots effectively indefinitely. Before commit
edbdb43fc96b,
KVM would zap all SMM TDP MMU roots and thus all SMM TDP MMU shadow pages
once all vCPUs exited SMM, which made the window where this bug (recovering
an SMM NX huge page) could be encountered quite tiny. To hit the bug, the
NX recovery thread would have to run while at least one vCPU was in SMM.
Most VMs typically only use SMM during boot, and so the problematic shadow
pages were gone by the time the NX recovery thread ran.
Now that KVM preserves TDP MMU roots until they are explicitly invalidated
(e.g. by a memslot deletion), the window to trigger the bug is effectively
never closed because most VMMs don't delete memslots after boot (except
for a handful of special scenarios).
Fixes:
eb298605705a ("KVM: x86/mmu: Do not recover dirty-tracked NX Huge Pages")
Reported-by: Fabio Coatti <fabio.coatti@gmail.com>
Closes: https://lore.kernel.org/all/CADpTngX9LESCdHVu_2mQkNGena_Ng2CphWNwsRGSMxzDsTjU2A@mail.gmail.com
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230602010137.784664-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Lino Sanfilippo [Tue, 30 May 2023 16:41:16 +0000 (18:41 +0200)]
tpm, tpm_tis: correct tpm_tis_flags enumeration values
With commit
858e8b792d06 ("tpm, tpm_tis: Avoid cache incoherency in test
for interrupts") bit accessor functions are used to access flags in
tpm_tis_data->flags.
However these functions expect bit numbers, while the flags are defined
as bit masks in enum tpm_tis_flag.
Fix this inconsistency by using numbers instead of masks also for the
flags in the enum.
Reported-by: Pavel Machek <pavel@denx.de>
Fixes:
858e8b792d06 ("tpm, tpm_tis: Avoid cache incoherency in test for interrupts")
Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com>
Cc: stable@vger.kernel.org
Reviewed-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds [Fri, 2 Jun 2023 21:25:22 +0000 (17:25 -0400)]
Merge tag 'ext4_for_linus_stable' of git://git./linux/kernel/git/tytso/ext4
Pull ext4 fix from Ted Ts'o:
"Fix an ext4 regression which landed during the 6.4 merge window"
* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
Revert "ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in ext4_mb_check_limits"
Linus Torvalds [Fri, 2 Jun 2023 21:16:19 +0000 (17:16 -0400)]
Merge tag 'for-6.4-rc4-tag' of git://git./linux/kernel/git/kdave/linux
Pull btrfs fix from David Sterba:
"One regression fix.
The rewrite of scrub code in 6.4 broke device replace in zoned mode,
some of the writes could happen out of order so this had to be
adjusted for all cases"
* tag 'for-6.4-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: zoned: fix dev-replace after the scrub rework
Ojaswin Mujoo [Tue, 30 May 2023 12:33:39 +0000 (18:03 +0530)]
Revert "ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in ext4_mb_check_limits"
This reverts commit
32c0869370194ae5ac9f9f501953ef693040f6a1.
The reverted commit was intended to remove a dead check however it was observed
that this check was actually being used to exit early instead of looping
sbi->s_mb_max_to_scan times when we are able to find a free extent bigger than
the goal extent. Due to this, a my performance tests (fsmark, parallel file
writes in a highly fragmented FS) were seeing a 2x-3x regression.
Example, the default value of the following variables is:
sbi->s_mb_max_to_scan = 200
sbi->s_mb_min_to_scan = 10
In ext4_mb_check_limits() if we find an extent smaller than goal, then we return
early and try again. This loop will go on until we have processed
sbi->s_mb_max_to_scan(=200) number of free extents at which point we exit and
just use whatever we have even if it is smaller than goal extent.
Now, the regression comes when we find an extent bigger than goal. Earlier, in
this case we would loop only sbi->s_mb_min_to_scan(=10) times and then just use
the bigger extent. However with commit
32c08693 that check was removed and hence
we would loop sbi->s_mb_max_to_scan(=200) times even though we have a big enough
free extent to satisfy the request. The only time we would exit early would be
when the free extent is *exactly* the size of our goal, which is pretty uncommon
occurrence and so we would almost always end up looping 200 times.
Hence, revert the commit by adding the check back to fix the regression. Also
add a comment to outline this policy.
Fixes:
32c086937019 ("ext4: remove ac->ac_found > sbi->s_mb_min_to_scan dead check in ext4_mb_check_limits")
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Reviewed-by: Kemeng Shi <shikemeng@huaweicloud.com>
Link: https://lore.kernel.org/r/ddcae9658e46880dfec2fb0aa61d01fb3353d202.1685449706.git.ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>