]> git.proxmox.com Git - mirror_ubuntu-kernels.git/log
mirror_ubuntu-kernels.git
4 years agomedia: atomisp: fix call to g_frame_interval
Mauro Carvalho Chehab [Sun, 21 Jun 2020 06:32:27 +0000 (08:32 +0200)]
media: atomisp: fix call to g_frame_interval

The media core has now a check if fi->pad is bigger than zero
or bigger than sd->entity.num_pads, if the media controller
is defined.

This causes a call to g_frame_interval to return -EINVAL.

Fix it by first cleaning up the struct.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: properly parse CLK PMIC on newer devices
Mauro Carvalho Chehab [Sat, 20 Jun 2020 10:25:10 +0000 (12:25 +0200)]
media: atomisp: properly parse CLK PMIC on newer devices

Newer devices don't place the PMIC CLK line inside an EFI
var. Instead, those are found at the _PR0 table.

Add a parser for it, using info stored via the DSDT table.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Prepare sensor support for ACPI PM
Mauro Carvalho Chehab [Sun, 14 Jun 2020 07:02:01 +0000 (09:02 +0200)]
media: atomisp: Prepare sensor support for ACPI PM

Add support code for this driver to use ACPI power management.

Yet, at least with known devices, this won't work without
further changes.

The rationale is that the ACPI handling code checks for the _PR? tables
in order to know what is required to switch the device from power state
D0 (_PR0) up to D3COLD (_PR3).

The adev->flags.power_manageable is set to true if the device has a _PR0
table, which can be checked by calling acpi_device_power_manageable(adev).

However, this only says that the device can be set to power off mode.

At least on the DSDT tables we've seen so far, there's no _PR3 nor _PS3
(which would have a somewhat similar effect).

So, using ACPI for power management won't work, except if adding
an ACPI override logic somewhere.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: reorganize the code under gmin_subdev_add()
Mauro Carvalho Chehab [Sun, 14 Jun 2020 06:36:23 +0000 (08:36 +0200)]
media: atomisp: reorganize the code under gmin_subdev_add()

The gmin_subdev_add() currently doesn't use ACPI device
power management. In order to prepare for adding support
for it, let's shift some things, placing the PM-related
stuff at the end of the probing logic.

Let's also store the current gs on a temporary var, in
order to simplify the source code.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix the handling of clock number
Mauro Carvalho Chehab [Sat, 13 Jun 2020 06:46:25 +0000 (08:46 +0200)]
media: atomisp: fix the handling of clock number

Right now, the driver is not doing the right thing to detect
the clock like used by the sensor, at least on devices
without the gmin's EFI vars.

Add some notes at the code to explain why and skip the wrong
value provided by the _DSM table.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: rkvdec: Fix H264 scaling list order
Jonas Karlman [Fri, 22 May 2020 20:21:33 +0000 (22:21 +0200)]
media: rkvdec: Fix H264 scaling list order

The Rockchip Video Decoder driver is expecting that the values in a
scaling list are in zig-zag order and applies the inverse scanning process
to get the values in matrix order.

Commit 0b0393d59eb4 ("media: uapi: h264: clarify expected
scaling_list_4x4/8x8 order") clarified that the values in the scaling list
should already be in matrix order.

Fix this by removing the reordering and change to use two memcpy.

Fixes: cd33c830448b ("media: rkvdec: Add the rkvdec driver")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Tested-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
[hverkuil-cisco@xs4all.nl: rkvdec_scaling_matrix -> rkvdec_h264_scaling_list]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-ctrls: Unset correct HEVC loop filter flag
Jonas Karlman [Tue, 26 May 2020 22:25:15 +0000 (00:25 +0200)]
media: v4l2-ctrls: Unset correct HEVC loop filter flag

Wrong loop filter flag is unset when tiles enabled flag is not set,
this cause HEVC decoding issues with Rockchip Video Decoder.

Fix this by unsetting the loop filter across tiles enabled flag instead of
the pps loop filter across slices enabled flag when tiles are disabled.

Fixes: 256fa3920874 ("media: v4l: Add definitions for HEVC stateless decoding")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size
Tomi Valkeinen [Wed, 27 May 2020 08:23:34 +0000 (10:23 +0200)]
media: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size

Commit 9495b7e92f716ab2bd6814fab5e97ab4a39adfdd ("driver core: platform:
Initialize dma_parms for platform devices") in v5.7-rc5 causes
vb2_dma_contig_clear_max_seg_size() to kfree memory that was not
allocated by vb2_dma_contig_set_max_seg_size().

The assumption in vb2_dma_contig_set_max_seg_size() seems to be that
dev->dma_parms is always NULL when the driver is probed, and the case
where dev->dma_parms has bee initialized by someone else than the driver
(by calling vb2_dma_contig_set_max_seg_size) will cause a failure.

All the current users of these functions are platform devices, which now
always have dma_parms set by the driver core. To fix the issue for v5.7,
make vb2_dma_contig_set_max_seg_size() return an error if dma_parms is
NULL to be on the safe side, and remove the kfree code from
vb2_dma_contig_clear_max_seg_size().

For v5.8 we should remove the two functions and move the
dma_set_max_seg_size() calls into the drivers.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Fixes: 9495b7e92f71 ("driver core: platform: Initialize dma_parms for platform devices")
Cc: stable@vger.kernel.org
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: v4l2-subdev.rst: correct information about v4l2 events
Michael Rodin [Wed, 27 May 2020 16:21:32 +0000 (18:21 +0200)]
media: v4l2-subdev.rst: correct information about v4l2 events

Remove description of non-existing v4l2_subdev.nevents and replace the
undefined flag V4L2_SUBDEV_USES_EVENTS by the correct flag
V4L2_SUBDEV_FL_HAS_EVENTS, which is already documented in v4l2_subdev.flags

Fixes: commit 02adb1cc765b ("[media] v4l: subdev: Events support")
Signed-off-by: Michael Rodin <mrodin@de.adit-jv.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: s5p-mfc: Properly handle dma_parms for the allocated devices
Marek Szyprowski [Thu, 28 May 2020 14:03:26 +0000 (16:03 +0200)]
media: s5p-mfc: Properly handle dma_parms for the allocated devices

Commit 9495b7e92f71 ("driver core: platform: Initialize dma_parms for
platform devices") in v5.7-rc5 added allocation of dma_parms structure to
all platform devices. Then vb2_dma_contig_set_max_seg_size() have been
changed not to allocate dma_parms structure and rely on the one allocated
by the device core. Lets allocate the needed structure also for the
devices created for the 2 MFC device memory ports.

Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Suggested-by: Ulf Hansson <ulf.hansson@linaro.org>
Fixes: 9495b7e92f71 ("driver core: platform: Initialize dma_parms for platform devices")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: medium: cec: Make MEDIA_CEC_SUPPORT default to n if !MEDIA_SUPPORT
Geert Uytterhoeven [Thu, 4 Jun 2020 09:39:53 +0000 (11:39 +0200)]
media: medium: cec: Make MEDIA_CEC_SUPPORT default to n if !MEDIA_SUPPORT

Recently, MEDIA_CEC_SUPPORT became indepedent of MEDIA_SUPPORT.
However, if MEDIA_SUPPORT is not enabled, MEDIA_SUPPORT_FILTER is not
defined, and MEDIA_CEC_SUPPORT is thus enabled by default, which is not
desirable.

Fix this by adding a dependency on MEDIA_CEC_SUPPORT to the default
configuration.

Fixes: 46d2a3b964ddbe63 ("media: place CEC menu before MEDIA_SUPPORT")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: cedrus: Implement runtime PM
Jernej Skrabec [Sat, 9 May 2020 20:06:43 +0000 (22:06 +0200)]
media: cedrus: Implement runtime PM

This allows the VE clocks and PLL_VE to be disabled most of the time.
A runtime PM reference is held while streaming.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: cedrus: Program output format during each run
Samuel Holland [Sat, 9 May 2020 20:06:42 +0000 (22:06 +0200)]
media: cedrus: Program output format during each run

Previously, the output format was programmed as part of the ioctl()
handler. However, this has two problems:

  1) If there are multiple active streams with different output
     formats, the hardware will use whichever format was set last
     for both streams. Similarly, an ioctl() done in an inactive
     context will wrongly affect other active contexts.
  2) The registers are written while the device is not actively
     streaming. To enable runtime PM tied to the streaming state,
     all hardware access needs to be moved inside cedrus_device_run().

The call to cedrus_dst_format_set() is now placed just before the
codec-specific callback that programs the hardware.

Cc: <stable@vger.kernel.org>
Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
Suggested-by: Jernej Skrabec <jernej.skrabec@siol.net>
Suggested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
Tested-by: Jernej Skrabec <jernej.skrabec@siol.net>
Reviewed-by: Jernej Skrabec <jernej.skrabec@siol.net>
Reviewed-by: Ezequiel Garcia <ezequiel@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: improve ACPI/DMI detection logs
Mauro Carvalho Chehab [Thu, 4 Jun 2020 15:04:33 +0000 (17:04 +0200)]
media: atomisp: improve ACPI/DMI detection logs

As there are several ways where the driver could possible
retrieve sensor data, make the prints clearer about what
was detected and from where.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Revert "media: atomisp: add Asus Transform T101HA ACPI vars"
Mauro Carvalho Chehab [Thu, 4 Jun 2020 20:28:38 +0000 (22:28 +0200)]
media: Revert "media: atomisp: add Asus Transform T101HA ACPI vars"

Now that the EFI _DSM table is parsed by the driver, we don't
need a DMI match anymore for Asus Transform T101HA.

This reverts commit 0a76fd8e8d202dcaabc714850205d5d75c9b8271.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: Revert "media: atomisp: Add some ACPI detection info"
Mauro Carvalho Chehab [Thu, 4 Jun 2020 12:40:40 +0000 (14:40 +0200)]
media: Revert "media: atomisp: Add some ACPI detection info"

This reverts commit 0d64e9420583cbc3c4a3f949ebe38fd8f7769281.

As gmin_subdev_add() now takes the ACPI handle directly,
we can deprecate the code that were doing this inside each
I2C driver.

PS.: This also reverts commit c03496b3bd92 ("media: atomisp: add a notice about possible leak resources")

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: improve sensor detection code to use _DSM table
Mauro Carvalho Chehab [Thu, 4 Jun 2020 09:46:03 +0000 (11:46 +0200)]
media: atomisp: improve sensor detection code to use _DSM table

Instead of keep hardcoding device-specific tables, read them
directly from the ACPI BIOS, if available.

This method is know to work with Asus T101HA device. the
same table is also visible on EzPad devices. So, it seems
that at least some BIOSes use this method to pass data about
ISP2401-connected sensors.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of an iomem abstraction layer
Mauro Carvalho Chehab [Mon, 1 Jun 2020 08:50:35 +0000 (10:50 +0200)]
media: atomisp: get rid of an iomem abstraction layer

The hive_isp_css_custom_host_hrt.h code, together
with atomisp_helper.h, provides an abstraction layer for
some functions inside atomisp_compat_css20.c and atomisp_cmd.c.

There's no good reason for that. In a matter of fact, after
removing the abstraction, the code looked a lot cleaner
and easier to understand.

So, get rid of them.

While here, get rid also of the udelay(1) abstraction code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of a string_support.h abstraction layer
Mauro Carvalho Chehab [Wed, 3 Jun 2020 06:19:44 +0000 (08:19 +0200)]
media: atomisp: get rid of a string_support.h abstraction layer

Some parts of the driver have their own implementation of
memcpy() & friends. Replace all of them by strscpy().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use strscpy() instead of less secure variants
Mauro Carvalho Chehab [Wed, 3 Jun 2020 06:12:14 +0000 (08:12 +0200)]
media: atomisp: use strscpy() instead of less secure variants

Replace usages of strcpy(), strlcpy() and strncpy() in favor
of strscpy().

Suggested-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: set DFS to MAX if sensor doesn't report fps
Mauro Carvalho Chehab [Mon, 1 Jun 2020 08:38:47 +0000 (10:38 +0200)]
media: atomisp: set DFS to MAX if sensor doesn't report fps

If the sensor doesn't implement support for g_frame_interval,
it won't return the expected fps rate.

Instead of keeping DFS on its minimal value (which will likely
not work), set it to the max.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use different dfs failed messages
Mauro Carvalho Chehab [Sun, 31 May 2020 12:02:55 +0000 (14:02 +0200)]
media: atomisp: use different dfs failed messages

There are several parts of the driver that could produce
a "dfs failed!" message. Change the texts, in order to help
identifying from where they're coming.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: change the detection of ISP2401 at runtime
Mauro Carvalho Chehab [Mon, 1 Jun 2020 07:43:24 +0000 (09:43 +0200)]
media: atomisp: change the detection of ISP2401 at runtime

Instead of having a static var to detect it, let's use the
already-existing arch-specific bytes, as this is how other
parts of the code also checks when it needs to do something
different, depending on an specific chipset version.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use macros from intel-family.h
Mauro Carvalho Chehab [Mon, 1 Jun 2020 07:39:55 +0000 (09:39 +0200)]
media: atomisp: use macros from intel-family.h

Instead of hardcoding the intel family values there, use
the already defined ones from asm/intel-family.h.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: don't set hpll_freq twice with different values
Mauro Carvalho Chehab [Mon, 1 Jun 2020 07:02:46 +0000 (09:02 +0200)]
media: atomisp: don't set hpll_freq twice with different values

The logic which sets the hpll_freq for BYT sets hpll_freq
to 1600MHz, but ignores it, and sets it again after reading
from-device-specific EFI vars (this time, using a default
of 2000MHz).

Remove the first set, as this will be overriden anyway.

While here, do minor adjustments on comments and on a
printk message.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of a detection hack for a BYT Andorid-based tablet
Mauro Carvalho Chehab [Mon, 1 Jun 2020 06:34:08 +0000 (08:34 +0200)]
media: atomisp: get rid of a detection hack for a BYT Andorid-based tablet

There's a hack at the driver that selects a different table
for a BYT tablet, which sets the maximum frequency to 320 MHz,
instead of 400 MHz.

After looking at the Intel Aero Yocto's version from:

https://download.01.org/aero/deb/pool/main/l/linux-4.4.76-aero-1.3/

It was noticed that this depends on an Android-specific modprobe parameter,
which uses a macro (INTEL_MID_BOARD) from this file:

arch/x86/include/asm/spid.h

>From the comments there, it looks like this macro parses a
variable passed at boot time:

cmdline : androidboot.spid=vend:cust:manu:plat:prod:hard

The devices in question are identified there as:

INTEL_BYT_TABLET_BLK_PRO = 0x0000
INTEL_BYT_TABLET_BLK_ENG = 0x8000

Well, this is something that we don't have upstream. So,
without further details about that, we can't really parse it.

If we ever end supporting those devices with the upstream driver,
this patch can be reverted and the device can be detected
via DMI (or maybe via PCI ID?).

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use just one mamoiada_params.h
Mauro Carvalho Chehab [Sun, 31 May 2020 11:53:08 +0000 (13:53 +0200)]
media: atomisp: use just one mamoiada_params.h

As both isp2400 and isp2401 files are identical, remove one
of them and remove the test for ISP variant.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: remove some unused defines from *mamoiada_params.h
Mauro Carvalho Chehab [Sun, 31 May 2020 11:50:05 +0000 (13:50 +0200)]
media: atomisp: remove some unused defines from *mamoiada_params.h

There are some parameters that are different between
isp2400 and isp2401. None of those are actually used.

So, get rid of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: simplify IRQ ifdef logic
Mauro Carvalho Chehab [Sun, 31 May 2020 11:28:12 +0000 (13:28 +0200)]
media: atomisp: simplify IRQ ifdef logic

There are lots of mess with IRQ ifdef settings. As the
*_global.h will already detect the type of IRQ system at
compile time, we can get rid of them, replacing by just
one ifdef for ISP2401.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of ifdef nonsense
Mauro Carvalho Chehab [Sun, 31 May 2020 11:06:01 +0000 (13:06 +0200)]
media: atomisp: get rid of ifdef nonsense

There are some ifdefs there that end doing the same thing.
Get rid of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of a duplicated file
Mauro Carvalho Chehab [Sun, 31 May 2020 10:57:41 +0000 (12:57 +0200)]
media: atomisp: get rid of a duplicated file

The contents of hive_isp_css_2401_irq_types_hrt.h and
hive_isp_css_common/irq_global.h are identical, except for
one unused enum:

On isp2401, this IRQ line has this name:

hrt_isp_css_irq_is2401 = HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID,

While the same bit is named as:
hrt_isp_css_irq_isp_pmem_error = HIVE_GP_DEV_IRQ_ISP_PMEM_ERROR_BIT_ID,

At the isp2400 version.

Remove one of them, in order to reduce the code differences
between those two versions.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: do some cleanup at irq_local.h
Mauro Carvalho Chehab [Sun, 31 May 2020 10:47:00 +0000 (12:47 +0200)]
media: atomisp: do some cleanup at irq_local.h

- Get rid of typedefs;
- Get rid of a duplicated enum type with different names for
  ISP2400 and ISP2401;
- adjust indentation on the touched code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: improve IRQ handling debug messages
Mauro Carvalho Chehab [Sun, 31 May 2020 09:55:21 +0000 (11:55 +0200)]
media: atomisp: improve IRQ handling debug messages

When an IRQ is not handled, it is nice to know what's the
reason.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: comment an unused code
Mauro Carvalho Chehab [Sun, 31 May 2020 09:39:17 +0000 (11:39 +0200)]
media: atomisp: comment an unused code

There's a different table for some BYT variants that depend
on something inside a FIXME ifdef.

Place this also inside it, just to shut up a clang-11 warning.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of a left-over wrapper function
Mauro Carvalho Chehab [Sun, 31 May 2020 09:38:41 +0000 (11:38 +0200)]
media: atomisp: get rid of a left-over wrapper function

The abstraction layer for kvfree() was removed, but there
is still a left-over code there.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of an unused IRQ duplicated event
Mauro Carvalho Chehab [Sat, 30 May 2020 22:08:41 +0000 (00:08 +0200)]
media: atomisp: get rid of an unused IRQ duplicated event

There are two names for the same IRQ, but just one is used.
Remove the unused one.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of sh_css_pipe.c
Mauro Carvalho Chehab [Sat, 30 May 2020 19:06:42 +0000 (21:06 +0200)]
media: atomisp: get rid of sh_css_pipe.c

There's nothing there, just comments.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: atomisp: fix stack overflow in init_pipe_defaults()
Arnd Bergmann [Fri, 29 May 2020 20:00:27 +0000 (22:00 +0200)]
media: staging: media: atomisp: fix stack overflow in init_pipe_defaults()

When building with clang, multiple copies of the structures to be
initialized are passed around on the stack and copied locally, using an
insane amount of stack space:

drivers/staging/media/atomisp/pci/sh_css.c:2371:1: error: stack frame size of 26864 bytes in function 'create_pipe' [-Werror,-Wframe-larger-than=]

Use constantly-allocated variables plus an explicit memcpy()
to avoid that.

Co-authored-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fixes: 6dc9a2568f84 ("media: atomisp: convert default struct values to use compound-literals with designated initializers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: re-enable warnings again
Mauro Carvalho Chehab [Sat, 30 May 2020 16:10:07 +0000 (18:10 +0200)]
media: atomisp: re-enable warnings again

For most warnings, the current code is OK. There are still
some issues with implicit-fallthough warnings.

Solve those and re-enable all warnings for this driver.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: remove format duplication at mbus->fourcc table
Mauro Carvalho Chehab [Sat, 30 May 2020 15:24:15 +0000 (17:24 +0200)]
media: atomisp: remove format duplication at mbus->fourcc table

This table used to be used also to translate between ia_css
abstraction and V4L2 fourcc codes.

This was removed on a past patch, but the table now contains
two fields with identical values.

Get rid of one of them.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: atomisp: add PMIC_OPREGION dependency
Arnd Bergmann [Fri, 29 May 2020 20:00:31 +0000 (22:00 +0200)]
media: staging: media: atomisp: add PMIC_OPREGION dependency

Without that driver, there is a link failure in

ERROR: modpost: "intel_soc_pmic_exec_mipi_pmic_seq_element"
[drivers/staging/media/atomisp/pci/atomisp_gmin_platform.ko] undefined!

Add an explicit Kconfig dependency.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: atomisp: disable all custom formats
Arnd Bergmann [Fri, 29 May 2020 20:00:30 +0000 (22:00 +0200)]
media: staging: media: atomisp: disable all custom formats

clang points out the usage of an incorrect enum type in the
list of supported image formats:

drivers/staging/media/atomisp/pci/atomisp_subdev.c:49:65: error: implicit conversion from enumeration type 'enum ia_css_frame_format' to different enumeration type 'enum atomisp_input_format' [-Werror,-Wenum-conversion]
        { V4L2_MBUS_FMT_CUSTOM_NV21, 12, 12, CSS_FRAME_FORMAT_NV21, 0, CSS_FRAME_FORMAT_NV21 },
drivers/staging/media/atomisp/pci/atomisp_subdev.c:49:39: error: implicit conversion from enumeration type 'enum ia_css_frame_format' to different enumeration type 'enum atomisp_input_format' [-Werror,-Wenum-conversion]
        { V4L2_MBUS_FMT_CUSTOM_NV21, 12, 12, CSS_FRAME_FORMAT_NV21, 0, CSS_FRAME_FORMAT_NV21 },
        { V4L2_MBUS_FMT_CUSTOM_NV12, 12, 12, CSS_FRAME_FORMAT_NV12, 0, CSS_FRAME_FORMAT_NV12 },
        { MEDIA_BUS_FMT_JPEG_1X8, 8, 8, CSS_FRAME_FORMAT_BINARY_8, 0, ATOMISP_INPUT_FORMAT_BINARY_8 },

Checking the git history, I found a commit that disabled one such case
because it did not work. It seems likely that the incorrect enum was
part of the original problem and that the others do not work either,
or have never been tested.

Disable all the ones that cause a warning.

Fixes: cb02ae3d71ea ("media: staging: atomisp: Disable custom format for now")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: atomisp: fix enum type mixups
Arnd Bergmann [Fri, 29 May 2020 20:00:29 +0000 (22:00 +0200)]
media: staging: media: atomisp: fix enum type mixups

Some function calls pass an incorrect enum type:

drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c:858:16: error: implicit conversion from enumeration type 'input_system_ID_t' to different enumeration type 'gp_device_ID_t' [-Werror,-Wenum-conversion]
        gp_device_rst(INPUT_SYSTEM0_ID);
        ~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c:860:19: error: implicit conversion from enumeration type 'input_system_ID_t' to different enumeration type 'gp_device_ID_t' [-Werror,-Wenum-conversion]
        input_switch_rst(INPUT_SYSTEM0_ID);
        ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c:876:27: error: implicit conversion from enumeration type 'input_system_cfg_flag_t' to different enumeration type 'input_system_connection_t' [-Werror,-Wenum-conversion]
                config.multicast[i]              = INPUT_SYSTEM_CFG_FLAG_RESET;
                                                 ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c:1326:32: error: implicit conversion from enumeration type 'input_system_ID_t' to different enumeration type 'gp_device_ID_t' [-Werror,-Wenum-conversion]
        input_selector_cfg_for_sensor(INPUT_SYSTEM0_ID);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~
drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c:1329:19: error: implicit conversion from enumeration type 'input_system_ID_t' to different enumeration type 'gp_device_ID_t' [-Werror,-Wenum-conversion]
        input_switch_cfg(INPUT_SYSTEM0_ID, &config.input_switch_cfg);
        ~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~

INPUT_SYSTEM0_ID is zero, so use the corresponding zero-value
of the expected types instead.

Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: media: atomisp: declare 'struct device' before using it
Arnd Bergmann [Fri, 29 May 2020 20:00:24 +0000 (22:00 +0200)]
media: staging: media: atomisp: declare 'struct device' before using it

In some configurations, including this header leads to a warning:

drivers/staging/media/atomisp//pci/sh_css_firmware.h:41:38: error: declaration of 'struct device' will not be visible outside of this function [-Werror,-Wvisibility]

Make sure the struct tag is known before declaring a function
that uses it as an argument.

Fixes: 9d4fa1a16b28 ("media: atomisp: cleanup directory hierarchy")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add SPDX headers
Mauro Carvalho Chehab [Sat, 30 May 2020 05:38:24 +0000 (07:38 +0200)]
media: atomisp: add SPDX headers

This driver is licensed under GPL 2.0, as stated inside their
headers.

Add the proper tag there. We should probably latter cleanup
the reduntant licensing text, but this could be done later,
after we get rid of other abstraction layers.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: atomisp: Check return value from compat_alloc_user_space
Sakari Ailus [Thu, 4 Jun 2020 16:16:21 +0000 (18:16 +0200)]
media: staging: atomisp: Check return value from compat_alloc_user_space

If something gets wrong, return, instead of trying to
convert from a NULL pointer.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: atomisp: Fix compat IOCTL handling
Sakari Ailus [Thu, 4 Jun 2020 16:16:20 +0000 (18:16 +0200)]
media: staging: atomisp: Fix compat IOCTL handling

Atomisp compat IOCTL handling suffers from the same security issue than
the V4L2 did. Fix this for atomisp.

See more information in patch a1dfb4c48cc1 ("media: v4l2-compat-ioctl32.c:
refactor compat ioctl32 logic").

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: atomisp: Fix atomisp_overlay32 compat handling
Sakari Ailus [Thu, 4 Jun 2020 16:16:19 +0000 (18:16 +0200)]
media: staging: atomisp: Fix atomisp_overlay32 compat handling

The struct atomisp_overlay contains overlay_start_x and overlay_start_y
fields. Instead of copying the value of the overlay_start_x field between
the two structs, the value of the overlay_start_y field of the compat
struct was copied to the overlay_start_x field of the 64-bit kernel struct
in get operation and back in put. The overlay_start_x field value was not
copied from or to the user space struct.

Fix this so that the value of overlay_start_x is copied to overlay_start_x
and the value of overlay_start_y is copied to overlay_start_y.

Also do copy blend_overlay_perc_u field only once.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: staging: atomisp: There's no struct atomisp_dvs2_coefficients
Sakari Ailus [Thu, 4 Jun 2020 16:16:18 +0000 (18:16 +0200)]
media: staging: atomisp: There's no struct atomisp_dvs2_coefficients

It's called struct atomisp_dis_coefficients.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add some debug messages when binaries are used
Mauro Carvalho Chehab [Fri, 29 May 2020 08:41:02 +0000 (10:41 +0200)]
media: atomisp: add some debug messages when binaries are used

The ISP firmware logic is complex, as several binaries are
contained into a single file.

Print debug messages:
- with a stack dump if binary not found;
- when a firmware is selected.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add a debug message at hmm free
Mauro Carvalho Chehab [Fri, 29 May 2020 10:18:25 +0000 (12:18 +0200)]
media: atomisp: add a debug message at hmm free

In order to check if aren't there any memory leaks, let's
add a debug print for hmm_free().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: allow passing firmware name at modprobe time
Mauro Carvalho Chehab [Fri, 29 May 2020 07:56:05 +0000 (09:56 +0200)]
media: atomisp: allow passing firmware name at modprobe time

It can be useful to be able to test different firmware files
at modprobe time, in order to be able to test different
variants without much efforts.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: print firmware data during load
Mauro Carvalho Chehab [Fri, 29 May 2020 07:29:58 +0000 (09:29 +0200)]
media: atomisp: print firmware data during load

While there's a way to list the firmware binaries in runtime,
it is worth to also print it during firmware load.

One advantage is that this code also introduces additional
checks with regards to invalid firmware types, which can be
useful to identify problems.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: provide more details about the firmware binaries
Mauro Carvalho Chehab [Fri, 29 May 2020 06:10:30 +0000 (08:10 +0200)]
media: atomisp: provide more details about the firmware binaries

In order to make easier to identify what a firmware file
contains, add more info at the firmware dump log facility.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of system_types.h
Mauro Carvalho Chehab [Fri, 29 May 2020 06:15:52 +0000 (08:15 +0200)]
media: atomisp: get rid of system_types.h

This is just a wrapper for system_local.h.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of a bunch of other wrappers
Mauro Carvalho Chehab [Thu, 28 May 2020 10:35:44 +0000 (12:35 +0200)]
media: atomisp: get rid of a bunch of other wrappers

There are too many wrapper functions at atomisp_compat_css20.c.

Get rid of another set of such wrappers.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: don't cause a warn if probe failed
Mauro Carvalho Chehab [Thu, 28 May 2020 10:11:57 +0000 (12:11 +0200)]
media: atomisp: don't cause a warn if probe failed

When probe fails, it is possible that hmm_init() to not be
called. On such case, hmm_cleanup() will cause a WARN_ON().

Avoid it by adding an explicit check at hmm_cleanup() to
ensure that the hmm code was properly initialized.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of an error abstraction layer
Mauro Carvalho Chehab [Fri, 29 May 2020 06:42:56 +0000 (08:42 +0200)]
media: atomisp: get rid of an error abstraction layer

There is an abstraction layer there meant to convert to
the Linux standard error codes. As the driver now use
such errors everywhere. we can get rid of this.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of non-Linux error codes
Mauro Carvalho Chehab [Thu, 28 May 2020 08:01:53 +0000 (10:01 +0200)]
media: atomisp: get rid of non-Linux error codes

The atomisp driver has its own error codes under the
ia_css_err.h file. On several places, those got already
replaced by standard error codes, but there are still a
lot more to be fixed.

Let's get rid of all of those, mapping them into
the already-existing set of Linux error codes.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: do another round of coding style cleanup
Mauro Carvalho Chehab [Thu, 28 May 2020 08:29:31 +0000 (10:29 +0200)]
media: atomisp: do another round of coding style cleanup

Run checkpatch --fix-inline again, in order to get rid
of some additional issues that got introduced (or that
checkpatch can now detect).

This should help preventing receiving random cleanups,
while keeping the code on a better shape.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: remove some trivial wrappers from compat css20
Mauro Carvalho Chehab [Thu, 28 May 2020 07:31:23 +0000 (09:31 +0200)]
media: atomisp: remove some trivial wrappers from compat css20

There are tons of code inside atomisp_compat_css20.c, but
several of them are just trivial wrappers to other functions.

Getting rid of all of them will take some time, but let's
start getting rid of some of the trivial ones.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: avoid an extra memset() when alloc memory
Mauro Carvalho Chehab [Thu, 28 May 2020 07:17:28 +0000 (09:17 +0200)]
media: atomisp: avoid an extra memset() when alloc memory

Use the variant which zeroes the memory when allocating,
instead of having an explicit memset.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Remove binary_supports_input_format
Nathan Chancellor [Wed, 27 May 2020 07:11:50 +0000 (09:11 +0200)]
media: atomisp: Remove binary_supports_input_format

Clang warns:

drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c:1707:64:
warning: implicit conversion from enumeration type 'const enum
ia_css_frame_format' to different enumeration type 'enum
atomisp_input_format' [-Wenum-conversion]
        binary_supports_input_format(xcandidate, req_in_info->format));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ~~~~~~~~~~~~~^~~~~~

As it turns out, binary_supports_input_format only asserts that
xcandidate is not NULL and just returns true so this call is never
actually made.

There are other functions that are called that assert info is not NULL
so this function actually serves no purpose. Remove it. It can be
brought back if needed later.

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Avoid overflow in compute_blending
Nathan Chancellor [Wed, 27 May 2020 07:11:49 +0000 (09:11 +0200)]
media: atomisp: Avoid overflow in compute_blending

Clang warns:

drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c:129:35:
warning: implicit conversion from 'unsigned long' to 'int32_t' (aka
'int') changes value from 18446744073709543424 to -8192
[-Wconstant-conversion]
        return MAX(MIN(isp_strength, 0), -XNR_BLENDING_SCALE_FACTOR);
        ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

XNR_BLENDING_SCALE_FACTOR is BIT(13), or 8192, which will easily fit
into a signed 32-bit integer. However, it is an unsigned long, which
means that negating it is the same as subtracting that value from
ULONG_MAX + 1, which causes it to be larger than a signed 32-bit
integer so it gets implicitly converted.

We can avoid this by using the variable isp_scale, which holds the value
of XNR_BLENDING_SCALE_FACTOR already, where the implicit conversion from
unsigned long to s32 already happened. If that were to ever overflow,
clang would warn: https://godbolt.org/z/EeSxLG

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Remove unnecessary NULL check in atomisp_param
Nathan Chancellor [Wed, 27 May 2020 07:11:48 +0000 (09:11 +0200)]
media: atomisp: Remove unnecessary NULL check in atomisp_param

Clang warns:

drivers/staging/media/atomisp/pci/atomisp_cmd.c:4278:17: warning:
address of 'config->info' will always evaluate to 'true'
[-Wpointer-bool-conversion]
                if (!&config->info) {
                    ~ ~~~~~~~~^~~~

config cannot be NULL because it comes from an ioctl, which ensures that
the user is not giving us an invalid pointer through copy_from_user. If
config is not NULL, info cannot be NULL. Remove this check.

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Remove unnecessary NULL checks in ia_css_pipe_load_extension
Nathan Chancellor [Wed, 27 May 2020 07:11:47 +0000 (09:11 +0200)]
media: atomisp: Remove unnecessary NULL checks in ia_css_pipe_load_extension

Clang warns:

../drivers/staging/media/atomisp/pci/sh_css.c:8537:14: warning: address
of 'pipe->output_stage' will always evaluate to 'true'
[-Wpointer-bool-conversion]
                if (&pipe->output_stage)
                ~~   ~~~~~~^~~~~~~~~~~~
../drivers/staging/media/atomisp/pci/sh_css.c:8545:14: warning: address
of 'pipe->vf_stage' will always evaluate to 'true'
[-Wpointer-bool-conversion]
                if (&pipe->vf_stage)
                ~~   ~~~~~~^~~~~~~~

output_stage and vf_stage are pointers in the middle of a struct, their
addresses cannot be NULL if pipe is not NULL and pipe is already checked
for NULL in this function. Simplify this if block.

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Remove second increment of count in atomisp_subdev_probe
Nathan Chancellor [Wed, 27 May 2020 07:11:45 +0000 (09:11 +0200)]
media: atomisp: Remove second increment of count in atomisp_subdev_probe

Clang warns:

../drivers/staging/media/atomisp/pci/atomisp_v4l2.c:1097:3: warning:
variable 'count' is incremented both in the loop header and in the loop
body [-Wfor-loop-analysis]
                count++;
                ^

This was probably unintentional, remove it.

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: Clean up if block in sh_css_sp_init_stage
Nathan Chancellor [Wed, 27 May 2020 07:11:44 +0000 (09:11 +0200)]
media: atomisp: Clean up if block in sh_css_sp_init_stage

Clang warns:

../drivers/staging/media/atomisp/pci/sh_css_sp.c:1039:23: warning:
address of 'binary->in_frame_info' will always evaluate to 'true'
[-Wpointer-bool-conversion]
                } else if (&binary->in_frame_info) {
                       ~~   ~~~~~~~~^~~~~~~~~~~~~

in_frame_info is not a pointer so if binary is not NULL, in_frame_info's
address cannot be NULL. Change this to an else since it will always be
evaluated as one.

While we are here, clean up this if block. The contents of both if
blocks are the same but a check against "stage == 0" is added when
ISP2401 is defined. USE_INPUT_SYSTEM_VERSION_2401 is only defined when
isp2401_system_global.h is included, which only happens when ISP2401. In
other words, USE_INPUT_SYSTEM_VERSION_2401 always requires ISP2401 to be
defined so the '#ifndef ISP2401' makes no sense. Remove that part of the
block to simplify everything.

Link: https://github.com/ClangBuiltLinux/linux/issues/1036
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: avoid OOPS due to non-existing ref_frames
Mauro Carvalho Chehab [Wed, 27 May 2020 13:46:54 +0000 (15:46 +0200)]
media: atomisp: avoid OOPS due to non-existing ref_frames

stage->args->delay_frames array could point to NULL frames.

What's weird is that we didn't notice this behavior with the
Intel Aero Yocto code.

Handle it, while adding a notice at the code, as this could
be due to some broken pipeline setup.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: remove kvmalloc/kvcalloc abstractions
Mauro Carvalho Chehab [Wed, 27 May 2020 12:23:31 +0000 (14:23 +0200)]
media: atomisp: remove kvmalloc/kvcalloc abstractions

The sh_css layer adds an abstraction for kvmalloc/kvcalloc.

Get rid of them. Most of the work here was done by this
small coccinelle script:

<cocci>
@@
expression size;
@@

- sh_css_malloc(size)
+ kvmalloc(size, GFP_KERNEL)

@@
expression n;
expression size;
@@

- sh_css_calloc(n, size)
+ kvcalloc(n, size, GFP_KERNEL)
</cocci>

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add more comments about frame allocation
Mauro Carvalho Chehab [Wed, 27 May 2020 12:21:26 +0000 (14:21 +0200)]
media: atomisp: add more comments about frame allocation

The frame allocation logic happens differently for userptr
or normal mmap. On a quick look, this sounded to be unbalanced,
but the logic should actually work for both cases.

Add an extra comment to reflect it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add debug functions for received events
Mauro Carvalho Chehab [Wed, 27 May 2020 12:19:27 +0000 (14:19 +0200)]
media: atomisp: add debug functions for received events

For debugging purposes, it helps to know what event
was actually received.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: improve warning for IRQ enable function
Mauro Carvalho Chehab [Wed, 27 May 2020 12:18:00 +0000 (14:18 +0200)]
media: atomisp: improve warning for IRQ enable function

If something gets wrong when enabling or disabling an IRQ,
we should know better about what happened.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add debug for hmm alloc
Mauro Carvalho Chehab [Tue, 26 May 2020 12:35:16 +0000 (14:35 +0200)]
media: atomisp: add debug for hmm alloc

The hmm code is still complex and has bugs. Add a debug print
when memory gets allocated, in order to help identifying what's
happening out there.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use pin_user_pages() for memory allocation
Mauro Carvalho Chehab [Tue, 26 May 2020 10:07:26 +0000 (12:07 +0200)]
media: atomisp: use pin_user_pages() for memory allocation

Instead of using a hacked version of an old copy of
get_user_pages(), use pin_user_pages().

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix driver caps
Mauro Carvalho Chehab [Tue, 26 May 2020 11:05:21 +0000 (13:05 +0200)]
media: atomisp: fix driver caps

This device driver is not MC-centric. So, remove the wrong
caps from it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: use Yocto Aero default hmm pool sizes
Mauro Carvalho Chehab [Tue, 26 May 2020 08:45:00 +0000 (10:45 +0200)]
media: atomisp: use Yocto Aero default hmm pool sizes

Yocto Aero driver has a different default for hmm pools.

Use the definitions there.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: add debug message to help debugging hmm code
Mauro Carvalho Chehab [Tue, 26 May 2020 08:11:14 +0000 (10:11 +0200)]
media: atomisp: add debug message to help debugging hmm code

The hmm code is partially based on a fork from 3.10 code,
and has bugs.

Add debug there to help tracking what happens there.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: hmm_bo: untag user pointers
Mauro Carvalho Chehab [Tue, 26 May 2020 07:45:16 +0000 (09:45 +0200)]
media: atomisp: hmm_bo: untag user pointers

The kernel ABI was extended to allow pass tagged user pointers.

Untag the pointers in this function.

Fixes: d93445225cd3 ("uaccess: add noop untagged_addr definition")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of memory_access.c
Mauro Carvalho Chehab [Tue, 26 May 2020 06:40:16 +0000 (08:40 +0200)]
media: atomisp: get rid of memory_access.c

Now that we have everything in place, we can get rid of the
memory_access abstraction layer.

Now, everything related to heterogeneous memory management
(hmm) is under hmm.c & related pools.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: change the type returned by mmgr alloc
Mauro Carvalho Chehab [Tue, 26 May 2020 06:13:27 +0000 (08:13 +0200)]
media: atomisp: change the type returned by mmgr alloc

The mmgr alloc code returns a different type than hmm, due to
some abstraction layer.

Change the driver to use just one type to represent the
hmm memory.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of unused memory_realloc code
Mauro Carvalho Chehab [Tue, 26 May 2020 06:10:18 +0000 (08:10 +0200)]
media: atomisp: get rid of unused memory_realloc code

The code for it is commented out, probably because it is
broken or uneeded for the driver to work. So, let's get
rid of it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of mmgr_load and mmgr_store
Mauro Carvalho Chehab [Tue, 26 May 2020 06:02:00 +0000 (08:02 +0200)]
media: atomisp: get rid of mmgr_load and mmgr_store

Those functions are just wrappers for hmm_load/hmm_store.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: go one step further to drop ia_css_memory_access.c
Mauro Carvalho Chehab [Mon, 25 May 2020 10:46:23 +0000 (12:46 +0200)]
media: atomisp: go one step further to drop ia_css_memory_access.c

Move the attrs handling into hmm, simplifying even further
what the ia_css_memory_access.c file does.

Yet, the returned type for ia_css_memory_access.c is an
integer, instead of a pointer.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: reduce abstraction at ia_css_memory_access
Mauro Carvalho Chehab [Mon, 25 May 2020 09:33:24 +0000 (11:33 +0200)]
media: atomisp: reduce abstraction at ia_css_memory_access

Yet another memory abstraction layer. Getting rid of this
may be a little trickier, but let's reduce it to a minimal.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction layer
Mauro Carvalho Chehab [Mon, 25 May 2020 08:53:20 +0000 (10:53 +0200)]
media: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction layer

Simplify the code by removing this extra memory management
abstraction layer.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: simplify hive_isp_css_mm_hrt wrapper
Mauro Carvalho Chehab [Mon, 25 May 2020 08:11:49 +0000 (10:11 +0200)]
media: atomisp: simplify hive_isp_css_mm_hrt wrapper

The code there is a wrapper for hmm/ wrapper. Simplify it,
and get rid of ION-specific code.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix a handful of spelling mistakes
Colin Ian King [Thu, 21 May 2020 19:44:32 +0000 (21:44 +0200)]
media: atomisp: fix a handful of spelling mistakes

There are several spelling mistakes in various messages and literal
strings. Fix these.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix size of delay_frames array
Mauro Carvalho Chehab [Sun, 24 May 2020 07:11:07 +0000 (09:11 +0200)]
media: atomisp: fix size of delay_frames array

Right now, the variables that define the max number of
delay frames is defined as:

#define VIDEO_FRAME_DELAY 2
#define MAX_NUM_VIDEO_DELAY_FRAMES (VIDEO_FRAME_DELAY + 1)
#define NUM_PREVIEW_DVS_FRAMES          (2)
#define MAX_NUM_DELAY_FRAMES   MAX(MAX_NUM_VIDEO_DELAY_FRAMES, NUM_PREVIEW_DVS_FRAMES)

In other words, we have:
MAX_NUM_VIDEO_DELAY_FRAMES = 3
MAX_NUM_DELAY_FRAMES = 2

The MAX_NUM_DELAY_FRAMES macro is used only only when allocating
memory. On all other parts, including looping over such array,
MAX_NUM_VIDEO_DELAY_FRAMES is used instead, like:

void sh_css_binary_args_reset(struct sh_css_binary_args *args)
{
unsigned int i;
...

for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++)
args->delay_frames[i] = NULL;

Which will cause buffer overflows, with may override the next array
(tnr_frames[]).

In practice, this may not be causing real issues, as the code
checks for num_delay_frames on some parts (but not everywhere).

So, get rid of the smallest value.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: drop a cast for a const argument
Mauro Carvalho Chehab [Sun, 24 May 2020 06:56:58 +0000 (08:56 +0200)]
media: atomisp: drop a cast for a const argument

Some arguments for tnf and ref settings are meant to be const, but
they're defined without such annotation. Due to that, there's an
ugly cast at sh_css_sp.c.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: partially get rid of one abstraction layer
Mauro Carvalho Chehab [Thu, 21 May 2020 10:07:53 +0000 (12:07 +0200)]
media: atomisp: partially get rid of one abstraction layer

The very same macros are defined as CSS_foo and IA_CSS_foo.

Remove this abstraction, as it just make things confusing,
for no good reason.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: make it use dbg_level to control debug level
Mauro Carvalho Chehab [Sat, 23 May 2020 14:59:14 +0000 (16:59 +0200)]
media: atomisp: make it use dbg_level to control debug level

This driver has 3 different types of debug messages:

- dev_dbg()
- dbg_level
- ia_css_debug_trace_level

Which is crazy. Ideally, it shold just use dev_dbg()
everywhere, but for now let's unify the last two machanisms.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of some old broken debug code
Mauro Carvalho Chehab [Sat, 23 May 2020 14:44:42 +0000 (16:44 +0200)]
media: atomisp: get rid of some old broken debug code

It sounds that someone once changed the debug level at compile
time for some testing, but forgot to remove the legacy code after
finishing debuging it.

Get rid of the dead code.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: update TODO list
Mauro Carvalho Chehab [Fri, 22 May 2020 12:01:00 +0000 (14:01 +0200)]
media: atomisp: update TODO list

Let's reflect the current status at the TODO list, as other
developers can help addressing issues over there.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: don't flood dmesg with -EAGAIN return codes
Mauro Carvalho Chehab [Thu, 21 May 2020 08:04:49 +0000 (10:04 +0200)]
media: atomisp: don't flood dmesg with -EAGAIN return codes

Using DQBUF on non-blocking mode will return -EAGAIN
if nothing arrives. Printing it has no value, even for debug
purposes. So, only display real return codes.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: improve debug messages for set format
Mauro Carvalho Chehab [Wed, 20 May 2020 22:10:04 +0000 (00:10 +0200)]
media: atomisp: improve debug messages for set format

There are several error conditions that don't print anything,
making harder to identify bugs at the code there.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: avoid a copy of v4l2_mbus_framefmt at stack
Mauro Carvalho Chehab [Thu, 21 May 2020 07:43:01 +0000 (09:43 +0200)]
media: atomisp: avoid a copy of v4l2_mbus_framefmt at stack

There's no reason to copy isp_sink_fmt, as the driver
uses it for read-only purposes.

Linux stack is a precious resource. Let's avoid wasting it.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: reduce debug printk rate when IRQs are received
Mauro Carvalho Chehab [Thu, 21 May 2020 07:05:11 +0000 (09:05 +0200)]
media: atomisp: reduce debug printk rate when IRQs are received

Currently, when an EOF IRQ is received, it generates two messages:

[   59.191893] atomisp-isp2 0000:00:03.0: irq:0x200000
[   59.191913] atomisp-isp2 0000:00:03.0: atomisp_isr EOF exp_id 142, asd 0

Flooding the dmesg with lots of messages per second. The same
pattern happens for all other IRQs.

Change the logic for printing just one message per IRQ and
rate-limit those, as, for debugging purposes, it is usually
interesting to know that IRQs are being received, but not
displaying every single one.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: get rid of hmm_vm.c
Mauro Carvalho Chehab [Wed, 20 May 2020 21:04:09 +0000 (23:04 +0200)]
media: atomisp: get rid of hmm_vm.c

This is not used anywhere. So, let's trash it.

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
4 years agomedia: atomisp: fix pipeline initialization code
Mauro Carvalho Chehab [Wed, 20 May 2020 05:28:50 +0000 (07:28 +0200)]
media: atomisp: fix pipeline initialization code

The code under load_primary_binaries() is complex and
were hard to understand, because it used to have lots
of ifdefs and broken identation.

The patch which cleaned it and removed the version-specific
ifdefs added a regression.

Solve it.

Fixes: 3c0538fbad9f ("media: atomisp: get rid of most checks for ISP2401 version")
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>