[driver-core:kobject-const] BUILD SUCCESS 50dfafdd5926d0d85c1922452b641f1d075cc8fe

2022-03-30 Thread kernel test robot
tree/branch: 
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 
kobject-const
branch HEAD: 50dfafdd5926d0d85c1922452b641f1d075cc8fe  kobject: kobj_type: 
remove default_attrs

elapsed time: 1014m

configs tested: 139
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
powerpc  randconfig-c003-20220330
i386  randconfig-c001
sh  rts7751r2d1_defconfig
armrealview_defconfig
arm assabet_defconfig
xtensa   allyesconfig
sh   se7619_defconfig
sh  lboxre2_defconfig
powerpc  pasemi_defconfig
arm   imx_v6_v7_defconfig
parisc64 alldefconfig
mips tb0226_defconfig
h8300   h8s-sim_defconfig
sh   se7751_defconfig
shmigor_defconfig
arm  integrator_defconfig
arm pxa_defconfig
ia64 allmodconfig
arc defconfig
i386defconfig
m68kq40_defconfig
parisc   alldefconfig
sh ecovec24_defconfig
sh magicpanelr2_defconfig
armcerfcube_defconfig
openriscor1ksim_defconfig
m68k   m5249evb_defconfig
powerpc  ppc40x_defconfig
armqcom_defconfig
mips db1xxx_defconfig
sh  sdk7786_defconfig
powerpc wii_defconfig
powerpc mpc85xx_cds_defconfig
m68k  amiga_defconfig
sh   se7712_defconfig
csky alldefconfig
shsh7757lcr_defconfig
arm  randconfig-c002-20220327
arm  randconfig-c002-20220329
arm  randconfig-c002-20220330
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nios2allyesconfig
cskydefconfig
alpha   defconfig
alphaallyesconfig
h8300allyesconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc64defconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc  allyesconfig
powerpc  allmodconfig
powerpc   allnoconfig
x86_64   randconfig-a001-20220328
x86_64   randconfig-a003-20220328
x86_64   randconfig-a004-20220328
x86_64   randconfig-a002-20220328
x86_64   randconfig-a005-20220328
x86_64   randconfig-a006-20220328
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv allnoconfig
riscv   defconfig
riscv  rv32_defconfig
riscvallmodconfig
x86_64rhel-8.3-kselftests
um   x86_64_defconfig
um i386_defconfig
x86_64   allyesconfig
x86_64  defconfig
x86_64   rhel-8.3
x86_64  rhel-8.3-func
x86_64 rhel-8.3-kunit
x86_64  kexec

clang tested configs:
mips randconfig-c004-20220329
x86_64randconfig-c007
mips randconfig-c004-20220327
arm  randconfig-c002

[staging:staging-testing] BUILD SUCCESS c93c68f19e68e19c319d9471fdb9dab37d85d7f0

2022-03-30 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
branch HEAD: c93c68f19e68e19c319d9471fdb9dab37d85d7f0  staging: r8188eu: 
convert rtw_inc_and_chk_continual_urb_error() to bool

elapsed time: 740m

configs tested: 159
configs skipped: 4

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
powerpc  randconfig-c003-20220330
i386  randconfig-c001
sh  rts7751r2d1_defconfig
armrealview_defconfig
alpha   defconfig
arm assabet_defconfig
powerpc pq2fads_defconfig
arc haps_hs_smp_defconfig
riscv nommu_k210_sdcard_defconfig
um   alldefconfig
xtensa   allyesconfig
sh   se7619_defconfig
sh  lboxre2_defconfig
powerpc  pasemi_defconfig
arm   imx_v6_v7_defconfig
parisc64 alldefconfig
mips tb0226_defconfig
armclps711x_defconfig
armxcep_defconfig
arm  badge4_defconfig
h8300   h8s-sim_defconfig
m68kq40_defconfig
parisc   alldefconfig
sh ecovec24_defconfig
sh magicpanelr2_defconfig
armcerfcube_defconfig
openriscor1ksim_defconfig
armshmobile_defconfig
powerpc sequoia_defconfig
arm  integrator_defconfig
openrisc  or1klitex_defconfig
m68k   m5249evb_defconfig
powerpc   currituck_defconfig
armqcom_defconfig
mips db1xxx_defconfig
sh  sdk7786_defconfig
powerpc wii_defconfig
powerpc mpc85xx_cds_defconfig
m68k  amiga_defconfig
sh   se7712_defconfig
csky alldefconfig
shsh7757lcr_defconfig
arm  randconfig-c002-20220327
arm  randconfig-c002-20220329
arm  randconfig-c002-20220330
ia64 allmodconfig
ia64defconfig
ia64 allyesconfig
m68k allmodconfig
m68kdefconfig
m68k allyesconfig
nios2   defconfig
arc  allyesconfig
nios2allyesconfig
cskydefconfig
alphaallyesconfig
h8300allyesconfig
arc defconfig
sh   allmodconfig
parisc  defconfig
s390 allyesconfig
s390 allmodconfig
parisc64defconfig
parisc   allyesconfig
s390defconfig
i386 allyesconfig
sparcallyesconfig
sparc   defconfig
i386defconfig
i386   debian-10.3-kselftests
i386  debian-10.3
mips allyesconfig
mips allmodconfig
powerpc   allnoconfig
powerpc  allmodconfig
powerpc  allyesconfig
x86_64   randconfig-a001-20220328
x86_64   randconfig-a003-20220328
x86_64   randconfig-a004-20220328
x86_64   randconfig-a002-20220328
x86_64   randconfig-a005-20220328
x86_64   randconfig-a006-20220328
i386 randconfig-a001-20220328
i386 randconfig-a003-20220328
i386 randconfig-a006-20220328
i386 randconfig-a005-20220328
i386 randconfig-a004-20220328
i386 randconfig-a002-20220328
x86_64randconfig-a006
x86_64randconfig-a004
x86_64randconfig-a002
riscvnommu_k210_defconfig
riscvallyesconfig
riscvnommu_virt_defconfig
riscv

[PATCH AUTOSEL 5.17 01/66] media: staging: media: zoran: move videodev alloc

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit 82e3a496eb56da0b9f29fdc5b63cedb3289e91de ]

Move some code out of zr36057_init() and create new functions for handling
zr->video_dev. This permit to ease code reading and fix a zr->video_dev
memory leak.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran.h|  2 +-
 drivers/staging/media/zoran/zoran_card.c   | 80 ++
 drivers/staging/media/zoran/zoran_driver.c |  5 +-
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index b1ad2a2b914c..50d5a7acfab6 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -313,6 +313,6 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index f259585b0689..677d3a26cef4 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -803,6 +803,52 @@ int zoran_check_jpg_settings(struct zoran *zr,
return 0;
 }
 
+static int zoran_init_video_device(struct zoran *zr, struct video_device 
*video_dev, int dir)
+{
+   int err;
+
+   /* Now add the template and register the device unit. */
+   *video_dev = zoran_template;
+   video_dev->v4l2_dev = &zr->v4l2_dev;
+   video_dev->lock = &zr->lock;
+   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+
+   strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
+   /*
+* It's not a mem2mem device, but you can both capture and output from 
one and the same
+* device. This should really be split up into two device nodes, but 
that's a job for
+* another day.
+*/
+   video_dev->vfl_dir = VFL_DIR_M2M;
+   zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+
+   err = video_register_device(video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
+   if (err < 0)
+   return err;
+   video_set_drvdata(video_dev, zr);
+   return 0;
+}
+
+static void zoran_exit_video_devices(struct zoran *zr)
+{
+   video_unregister_device(zr->video_dev);
+   kfree(zr->video_dev);
+}
+
+static int zoran_init_video_devices(struct zoran *zr)
+{
+   int err;
+
+   zr->video_dev = video_device_alloc();
+   if (!zr->video_dev)
+   return -ENOMEM;
+
+   err = zoran_init_video_device(zr, zr->video_dev, 
V4L2_CAP_VIDEO_CAPTURE);
+   if (err)
+   kfree(zr->video_dev);
+   return err;
+}
+
 void zoran_open_init_params(struct zoran *zr)
 {
int i;
@@ -874,17 +920,11 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->video_dev = video_device_alloc();
-   if (!zr->video_dev) {
-   err = -ENOMEM;
-   goto exit;
-   }
zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
  BUZ_NUM_STAT_COM * sizeof(u32),
  &zr->p_sc, GFP_KERNEL);
if (!zr->stat_com) {
-   err = -ENOMEM;
-   goto exit_video;
+   return -ENOMEM;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -897,26 +937,9 @@ static int zr36057_init(struct zoran *zr)
goto exit_statcom;
}
 
-   /* Now add the template and register the device unit. */
-   *zr->video_dev = zoran_template;
-   zr->video_dev->v4l2_dev = &zr->v4l2_dev;
-   zr->video_dev->lock = &zr->lock;
-   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
-
-   strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
-   /*
-* It's not a mem2mem device, but you can both capture and output from 
one and the same
-* device. This should really be split up into two device nodes, but 
that's a job for
-* another day.
-*/
-   zr->video_dev->vfl_dir = VFL_DIR_M2M;
-
-   zoran_queue_init(zr, &zr->vq);
-
-   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
-   if (err < 0)
+   err = zoran_init_video_devices(zr);
+   if (err)
goto exit_statcomb;
-   video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
if (!pass_through) {
@@ -931,9 +954,6 @@ static int zr36057_init(struct zoran *zr)
dma_f

[PATCH AUTOSEL 5.17 02/66] media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]

On the case tmp_dcim=1, the index of buffer is miscalculated.
This generate a NULL pointer dereference later.

So let's fix the calcul and add a check to prevent this to reappear.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_device.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 5b12a730a229..fb1f0465ca87 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -814,7 +814,7 @@ static void zoran_reap_stat_com(struct zoran *zr)
if (zr->jpg_settings.tmp_dcm == 1)
i = (zr->jpg_dma_tail - zr->jpg_err_shift) & 
BUZ_MASK_STAT_COM;
else
-   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2 + 
1;
+   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2;
 
stat_com = le32_to_cpu(zr->stat_com[i]);
if ((stat_com & 1) == 0) {
@@ -826,6 +826,11 @@ static void zoran_reap_stat_com(struct zoran *zr)
size = (stat_com & GENMASK(22, 1)) >> 1;
 
buf = zr->inuse[i];
+   if (!buf) {
+   spin_unlock_irqrestore(&zr->queued_bufs_lock, flags);
+   pci_err(zr->pci_dev, "No buffer at slot %d\n", i);
+   return;
+   }
buf->vbuf.vb2_buf.timestamp = ktime_get_ns();
 
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.17 03/66] media: staging: media: zoran: fix various V4L2 compliance errors

2022-03-30 Thread Sasha Levin
From: Hans Verkuil 

[ Upstream commit 914941827aad5ecddf9bf3a6dee67fbec1af1fff ]

This fixes several issues found with 'v4l2-compliance -s':

1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.

Signed-off-by: Hans Verkuil 
Signed-off-by: Corentin Labbe 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 677d3a26cef4..175654d104c5 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -811,7 +811,7 @@ static int zoran_init_video_device(struct zoran *zr, struct 
video_device *video_
*video_dev = zoran_template;
video_dev->v4l2_dev = &zr->v4l2_dev;
video_dev->lock = &zr->lock;
-   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+   video_dev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | dir;
 
strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
/*
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 551db338c7f7..84665637ebb7 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -255,8 +255,6 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = zr->video_dev->device_caps;
-   cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
@@ -582,6 +580,9 @@ static int zoran_s_std(struct file *file, void *__fh, 
v4l2_std_id std)
struct zoran *zr = video_drvdata(file);
int res = 0;
 
+   if (zr->norm == std)
+   return 0;
+
if (zr->running != ZORAN_MAP_MODE_NONE)
return -EBUSY;
 
@@ -739,6 +740,7 @@ static int zoran_g_parm(struct file *file, void *priv, 
struct v4l2_streamparm *p
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   parm->parm.capture.readbuffers = 9;
return 0;
 }
 
@@ -869,6 +871,10 @@ int zr_set_buf(struct zoran *zr)
vbuf = &buf->vbuf;
 
buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
+   buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   else
+   buf->vbuf.field = V4L2_FIELD_TOP;
vb2_set_plane_payload(&buf->vbuf.vb2_buf, 0, zr->buffer_size);
vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_DONE);
zr->inuse[0] = NULL;
@@ -928,6 +934,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
zr->stat_com[j] = cpu_to_le32(1);
zr->inuse[j] = NULL;
}
+   zr->vbseq = 0;
 
if (zr->map_mode != ZORAN_MAP_MODE_RAW) {
pci_info(zr->pci_dev, "START JPG\n");
@@ -1018,7 +1025,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue 
*vq, int dir)
vq->dev = &zr->pci_dev->dev;
vq->type = dir;
 
-   vq->io_modes = VB2_USERPTR | VB2_DMABUF | VB2_MMAP | VB2_READ | 
VB2_WRITE;
+   vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ | VB2_WRITE;
vq->drv_priv = zr;
vq->buf_struct_size = sizeof(struct zr_buffer);
vq->ops = &zr_video_qops;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.17 21/66] media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards

2022-03-30 Thread Sasha Levin
From: Hans de Goede 

[ Upstream commit 2c39a01154ea57d596470afa1d278e3be3b37f6a ]

The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on
after having turned it off causes the CPLM3218 ambient-light-sensor on
the front camera sensor's I2C bus to crash, hanging the bus.

Add a DMI quirk table for systems on which to leave eldo2 on.

Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor
as long as the camera sensor is being used, this is what Windows seems
to do as a workaround (based on analyzing the DSDT). But that is not
easy to do cleanly under Linux.

Link: 
https://lore.kernel.org/linux-media/20220116215204.307649-10-hdego...@redhat.com
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../media/atomisp/pci/atomisp_gmin_platform.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c 
b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 1cc581074ba7..9a194fbb305b 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -748,6 +748,21 @@ static int axp_regulator_set(struct device *dev, struct 
gmin_subdev *gs,
return 0;
 }
 
+/*
+ * Some boards contain a hw-bug where turning eldo2 back on after having turned
+ * it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C 
bus
+ * to crash, hanging the bus. Do not turn eldo2 off on these systems.
+ */
+static const struct dmi_system_id axp_leave_eldo2_on_ids[] = {
+   {
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab duo W1 10.1 
(VT4)"),
+   },
+   },
+   { }
+};
+
 static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs)
 {
int ret;
@@ -782,6 +797,9 @@ static int axp_v1p8_off(struct device *dev, struct 
gmin_subdev *gs)
if (ret)
return ret;
 
+   if (dmi_check_system(axp_leave_eldo2_on_ids))
+   return 0;
+
ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v,
ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false);
return ret;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.17 22/66] media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

2022-03-30 Thread Sasha Levin
From: Tsuchiya Yuto 

[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[  140.230662] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:03.0/active_bo'
[  140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE
 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[  140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 
03/09/2015
[  140.230678] Call Trace:
[  140.230687]  dump_stack_lvl+0x46/0x5a
[  140.230702]  sysfs_warn_dup.cold+0x17/0x24
[  140.230710]  sysfs_add_file_mode_ns+0x160/0x170
[  140.230717]  internal_create_group+0x126/0x390
[  140.230723]  hmm_init+0x5c/0x70 [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230811]  atomisp_pci_probe.cold+0x1136/0x148e [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230875]  local_pci_probe+0x45/0x80
[  140.230882]  ? pci_match_device+0xd7/0x130
[  140.230887]  pci_device_probe+0xfa/0x1b0
[  140.230892]  really_probe+0x1f5/0x3f0
[  140.230899]  __driver_probe_device+0xfe/0x180
[  140.230903]  driver_probe_device+0x1e/0x90
[  140.230908]  __driver_attach+0xc0/0x1c0
[  140.230912]  ? __device_attach_driver+0xe0/0xe0
[  140.230915]  ? __device_attach_driver+0xe0/0xe0
[  140.230919]  bus_for_each_dev+0x89/0xd0
[  140.230924]  bus_add_driver+0x12b/0x1e0
[  140.230929]  driver_register+0x8f/0xe0
[  140.230933]  ? 0xc153f000
[  140.230937]  do_one_initcall+0x57/0x220
[  140.230945]  do_init_module+0x5c/0x260
[  140.230952]  load_module+0x24bd/0x26a0
[  140.230962]  ? __do_sys_finit_module+0xae/0x110
[  140.230966]  __do_sys_finit_module+0xae/0x110
[  140.230972]  do_syscall_64+0x5c/0x80
[  140.230979]  ? syscall_exit_to_user_mode+0x23/0x40
[  140.230983]  ? do_syscall_64+0x69/0x80
[  140.230988]  ? exc_page_fault+0x72/0x170
[  140.230991]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  140.230997] RIP: 0033:0x7f7fd5d8718d
[  140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 
48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 
3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[  140.231006] RSP: 002b:7ffefc25f0e8 EFLAGS: 0246 ORIG_RAX: 
0139
[  140.231012] RAX: ffda RBX: 55ac3edcd7f0 RCX: 
7f7fd5d8718d
[  140.231015] RDX:  RSI: 55ac3d723270 RDI: 
0003
[  140.231017] RBP:  R08:  R09: 
7f7fd5e52380
[  140.231019] R10: 0003 R11: 0246 R12: 
55ac3d723270
[  140.231021] R13:  R14: 55ac3edd06e0 R15: 

[  140.231038] atomisp-isp2 :00:03.0: hmm_init Failed to create 
sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: 
https://lore.kernel.org/linux-media/20211017162337.44860-3-kita...@gmail.com

Signed-off-by: Tsuchiya Yuto 
Co-developed-by: Mauro Carvalho Chehab 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 6a5ee4607089..c1cda16f2dc0 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -39,7 +39,7 @@
 struct hmm_bo_device bo_device;
 struct hmm_pooldynamic_pool;
 struct hmm_poolreserved_pool;
-static ia_css_ptr dummy_ptr;
+static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;
 static bool hmm_initialized;
 struct _hmm_mem_stat hmm_mem_stat;
 
@@ -209,7 +209,7 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
-   if (!dummy_ptr)
+   if (dummy_ptr == mmgr_EXCEPTION)
return;
sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group);
 
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)
 
dev_dbg(atomisp_dev, "%s

[PATCH AUTOSEL 5.17 65/66] media: atomisp: fix bad usage at error handling logic

2022-03-30 Thread Sasha Levin
From: Mauro Carvalho Chehab 

[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]

As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'

The acc_fw interactor is used outside the loop, at the error handling
logic. On most cases, this is actually safe there, but, if
atomisp_css_set_acc_parameters() has an error, an attempt to use it
will pick an invalid value for acc_fw.

Reported-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../staging/media/atomisp/pci/atomisp_acc.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index 9a1751895ab0..28cb271663c4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device 
*asd,
return 0;
 }
 
+static void atomisp_acc_unload_some_extensions(struct atomisp_sub_device *asd,
+ int i,
+ struct atomisp_acc_fw *acc_fw)
+{
+   while (--i >= 0) {
+   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
+   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
+
acc_flag_to_pipe[i].pipe_id);
+   }
+   }
+}
+
 /*
  * Appends the loaded acceleration binary extensions to the
  * current ISP mode. Must be called just before sh_css_start().
@@ -479,16 +491,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
 acc_fw->fw,
 
acc_flag_to_pipe[i].pipe_id,
 
acc_fw->type);
-   if (ret)
+   if (ret) {
+   atomisp_acc_unload_some_extensions(asd, 
i, acc_fw);
goto error;
+   }
 
ext_loaded = true;
}
}
 
ret = atomisp_css_set_acc_parameters(acc_fw);
-   if (ret < 0)
+   if (ret < 0) {
+   atomisp_acc_unload_some_extensions(asd, i, acc_fw);
goto error;
+   }
}
 
if (!ext_loaded)
@@ -497,6 +513,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
ret = atomisp_css_update_stream(asd);
if (ret) {
dev_err(isp->dev, "%s: update stream failed.\n", __func__);
+   atomisp_acc_unload_extensions(asd);
goto error;
}
 
@@ -504,13 +521,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
return 0;
 
 error:
-   while (--i >= 0) {
-   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-
acc_flag_to_pipe[i].pipe_id);
-   }
-   }
-
list_for_each_entry_continue_reverse(acc_fw, &asd->acc.fw, list) {
if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.16 01/59] media: staging: media: zoran: move videodev alloc

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit 82e3a496eb56da0b9f29fdc5b63cedb3289e91de ]

Move some code out of zr36057_init() and create new functions for handling
zr->video_dev. This permit to ease code reading and fix a zr->video_dev
memory leak.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran.h|  2 +-
 drivers/staging/media/zoran/zoran_card.c   | 80 ++
 drivers/staging/media/zoran/zoran_driver.c |  5 +-
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index b1ad2a2b914c..50d5a7acfab6 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -313,6 +313,6 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index f259585b0689..677d3a26cef4 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -803,6 +803,52 @@ int zoran_check_jpg_settings(struct zoran *zr,
return 0;
 }
 
+static int zoran_init_video_device(struct zoran *zr, struct video_device 
*video_dev, int dir)
+{
+   int err;
+
+   /* Now add the template and register the device unit. */
+   *video_dev = zoran_template;
+   video_dev->v4l2_dev = &zr->v4l2_dev;
+   video_dev->lock = &zr->lock;
+   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+
+   strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
+   /*
+* It's not a mem2mem device, but you can both capture and output from 
one and the same
+* device. This should really be split up into two device nodes, but 
that's a job for
+* another day.
+*/
+   video_dev->vfl_dir = VFL_DIR_M2M;
+   zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+
+   err = video_register_device(video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
+   if (err < 0)
+   return err;
+   video_set_drvdata(video_dev, zr);
+   return 0;
+}
+
+static void zoran_exit_video_devices(struct zoran *zr)
+{
+   video_unregister_device(zr->video_dev);
+   kfree(zr->video_dev);
+}
+
+static int zoran_init_video_devices(struct zoran *zr)
+{
+   int err;
+
+   zr->video_dev = video_device_alloc();
+   if (!zr->video_dev)
+   return -ENOMEM;
+
+   err = zoran_init_video_device(zr, zr->video_dev, 
V4L2_CAP_VIDEO_CAPTURE);
+   if (err)
+   kfree(zr->video_dev);
+   return err;
+}
+
 void zoran_open_init_params(struct zoran *zr)
 {
int i;
@@ -874,17 +920,11 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->video_dev = video_device_alloc();
-   if (!zr->video_dev) {
-   err = -ENOMEM;
-   goto exit;
-   }
zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
  BUZ_NUM_STAT_COM * sizeof(u32),
  &zr->p_sc, GFP_KERNEL);
if (!zr->stat_com) {
-   err = -ENOMEM;
-   goto exit_video;
+   return -ENOMEM;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -897,26 +937,9 @@ static int zr36057_init(struct zoran *zr)
goto exit_statcom;
}
 
-   /* Now add the template and register the device unit. */
-   *zr->video_dev = zoran_template;
-   zr->video_dev->v4l2_dev = &zr->v4l2_dev;
-   zr->video_dev->lock = &zr->lock;
-   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
-
-   strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
-   /*
-* It's not a mem2mem device, but you can both capture and output from 
one and the same
-* device. This should really be split up into two device nodes, but 
that's a job for
-* another day.
-*/
-   zr->video_dev->vfl_dir = VFL_DIR_M2M;
-
-   zoran_queue_init(zr, &zr->vq);
-
-   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
-   if (err < 0)
+   err = zoran_init_video_devices(zr);
+   if (err)
goto exit_statcomb;
-   video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
if (!pass_through) {
@@ -931,9 +954,6 @@ static int zr36057_init(struct zoran *zr)
dma_f

[PATCH AUTOSEL 5.16 02/59] media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]

On the case tmp_dcim=1, the index of buffer is miscalculated.
This generate a NULL pointer dereference later.

So let's fix the calcul and add a check to prevent this to reappear.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_device.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 5b12a730a229..fb1f0465ca87 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -814,7 +814,7 @@ static void zoran_reap_stat_com(struct zoran *zr)
if (zr->jpg_settings.tmp_dcm == 1)
i = (zr->jpg_dma_tail - zr->jpg_err_shift) & 
BUZ_MASK_STAT_COM;
else
-   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2 + 
1;
+   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2;
 
stat_com = le32_to_cpu(zr->stat_com[i]);
if ((stat_com & 1) == 0) {
@@ -826,6 +826,11 @@ static void zoran_reap_stat_com(struct zoran *zr)
size = (stat_com & GENMASK(22, 1)) >> 1;
 
buf = zr->inuse[i];
+   if (!buf) {
+   spin_unlock_irqrestore(&zr->queued_bufs_lock, flags);
+   pci_err(zr->pci_dev, "No buffer at slot %d\n", i);
+   return;
+   }
buf->vbuf.vb2_buf.timestamp = ktime_get_ns();
 
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.16 03/59] media: staging: media: zoran: fix various V4L2 compliance errors

2022-03-30 Thread Sasha Levin
From: Hans Verkuil 

[ Upstream commit 914941827aad5ecddf9bf3a6dee67fbec1af1fff ]

This fixes several issues found with 'v4l2-compliance -s':

1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.

Signed-off-by: Hans Verkuil 
Signed-off-by: Corentin Labbe 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 677d3a26cef4..175654d104c5 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -811,7 +811,7 @@ static int zoran_init_video_device(struct zoran *zr, struct 
video_device *video_
*video_dev = zoran_template;
video_dev->v4l2_dev = &zr->v4l2_dev;
video_dev->lock = &zr->lock;
-   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+   video_dev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | dir;
 
strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
/*
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 551db338c7f7..84665637ebb7 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -255,8 +255,6 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = zr->video_dev->device_caps;
-   cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
@@ -582,6 +580,9 @@ static int zoran_s_std(struct file *file, void *__fh, 
v4l2_std_id std)
struct zoran *zr = video_drvdata(file);
int res = 0;
 
+   if (zr->norm == std)
+   return 0;
+
if (zr->running != ZORAN_MAP_MODE_NONE)
return -EBUSY;
 
@@ -739,6 +740,7 @@ static int zoran_g_parm(struct file *file, void *priv, 
struct v4l2_streamparm *p
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   parm->parm.capture.readbuffers = 9;
return 0;
 }
 
@@ -869,6 +871,10 @@ int zr_set_buf(struct zoran *zr)
vbuf = &buf->vbuf;
 
buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
+   buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   else
+   buf->vbuf.field = V4L2_FIELD_TOP;
vb2_set_plane_payload(&buf->vbuf.vb2_buf, 0, zr->buffer_size);
vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_DONE);
zr->inuse[0] = NULL;
@@ -928,6 +934,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
zr->stat_com[j] = cpu_to_le32(1);
zr->inuse[j] = NULL;
}
+   zr->vbseq = 0;
 
if (zr->map_mode != ZORAN_MAP_MODE_RAW) {
pci_info(zr->pci_dev, "START JPG\n");
@@ -1018,7 +1025,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue 
*vq, int dir)
vq->dev = &zr->pci_dev->dev;
vq->type = dir;
 
-   vq->io_modes = VB2_USERPTR | VB2_DMABUF | VB2_MMAP | VB2_READ | 
VB2_WRITE;
+   vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ | VB2_WRITE;
vq->drv_priv = zr;
vq->buf_struct_size = sizeof(struct zr_buffer);
vq->ops = &zr_video_qops;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.16 21/59] media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards

2022-03-30 Thread Sasha Levin
From: Hans de Goede 

[ Upstream commit 2c39a01154ea57d596470afa1d278e3be3b37f6a ]

The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on
after having turned it off causes the CPLM3218 ambient-light-sensor on
the front camera sensor's I2C bus to crash, hanging the bus.

Add a DMI quirk table for systems on which to leave eldo2 on.

Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor
as long as the camera sensor is being used, this is what Windows seems
to do as a workaround (based on analyzing the DSDT). But that is not
easy to do cleanly under Linux.

Link: 
https://lore.kernel.org/linux-media/20220116215204.307649-10-hdego...@redhat.com
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../media/atomisp/pci/atomisp_gmin_platform.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c 
b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 62dc06e22476..cd0a771454da 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -729,6 +729,21 @@ static int axp_regulator_set(struct device *dev, struct 
gmin_subdev *gs,
return 0;
 }
 
+/*
+ * Some boards contain a hw-bug where turning eldo2 back on after having turned
+ * it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C 
bus
+ * to crash, hanging the bus. Do not turn eldo2 off on these systems.
+ */
+static const struct dmi_system_id axp_leave_eldo2_on_ids[] = {
+   {
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab duo W1 10.1 
(VT4)"),
+   },
+   },
+   { }
+};
+
 static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs)
 {
int ret;
@@ -763,6 +778,9 @@ static int axp_v1p8_off(struct device *dev, struct 
gmin_subdev *gs)
if (ret)
return ret;
 
+   if (dmi_check_system(axp_leave_eldo2_on_ids))
+   return 0;
+
ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v,
ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false);
return ret;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.16 22/59] media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

2022-03-30 Thread Sasha Levin
From: Tsuchiya Yuto 

[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[  140.230662] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:03.0/active_bo'
[  140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE
 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[  140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 
03/09/2015
[  140.230678] Call Trace:
[  140.230687]  dump_stack_lvl+0x46/0x5a
[  140.230702]  sysfs_warn_dup.cold+0x17/0x24
[  140.230710]  sysfs_add_file_mode_ns+0x160/0x170
[  140.230717]  internal_create_group+0x126/0x390
[  140.230723]  hmm_init+0x5c/0x70 [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230811]  atomisp_pci_probe.cold+0x1136/0x148e [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230875]  local_pci_probe+0x45/0x80
[  140.230882]  ? pci_match_device+0xd7/0x130
[  140.230887]  pci_device_probe+0xfa/0x1b0
[  140.230892]  really_probe+0x1f5/0x3f0
[  140.230899]  __driver_probe_device+0xfe/0x180
[  140.230903]  driver_probe_device+0x1e/0x90
[  140.230908]  __driver_attach+0xc0/0x1c0
[  140.230912]  ? __device_attach_driver+0xe0/0xe0
[  140.230915]  ? __device_attach_driver+0xe0/0xe0
[  140.230919]  bus_for_each_dev+0x89/0xd0
[  140.230924]  bus_add_driver+0x12b/0x1e0
[  140.230929]  driver_register+0x8f/0xe0
[  140.230933]  ? 0xc153f000
[  140.230937]  do_one_initcall+0x57/0x220
[  140.230945]  do_init_module+0x5c/0x260
[  140.230952]  load_module+0x24bd/0x26a0
[  140.230962]  ? __do_sys_finit_module+0xae/0x110
[  140.230966]  __do_sys_finit_module+0xae/0x110
[  140.230972]  do_syscall_64+0x5c/0x80
[  140.230979]  ? syscall_exit_to_user_mode+0x23/0x40
[  140.230983]  ? do_syscall_64+0x69/0x80
[  140.230988]  ? exc_page_fault+0x72/0x170
[  140.230991]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  140.230997] RIP: 0033:0x7f7fd5d8718d
[  140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 
48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 
3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[  140.231006] RSP: 002b:7ffefc25f0e8 EFLAGS: 0246 ORIG_RAX: 
0139
[  140.231012] RAX: ffda RBX: 55ac3edcd7f0 RCX: 
7f7fd5d8718d
[  140.231015] RDX:  RSI: 55ac3d723270 RDI: 
0003
[  140.231017] RBP:  R08:  R09: 
7f7fd5e52380
[  140.231019] R10: 0003 R11: 0246 R12: 
55ac3d723270
[  140.231021] R13:  R14: 55ac3edd06e0 R15: 

[  140.231038] atomisp-isp2 :00:03.0: hmm_init Failed to create 
sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: 
https://lore.kernel.org/linux-media/20211017162337.44860-3-kita...@gmail.com

Signed-off-by: Tsuchiya Yuto 
Co-developed-by: Mauro Carvalho Chehab 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 6a5ee4607089..c1cda16f2dc0 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -39,7 +39,7 @@
 struct hmm_bo_device bo_device;
 struct hmm_pooldynamic_pool;
 struct hmm_poolreserved_pool;
-static ia_css_ptr dummy_ptr;
+static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;
 static bool hmm_initialized;
 struct _hmm_mem_stat hmm_mem_stat;
 
@@ -209,7 +209,7 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
-   if (!dummy_ptr)
+   if (dummy_ptr == mmgr_EXCEPTION)
return;
sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group);
 
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)
 
dev_dbg(atomisp_dev, "%s

[PATCH AUTOSEL 5.16 58/59] media: atomisp: fix bad usage at error handling logic

2022-03-30 Thread Sasha Levin
From: Mauro Carvalho Chehab 

[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]

As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'

The acc_fw interactor is used outside the loop, at the error handling
logic. On most cases, this is actually safe there, but, if
atomisp_css_set_acc_parameters() has an error, an attempt to use it
will pick an invalid value for acc_fw.

Reported-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../staging/media/atomisp/pci/atomisp_acc.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index 9a1751895ab0..28cb271663c4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device 
*asd,
return 0;
 }
 
+static void atomisp_acc_unload_some_extensions(struct atomisp_sub_device *asd,
+ int i,
+ struct atomisp_acc_fw *acc_fw)
+{
+   while (--i >= 0) {
+   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
+   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
+
acc_flag_to_pipe[i].pipe_id);
+   }
+   }
+}
+
 /*
  * Appends the loaded acceleration binary extensions to the
  * current ISP mode. Must be called just before sh_css_start().
@@ -479,16 +491,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
 acc_fw->fw,
 
acc_flag_to_pipe[i].pipe_id,
 
acc_fw->type);
-   if (ret)
+   if (ret) {
+   atomisp_acc_unload_some_extensions(asd, 
i, acc_fw);
goto error;
+   }
 
ext_loaded = true;
}
}
 
ret = atomisp_css_set_acc_parameters(acc_fw);
-   if (ret < 0)
+   if (ret < 0) {
+   atomisp_acc_unload_some_extensions(asd, i, acc_fw);
goto error;
+   }
}
 
if (!ext_loaded)
@@ -497,6 +513,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
ret = atomisp_css_update_stream(asd);
if (ret) {
dev_err(isp->dev, "%s: update stream failed.\n", __func__);
+   atomisp_acc_unload_extensions(asd);
goto error;
}
 
@@ -504,13 +521,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
return 0;
 
 error:
-   while (--i >= 0) {
-   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-
acc_flag_to_pipe[i].pipe_id);
-   }
-   }
-
list_for_each_entry_continue_reverse(acc_fw, &asd->acc.fw, list) {
if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.15 02/50] media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]

On the case tmp_dcim=1, the index of buffer is miscalculated.
This generate a NULL pointer dereference later.

So let's fix the calcul and add a check to prevent this to reappear.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_device.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index 5b12a730a229..fb1f0465ca87 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -814,7 +814,7 @@ static void zoran_reap_stat_com(struct zoran *zr)
if (zr->jpg_settings.tmp_dcm == 1)
i = (zr->jpg_dma_tail - zr->jpg_err_shift) & 
BUZ_MASK_STAT_COM;
else
-   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2 + 
1;
+   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2;
 
stat_com = le32_to_cpu(zr->stat_com[i]);
if ((stat_com & 1) == 0) {
@@ -826,6 +826,11 @@ static void zoran_reap_stat_com(struct zoran *zr)
size = (stat_com & GENMASK(22, 1)) >> 1;
 
buf = zr->inuse[i];
+   if (!buf) {
+   spin_unlock_irqrestore(&zr->queued_bufs_lock, flags);
+   pci_err(zr->pci_dev, "No buffer at slot %d\n", i);
+   return;
+   }
buf->vbuf.vb2_buf.timestamp = ktime_get_ns();
 
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.15 01/50] media: staging: media: zoran: move videodev alloc

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit 82e3a496eb56da0b9f29fdc5b63cedb3289e91de ]

Move some code out of zr36057_init() and create new functions for handling
zr->video_dev. This permit to ease code reading and fix a zr->video_dev
memory leak.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran.h|  2 +-
 drivers/staging/media/zoran/zoran_card.c   | 80 ++
 drivers/staging/media/zoran/zoran_driver.c |  5 +-
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index b1ad2a2b914c..50d5a7acfab6 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -313,6 +313,6 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index f259585b0689..677d3a26cef4 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -803,6 +803,52 @@ int zoran_check_jpg_settings(struct zoran *zr,
return 0;
 }
 
+static int zoran_init_video_device(struct zoran *zr, struct video_device 
*video_dev, int dir)
+{
+   int err;
+
+   /* Now add the template and register the device unit. */
+   *video_dev = zoran_template;
+   video_dev->v4l2_dev = &zr->v4l2_dev;
+   video_dev->lock = &zr->lock;
+   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+
+   strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
+   /*
+* It's not a mem2mem device, but you can both capture and output from 
one and the same
+* device. This should really be split up into two device nodes, but 
that's a job for
+* another day.
+*/
+   video_dev->vfl_dir = VFL_DIR_M2M;
+   zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+
+   err = video_register_device(video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
+   if (err < 0)
+   return err;
+   video_set_drvdata(video_dev, zr);
+   return 0;
+}
+
+static void zoran_exit_video_devices(struct zoran *zr)
+{
+   video_unregister_device(zr->video_dev);
+   kfree(zr->video_dev);
+}
+
+static int zoran_init_video_devices(struct zoran *zr)
+{
+   int err;
+
+   zr->video_dev = video_device_alloc();
+   if (!zr->video_dev)
+   return -ENOMEM;
+
+   err = zoran_init_video_device(zr, zr->video_dev, 
V4L2_CAP_VIDEO_CAPTURE);
+   if (err)
+   kfree(zr->video_dev);
+   return err;
+}
+
 void zoran_open_init_params(struct zoran *zr)
 {
int i;
@@ -874,17 +920,11 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->video_dev = video_device_alloc();
-   if (!zr->video_dev) {
-   err = -ENOMEM;
-   goto exit;
-   }
zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
  BUZ_NUM_STAT_COM * sizeof(u32),
  &zr->p_sc, GFP_KERNEL);
if (!zr->stat_com) {
-   err = -ENOMEM;
-   goto exit_video;
+   return -ENOMEM;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -897,26 +937,9 @@ static int zr36057_init(struct zoran *zr)
goto exit_statcom;
}
 
-   /* Now add the template and register the device unit. */
-   *zr->video_dev = zoran_template;
-   zr->video_dev->v4l2_dev = &zr->v4l2_dev;
-   zr->video_dev->lock = &zr->lock;
-   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
-
-   strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
-   /*
-* It's not a mem2mem device, but you can both capture and output from 
one and the same
-* device. This should really be split up into two device nodes, but 
that's a job for
-* another day.
-*/
-   zr->video_dev->vfl_dir = VFL_DIR_M2M;
-
-   zoran_queue_init(zr, &zr->vq);
-
-   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
-   if (err < 0)
+   err = zoran_init_video_devices(zr);
+   if (err)
goto exit_statcomb;
-   video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
if (!pass_through) {
@@ -931,9 +954,6 @@ static int zr36057_init(struct zoran *zr)
dma_f

[PATCH AUTOSEL 5.15 03/50] media: staging: media: zoran: fix various V4L2 compliance errors

2022-03-30 Thread Sasha Levin
From: Hans Verkuil 

[ Upstream commit 914941827aad5ecddf9bf3a6dee67fbec1af1fff ]

This fixes several issues found with 'v4l2-compliance -s':

1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.

Signed-off-by: Hans Verkuil 
Signed-off-by: Corentin Labbe 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index 677d3a26cef4..175654d104c5 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -811,7 +811,7 @@ static int zoran_init_video_device(struct zoran *zr, struct 
video_device *video_
*video_dev = zoran_template;
video_dev->v4l2_dev = &zr->v4l2_dev;
video_dev->lock = &zr->lock;
-   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+   video_dev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | dir;
 
strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
/*
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 551db338c7f7..84665637ebb7 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -255,8 +255,6 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = zr->video_dev->device_caps;
-   cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
@@ -582,6 +580,9 @@ static int zoran_s_std(struct file *file, void *__fh, 
v4l2_std_id std)
struct zoran *zr = video_drvdata(file);
int res = 0;
 
+   if (zr->norm == std)
+   return 0;
+
if (zr->running != ZORAN_MAP_MODE_NONE)
return -EBUSY;
 
@@ -739,6 +740,7 @@ static int zoran_g_parm(struct file *file, void *priv, 
struct v4l2_streamparm *p
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   parm->parm.capture.readbuffers = 9;
return 0;
 }
 
@@ -869,6 +871,10 @@ int zr_set_buf(struct zoran *zr)
vbuf = &buf->vbuf;
 
buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
+   buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   else
+   buf->vbuf.field = V4L2_FIELD_TOP;
vb2_set_plane_payload(&buf->vbuf.vb2_buf, 0, zr->buffer_size);
vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_DONE);
zr->inuse[0] = NULL;
@@ -928,6 +934,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
zr->stat_com[j] = cpu_to_le32(1);
zr->inuse[j] = NULL;
}
+   zr->vbseq = 0;
 
if (zr->map_mode != ZORAN_MAP_MODE_RAW) {
pci_info(zr->pci_dev, "START JPG\n");
@@ -1018,7 +1025,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue 
*vq, int dir)
vq->dev = &zr->pci_dev->dev;
vq->type = dir;
 
-   vq->io_modes = VB2_USERPTR | VB2_DMABUF | VB2_MMAP | VB2_READ | 
VB2_WRITE;
+   vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ | VB2_WRITE;
vq->drv_priv = zr;
vq->buf_struct_size = sizeof(struct zr_buffer);
vq->ops = &zr_video_qops;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.15 20/50] media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards

2022-03-30 Thread Sasha Levin
From: Hans de Goede 

[ Upstream commit 2c39a01154ea57d596470afa1d278e3be3b37f6a ]

The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on
after having turned it off causes the CPLM3218 ambient-light-sensor on
the front camera sensor's I2C bus to crash, hanging the bus.

Add a DMI quirk table for systems on which to leave eldo2 on.

Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor
as long as the camera sensor is being used, this is what Windows seems
to do as a workaround (based on analyzing the DSDT). But that is not
easy to do cleanly under Linux.

Link: 
https://lore.kernel.org/linux-media/20220116215204.307649-10-hdego...@redhat.com
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../media/atomisp/pci/atomisp_gmin_platform.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c 
b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 62dc06e22476..cd0a771454da 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -729,6 +729,21 @@ static int axp_regulator_set(struct device *dev, struct 
gmin_subdev *gs,
return 0;
 }
 
+/*
+ * Some boards contain a hw-bug where turning eldo2 back on after having turned
+ * it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C 
bus
+ * to crash, hanging the bus. Do not turn eldo2 off on these systems.
+ */
+static const struct dmi_system_id axp_leave_eldo2_on_ids[] = {
+   {
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab duo W1 10.1 
(VT4)"),
+   },
+   },
+   { }
+};
+
 static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs)
 {
int ret;
@@ -763,6 +778,9 @@ static int axp_v1p8_off(struct device *dev, struct 
gmin_subdev *gs)
if (ret)
return ret;
 
+   if (dmi_check_system(axp_leave_eldo2_on_ids))
+   return 0;
+
ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v,
ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false);
return ret;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.15 21/50] media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

2022-03-30 Thread Sasha Levin
From: Tsuchiya Yuto 

[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[  140.230662] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:03.0/active_bo'
[  140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE
 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[  140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 
03/09/2015
[  140.230678] Call Trace:
[  140.230687]  dump_stack_lvl+0x46/0x5a
[  140.230702]  sysfs_warn_dup.cold+0x17/0x24
[  140.230710]  sysfs_add_file_mode_ns+0x160/0x170
[  140.230717]  internal_create_group+0x126/0x390
[  140.230723]  hmm_init+0x5c/0x70 [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230811]  atomisp_pci_probe.cold+0x1136/0x148e [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230875]  local_pci_probe+0x45/0x80
[  140.230882]  ? pci_match_device+0xd7/0x130
[  140.230887]  pci_device_probe+0xfa/0x1b0
[  140.230892]  really_probe+0x1f5/0x3f0
[  140.230899]  __driver_probe_device+0xfe/0x180
[  140.230903]  driver_probe_device+0x1e/0x90
[  140.230908]  __driver_attach+0xc0/0x1c0
[  140.230912]  ? __device_attach_driver+0xe0/0xe0
[  140.230915]  ? __device_attach_driver+0xe0/0xe0
[  140.230919]  bus_for_each_dev+0x89/0xd0
[  140.230924]  bus_add_driver+0x12b/0x1e0
[  140.230929]  driver_register+0x8f/0xe0
[  140.230933]  ? 0xc153f000
[  140.230937]  do_one_initcall+0x57/0x220
[  140.230945]  do_init_module+0x5c/0x260
[  140.230952]  load_module+0x24bd/0x26a0
[  140.230962]  ? __do_sys_finit_module+0xae/0x110
[  140.230966]  __do_sys_finit_module+0xae/0x110
[  140.230972]  do_syscall_64+0x5c/0x80
[  140.230979]  ? syscall_exit_to_user_mode+0x23/0x40
[  140.230983]  ? do_syscall_64+0x69/0x80
[  140.230988]  ? exc_page_fault+0x72/0x170
[  140.230991]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  140.230997] RIP: 0033:0x7f7fd5d8718d
[  140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 
48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 
3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[  140.231006] RSP: 002b:7ffefc25f0e8 EFLAGS: 0246 ORIG_RAX: 
0139
[  140.231012] RAX: ffda RBX: 55ac3edcd7f0 RCX: 
7f7fd5d8718d
[  140.231015] RDX:  RSI: 55ac3d723270 RDI: 
0003
[  140.231017] RBP:  R08:  R09: 
7f7fd5e52380
[  140.231019] R10: 0003 R11: 0246 R12: 
55ac3d723270
[  140.231021] R13:  R14: 55ac3edd06e0 R15: 

[  140.231038] atomisp-isp2 :00:03.0: hmm_init Failed to create 
sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: 
https://lore.kernel.org/linux-media/20211017162337.44860-3-kita...@gmail.com

Signed-off-by: Tsuchiya Yuto 
Co-developed-by: Mauro Carvalho Chehab 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 6a5ee4607089..c1cda16f2dc0 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -39,7 +39,7 @@
 struct hmm_bo_device bo_device;
 struct hmm_pooldynamic_pool;
 struct hmm_poolreserved_pool;
-static ia_css_ptr dummy_ptr;
+static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;
 static bool hmm_initialized;
 struct _hmm_mem_stat hmm_mem_stat;
 
@@ -209,7 +209,7 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
-   if (!dummy_ptr)
+   if (dummy_ptr == mmgr_EXCEPTION)
return;
sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group);
 
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)
 
dev_dbg(atomisp_dev, "%s

[PATCH AUTOSEL 5.15 49/50] media: atomisp: fix bad usage at error handling logic

2022-03-30 Thread Sasha Levin
From: Mauro Carvalho Chehab 

[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]

As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'

The acc_fw interactor is used outside the loop, at the error handling
logic. On most cases, this is actually safe there, but, if
atomisp_css_set_acc_parameters() has an error, an attempt to use it
will pick an invalid value for acc_fw.

Reported-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../staging/media/atomisp/pci/atomisp_acc.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index 9a1751895ab0..28cb271663c4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device 
*asd,
return 0;
 }
 
+static void atomisp_acc_unload_some_extensions(struct atomisp_sub_device *asd,
+ int i,
+ struct atomisp_acc_fw *acc_fw)
+{
+   while (--i >= 0) {
+   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
+   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
+
acc_flag_to_pipe[i].pipe_id);
+   }
+   }
+}
+
 /*
  * Appends the loaded acceleration binary extensions to the
  * current ISP mode. Must be called just before sh_css_start().
@@ -479,16 +491,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
 acc_fw->fw,
 
acc_flag_to_pipe[i].pipe_id,
 
acc_fw->type);
-   if (ret)
+   if (ret) {
+   atomisp_acc_unload_some_extensions(asd, 
i, acc_fw);
goto error;
+   }
 
ext_loaded = true;
}
}
 
ret = atomisp_css_set_acc_parameters(acc_fw);
-   if (ret < 0)
+   if (ret < 0) {
+   atomisp_acc_unload_some_extensions(asd, i, acc_fw);
goto error;
+   }
}
 
if (!ext_loaded)
@@ -497,6 +513,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
ret = atomisp_css_update_stream(asd);
if (ret) {
dev_err(isp->dev, "%s: update stream failed.\n", __func__);
+   atomisp_acc_unload_extensions(asd);
goto error;
}
 
@@ -504,13 +521,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
return 0;
 
 error:
-   while (--i >= 0) {
-   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-
acc_flag_to_pipe[i].pipe_id);
-   }
-   }
-
list_for_each_entry_continue_reverse(acc_fw, &asd->acc.fw, list) {
if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 01/37] media: staging: media: zoran: move videodev alloc

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit 82e3a496eb56da0b9f29fdc5b63cedb3289e91de ]

Move some code out of zr36057_init() and create new functions for handling
zr->video_dev. This permit to ease code reading and fix a zr->video_dev
memory leak.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran.h|  2 +-
 drivers/staging/media/zoran/zoran_card.c   | 80 ++
 drivers/staging/media/zoran/zoran_driver.c |  5 +-
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h 
b/drivers/staging/media/zoran/zoran.h
index e7fe8da7732c..3f223e5b1872 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -314,6 +314,6 @@ static inline struct zoran *to_zoran(struct v4l2_device 
*v4l2_dev)
 
 #endif
 
-int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq);
+int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir);
 void zoran_queue_exit(struct zoran *zr);
 int zr_set_buf(struct zoran *zr);
diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index dfc60e2e9dd7..e4df72cd4d28 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -802,6 +802,52 @@ int zoran_check_jpg_settings(struct zoran *zr,
return 0;
 }
 
+static int zoran_init_video_device(struct zoran *zr, struct video_device 
*video_dev, int dir)
+{
+   int err;
+
+   /* Now add the template and register the device unit. */
+   *video_dev = zoran_template;
+   video_dev->v4l2_dev = &zr->v4l2_dev;
+   video_dev->lock = &zr->lock;
+   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+
+   strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
+   /*
+* It's not a mem2mem device, but you can both capture and output from 
one and the same
+* device. This should really be split up into two device nodes, but 
that's a job for
+* another day.
+*/
+   video_dev->vfl_dir = VFL_DIR_M2M;
+   zoran_queue_init(zr, &zr->vq, V4L2_BUF_TYPE_VIDEO_CAPTURE);
+
+   err = video_register_device(video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
+   if (err < 0)
+   return err;
+   video_set_drvdata(video_dev, zr);
+   return 0;
+}
+
+static void zoran_exit_video_devices(struct zoran *zr)
+{
+   video_unregister_device(zr->video_dev);
+   kfree(zr->video_dev);
+}
+
+static int zoran_init_video_devices(struct zoran *zr)
+{
+   int err;
+
+   zr->video_dev = video_device_alloc();
+   if (!zr->video_dev)
+   return -ENOMEM;
+
+   err = zoran_init_video_device(zr, zr->video_dev, 
V4L2_CAP_VIDEO_CAPTURE);
+   if (err)
+   kfree(zr->video_dev);
+   return err;
+}
+
 void zoran_open_init_params(struct zoran *zr)
 {
int i;
@@ -873,17 +919,11 @@ static int zr36057_init(struct zoran *zr)
zoran_open_init_params(zr);
 
/* allocate memory *before* doing anything to the hardware in case 
allocation fails */
-   zr->video_dev = video_device_alloc();
-   if (!zr->video_dev) {
-   err = -ENOMEM;
-   goto exit;
-   }
zr->stat_com = dma_alloc_coherent(&zr->pci_dev->dev,
  BUZ_NUM_STAT_COM * sizeof(u32),
  &zr->p_sc, GFP_KERNEL);
if (!zr->stat_com) {
-   err = -ENOMEM;
-   goto exit_video;
+   return -ENOMEM;
}
for (j = 0; j < BUZ_NUM_STAT_COM; j++)
zr->stat_com[j] = cpu_to_le32(1); /* mark as unavailable to 
zr36057 */
@@ -896,26 +936,9 @@ static int zr36057_init(struct zoran *zr)
goto exit_statcom;
}
 
-   /* Now add the template and register the device unit. */
-   *zr->video_dev = zoran_template;
-   zr->video_dev->v4l2_dev = &zr->v4l2_dev;
-   zr->video_dev->lock = &zr->lock;
-   zr->video_dev->device_caps = V4L2_CAP_STREAMING | 
V4L2_CAP_VIDEO_CAPTURE;
-
-   strscpy(zr->video_dev->name, ZR_DEVNAME(zr), 
sizeof(zr->video_dev->name));
-   /*
-* It's not a mem2mem device, but you can both capture and output from 
one and the same
-* device. This should really be split up into two device nodes, but 
that's a job for
-* another day.
-*/
-   zr->video_dev->vfl_dir = VFL_DIR_M2M;
-
-   zoran_queue_init(zr, &zr->vq);
-
-   err = video_register_device(zr->video_dev, VFL_TYPE_VIDEO, 
video_nr[zr->id]);
-   if (err < 0)
+   err = zoran_init_video_devices(zr);
+   if (err)
goto exit_statcomb;
-   video_set_drvdata(zr->video_dev, zr);
 
zoran_init_hardware(zr);
if (!pass_through) {
@@ -930,9 +953,6 @@ static int zr36057_init(struct zoran *zr)
dma_f

[PATCH AUTOSEL 5.10 02/37] media: staging: media: zoran: calculate the right buffer number for zoran_reap_stat_com

2022-03-30 Thread Sasha Levin
From: Corentin Labbe 

[ Upstream commit e3b86f4e558cea9eed71d894df2f19b10d60a207 ]

On the case tmp_dcim=1, the index of buffer is miscalculated.
This generate a NULL pointer dereference later.

So let's fix the calcul and add a check to prevent this to reappear.

Signed-off-by: Corentin Labbe 
Signed-off-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_device.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/zoran/zoran_device.c 
b/drivers/staging/media/zoran/zoran_device.c
index e569a1341d01..913f5a3c5bfc 100644
--- a/drivers/staging/media/zoran/zoran_device.c
+++ b/drivers/staging/media/zoran/zoran_device.c
@@ -879,7 +879,7 @@ static void zoran_reap_stat_com(struct zoran *zr)
if (zr->jpg_settings.tmp_dcm == 1)
i = (zr->jpg_dma_tail - zr->jpg_err_shift) & 
BUZ_MASK_STAT_COM;
else
-   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2 + 
1;
+   i = ((zr->jpg_dma_tail - zr->jpg_err_shift) & 1) * 2;
 
stat_com = le32_to_cpu(zr->stat_com[i]);
if ((stat_com & 1) == 0) {
@@ -891,6 +891,11 @@ static void zoran_reap_stat_com(struct zoran *zr)
size = (stat_com & GENMASK(22, 1)) >> 1;
 
buf = zr->inuse[i];
+   if (!buf) {
+   spin_unlock_irqrestore(&zr->queued_bufs_lock, flags);
+   pci_err(zr->pci_dev, "No buffer at slot %d\n", i);
+   return;
+   }
buf->vbuf.vb2_buf.timestamp = ktime_get_ns();
 
if (zr->codec_mode == BUZ_MODE_MOTION_COMPRESS) {
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 03/37] media: staging: media: zoran: fix various V4L2 compliance errors

2022-03-30 Thread Sasha Levin
From: Hans Verkuil 

[ Upstream commit 914941827aad5ecddf9bf3a6dee67fbec1af1fff ]

This fixes several issues found with 'v4l2-compliance -s':

1) read()/write() is supported, but not reported in the capabilities
2) S_STD(G_STD()) failed: setting the same standard should just return 0.
3) G_PARM failed to set readbuffers.
4) different field values in the format vs. what v4l2_buffer reported.
5) zero the sequence number when starting streaming.
6) drop VB_USERPTR: makes no sense with dma_contig streaming.

Signed-off-by: Hans Verkuil 
Signed-off-by: Corentin Labbe 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/zoran/zoran_card.c   |  2 +-
 drivers/staging/media/zoran/zoran_driver.c | 13 ++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran_card.c 
b/drivers/staging/media/zoran/zoran_card.c
index e4df72cd4d28..fb7a5f87d3bc 100644
--- a/drivers/staging/media/zoran/zoran_card.c
+++ b/drivers/staging/media/zoran/zoran_card.c
@@ -810,7 +810,7 @@ static int zoran_init_video_device(struct zoran *zr, struct 
video_device *video_
*video_dev = zoran_template;
video_dev->v4l2_dev = &zr->v4l2_dev;
video_dev->lock = &zr->lock;
-   video_dev->device_caps = V4L2_CAP_STREAMING | dir;
+   video_dev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_READWRITE | dir;
 
strscpy(video_dev->name, ZR_DEVNAME(zr), sizeof(video_dev->name));
/*
diff --git a/drivers/staging/media/zoran/zoran_driver.c 
b/drivers/staging/media/zoran/zoran_driver.c
index 7f22596cc630..ea04f6c732b2 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -255,8 +255,6 @@ static int zoran_querycap(struct file *file, void *__fh, 
struct v4l2_capability
strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card));
strscpy(cap->driver, "zoran", sizeof(cap->driver));
snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", 
pci_name(zr->pci_dev));
-   cap->device_caps = zr->video_dev->device_caps;
-   cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
return 0;
 }
 
@@ -582,6 +580,9 @@ static int zoran_s_std(struct file *file, void *__fh, 
v4l2_std_id std)
struct zoran *zr = video_drvdata(file);
int res = 0;
 
+   if (zr->norm == std)
+   return 0;
+
if (zr->running != ZORAN_MAP_MODE_NONE)
return -EBUSY;
 
@@ -737,6 +738,7 @@ static int zoran_g_parm(struct file *file, void *priv, 
struct v4l2_streamparm *p
if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
 
+   parm->parm.capture.readbuffers = 9;
return 0;
 }
 
@@ -867,6 +869,10 @@ int zr_set_buf(struct zoran *zr)
vbuf = &buf->vbuf;
 
buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2))
+   buf->vbuf.field = V4L2_FIELD_INTERLACED;
+   else
+   buf->vbuf.field = V4L2_FIELD_TOP;
vb2_set_plane_payload(&buf->vbuf.vb2_buf, 0, zr->buffer_size);
vb2_buffer_done(&buf->vbuf.vb2_buf, VB2_BUF_STATE_DONE);
zr->inuse[0] = NULL;
@@ -926,6 +932,7 @@ static int zr_vb2_start_streaming(struct vb2_queue *vq, 
unsigned int count)
zr->stat_com[j] = cpu_to_le32(1);
zr->inuse[j] = NULL;
}
+   zr->vbseq = 0;
 
if (zr->map_mode != ZORAN_MAP_MODE_RAW) {
pci_info(zr->pci_dev, "START JPG\n");
@@ -1016,7 +1023,7 @@ int zoran_queue_init(struct zoran *zr, struct vb2_queue 
*vq, int dir)
vq->dev = &zr->pci_dev->dev;
vq->type = dir;
 
-   vq->io_modes = VB2_USERPTR | VB2_DMABUF | VB2_MMAP | VB2_READ | 
VB2_WRITE;
+   vq->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ | VB2_WRITE;
vq->drv_priv = zr;
vq->buf_struct_size = sizeof(struct zr_buffer);
vq->ops = &zr_video_qops;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 13/37] media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards

2022-03-30 Thread Sasha Levin
From: Hans de Goede 

[ Upstream commit 2c39a01154ea57d596470afa1d278e3be3b37f6a ]

The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on
after having turned it off causes the CPLM3218 ambient-light-sensor on
the front camera sensor's I2C bus to crash, hanging the bus.

Add a DMI quirk table for systems on which to leave eldo2 on.

Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor
as long as the camera sensor is being used, this is what Windows seems
to do as a workaround (based on analyzing the DSDT). But that is not
easy to do cleanly under Linux.

Link: 
https://lore.kernel.org/linux-media/20220116215204.307649-10-hdego...@redhat.com
Signed-off-by: Hans de Goede 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../media/atomisp/pci/atomisp_gmin_platform.c  | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c 
b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index 34480ca16474..c9ee85037644 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -729,6 +729,21 @@ static int axp_regulator_set(struct device *dev, struct 
gmin_subdev *gs,
return 0;
 }
 
+/*
+ * Some boards contain a hw-bug where turning eldo2 back on after having turned
+ * it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C 
bus
+ * to crash, hanging the bus. Do not turn eldo2 off on these systems.
+ */
+static const struct dmi_system_id axp_leave_eldo2_on_ids[] = {
+   {
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"),
+   DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab duo W1 10.1 
(VT4)"),
+   },
+   },
+   { }
+};
+
 static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs)
 {
int ret;
@@ -763,6 +778,9 @@ static int axp_v1p8_off(struct device *dev, struct 
gmin_subdev *gs)
if (ret)
return ret;
 
+   if (dmi_check_system(axp_leave_eldo2_on_ids))
+   return 0;
+
ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v,
ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false);
return ret;
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.10 14/37] media: atomisp: fix dummy_ptr check to avoid duplicate active_bo

2022-03-30 Thread Sasha Levin
From: Tsuchiya Yuto 

[ Upstream commit 127efdbc51fe6064336c0452ce9c910b3e107cf0 ]

The dummy_ptr check in hmm_init() [1] results in the following
"hmm_init Failed to create sysfs" error exactly once every
two times on atomisp reload by rmmod/insmod (although atomisp module
loads and works fine regardless of this error):

[  140.230662] sysfs: cannot create duplicate filename 
'/devices/pci:00/:00:03.0/active_bo'
[  140.230668] CPU: 1 PID: 2502 Comm: insmod Tainted: G C OE
 5.15.0-rc4-1-surface-mainline #1 b8acf6eb64994414b2e20bad312a7a2c45f748f9
[  140.230675] Hardware name: OEMB OEMB/OEMB, BIOS 1.51116.238 
03/09/2015
[  140.230678] Call Trace:
[  140.230687]  dump_stack_lvl+0x46/0x5a
[  140.230702]  sysfs_warn_dup.cold+0x17/0x24
[  140.230710]  sysfs_add_file_mode_ns+0x160/0x170
[  140.230717]  internal_create_group+0x126/0x390
[  140.230723]  hmm_init+0x5c/0x70 [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230811]  atomisp_pci_probe.cold+0x1136/0x148e [atomisp 
7a6a680bf400629363d2a6f58fd10e7299678b99]
[  140.230875]  local_pci_probe+0x45/0x80
[  140.230882]  ? pci_match_device+0xd7/0x130
[  140.230887]  pci_device_probe+0xfa/0x1b0
[  140.230892]  really_probe+0x1f5/0x3f0
[  140.230899]  __driver_probe_device+0xfe/0x180
[  140.230903]  driver_probe_device+0x1e/0x90
[  140.230908]  __driver_attach+0xc0/0x1c0
[  140.230912]  ? __device_attach_driver+0xe0/0xe0
[  140.230915]  ? __device_attach_driver+0xe0/0xe0
[  140.230919]  bus_for_each_dev+0x89/0xd0
[  140.230924]  bus_add_driver+0x12b/0x1e0
[  140.230929]  driver_register+0x8f/0xe0
[  140.230933]  ? 0xc153f000
[  140.230937]  do_one_initcall+0x57/0x220
[  140.230945]  do_init_module+0x5c/0x260
[  140.230952]  load_module+0x24bd/0x26a0
[  140.230962]  ? __do_sys_finit_module+0xae/0x110
[  140.230966]  __do_sys_finit_module+0xae/0x110
[  140.230972]  do_syscall_64+0x5c/0x80
[  140.230979]  ? syscall_exit_to_user_mode+0x23/0x40
[  140.230983]  ? do_syscall_64+0x69/0x80
[  140.230988]  ? exc_page_fault+0x72/0x170
[  140.230991]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[  140.230997] RIP: 0033:0x7f7fd5d8718d
[  140.231003] Code: b4 0c 00 0f 05 eb a9 66 0f 1f 44 00 00 f3 0f 1e fa 
48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 
3d 01 f0 ff ff 73 01 c3 48 8b 0d b3 6c 0c 00 f7 d8 64 89 01 48
[  140.231006] RSP: 002b:7ffefc25f0e8 EFLAGS: 0246 ORIG_RAX: 
0139
[  140.231012] RAX: ffda RBX: 55ac3edcd7f0 RCX: 
7f7fd5d8718d
[  140.231015] RDX:  RSI: 55ac3d723270 RDI: 
0003
[  140.231017] RBP:  R08:  R09: 
7f7fd5e52380
[  140.231019] R10: 0003 R11: 0246 R12: 
55ac3d723270
[  140.231021] R13:  R14: 55ac3edd06e0 R15: 

[  140.231038] atomisp-isp2 :00:03.0: hmm_init Failed to create 
sysfs

The problem is that dummy_ptr == 0 is a valid value. So, change the logic
which checks if dummy_ptr was allocated.

At this point, atomisp now gives WARN_ON() in hmm_free() [2] on atomisp
reload by rmmod/insmod. Again, the check is wrong there.

So, change both checks for mmgr_EXCEPTION, which is the error value when
HMM allocation fails, and initialize dummy_ptr with such value.

[1] added on commit
d9ab83953fa7 ("media: atomisp: don't cause a warn if probe failed")
[2] added on commit
b83cc378dfc4 ("atomisp: clean up the hmm init/cleanup indirections")

Link: 
https://lore.kernel.org/linux-media/20211017162337.44860-3-kita...@gmail.com

Signed-off-by: Tsuchiya Yuto 
Co-developed-by: Mauro Carvalho Chehab 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 6a5ee4607089..c1cda16f2dc0 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -39,7 +39,7 @@
 struct hmm_bo_device bo_device;
 struct hmm_pooldynamic_pool;
 struct hmm_poolreserved_pool;
-static ia_css_ptr dummy_ptr;
+static ia_css_ptr dummy_ptr = mmgr_EXCEPTION;
 static bool hmm_initialized;
 struct _hmm_mem_stat hmm_mem_stat;
 
@@ -209,7 +209,7 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
-   if (!dummy_ptr)
+   if (dummy_ptr == mmgr_EXCEPTION)
return;
sysfs_remove_group(&atomisp_dev->kobj, atomisp_attribute_group);
 
@@ -288,7 +288,8 @@ void hmm_free(ia_css_ptr virt)
 
dev_dbg(atomisp_dev, "%s

[PATCH AUTOSEL 5.10 36/37] media: atomisp: fix bad usage at error handling logic

2022-03-30 Thread Sasha Levin
From: Mauro Carvalho Chehab 

[ Upstream commit fc0b582c858ed73f94c8f3375c203ea46f1f7402 ]

As warned by sparse:
atomisp: drivers/staging/media/atomisp/pci/atomisp_acc.c:508 
atomisp_acc_load_extensions() warn: iterator used outside loop: 'acc_fw'

The acc_fw interactor is used outside the loop, at the error handling
logic. On most cases, this is actually safe there, but, if
atomisp_css_set_acc_parameters() has an error, an attempt to use it
will pick an invalid value for acc_fw.

Reported-by: Hans Verkuil 
Signed-off-by: Mauro Carvalho Chehab 
Signed-off-by: Sasha Levin 
---
 .../staging/media/atomisp/pci/atomisp_acc.c   | 28 +--
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index f638d0bd09fe..b1614cce2dfb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -439,6 +439,18 @@ int atomisp_acc_s_mapped_arg(struct atomisp_sub_device 
*asd,
return 0;
 }
 
+static void atomisp_acc_unload_some_extensions(struct atomisp_sub_device *asd,
+ int i,
+ struct atomisp_acc_fw *acc_fw)
+{
+   while (--i >= 0) {
+   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
+   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
+
acc_flag_to_pipe[i].pipe_id);
+   }
+   }
+}
+
 /*
  * Appends the loaded acceleration binary extensions to the
  * current ISP mode. Must be called just before sh_css_start().
@@ -477,16 +489,20 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
 acc_fw->fw,
 
acc_flag_to_pipe[i].pipe_id,
 
acc_fw->type);
-   if (ret)
+   if (ret) {
+   atomisp_acc_unload_some_extensions(asd, 
i, acc_fw);
goto error;
+   }
 
ext_loaded = true;
}
}
 
ret = atomisp_css_set_acc_parameters(acc_fw);
-   if (ret < 0)
+   if (ret < 0) {
+   atomisp_acc_unload_some_extensions(asd, i, acc_fw);
goto error;
+   }
}
 
if (!ext_loaded)
@@ -495,6 +511,7 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
ret = atomisp_css_update_stream(asd);
if (ret) {
dev_err(isp->dev, "%s: update stream failed.\n", __func__);
+   atomisp_acc_unload_extensions(asd);
goto error;
}
 
@@ -502,13 +519,6 @@ int atomisp_acc_load_extensions(struct atomisp_sub_device 
*asd)
return 0;
 
 error:
-   while (--i >= 0) {
-   if (acc_fw->flags & acc_flag_to_pipe[i].flag) {
-   atomisp_css_unload_acc_extension(asd, acc_fw->fw,
-
acc_flag_to_pipe[i].pipe_id);
-   }
-   }
-
list_for_each_entry_continue_reverse(acc_fw, &asd->acc.fw, list) {
if (acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_OUTPUT &&
acc_fw->type != ATOMISP_ACC_FW_LOAD_TYPE_VIEWFINDER)
-- 
2.34.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:staging-testing] BUILD SUCCESS 0dfcaebf8157d5d12ceb4c11bea590b8f826555b

2022-03-30 Thread kernel test robot
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
staging-testing
branch HEAD: 0dfcaebf8157d5d12ceb4c11bea590b8f826555b  staging: r8188eu: 
convert rtw_inc_and_chk_continual_urb_error() to bool

elapsed time: 720m

configs tested: 164
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm defconfig
arm64allyesconfig
arm64   defconfig
arm  allyesconfig
arm  allmodconfig
i386  randconfig-c001
mips randconfig-c004-20220330
powerpc  randconfig-c003-20220330
sh  landisk_defconfig
shedosk7760_defconfig
powerpc rainier_defconfig
um i386_defconfig
xtensasmp_lx200_defconfig
armmini2440_defconfig
powerpcadder875_defconfig
m68k allmodconfig
powerpc pq2fads_defconfig
arc haps_hs_smp_defconfig
riscv nommu_k210_sdcard_defconfig
um   alldefconfig
mipsgpr_defconfig
nios2 3c120_defconfig
sh   alldefconfig
arm   aspeed_g5_defconfig
parisc64defconfig
shsh7757lcr_defconfig
powerpcklondike_defconfig
sparc   sparc64_defconfig
sh  rsk7201_defconfig
mipsar7_defconfig
xtensa  defconfig
mipsvocore2_defconfig
armlart_defconfig
armtrizeps4_defconfig
alphaalldefconfig
armcerfcube_defconfig
powerpc mpc837x_mds_defconfig
arc nsimosci_hs_defconfig
s390defconfig
powerpc mpc85xx_cds_defconfig
mips   gcw0_defconfig
arm   sama5_defconfig
pariscgeneric-64bit_defconfig
powerpc  arches_defconfig
ia64zx1_defconfig
m68kstmark2_defconfig
powerpc  iss476-smp_defconfig
arm cm_x300_defconfig
sh espt_defconfig
powerpc  storcenter_defconfig
shapsh4ad0a_defconfig
mipsbcm47xx_defconfig
powerpc mpc834x_itx_defconfig
sh ap325rxa_defconfig
mips decstation_defconfig
sh   se7705_defconfig
arm s3c6400_defconfig
ia64defconfig
m68k amcore_defconfig
riscv   defconfig
powerpc   eiger_defconfig
um  defconfig
openriscor1ksim_defconfig
sh  urquell_defconfig
sh   sh2007_defconfig
shhp6xx_defconfig
sh   se7721_defconfig
openrisc  or1klitex_defconfig
arm at91_dt_defconfig
arc haps_hs_defconfig
m68k  multi_defconfig
powerpc  ppc6xx_defconfig
sh  kfr2r09_defconfig
mips   ip32_defconfig
shmigor_defconfig
powerpc sequoia_defconfig
ia64  gensparse_defconfig
riscvallmodconfig
nios2   defconfig
m68kq40_defconfig
mips   jazz_defconfig
m68k  hp300_defconfig
arm axm55xx_defconfig
shecovec24-romimage_defconfig
sh   sh7724_generic_defconfig
parisc  defconfig
mips bigsur_defconfig
powerpc linkstation_defconfig
archsdk_defconfig
powerpcwarp_defconfig
xtensa  iss_defconfig
arm   sunxi_defconfig
arm  randconfig-c002-20220330
ia64 allmodconfig
ia64 allyesconfig
m68kdefconfig
m68k allyesconfig
arc  allyesconfig
nios2allyesconfig
csky