PLEASE CONFIRM

2020-05-30 Thread Wade KAHN
I need you as a partner to invest US$27.5Million. 
You will invest and manage it based on terms of agreement
We shall do the needful to position and make you the beneficiary. 
Please confirm your full names, contact address, phone, numbers, age, sex, 
occupation. 
I will supply you all necessary information once I hear from you. 
This transaction is a deal and MUST be kept a SECRET. Feel free to ask 
questions. 
I await your immediate response.
 
Regards,
Mr. Wade KAHN.
Email: wadekahn...@yahoo.co.jp


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


[PATCH 0/2] A couple additional patches for atomisp

2020-05-30 Thread Mauro Carvalho Chehab
Patch 1 was sent by Arnd already, but, while it improved stack usage with
clang, it broke compilation with gcc ;-(

Each compiler seems to have different issues with different types of
struct initalizers, so we ended needing some discussions in order to find
something that would work for both.

So, the new version works fine with both compilers.

While here, I noticed a file that has nothing but comments. The second
patch gets rid of it.

Arnd Bergmann (1):
  staging: media: atomisp: fix stack overflow in init_pipe_defaults()

Mauro Carvalho Chehab (1):
  media: atomisp: get rid of sh_css_pipe.c

 drivers/staging/media/atomisp/Makefile|  1 -
 .../media/atomisp/pci/ia_css_frame_public.h   |  6 ++---
 .../staging/media/atomisp/pci/ia_css_pipe.h   | 15 ---
 .../media/atomisp/pci/ia_css_pipe_public.h|  6 ++---
 .../staging/media/atomisp/pci/ia_css_types.h  |  6 ++---
 .../sdis/common/ia_css_sdis_common_types.h|  9 +++
 .../runtime/binary/interface/ia_css_binary.h  |  3 +--
 .../pipeline/interface/ia_css_pipeline.h  |  3 +--
 .../pci/runtime/pipeline/src/pipeline.c   | 13 ++---
 drivers/staging/media/atomisp/pci/sh_css.c| 27 +--
 .../staging/media/atomisp/pci/sh_css_pipe.c   | 17 
 11 files changed, 46 insertions(+), 60 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/pci/sh_css_pipe.c

-- 
2.26.2


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


[PATCH 2/2] media: atomisp: get rid of sh_css_pipe.c

2020-05-30 Thread Mauro Carvalho Chehab
There's nothing there, just comments.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/Makefile  |  1 -
 drivers/staging/media/atomisp/pci/sh_css_pipe.c | 17 -
 2 files changed, 18 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/pci/sh_css_pipe.c

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index 0b62020f9b8b..9dc8072799e3 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -37,7 +37,6 @@ atomisp-objs += \
pci/sh_css_param_dvs.o \
pci/sh_css_param_shading.o \
pci/sh_css_params.o \
-   pci/sh_css_pipe.o \
pci/sh_css_properties.o \
pci/sh_css_shading.o \
pci/sh_css_sp.o \
diff --git a/drivers/staging/media/atomisp/pci/sh_css_pipe.c 
b/drivers/staging/media/atomisp/pci/sh_css_pipe.c
deleted file mode 100644
index b6bd47d9b01c..
--- a/drivers/staging/media/atomisp/pci/sh_css_pipe.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-/* This file will contain the code to implement the functions declared in 
ia_css_pipe.h and ia_css_pipe_public.h
-   and associated helper functions */
-- 
2.26.2

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


[PATCH 1/2] staging: media: atomisp: fix stack overflow in init_pipe_defaults()

2020-05-30 Thread Mauro Carvalho Chehab
From: Arnd Bergmann 

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.

Fixes: 6dc9a2568f84 ("media: atomisp: convert default struct values to use 
compound-literals with designated initializers")
Co-authored-by: Mauro Carvalho Chehab 
Signed-off-by: Arnd Bergmann 
Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/atomisp/pci/ia_css_frame_public.h   |  6 ++---
 .../staging/media/atomisp/pci/ia_css_pipe.h   | 15 ---
 .../media/atomisp/pci/ia_css_pipe_public.h|  6 ++---
 .../staging/media/atomisp/pci/ia_css_types.h  |  6 ++---
 .../sdis/common/ia_css_sdis_common_types.h|  9 +++
 .../runtime/binary/interface/ia_css_binary.h  |  3 +--
 .../pipeline/interface/ia_css_pipeline.h  |  3 +--
 .../pci/runtime/pipeline/src/pipeline.c   | 13 ++---
 drivers/staging/media/atomisp/pci/sh_css.c| 27 +--
 9 files changed, 46 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/ia_css_frame_public.h 
b/drivers/staging/media/atomisp/pci/ia_css_frame_public.h
index d822aa235ffe..96c86f0dc81c 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_frame_public.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_frame_public.h
@@ -122,8 +122,7 @@ struct ia_css_frame_info {
struct ia_css_crop_info crop_info;
 };
 
-#define IA_CSS_BINARY_DEFAULT_FRAME_INFO \
-(struct ia_css_frame_info) { \
+#define IA_CSS_BINARY_DEFAULT_FRAME_INFO { \
.format = IA_CSS_FRAME_FORMAT_NUM,  \
.raw_bayer_order= IA_CSS_BAYER_ORDER_NUM, \
 }
@@ -185,8 +184,7 @@ struct ia_css_frame {
   info.format */
 };
 
-#define DEFAULT_FRAME \
-(struct ia_css_frame) { \
+#define DEFAULT_FRAME { \
.info   = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
.dynamic_queue_id   = SH_CSS_INVALID_QUEUE_ID, \
.buf_type   = IA_CSS_BUFFER_TYPE_INVALID, \
diff --git a/drivers/staging/media/atomisp/pci/ia_css_pipe.h 
b/drivers/staging/media/atomisp/pci/ia_css_pipe.h
index 9c0c4ccf4571..bb0abf9bffb1 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_pipe.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_pipe.h
@@ -40,8 +40,7 @@ struct ia_css_preview_settings {
struct ia_css_pipe *acc_pipe;
 };
 
-#define IA_CSS_DEFAULT_PREVIEW_SETTINGS \
-(struct ia_css_preview_settings) { \
+#define IA_CSS_DEFAULT_PREVIEW_SETTINGS { \
.copy_binary= IA_CSS_BINARY_DEFAULT_SETTINGS, \
.preview_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
.vf_pp_binary   = IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -65,8 +64,7 @@ struct ia_css_capture_settings {
unsigned int num_yuv_scaler;
 };
 
-#define IA_CSS_DEFAULT_CAPTURE_SETTINGS \
-(struct ia_css_capture_settings) { \
+#define IA_CSS_DEFAULT_CAPTURE_SETTINGS { \
.copy_binary= IA_CSS_BINARY_DEFAULT_SETTINGS, \
.primary_binary = {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
.pre_isp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -91,8 +89,7 @@ struct ia_css_video_settings {
unsigned int num_yuv_scaler;
 };
 
-#define IA_CSS_DEFAULT_VIDEO_SETTINGS \
-(struct ia_css_video_settings) { \
+#define IA_CSS_DEFAULT_VIDEO_SETTINGS { \
.copy_binary= IA_CSS_BINARY_DEFAULT_SETTINGS, \
.video_binary   = IA_CSS_BINARY_DEFAULT_SETTINGS, \
.vf_pp_binary   = IA_CSS_BINARY_DEFAULT_SETTINGS, \
@@ -108,8 +105,7 @@ struct ia_css_yuvpp_settings {
unsigned int num_output;
 };
 
-#define IA_CSS_DEFAULT_YUVPP_SETTINGS \
-(struct ia_css_yuvpp_settings) { \
+#define IA_CSS_DEFAULT_YUVPP_SETTINGS { \
.copy_binary= IA_CSS_BINARY_DEFAULT_SETTINGS, \
 }
 
@@ -157,8 +153,7 @@ struct ia_css_pipe {
unsigned int pipe_num;
 };
 
-#define IA_CSS_DEFAULT_PIPE \
-(struct ia_css_pipe) { \
+#define IA_CSS_DEFAULT_PIPE { \
.config = DEFAULT_PIPE_CONFIG, \
.info   = DEFAULT_PIPE_INFO, \
.mode   = IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
diff --git a/drivers/staging/media/atomisp/pci/ia_css_pipe_public.h 
b/drivers/staging/media/atomisp/pci/ia_css_pipe_public.h
index 17b0941382bf..4affd21f9e3f 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_pipe_public.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_pipe_public.h
@@ -149,8 +149,7 @@ struct ia_css_pipe_config {
 /**
  * Default settings for newly created pipe configurations.
  */
-#define DEFAULT_PIPE_CONFIG \
-(struct ia_css_pipe_config) { \
+#define DEFAULT_PIPE_CONFIG { \
.mode   = IA_CSS_PIPE_MODE_PREVIEW, \
.isp_pipe_version   = 1, \
.output_info= 

[PATCH 1/2] media: atomisp: remove format duplication at mbus->fourcc table

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  8 ++--
 .../media/atomisp/pci/atomisp_subdev.c| 42 +--
 .../media/atomisp/pci/atomisp_subdev.h|  1 -
 3 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index efae44c3be43..cea3c1bcefa9 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -5026,7 +5026,7 @@ static inline int atomisp_set_sensor_mipi_to_isp(
 mipi_info->input_format);
if (!fc)
return -EINVAL;
-   input_format = fc->css_stream_fmt;
+   input_format = fc->atomisp_in_fmt;
} else {
struct v4l2_mbus_framefmt *sink;
 
@@ -5036,7 +5036,7 @@ static inline int atomisp_set_sensor_mipi_to_isp(
fc = atomisp_find_in_fmt_conv(sink->code);
if (!fc)
return -EINVAL;
-   input_format = fc->css_stream_fmt;
+   input_format = fc->atomisp_in_fmt;
bayer_order = fc->bayer_order;
}
 
@@ -5047,7 +5047,7 @@ static inline int atomisp_set_sensor_mipi_to_isp(
 mipi_info->metadata_format);
if (!fc)
return -EINVAL;
-   input_format = fc->css_stream_fmt;
+   input_format = fc->atomisp_in_fmt;
atomisp_css_input_configure_port(asd,
 __get_mipi_port(asd->isp, 
mipi_info->port),
 mipi_info->num_lanes,
@@ -5230,7 +5230,7 @@ static int atomisp_set_fmt_to_isp(struct video_device 
*vdev,
if (!fc)
return -EINVAL;
if (format->sh_fmt == IA_CSS_FRAME_FORMAT_RAW &&
-   raw_output_format_match_input(fc->css_stream_fmt,
+   raw_output_format_match_input(fc->atomisp_in_fmt,
  pix->pixelformat))
return -EINVAL;
}
diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c 
b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
index ba0eb60e87d9..7bc8083a2fb5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
@@ -31,31 +31,31 @@
 #include "atomisp_internal.h"
 
 const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[] = {
-   { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_BGGR, ATOMISP_INPUT_FORMAT_RAW_8 },
-   { MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_GBRG, ATOMISP_INPUT_FORMAT_RAW_8 },
-   { MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_GRBG, ATOMISP_INPUT_FORMAT_RAW_8 },
-   { MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_RGGB, ATOMISP_INPUT_FORMAT_RAW_8 },
-   { MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, 
IA_CSS_BAYER_ORDER_BGGR, ATOMISP_INPUT_FORMAT_RAW_10 },
-   { MEDIA_BUS_FMT_SGBRG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, 
IA_CSS_BAYER_ORDER_GBRG, ATOMISP_INPUT_FORMAT_RAW_10 },
-   { MEDIA_BUS_FMT_SGRBG10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, 
IA_CSS_BAYER_ORDER_GRBG, ATOMISP_INPUT_FORMAT_RAW_10 },
-   { MEDIA_BUS_FMT_SRGGB10_1X10, 10, 10, ATOMISP_INPUT_FORMAT_RAW_10, 
IA_CSS_BAYER_ORDER_RGGB, ATOMISP_INPUT_FORMAT_RAW_10 },
-   { MEDIA_BUS_FMT_SBGGR12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, 
IA_CSS_BAYER_ORDER_BGGR, ATOMISP_INPUT_FORMAT_RAW_12 },
-   { MEDIA_BUS_FMT_SGBRG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, 
IA_CSS_BAYER_ORDER_GBRG, ATOMISP_INPUT_FORMAT_RAW_12 },
-   { MEDIA_BUS_FMT_SGRBG12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, 
IA_CSS_BAYER_ORDER_GRBG, ATOMISP_INPUT_FORMAT_RAW_12 },
-   { MEDIA_BUS_FMT_SRGGB12_1X12, 12, 12, ATOMISP_INPUT_FORMAT_RAW_12, 
IA_CSS_BAYER_ORDER_RGGB, ATOMISP_INPUT_FORMAT_RAW_12 },
-   { MEDIA_BUS_FMT_UYVY8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0, 
ATOMISP_INPUT_FORMAT_YUV422_8 },
-   { MEDIA_BUS_FMT_YUYV8_1X16, 8, 8, ATOMISP_INPUT_FORMAT_YUV422_8, 0, 
ATOMISP_INPUT_FORMAT_YUV422_8 },
+   { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_BGGR },
+   { MEDIA_BUS_FMT_SGBRG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_GBRG },
+   { MEDIA_BUS_FMT_SGRBG8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_GRBG },
+   { MEDIA_BUS_FMT_SRGGB8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, 
IA_CSS_BAYER_ORDER_RGGB },
+   { MEDIA_BUS_FMT_SBGGR10_1X10, 10, 10, 

[PATCH 2/2] media: atomisp: re-enable warnings again

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/Makefile|  9 -
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  7 ++--
 .../media/atomisp/pci/atomisp_compat_css20.c  | 35 ++-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  |  4 +--
 .../staging/media/atomisp/pci/hmm/hmm_bo.c|  2 ++
 drivers/staging/media/atomisp/pci/sh_css.c|  1 +
 .../media/atomisp/pci/sh_css_firmware.c   |  1 +
 drivers/staging/media/atomisp/pci/sh_css_sp.c |  2 ++
 8 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index 1ed410d83f40..0b62020f9b8b 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -344,12 +344,3 @@ DEFINES += -DISP2400 -DSYSTEM_hive_isp_css_2400_system
 endif
 
 ccflags-y += $(INCLUDES) $(DEFINES) -fno-common
-
-# HACK! While this driver is in bad shape, don't enable several warnings
-#   that would be otherwise enabled with W=1
-ccflags-y += $(call cc-disable-warning, implicit-fallthrough)
-ccflags-y += $(call cc-disable-warning, missing-prototypes)
-ccflags-y += $(call cc-disable-warning, missing-declarations)
-ccflags-y += $(call cc-disable-warning, suggest-attribute=format)
-ccflags-y += $(call cc-disable-warning, unused-const-variable)
-ccflags-y += $(call cc-disable-warning, unused-but-set-variable)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index cea3c1bcefa9..d06173b62b99 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -4967,13 +4967,14 @@ enum mipi_port_id __get_mipi_port(struct atomisp_device 
*isp,
 {
switch (port) {
case ATOMISP_CAMERA_PORT_PRIMARY:
-   return MIPI_PORT0_ID;
+   return MIPI_PORT0_ID;
case ATOMISP_CAMERA_PORT_SECONDARY:
return MIPI_PORT1_ID;
case ATOMISP_CAMERA_PORT_TERTIARY:
-   if (MIPI_PORT1_ID + 1 != N_MIPI_PORT_ID)
+   if (MIPI_PORT1_ID + 1 != N_MIPI_PORT_ID) {
return MIPI_PORT1_ID + 1;
-   /* go through down for else case */
+   }
+   /* fall through */
default:
dev_err(isp->dev, "unsupported port: %d\n", port);
return MIPI_PORT0_ID;
diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 4a7331d15f41..b67503a77f29 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -690,22 +690,23 @@ static bool is_pipe_valid_to_current_run_mode(struct 
atomisp_sub_device *asd,
case ATOMISP_RUN_MODE_STILL_CAPTURE:
if (pipe_id == IA_CSS_PIPE_ID_CAPTURE)
return true;
-   else
-   return false;
+
+   return false;
case ATOMISP_RUN_MODE_PREVIEW:
if (!asd->continuous_mode->val) {
if (pipe_id == IA_CSS_PIPE_ID_PREVIEW)
return true;
-   else
-   return false;
+
+   return false;
}
-   /* fall through to ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE */
+   /* fall-through */
case ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE:
if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
pipe_id == IA_CSS_PIPE_ID_PREVIEW)
return true;
-   else
-   return false;
+
+   return false;
+   /* fall-through */
case ATOMISP_RUN_MODE_VIDEO:
if (!asd->continuous_mode->val) {
if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
@@ -714,13 +715,13 @@ static bool is_pipe_valid_to_current_run_mode(struct 
atomisp_sub_device *asd,
else
return false;
}
-   /* fall through to ATOMISP_RUN_MODE_SDV */
+   /* fall through  */
case ATOMISP_RUN_MODE_SDV:
if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
pipe_id == IA_CSS_PIPE_ID_VIDEO)
return true;
-   else
-   return false;
+
+   return false;
}
 
return false;
@@ -2749,16 +2750,18 @@ static unsigned int atomisp_get_pipe_index(struct 
atomisp_sub_device *asd,
if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO
|| asd->vfpp->val == ATOMISP_VFPP_DISABLE_SCALER)
return IA_CSS_PIPE_ID_VIDEO;
-   

Re: [PATCH 1/9] staging: media: atomisp: fix incorrect NULL pointer check

2020-05-30 Thread Mauro Carvalho Chehab
Em Fri, 29 May 2020 22:31:44 +0200
Arnd Bergmann  escreveu:

> On Fri, May 29, 2020 at 10:23 PM Arnd Bergmann  wrote:
> >
> > On Fri, May 29, 2020 at 10:04 PM 'Nick Desaulniers' via Clang Built
> > Linux  wrote:  
> > >
> > > See also Nathan's 7 patch series.
> > > https://lore.kernel.org/lkml/20200527071150.3381228-1-natechancel...@gmail.com/
> > >
> > > Might be some overlap between series?
> > >  
> >
> > Probably. I really should have checked when I saw the number of warnings.
> >
> > At least this gives Mauro a chance to double-check the changes and see if
> > Nathan and I came to different conclusions on any of them.  
> 
> I checked now and found that the overlap is smaller than I expected.
> In each case, Nathans' solution seems more complete than mine,
> so this patch ("staging: media: atomisp: fix incorrect NULL pointer check")
> and also "staging: media: atomisp: fix a type conversion warning" can be
> dropped, but I think the others are still needed.

Hi Arnd,

I applied most of the patches from you. I had to add two extra patches
before this one:

[PATCH 5/9] staging: media: atomisp: fix stack overflow in 
init_pipe_defaults()

And rebase it, because otherwise gcc would fail to compile here.

I'm placing the patches I have so far ready for atomisp on this
tree:

https://git.linuxtv.org/mchehab/media-next.git/log/

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


[PATCH v2 19/41] media: atomisp: remove kvmalloc/kvcalloc abstractions

2020-05-30 Thread Mauro Carvalho Chehab
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:


@@
expression size;
@@

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

@@
expression n;
expression size;
@@

- sh_css_calloc(n, size)
+ kvcalloc(n, size, GFP_KERNEL)


Signed-off-by: Mauro Carvalho Chehab 
---
 .../atomisp/pci/base/refcount/src/refcount.c  |   4 +-
 .../kernels/sdis/sdis_1.0/ia_css_sdis.host.c  |  14 +-
 .../kernels/sdis/sdis_2/ia_css_sdis2.host.c   |   4 +-
 .../atomisp/pci/runtime/binary/src/binary.c   |   6 +-
 .../atomisp/pci/runtime/frame/src/frame.c |  12 +-
 .../pci/runtime/isp_param/src/isp_param.c |   6 +-
 .../pci/runtime/pipeline/src/pipeline.c   |   4 +-
 .../atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c  |   4 +-
 drivers/staging/media/atomisp/pci/sh_css.c|  35 +--
 .../media/atomisp/pci/sh_css_host_data.c  |   4 +-
 .../media/atomisp/pci/sh_css_internal.h   |   6 -
 .../media/atomisp/pci/sh_css_metrics.c|   9 +-
 .../media/atomisp/pci/sh_css_param_dvs.c  |  30 +-
 .../media/atomisp/pci/sh_css_param_shading.c  |   7 +-
 .../staging/media/atomisp/pci/sh_css_params.c | 262 ++
 15 files changed, 202 insertions(+), 205 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c 
b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
index 1616f3a38ddd..997f275ea9ec 100644
--- a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
+++ b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
@@ -81,7 +81,7 @@ enum ia_css_err ia_css_refcount_init(uint32_t size)
return IA_CSS_ERR_INTERNAL_ERROR;
}
myrefcount.items =
-   sh_css_malloc(sizeof(struct ia_css_refcount_entry) * size);
+   kvmalloc(sizeof(struct ia_css_refcount_entry) * size, GFP_KERNEL);
if (!myrefcount.items)
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
if (err == IA_CSS_SUCCESS) {
@@ -115,7 +115,7 @@ void ia_css_refcount_uninit(void)
entry->id = 0;
}
}
-   sh_css_free(myrefcount.items);
+   kvfree(myrefcount.items);
myrefcount.items = NULL;
myrefcount.size = 0;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c
 
b/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c
index dfd621d3f6da..2fe081ee005a 100644
--- 
a/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c
+++ 
b/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_1.0/ia_css_sdis.host.c
@@ -318,7 +318,7 @@ ia_css_isp_dvs_statistics_allocate(
if (!grid->enable)
return NULL;
 
-   me = sh_css_calloc(1, sizeof(*me));
+   me = kvcalloc(1, sizeof(*me), GFP_KERNEL);
if (!me)
goto err;
 
@@ -359,7 +359,7 @@ ia_css_isp_dvs_statistics_map_allocate(
 * so we use a local char * instead. */
char *base_ptr;
 
-   me = sh_css_malloc(sizeof(*me));
+   me = kvmalloc(sizeof(*me), GFP_KERNEL);
if (!me) {
IA_CSS_LOG("cannot allocate memory");
goto err;
@@ -369,7 +369,7 @@ ia_css_isp_dvs_statistics_map_allocate(
me->data_allocated = !data_ptr;
 
if (!me->data_ptr) {
-   me->data_ptr = sh_css_malloc(isp_stats->size);
+   me->data_ptr = kvmalloc(isp_stats->size, GFP_KERNEL);
if (!me->data_ptr) {
IA_CSS_LOG("cannot allocate memory");
goto err;
@@ -386,7 +386,7 @@ ia_css_isp_dvs_statistics_map_allocate(
return me;
 err:
if (me)
-   sh_css_free(me);
+   kvfree(me);
return NULL;
 }
 
@@ -395,8 +395,8 @@ ia_css_isp_dvs_statistics_map_free(struct 
ia_css_isp_dvs_statistics_map *me)
 {
if (me) {
if (me->data_allocated)
-   sh_css_free(me->data_ptr);
-   sh_css_free(me);
+   kvfree(me->data_ptr);
+   kvfree(me);
}
 }
 
@@ -405,7 +405,7 @@ ia_css_isp_dvs_statistics_free(struct 
ia_css_isp_dvs_statistics *me)
 {
if (me) {
hmm_free(me->data_ptr);
-   sh_css_free(me);
+   kvfree(me);
}
 }
 
diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.c 
b/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.c
index ca34299b7998..2d2708bde17e 100644
--- 
a/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.c
+++ 
b/drivers/staging/media/atomisp/pci/isp/kernels/sdis/sdis_2/ia_css_sdis2.host.c
@@ -285,7 +285,7 @@ ia_css_isp_dvs2_statistics_allocate(
if (!grid->enable)
return NULL;
 
-   me = sh_css_calloc(1, sizeof(*me));
+   me = 

[PATCH v2 35/41] media: atomisp: provide more details about the firmware binaries

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../media/atomisp/pci/atomisp_compat_css20.c  | 39 +--
 .../media/atomisp/pci/ia_css_acc_types.h  |  4 +-
 .../media/atomisp/pci/sh_css_firmware.c   |  2 +
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 76e5eda0a8a8..4d2441f07630 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -4306,6 +4306,20 @@ int atomisp_css_dump_sp_raw_copy_linecount(bool reduced)
return 0;
 }
 
+static const char *fw_type_name[] = {
+   [ia_css_sp_firmware]= "SP",
+   [ia_css_isp_firmware]   = "ISP",
+   [ia_css_bootloader_firmware]= "BootLoader",
+   [ia_css_acc_firmware]   = "accel",
+};
+
+static const char *fw_acc_type_name[] = {
+   [IA_CSS_ACC_NONE] = "Normal",
+   [IA_CSS_ACC_OUTPUT] =   "Accel stage on output",
+   [IA_CSS_ACC_VIEWFINDER] =   "Accel stage on viewfinder",
+   [IA_CSS_ACC_STANDALONE] =   "Stand-alone acceleration",
+};
+
 int atomisp_css_dump_blob_infor(void)
 {
struct ia_css_blob_descr *bd = sh_css_blob_info;
@@ -4316,9 +4330,28 @@ int atomisp_css_dump_blob_infor(void)
if (!bd)
return -EPERM;
 
-   for (i = 1; i < sh_css_num_binaries; i++)
-   dev_dbg(atomisp_dev, "Num%d binary id is %d, name is %s\n", i,
-   bd[i - 1].header.info.isp.sp.id, bd[i - 1].name);
+   /*
+* The sh_css_load_firmware function discard the initial
+* "SPS" binaries
+*/
+   for (i = 0; i < sh_css_num_binaries - NUM_OF_SPS; i++) {
+   switch (bd[i].header.type) {
+   case ia_css_isp_firmware:
+   dev_dbg(atomisp_dev,
+   "Num%2d type %s (%s), binary id is %2d, name is 
%s\n",
+   i + NUM_OF_SPS,
+   fw_type_name[bd[i].header.type],
+   fw_acc_type_name[bd[i].header.info.isp.type],
+   bd[i].header.info.isp.sp.id,
+   bd[i].name);
+   break;
+   default:
+   dev_dbg(atomisp_dev,
+   "Num%2d type %s, name is %s\n",
+   i + NUM_OF_SPS, fw_type_name[bd[i].header.type],
+   bd[i].name);
+   }
+   }
 
return 0;
 }
diff --git a/drivers/staging/media/atomisp/pci/ia_css_acc_types.h 
b/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
index 55b4dc9bb5ea..557fe8a3c18f 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
+++ b/drivers/staging/media/atomisp/pci/ia_css_acc_types.h
@@ -62,8 +62,8 @@ enum ia_css_cell_type {
  */
 enum ia_css_fw_type {
ia_css_sp_firmware, /** Firmware for the SP */
-   ia_css_isp_firmware,/** Firmware for the ISP */
-   ia_css_bootloader_firmware, /** Firmware for the BootLoader */
+   ia_css_isp_firmware,/** Firmware for the ISP */
+   ia_css_bootloader_firmware, /** Firmware for the BootLoader */
ia_css_acc_firmware /** Firmware for accelrations */
 };
 
diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 5009f47abf01..63415356c36d 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -282,6 +282,8 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
err = setup_binary(bi, fw_data, _css_sp_fw, i);
if (err)
return err;
+   dev_dbg(dev, "firmware #%d (SP), name %s\n", i, 
bd.name);
+
} else {
/* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
if (i < NUM_OF_SPS)
-- 
2.26.2

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


[PATCH v2 37/41] media: atomisp: allow passing firmware name at modprobe time

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 30 ---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 891c990ab857..dea420a77f0a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -95,6 +95,10 @@ int mipicsi_flag;
 module_param(mipicsi_flag, int, 0644);
 MODULE_PARM_DESC(mipicsi_flag, "mipi csi compression predictor algorithm");
 
+static char firmware_name[256];
+module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
+MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the 
default firmware name.");
+
 /*set to 16x16 since this is the amount of lines and pixels the sensor
 exports extra. If these are kept at the 10x8 that they were on, in yuv
 downscaling modes incorrect resolutions where requested to the sensor
@@ -1455,19 +1459,23 @@ atomisp_load_firmware(struct atomisp_device *isp)
if (skip_fwload)
return NULL;
 
-   if ((isp->media_dev.hw_revision  >> ATOMISP_HW_REVISION_SHIFT)
-== ATOMISP_HW_REVISION_ISP2401)
-   fw_path = "shisp_2401a0_v21.bin";
+   if (firmware_name[0] != '\0') {
+   fw_path = firmware_name;
+   } else {
+   if ((isp->media_dev.hw_revision  >> ATOMISP_HW_REVISION_SHIFT)
+   == ATOMISP_HW_REVISION_ISP2401)
+   fw_path = "shisp_2401a0_v21.bin";
 
-   if (isp->media_dev.hw_revision ==
-   ((ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT)
-| ATOMISP_HW_STEPPING_A0))
-   fw_path = "shisp_2401a0_legacy_v21.bin";
+   if (isp->media_dev.hw_revision ==
+   ((ATOMISP_HW_REVISION_ISP2401_LEGACY << 
ATOMISP_HW_REVISION_SHIFT)
+   | ATOMISP_HW_STEPPING_A0))
+   fw_path = "shisp_2401a0_legacy_v21.bin";
 
-   if (isp->media_dev.hw_revision ==
-   ((ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT)
-| ATOMISP_HW_STEPPING_B0))
-   fw_path = "shisp_2400b0_v21.bin";
+   if (isp->media_dev.hw_revision ==
+   ((ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT)
+   | ATOMISP_HW_STEPPING_B0))
+   fw_path = "shisp_2400b0_v21.bin";
+   }
 
if (!fw_path) {
dev_err(isp->dev, "Unsupported hw_revision 0x%x\n",
-- 
2.26.2

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


[PATCH v2 31/41] media: atomisp: get rid of an error abstraction layer

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  2 +-
 .../pci/camera/util/interface/ia_css_util.h   |  3 +-
 .../media/atomisp/pci/camera/util/src/util.c  | 29 
 .../pci/hive_isp_css_include/error_support.h  | 39 ---
 .../pci/hive_isp_css_include/string_support.h | 16 +++
 .../media/atomisp/pci/runtime/bufq/src/bufq.c | 47 ---
 .../runtime/eventq/interface/ia_css_eventq.h  |  8 ++--
 .../atomisp/pci/runtime/eventq/src/eventq.c   |  4 +-
 .../runtime/queue/interface/ia_css_queue.h| 30 ++--
 .../atomisp/pci/runtime/queue/src/queue.c | 44 -
 .../pci/runtime/queue/src/queue_access.c  | 16 +++
 .../pci/runtime/queue/src/queue_access.h  |  3 +-
 12 files changed, 83 insertions(+), 158 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/error_support.h

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 077017671513..75cbc46f4a07 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -16,6 +16,7 @@
  *
  *
  */
+#include 
 #include 
 #include 
 #include 
@@ -58,7 +59,6 @@
 #include "ia_css_types.h"
 #include "ia_css_stream.h"
 #include "ia_css_debug.h"
-#include "error_support.h"
 #include "bits.h"
 
 /* We should never need to run the flash for more than 2 frames.
diff --git 
a/drivers/staging/media/atomisp/pci/camera/util/interface/ia_css_util.h 
b/drivers/staging/media/atomisp/pci/camera/util/interface/ia_css_util.h
index 80ad3e064654..ca5617b3b870 100644
--- a/drivers/staging/media/atomisp/pci/camera/util/interface/ia_css_util.h
+++ b/drivers/staging/media/atomisp/pci/camera/util/interface/ia_css_util.h
@@ -15,8 +15,9 @@
 #ifndef __IA_CSS_UTIL_H__
 #define __IA_CSS_UTIL_H__
 
+#include 
+
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/drivers/staging/media/atomisp/pci/camera/util/src/util.c 
b/drivers/staging/media/atomisp/pci/camera/util/src/util.c
index 3ca79b23da70..4b2c4d7bc5b4 100644
--- a/drivers/staging/media/atomisp/pci/camera/util/src/util.c
+++ b/drivers/staging/media/atomisp/pci/camera/util/src/util.c
@@ -20,35 +20,6 @@
 /* for ia_css_binary_max_vf_width() */
 #include "ia_css_binary.h"
 
-int ia_css_convert_errno(
-int in_err)
-{
-   int out_err;
-
-   switch (in_err) {
-   case 0:
-   out_err = 0;
-   break;
-   case EINVAL:
-   out_err = -EINVAL;
-   break;
-   case ENODATA:
-   out_err = -ENODATA;
-   break;
-   case ENOSYS:
-   case ENOTSUP:
-   out_err = -EINVAL;
-   break;
-   case ENOBUFS:
-   out_err = -ENOBUFS;
-   break;
-   default:
-   out_err = -EINVAL;
-   break;
-   }
-   return out_err;
-}
-
 /* MW: Table look-up ??? */
 unsigned int ia_css_util_input_format_bpp(
 enum atomisp_input_format format,
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/error_support.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/error_support.h
deleted file mode 100644
index 4f0d259bf7ed..
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/error_support.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Support for Intel Camera Imaging ISP subsystem.
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- */
-
-#ifndef __ERROR_SUPPORT_H_INCLUDED__
-#define __ERROR_SUPPORT_H_INCLUDED__
-
-#include 
-/*
- * Put here everything __KERNEL__ specific not covered in
- * "errno.h"
- */
-#define ENOTSUP 252
-
-#define verifexit(cond, error_tag)  \
-do {   \
-   if (!(cond)) {  \
-   goto EXIT; \
-   }  \
-} while (0)
-
-#define verifjmpexit(cond) \
-do {   \
-   if (!(cond)) {  \
-   goto EXIT; \
-   }  \
-} while (0)
-
-#endif /* __ERROR_SUPPORT_H_INCLUDED__ */
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/string_support.h
index f653ec797601..7b3af1b10b6d 100644
--- 

[PATCH v2 24/41] media: atomisp: Remove unnecessary NULL check in atomisp_param

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 (!>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 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 4913469df2bb..5f34e7586ee4 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -4270,7 +4270,6 @@ int atomisp_set_parameters(struct video_device *vdev,
 int atomisp_param(struct atomisp_sub_device *asd, int flag,
  struct atomisp_parm *config)
 {
-   struct atomisp_device *isp = asd->isp;
struct ia_css_pipe_config *vp_cfg =
>stream_env[ATOMISP_INPUT_STREAM_GENERAL].
pipe_configs[IA_CSS_PIPE_ID_VIDEO];
@@ -4281,10 +4280,6 @@ int atomisp_param(struct atomisp_sub_device *asd, int 
flag,
atomisp_css_get_dvs_grid_info(
>params.curr_grid_info);
 
-   if (!>info) {
-   dev_err(isp->dev, "ERROR: NULL pointer in grid_info\n");
-   return -EINVAL;
-   }
atomisp_curr_user_grid_info(asd, >info);
 
/* We always return the resolution and stride even if there is
-- 
2.26.2

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


[PATCH v2 34/41] media: atomisp: get rid of system_types.h

2020-05-30 Thread Mauro Carvalho Chehab
This is just a wrapper for system_local.h.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../base/refcount/interface/ia_css_refcount.h |  2 +-
 .../input_formatter_global.h  |  2 +-
 .../pci/hive_isp_css_common/irq_global.h  |  2 +-
 .../pci/hive_isp_css_common/isp_global.h  |  2 +-
 .../pci/hive_isp_css_common/sp_global.h   |  2 +-
 .../device_access/device_access.h |  2 +-
 .../hive_isp_css_include/host/debug_public.h  |  2 +-
 .../hive_isp_css_include/host/dma_public.h|  2 +-
 .../host/event_fifo_public.h  |  2 +-
 .../host/fifo_monitor_public.h|  2 +-
 .../host/gp_device_public.h   |  2 +-
 .../host/gp_timer_public.h|  2 +-
 .../hive_isp_css_include/host/gpio_public.h   |  2 +-
 .../host/input_formatter_public.h |  2 +-
 .../hive_isp_css_include/host/irq_public.h|  2 +-
 .../hive_isp_css_include/host/isp_public.h|  2 +-
 .../host/isys_dma_public.h|  2 +-
 .../hive_isp_css_include/host/mmu_public.h|  2 +-
 .../pci/hive_isp_css_include/host/sp_public.h |  2 +-
 .../host/timed_ctrl_public.h  |  2 +-
 .../pci/hive_isp_css_include/system_types.h   | 24 ---
 .../media/atomisp/pci/ia_css_acc_types.h  |  2 +-
 .../media/atomisp/pci/ia_css_device_access.c  |  2 +-
 .../media/atomisp/pci/ia_css_device_access.h  |  2 +-
 .../frame/interface/ia_css_frame_comm.h   |  2 +-
 .../runtime/rmgr/interface/ia_css_rmgr_vbuf.h |  2 +-
 .../media/atomisp/pci/sh_css_firmware.h   |  2 +-
 .../staging/media/atomisp/pci/sh_css_struct.h |  2 +-
 28 files changed, 27 insertions(+), 51 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/system_types.h

diff --git 
a/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h 
b/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
index 9d2b7f3b6c01..72ec09dde256 100644
--- 
a/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
+++ 
b/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
@@ -16,7 +16,7 @@
 #define _IA_CSS_REFCOUNT_H_
 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_common/input_formatter_global.h
 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/input_formatter_global.h
index 163521c53d4b..c0658972f9cb 100644
--- 
a/drivers/staging/media/atomisp/pci/hive_isp_css_common/input_formatter_global.h
+++ 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/input_formatter_global.h
@@ -19,7 +19,7 @@
 #define IS_INPUT_SWITCH_VERSION2
 
 #include 
-#include 
+#include 
 #include "if_defs.h"
 #include "str2mem_defs.h"
 #include "input_switch_2400_defs.h"
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h
index 64554d80dc0b..883754def2d8 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h
@@ -15,7 +15,7 @@
 #ifndef __IRQ_GLOBAL_H_INCLUDED__
 #define __IRQ_GLOBAL_H_INCLUDED__
 
-#include 
+#include 
 
 #define IS_IRQ_VERSION_2
 #define IS_IRQ_MAP_VERSION_2
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
index 1a8547d58435..ad25597c4f03 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/isp_global.h
@@ -15,7 +15,7 @@
 #ifndef __ISP_GLOBAL_H_INCLUDED__
 #define __ISP_GLOBAL_H_INCLUDED__
 
-#include 
+#include 
 
 #if defined(HAS_ISP_2401_MAMOIADA)
 #define IS_ISP_2401_MAMOIADA
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
index 6ec4e590e3b4..252fe8c624eb 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/sp_global.h
@@ -15,7 +15,7 @@
 #ifndef __SP_GLOBAL_H_INCLUDED__
 #define __SP_GLOBAL_H_INCLUDED__
 
-#include 
+#include 
 
 #if defined(HAS_SP_2401)
 #define IS_SP_2401
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/device_access/device_access.h
 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/device_access/device_access.h
index be031d41de7c..7168c3945772 100644
--- 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/device_access/device_access.h
+++ 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/device_access/device_access.h
@@ -39,7 +39,7 @@ more details.
  * User provided file that defines the system address types:
  * - hrt_address   a type that can hold the (sub)system address range
  */
-#include "system_types.h"
+#include "system_local.h"
 /*
  * We 

[PATCH v2 02/41] media: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction layer

2020-05-30 Thread Mauro Carvalho Chehab
Simplify the code by removing this extra memory management
abstraction layer.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/Makefile|  1 -
 .../staging/media/atomisp/pci/atomisp_acc.c   | 24 ---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  2 +-
 .../media/atomisp/pci/atomisp_compat.h|  2 +-
 .../media/atomisp/pci/atomisp_compat_css20.c  |  6 +-
 .../staging/media/atomisp/pci/atomisp_fops.c  |  2 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  7 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  |  2 -
 .../memory_access/memory_access.h |  2 +-
 .../atomisp/pci/hrt/hive_isp_css_mm_hrt.c | 71 ---
 .../atomisp/pci/hrt/hive_isp_css_mm_hrt.h | 45 
 .../media/atomisp/pci/ia_css_frame_public.h   |  2 +-
 .../media/atomisp/pci/ia_css_memory_access.c  | 43 ++-
 .../atomisp/pci/runtime/frame/src/frame.c |  4 +-
 14 files changed, 50 insertions(+), 163 deletions(-)
 delete mode 100644 drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c
 delete mode 100644 drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index b48eb7946a58..889227dcebfe 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -53,7 +53,6 @@ atomisp-objs += \
pci/hmm/hmm_dynamic_pool.o \
pci/hmm/hmm.o \
pci/hmm/hmm_reserved_pool.o \
-   pci/hrt/hive_isp_css_mm_hrt.o \
pci/ia_css_device_access.o \
pci/ia_css_memory_access.o \
pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index bb1f60fab786..5e7f4cd47c8f 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -28,7 +28,6 @@
 #include "atomisp_compat.h"
 #include "atomisp_cmd.h"
 
-#include "hrt/hive_isp_css_mm_hrt.h"
 #include "memory_access/memory_access.h"
 #include "ia_css.h"
 
@@ -353,16 +352,23 @@ int atomisp_acc_map(struct atomisp_sub_device *asd, 
struct atomisp_acc_map *map)
}
 
pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE);
-   cssptr = hrt_isp_css_mm_alloc_user_ptr(map->length,
-  map->user_ptr,
-  pgnr,
-  (map->flags & 
ATOMISP_MAP_FLAG_CACHED));
+   if (pgnr < ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
+   dev_err(atomisp_dev,
+   "user space memory size is less than the 
expected size..\n");
+   return -ENOMEM;
+   } else if (pgnr > ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
+   dev_err(atomisp_dev,
+   "user space memory size is large than the 
expected size..\n");
+   return -ENOMEM;
+   }
+
+   cssptr = hmm_alloc(map->length, HMM_BO_USER, 0, map->user_ptr,
+  map->flags & ATOMISP_MAP_FLAG_CACHED);
+
} else {
/* Allocate private buffer. */
-   if (map->flags & ATOMISP_MAP_FLAG_CACHED)
-   cssptr = hrt_isp_css_mm_calloc_cached(map->length);
-   else
-   cssptr = hrt_isp_css_mm_calloc(map->length);
+   cssptr = hmm_alloc(map->length, HMM_BO_PRIVATE, 0, NULL,
+  map->flags & ATOMISP_MAP_FLAG_CACHED);
}
 
if (!cssptr)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 900f1ccc25fe..4913469df2bb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -44,7 +44,7 @@
 #include "atomisp_subdev.h"
 #include "atomisp_dfs_tables.h"
 
-#include "hrt/hive_isp_css_mm_hrt.h"
+#include 
 
 #include "sh_css_hrt.h"
 #include "sh_css_defs.h"
diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat.h 
b/drivers/staging/media/atomisp/pci/atomisp_compat.h
index 8847e104bb65..8693f228a875 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat.h
@@ -261,7 +261,7 @@ void atomisp_css_frame_free(struct ia_css_frame *frame);
 int atomisp_css_frame_map(struct ia_css_frame **frame,
  const struct ia_css_frame_info *info,
  const void __user *data, uint16_t attribute,
- void *context);
+ unsigned int pgnr);
 
 int atomisp_css_set_black_frame(struct atomisp_sub_device *asd,
const struct ia_css_frame *raw_black_frame);
diff --git 

[PATCH v2 40/41] media: atomisp: get rid of set_fs() dirty hacks

2020-05-30 Thread Mauro Carvalho Chehab
This file was based on an older version of the V4L2 compat32
code, which had this ugly hack.

Change the code to remove the hack. Yet, the entire compat32
code is currently commented out. So, let's add a FIXME note
at the code, as we may need to check if some of the atomisp
specific ioctls would require it.

It is not worth to do such checks now, as we may get rid
of several of them while cleaning up other things while
at staging.

Reported-by: Christoph Hellwig 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/TODO|  3 +
 .../atomisp/pci/atomisp_compat_ioctl32.c  | 89 ++-
 2 files changed, 52 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/media/atomisp/TODO 
b/drivers/staging/media/atomisp/TODO
index e58643a9de43..9e46015ebcd5 100644
--- a/drivers/staging/media/atomisp/TODO
+++ b/drivers/staging/media/atomisp/TODO
@@ -161,6 +161,9 @@ TODO
 for this driver until the other work is done, as there will be a lot
 of code churn until this driver becomes functional again.
 
+16. Fix the compat32 code and remove the comment preventing it to be
+called.
+
 Limitations
 ===
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_ioctl32.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_ioctl32.c
index 3079043f1fac..e2e3a242b95d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_ioctl32.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_ioctl32.c
@@ -847,9 +847,17 @@ static long atomisp_do_compat_ioctl(struct file *file,
struct atomisp_metadata_with_type md_with_type;
struct atomisp_sensor_ae_bracketing_lut lut;
} karg;
-   mm_segment_t old_fs;
-   void __user *up = compat_ptr(arg);
+   void __user *p32 = compat_ptr(arg);
+   void __user *new_p64 = NULL;
long err = -ENOIOCTLCMD;
+   int compatible_arg = 1;
+
+   /*
+* FIXME: should verify if any of the functions below will be
+* setting a pointer. If so, compatible_arg should be zeroed.
+*
+* Please see v4l2-compat-ioctl32.c for more details
+*/
 
/* First, convert the command. */
switch (cmd) {
@@ -936,130 +944,131 @@ static long atomisp_do_compat_ioctl(struct file *file,
switch (cmd) {
case ATOMISP_IOC_G_HISTOGRAM:
case ATOMISP_IOC_S_HISTOGRAM:
-   err = get_atomisp_histogram32(, up);
+   err = get_atomisp_histogram32(, p32);
break;
case ATOMISP_IOC_G_DIS_STAT:
-   err = get_atomisp_dis_statistics32(_s, up);
+   err = get_atomisp_dis_statistics32(_s, p32);
break;
case ATOMISP_IOC_S_DIS_COEFS:
-   err = get_atomisp_dis_coefficients32(_c, up);
+   err = get_atomisp_dis_coefficients32(_c, p32);
break;
case ATOMISP_IOC_S_DIS_VECTOR:
-   err = get_atomisp_dvs_6axis_config32(_c, up);
+   err = get_atomisp_dvs_6axis_config32(_c, p32);
break;
case ATOMISP_IOC_G_3A_STAT:
-   err = get_atomisp_3a_statistics32(_s, up);
+   err = get_atomisp_3a_statistics32(_s, p32);
break;
case ATOMISP_IOC_G_ISP_GDC_TAB:
case ATOMISP_IOC_S_ISP_GDC_TAB:
-   err = get_atomisp_morph_table32(_t, up);
+   err = get_atomisp_morph_table32(_t, p32);
break;
case ATOMISP_IOC_S_ISP_FPN_TABLE:
-   err = get_v4l2_framebuffer32(_buf, up);
+   err = get_v4l2_framebuffer32(_buf, p32);
break;
case ATOMISP_IOC_G_ISP_OVERLAY:
case ATOMISP_IOC_S_ISP_OVERLAY:
-   err = get_atomisp_overlay32(, up);
+   err = get_atomisp_overlay32(, p32);
break;
case ATOMISP_IOC_G_SENSOR_CALIBRATION_GROUP:
-   err = get_atomisp_calibration_group32(_grp, up);
+   err = get_atomisp_calibration_group32(_grp, p32);
break;
case ATOMISP_IOC_ACC_LOAD:
-   err = get_atomisp_acc_fw_load32(_fw_load, up);
+   err = get_atomisp_acc_fw_load32(_fw_load, p32);
break;
case ATOMISP_IOC_ACC_S_ARG:
case ATOMISP_IOC_ACC_DESTAB:
-   err = get_atomisp_acc_fw_arg32(_fw_arg, up);
+   err = get_atomisp_acc_fw_arg32(_fw_arg, p32);
break;
case ATOMISP_IOC_G_SENSOR_PRIV_INT_DATA:
case ATOMISP_IOC_G_MOTOR_PRIV_INT_DATA:
-   err = get_v4l2_private_int_data32(_pri_data, up);
+   err = get_v4l2_private_int_data32(_pri_data, p32);
break;
case ATOMISP_IOC_S_ISP_SHD_TAB:
-   err = get_atomisp_shading_table32(_tbl, up);
+   err = get_atomisp_shading_table32(_tbl, p32);
break;
case ATOMISP_IOC_ACC_MAP:
case ATOMISP_IOC_ACC_UNMAP:
-   err 

[PATCH v2 08/41] media: atomisp: get rid of memory_access.c

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/Makefile|  1 -
 .../staging/media/atomisp/include/hmm/hmm.h   |  3 +
 .../staging/media/atomisp/pci/atomisp_acc.c   |  3 +-
 .../staging/media/atomisp/pci/atomisp_fops.c  |  1 -
 .../atomisp/pci/base/refcount/src/refcount.c  |  3 +-
 .../pci/hive_isp_css_common/host/debug.c  |  3 +-
 .../hive_isp_css_common/host/debug_private.h  |  1 -
 .../memory_access/memory_access.h | 94 ---
 .../media/atomisp/pci/ia_css_memory_access.c  | 20 
 .../pci/isp/kernels/bh/bh_2/ia_css_bh.host.c  |  1 -
 .../isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.c |  3 +-
 .../raw_aa_binning_1.0/ia_css_raa.host.c  |  1 -
 .../kernels/sdis/sdis_1.0/ia_css_sdis.host.c  |  5 +-
 .../kernels/sdis/sdis_2/ia_css_sdis2.host.c   |  5 +-
 .../media/atomisp/pci/mmu/sh_mmu_mrfld.c  |  1 -
 .../atomisp/pci/runtime/binary/src/binary.c   |  4 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  3 +-
 .../atomisp/pci/runtime/event/src/event.c |  1 -
 .../atomisp/pci/runtime/frame/src/frame.c | 21 +++--
 .../pci/runtime/isp_param/src/isp_param.c |  5 +-
 .../pci/runtime/pipeline/src/pipeline.c   |  3 +-
 .../pci/runtime/queue/src/queue_access.c  |  3 +-
 .../atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c  |  4 +-
 .../atomisp/pci/runtime/spctrl/src/spctrl.c   |  5 +-
 drivers/staging/media/atomisp/pci/sh_css.c|  3 +-
 .../media/atomisp/pci/sh_css_firmware.c   |  5 +-
 .../staging/media/atomisp/pci/sh_css_mmu.c|  1 -
 .../media/atomisp/pci/sh_css_param_dvs.c  |  1 -
 .../staging/media/atomisp/pci/sh_css_params.c | 46 +
 drivers/staging/media/atomisp/pci/sh_css_sp.c |  3 +-
 30 files changed, 79 insertions(+), 174 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
 delete mode 100644 drivers/staging/media/atomisp/pci/ia_css_memory_access.c

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index 4a77d6d6910d..01764c487b52 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -54,7 +54,6 @@ atomisp-objs += \
pci/hmm/hmm.o \
pci/hmm/hmm_reserved_pool.o \
pci/ia_css_device_access.o \
-   pci/ia_css_memory_access.o \
pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
pci/isp/kernels/anr/anr_1.0/ia_css_anr.host.o \
pci/isp/kernels/anr/anr_2/ia_css_anr2.host.o \
diff --git a/drivers/staging/media/atomisp/include/hmm/hmm.h 
b/drivers/staging/media/atomisp/include/hmm/hmm.h
index a661c039a2cc..5d725a6b6e10 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm.h
@@ -28,6 +28,9 @@
 #include "hmm/hmm_pool.h"
 #include "ia_css_types.h"
 
+#define mmgr_NULL  ((ia_css_ptr)0)
+#define mmgr_EXCEPTION ((ia_css_ptr)-1)
+
 int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type);
 void hmm_pool_unregister(enum hmm_pool_type pool_type);
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index 5e7f4cd47c8f..8633afdc3f39 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -23,12 +23,13 @@
 #include 
 #include 
 
+#include "hmm.h"
+
 #include "atomisp_acc.h"
 #include "atomisp_internal.h"
 #include "atomisp_compat.h"
 #include "atomisp_cmd.h"
 
-#include "memory_access/memory_access.h"
 #include "ia_css.h"
 
 static const struct {
diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c 
b/drivers/staging/media/atomisp/pci/atomisp_fops.c
index fc3043bded46..1588e84a6b91 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_fops.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c
@@ -36,7 +36,6 @@
 
 #include "type_support.h"
 #include "device_access/device_access.h"
-#include "memory_access/memory_access.h"
 
 #include "atomisp_acc.h"
 
diff --git a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c 
b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
index 52c40aaa1e52..1616f3a38ddd 100644
--- a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
+++ b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
@@ -12,8 +12,9 @@
  * more details.
  */
 
+#include "hmm.h"
+
 #include "ia_css_refcount.h"
-#include "memory_access/memory_access.h"
 #include "sh_css_defs.h"
 
 #include "platform_support.h"
diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c
index 3a5414b8912a..85b054c5ec80 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c

[PATCH v2 33/41] media: atomisp: get rid of a bunch of other wrappers

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 156 +-
 .../media/atomisp/pci/atomisp_compat.h|  79 -
 .../media/atomisp/pci/atomisp_compat_css20.c  | 281 --
 .../media/atomisp/pci/atomisp_compat_css20.h  |  12 -
 .../staging/media/atomisp/pci/atomisp_file.c  |   7 +-
 .../staging/media/atomisp/pci/atomisp_fops.c  |   3 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  15 +-
 7 files changed, 93 insertions(+), 460 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 75cbc46f4a07..f3548e741cc5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -1170,8 +1170,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int 
error,
atomisp_apply_css_parameters(asd,
 >params.css_param);
if (asd->params.css_param.update_flag.dz_config)
-   atomisp_css_set_dz_config(asd,
- 
>params.css_param.dz_config);
+   asd->params.config.dz_config = 
>params.css_param.dz_config;
/* New global dvs 6axis config should be blocked
 * here if there's a buffer with per-frame parameters
 * pending in CSS frame buffer queue.
@@ -1262,9 +1261,15 @@ void atomisp_delayed_init_work(struct work_struct *work)
 */
if (!ATOMISP_USE_YUVPP(asd)) {
struct v4l2_event event = {0};
+   struct ia_css_stream *stream;
 
-   atomisp_css_allocate_continuous_frames(false, asd);
-   atomisp_css_update_continuous_frames(asd);
+   stream = asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream;
+
+
+   if (ia_css_alloc_continuous_frame_remain(stream))
+   return;
+
+   ia_css_update_continuous_frames(stream);
 
event.type = V4L2_EVENT_ATOMISP_RAW_BUFFERS_ALLOC_DONE;
v4l2_event_queue(asd->subdev.devnode, );
@@ -1823,7 +1828,8 @@ void atomisp_setup_flash(struct atomisp_sub_device *asd)
return;
}
 
-   atomisp_css_request_flash(asd);
+   
ia_css_stream_request_flash(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream);
+
asd->params.flash_state = ATOMISP_FLASH_ONGOING;
} else {
asd->params.flash_state = ATOMISP_FLASH_IDLE;
@@ -2107,10 +2113,9 @@ int atomisp_gdc_cac(struct atomisp_sub_device *asd, int 
flag,
 
asd->params.gdc_cac_en = !!*value;
if (asd->params.gdc_cac_en) {
-   atomisp_css_set_morph_table(asd,
-   asd->params.css_param.morph_table);
+   asd->params.config.morph_table = 
asd->params.css_param.morph_table;
} else {
-   atomisp_css_set_morph_table(asd, NULL);
+   asd->params.config.morph_table = NULL;
}
asd->params.css_update_params_needed = true;
atomisp_update_capture_mode(asd);
@@ -2164,7 +2169,7 @@ int atomisp_nr(struct atomisp_sub_device *asd, int flag,
/* Set nr config to isp parameters */
memcpy(>params.css_param.nr_config, arg,
   sizeof(struct ia_css_nr_config));
-   atomisp_css_set_nr_config(asd, 
>params.css_param.nr_config);
+   asd->params.config.nr_config = >params.css_param.nr_config;
asd->params.css_update_params_needed = true;
}
return 0;
@@ -2185,7 +2190,7 @@ int atomisp_tnr(struct atomisp_sub_device *asd, int flag,
/* Set tnr config to isp parameters */
memcpy(>params.css_param.tnr_config, config,
   sizeof(struct ia_css_tnr_config));
-   atomisp_css_set_tnr_config(asd, 
>params.css_param.tnr_config);
+   asd->params.config.tnr_config = 
>params.css_param.tnr_config;
asd->params.css_update_params_needed = true;
}
 
@@ -2206,7 +2211,7 @@ int atomisp_black_level(struct atomisp_sub_device *asd, 
int flag,
/* Set ob config to isp parameters */
memcpy(>params.css_param.ob_config, config,
   sizeof(struct ia_css_ob_config));
-   atomisp_css_set_ob_config(asd, 
>params.css_param.ob_config);
+   asd->params.config.ob_config = >params.css_param.ob_config;
asd->params.css_update_params_needed = true;
}
 
@@ -2227,7 +2232,7 @@ int atomisp_ee(struct atomisp_sub_device *asd, int flag,
/* Set ee config to isp parameters */
   

[PATCH v2 10/41] media: atomisp: add debug message to help debugging hmm code

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/pci/hmm/hmm_bo.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
index 6fce8c95be1d..b6dcd246d7af 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
@@ -1015,6 +1015,11 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
bo->mem_type = HMM_BO_MEM_TYPE_USER;
}
 
+   dev_dbg(atomisp_dev, "%s: %d %s pages were allocated as 0x%08x\n",
+   __func__,
+   bo->pgnr,
+   bo->mem_type == HMM_BO_MEM_TYPE_USER ? "user" : "pfn", page_nr);
+
/* can be written by caller, not forced */
if (page_nr != bo->pgnr) {
dev_err(atomisp_dev,
-- 
2.26.2

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


[PATCH v2 12/41] media: atomisp: get rid of a warning message

2020-05-30 Thread Mauro Carvalho Chehab
There's a warning message about an unused code. The code that
were using it were commented out, due to a problem causing the
firmware load to fail on the machines we're using for testing.

Change the place where we're commenting the code out, in order
to avoid the warning.

Fixes: 95d1f398c4dc ("media: atomisp: keep the ISP powered on when setting it")
Signed-off-by: Mauro Carvalho Chehab 
---
 .../staging/media/atomisp/pci/atomisp_v4l2.c   | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index b30a2e54067c..c89d477a3948 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -734,6 +734,10 @@ static int atomisp_mrfld_pre_power_down(struct 
atomisp_device *isp)
 * WA for DDR DVFS enable/disable
 * By default, ISP will force DDR DVFS 1600MHz before disable DVFS
 */
+
+#if 0
+// Used only by atomisp_mrfld_power
+
 static void punit_ddr_dvfs_enable(bool enable)
 {
int door_bell = 1 << 8;
@@ -758,9 +762,12 @@ static void punit_ddr_dvfs_enable(bool enable)
if (max_wait == -1)
pr_info("DDR DVFS, door bell is not cleared within 3ms\n");
 }
+#endif
 
 static int atomisp_mrfld_power(struct atomisp_device *isp, bool enable)
 {
+// FIXME: at least with ISP2401, the code below causes the driver to break
+#if 0
unsigned long timeout;
u32 val = enable ? MRFLD_ISPSSPM0_IUNIT_POWER_ON :
   MRFLD_ISPSSPM0_IUNIT_POWER_OFF;
@@ -817,22 +824,21 @@ static int atomisp_mrfld_power(struct atomisp_device 
*isp, bool enable)
 
dev_err(isp->dev, "IUNIT power-%s timeout.\n", enable ? "on" : "off");
return -EBUSY;
+#else
+   return 0;
+#endif
 }
 
 /* Workaround for pmu_nc_set_power_state not ready in MRFLD */
 int atomisp_mrfld_power_down(struct atomisp_device *isp)
 {
-   return 0;
-// FIXME: at least with ISP2401, the code below causes the driver to break
-// return atomisp_mrfld_power(isp, false);
+   return atomisp_mrfld_power(isp, false);
 }
 
 /* Workaround for pmu_nc_set_power_state not ready in MRFLD */
 int atomisp_mrfld_power_up(struct atomisp_device *isp)
 {
-   return 0;
-// FIXME: at least with ISP2401, the code below causes the driver to break
-// return atomisp_mrfld_power(isp, true);
+   return atomisp_mrfld_power(isp, true);
 }
 
 int atomisp_runtime_suspend(struct device *dev)
-- 
2.26.2

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


[PATCH v2 09/41] media: atomisp: hmm_bo: untag user pointers

2020-05-30 Thread Mauro Carvalho Chehab
The kernel ABI was extended to allow pass tagged user pointers.

Untag the pointers in this function.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/hmm/hmm_bo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
index 492b76c29490..6fce8c95be1d 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
@@ -997,6 +997,9 @@ static int alloc_user_pages(struct hmm_buffer_object *bo,
 * Handle frame buffer allocated in other kerenl space driver
 * and map to user space
 */
+
+   userptr = untagged_addr(userptr);
+
if (vma->vm_flags & (VM_IO | VM_PFNMAP)) {
page_nr = get_pfnmap_pages(current, current->mm,
   (unsigned long)userptr,
-- 
2.26.2

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


[PATCH v2 04/41] media: atomisp: go one step further to drop ia_css_memory_access.c

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/include/hmm/hmm.h   |  3 ++-
 .../media/atomisp/include/linux/atomisp.h |  2 ++
 .../memory_access/memory_access.h |  3 ---
 drivers/staging/media/atomisp/pci/hmm/hmm.c   | 11 --
 .../media/atomisp/pci/ia_css_memory_access.c  | 21 +--
 .../atomisp/pci/runtime/frame/src/frame.c |  4 ++--
 .../staging/media/atomisp/pci/sh_css_params.c |  8 +++
 7 files changed, 20 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/hmm/hmm.h 
b/drivers/staging/media/atomisp/include/hmm/hmm.h
index e2149b16c9fd..a661c039a2cc 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm.h
@@ -35,7 +35,8 @@ int hmm_init(void);
 void hmm_cleanup(void);
 
 ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
-int from_highmem, const void __user *userptr, bool cached);
+int from_highmem, const void __user *userptr,
+const uint16_t attrs);
 void hmm_free(ia_css_ptr ptr);
 int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
 int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes);
diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h 
b/drivers/staging/media/atomisp/include/linux/atomisp.h
index e9670749bae0..fc2e76694613 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp.h
@@ -917,6 +917,8 @@ struct atomisp_acc_map {
 
 #define ATOMISP_MAP_FLAG_NOFLUSH   0x0001  /* Do not flush cache */
 #define ATOMISP_MAP_FLAG_CACHED0x0002  /* Enable cache */
+#define ATOMISP_MAP_FLAG_CONTIGUOUS0x0004
+#define ATOMISP_MAP_FLAG_CLEARED   0x0008
 
 struct atomisp_acc_state {
__u32 flags;/* Flags, see list below */
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
index c8a41e5d8dab..19b9083995a4 100644
--- 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
+++ 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
@@ -76,9 +76,6 @@
  * within the allocation referencable from the
  * returned pointer/address.
  */
-#define MMGR_ATTRIBUTE_CACHED  0x0001
-#define MMGR_ATTRIBUTE_CONTIGUOUS  0x0002
-#define MMGR_ATTRIBUTE_CLEARED 0x0008
 
 #define mmgr_NULL  ((hrt_vaddress)0)
 #define mmgr_EXCEPTION ((hrt_vaddress)-1)
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 975749d67131..68dab2393767 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -193,7 +193,7 @@ int hmm_init(void)
 * at the beginning, to avoid hmm_alloc return 0 in the
 * further allocation.
 */
-   dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, false);
+   dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, 0);
 
if (!ret) {
ret = sysfs_create_group(_dev->kobj,
@@ -219,12 +219,16 @@ void hmm_cleanup(void)
 }
 
 ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
-int from_highmem, const void __user *userptr, bool cached)
+int from_highmem, const void __user *userptr,
+const uint16_t attrs)
 {
unsigned int pgnr;
struct hmm_buffer_object *bo;
+   bool cached = attrs & ATOMISP_MAP_FLAG_CACHED;
int ret;
 
+   WARN_ON(attrs & ATOMISP_MAP_FLAG_CONTIGUOUS);
+
/*
 * Check if we are initialized. In the ideal world we wouldn't need
 * this but we can tackle it once the driver is a lot cleaner
@@ -258,6 +262,9 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
 
hmm_mem_stat.tol_cnt += pgnr;
 
+   if (attrs & ATOMISP_MAP_FLAG_CLEARED)
+   hmm_set(bo->start, 0, bytes);
+
return bo->start;
 
 bind_err:
diff --git a/drivers/staging/media/atomisp/pci/ia_css_memory_access.c 
b/drivers/staging/media/atomisp/pci/ia_css_memory_access.c
index d11843a717e0..e19b98fe7201 100644
--- a/drivers/staging/media/atomisp/pci/ia_css_memory_access.c
+++ b/drivers/staging/media/atomisp/pci/ia_css_memory_access.c
@@ -12,30 +12,11 @@
  * more details.
  */
 
-#include 
-#include 
-#include 
 #include 
-#include 
-
-#include "atomisp_internal.h"
 
 hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs)
 {
-   ia_css_ptr data;
-
-   WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
-
-   data = hmm_alloc(size, 

[PATCH v2 16/41] media: atomisp: improve warning for IRQ enable function

2020-05-30 Thread Mauro Carvalho Chehab
If something gets wrong when enabling or disabling an IRQ,
we should know better about what happened.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index f39b0ad85cfa..5718010a0bf6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -1042,7 +1042,9 @@ int atomisp_css_irq_enable(struct atomisp_device *isp,
__func__, info,
enable ? "enable" : "disable");
if (ia_css_irq_enable(info, enable) != IA_CSS_SUCCESS) {
-   dev_warn(isp->dev, "%s:Invalid irq info.\n", __func__);
+   dev_warn(isp->dev, "%s:Invalid irq info: 0x%08x when %s.\n",
+__func__, info,
+enable ? "enabling" : "disabling");
return -EINVAL;
}
 
-- 
2.26.2

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


[PATCH v2 36/41] media: atomisp: print firmware data during load

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../media/atomisp/pci/sh_css_firmware.c   | 48 ++-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c 
b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
index 63415356c36d..7cd27707a35f 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -206,6 +206,20 @@ sh_css_check_firmware_version(struct device *dev, const 
char *fw_data)
return 0;
 }
 
+static const char *fw_type_name[] = {
+   [ia_css_sp_firmware]= "SP",
+   [ia_css_isp_firmware]   = "ISP",
+   [ia_css_bootloader_firmware]= "BootLoader",
+   [ia_css_acc_firmware]   = "accel",
+};
+
+static const char *fw_acc_type_name[] = {
+   [IA_CSS_ACC_NONE] = "Normal",
+   [IA_CSS_ACC_OUTPUT] =   "Accel for output",
+   [IA_CSS_ACC_VIEWFINDER] =   "Accel for viewfinder",
+   [IA_CSS_ACC_STANDALONE] =   "Stand-alone accel",
+};
+
 int
 sh_css_load_firmware(struct device *dev, const char *fw_data,
 unsigned int fw_size) {
@@ -276,13 +290,45 @@ sh_css_load_firmware(struct device *dev, const char 
*fw_data,
if (bi->blob.offset + bi->blob.size > fw_size)
return -EINVAL;
 
+   switch (bd.header.type) {
+   case ia_css_isp_firmware:
+   if (bd.header.info.isp.type > IA_CSS_ACC_STANDALONE) {
+   dev_err(dev, "binary #%2d: invalid SP type\n",
+   i);
+   return -EINVAL;
+   }
+
+   dev_dbg(dev,
+   "binary #%-2d type %s (%s), binary id is %2d: 
%s\n",
+   i,
+   fw_type_name[bd.header.type],
+   fw_acc_type_name[bd.header.info.isp.type],
+   bd.header.info.isp.sp.id,
+   bd.name);
+   break;
+   case ia_css_sp_firmware:
+   case ia_css_bootloader_firmware:
+   case ia_css_acc_firmware:
+   dev_dbg(dev,
+   "binary #%-2d type %s: %s\n",
+   i, fw_type_name[bd.header.type],
+   bd.name);
+   default:
+   if (bd.header.info.isp.type > IA_CSS_ACC_STANDALONE) {
+   dev_err(dev,
+   "binary #%2d: invalid firmware type\n",
+   i);
+   return -EINVAL;
+   }
+   break;
+   }
+
if (bi->type == ia_css_sp_firmware) {
if (i != SP_FIRMWARE)
return -EINVAL;
err = setup_binary(bi, fw_data, _css_sp_fw, i);
if (err)
return err;
-   dev_dbg(dev, "firmware #%d (SP), name %s\n", i, 
bd.name);
 
} else {
/* All subsequent binaries (including bootloaders) 
(i>NUM_OF_SPS) are ISP firmware */
-- 
2.26.2

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


[PATCH v2 27/41] media: atomisp: avoid an extra memset() when alloc memory

2020-05-30 Thread Mauro Carvalho Chehab
Use the variant which zeroes the memory when allocating,
instead of having an explicit memset.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c  | 3 +--
 drivers/staging/media/atomisp/pci/sh_css.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c 
b/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
index ebf36f7a514f..feacd8f12b14 100644
--- a/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
+++ b/drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c
@@ -593,12 +593,11 @@ static enum ia_css_err pipeline_stage_create(
out_frame[i] = stage_desc->out_frame[i];
}
 
-   stage = kvmalloc(sizeof(*stage), GFP_KERNEL);
+   stage = kvzalloc(sizeof(*stage), GFP_KERNEL);
if (!stage) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto ERR;
}
-   memset(stage, 0, sizeof(*stage));
 
if (firmware) {
stage->binary = NULL;
diff --git a/drivers/staging/media/atomisp/pci/sh_css.c 
b/drivers/staging/media/atomisp/pci/sh_css.c
index 4269c16ad4f1..90d73fd8aa1b 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -9398,7 +9398,7 @@ ia_css_stream_create(const struct ia_css_stream_config 
*stream_config,
}
 
/* allocate the stream instance */
-   curr_stream = kmalloc(sizeof(struct ia_css_stream), GFP_KERNEL);
+   curr_stream = kzalloc(sizeof(struct ia_css_stream), GFP_KERNEL);
if (!curr_stream)
{
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
@@ -9406,7 +9406,6 @@ ia_css_stream_create(const struct ia_css_stream_config 
*stream_config,
return err;
}
/* default all to 0 */
-   memset(curr_stream, 0, sizeof(struct ia_css_stream));
curr_stream->info.metadata_info = md_info;
 
/* allocate pipes */
-- 
2.26.2

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


[PATCH v2 13/41] media: atomisp: fix driver caps

2020-05-30 Thread Mauro Carvalho Chehab
This device driver is not MC-centric. So, remove the wrong
caps from it.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_subdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c 
b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
index 830aefad9312..2bde2c8ea460 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c
@@ -1343,8 +1343,7 @@ int atomisp_subdev_register_entities(struct 
atomisp_sub_device *asd,
 * Should any of those use V4L2_CAP_META_OUTPUT? Probably yes.
 */
 
-   device_caps = V4L2_CAP_IO_MC |
- V4L2_CAP_VIDEO_CAPTURE |
+   device_caps = V4L2_CAP_VIDEO_CAPTURE |
  V4L2_CAP_STREAMING;
 
/* Register the subdev and video node. */
-- 
2.26.2

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


[PATCH v2 05/41] media: atomisp: get rid of mmgr_load and mmgr_store

2020-05-30 Thread Mauro Carvalho Chehab
Those functions are just wrappers for hmm_load/hmm_store.

Signed-off-by: Mauro Carvalho Chehab 
---
 .../pci/hive_isp_css_common/host/debug.c  |  8 +++---
 .../hive_isp_css_common/host/debug_private.h  |  8 +++---
 .../memory_access/memory_access.h | 20 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   | 18 +++-
 .../media/atomisp/pci/ia_css_memory_access.c  | 13 -
 .../kernels/sdis/sdis_1.0/ia_css_sdis.host.c  |  2 +-
 .../kernels/sdis/sdis_2/ia_css_sdis2.host.c   |  2 +-
 .../pci/runtime/isp_param/src/isp_param.c |  2 +-
 .../pci/runtime/queue/src/queue_access.c  |  8 +++---
 .../atomisp/pci/runtime/spctrl/src/spctrl.c   |  2 +-
 drivers/staging/media/atomisp/pci/sh_css.c| 12 
 .../media/atomisp/pci/sh_css_firmware.c   |  2 +-
 .../staging/media/atomisp/pci/sh_css_params.c | 28 +--
 13 files changed, 54 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c
index d911aec24185..6079ca1e7732 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug.c
@@ -48,13 +48,13 @@ void debug_buffer_ddr_init(const hrt_vaddress addr)
u32 tail = 0;
/* set the ddr queue */
debug_buffer_ddr_address = addr;
-   mmgr_store(addr + DEBUG_DATA_BUF_MODE_DDR_ADDR,
+   hmm_store(addr + DEBUG_DATA_BUF_MODE_DDR_ADDR,
   , sizeof(debug_buf_mode_t));
-   mmgr_store(addr + DEBUG_DATA_HEAD_DDR_ADDR,
+   hmm_store(addr + DEBUG_DATA_HEAD_DDR_ADDR,
   , sizeof(uint32_t));
-   mmgr_store(addr + DEBUG_DATA_TAIL_DDR_ADDR,
+   hmm_store(addr + DEBUG_DATA_TAIL_DDR_ADDR,
   , sizeof(uint32_t));
-   mmgr_store(addr + DEBUG_DATA_ENABLE_DDR_ADDR,
+   hmm_store(addr + DEBUG_DATA_ENABLE_DDR_ADDR,
   , sizeof(uint32_t));
 
/* set the local copy */
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug_private.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug_private.h
index 8447e33d1c04..f2f5b7658819 100644
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug_private.h
+++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/debug_private.h
@@ -101,22 +101,22 @@ STORAGE_CLASS_DEBUG_C void debug_synch_queue_ddr(void)
 {
u32 remote_tail;
 
-   mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_TAIL_DDR_ADDR, 
_tail,
+   hmm_load(debug_buffer_ddr_address + DEBUG_DATA_TAIL_DDR_ADDR, 
_tail,
  sizeof(uint32_t));
/* We could move the remote head after the upload, but we would have to 
limit the upload w.r.t. the local head. This is easier */
if (remote_tail > debug_data_ptr->tail) {
size_t  delta = remote_tail - debug_data_ptr->tail;
 
-   mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR +
+   hmm_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR +
  debug_data_ptr->tail * sizeof(uint32_t),
  (void *)_data_ptr->buf[debug_data_ptr->tail], 
delta * sizeof(uint32_t));
} else if (remote_tail < debug_data_ptr->tail) {
size_t  delta = DEBUG_BUF_SIZE - debug_data_ptr->tail;
 
-   mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR +
+   hmm_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR +
  debug_data_ptr->tail * sizeof(uint32_t),
  (void *)_data_ptr->buf[debug_data_ptr->tail], 
delta * sizeof(uint32_t));
-   mmgr_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR,
+   hmm_load(debug_buffer_ddr_address + DEBUG_DATA_BUF_DDR_ADDR,
  (void *)_data_ptr->buf[0],
  remote_tail * sizeof(uint32_t));
} /* else we are up to date */
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
index 19b9083995a4..4a062ee2f8df 100644
--- 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
+++ 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
@@ -91,24 +91,4 @@
 
 hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attribute);
 
-/*! Read an array of bytes from a virtual memory address
-
- \paramvaddr[in]   Address of an allocation
- \paramdata[out]   pointer to the destination array
- \paramsize[in]number of bytes to read
-
- \return none
- */
-void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size);
-
-/*! Write an array of bytes to device 

[PATCH v2 00/41] More atomisp fixes and cleanups

2020-05-30 Thread Mauro Carvalho Chehab
The first 20 patches on this series were already submitted, but I forgot
to c/c linux-media. So, I'm just resending, without any changes.
Most of them are working at the memory management abstraction,
cleaning it, removing abstraction layers and getting rid of legacy stuff.

Patch 20 contains an important bug fix: the logic which configures 
the hardware pipelines add some "delay frames" that are NULL, causing
the driver to crash when userspace selects a resolution different
than the sensor resolution.

The other patches are other random cleanups, fixes and removal
of some abstraction layers,.

-

It took me a lot of time debugging the OOPS, due to all the weirdness 
and abstractions with the mm/ allocation, plus the 4+ abstraction
layers that it takes for the driver to actually do something.

We should try to get rid of at least some of the layers as soon as
possible, as it takes a lot of time to debug certain things with all
those layers.

Mauro Carvalho Chehab (35):
  media: atomisp: simplify hive_isp_css_mm_hrt wrapper
  media: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction
layer
  media: atomisp: reduce abstraction at ia_css_memory_access
  media: atomisp: go one step further to drop ia_css_memory_access.c
  media: atomisp: get rid of mmgr_load and mmgr_store
  media: atomisp: get rid of unused memory_realloc code
  media: atomisp: change the type returned by mmgr alloc
  media: atomisp: get rid of memory_access.c
  media: atomisp: hmm_bo: untag user pointers
  media: atomisp: add debug message to help debugging hmm code
  media: atomisp: use Yocto Aero default hmm pool sizes
  media: atomisp: get rid of a warning message
  media: atomisp: fix driver caps
  media: atomisp: use pin_user_pages() for memory allocation
  media: atomisp: add debug for hmm alloc
  media: atomisp: improve warning for IRQ enable function
  media: atomisp: add debug functions for received events
  media: atomisp: add more comments about frame allocation
  media: atomisp: remove kvmalloc/kvcalloc abstractions
  media: atomisp: avoid OOPS due to non-existing ref_frames
  media: atomisp: avoid an extra memset() when alloc memory
  media: atomisp: remove some trivial wrappers from compat css20
  media: atomisp: do another round of coding style cleanup
  media: atomisp: get rid of non-Linux error codes
  media: atomisp: get rid of an error abstraction layer
  media: atomisp: don't cause a warn if probe failed
  media: atomisp: get rid of a bunch of other wrappers
  media: atomisp: get rid of system_types.h
  media: atomisp: provide more details about the firmware binaries
  media: atomisp: print firmware data during load
  media: atomisp: allow passing firmware name at modprobe time
  media: atomisp: add a debug message at hmm free
  media: atomisp: add some debug messages when binaries are used
  media: atomisp: get rid of set_fs() dirty hacks
  media: atomisp: add SPDX headers

Nathan Chancellor (6):
  media: atomisp: Clean up if block in sh_css_sp_init_stage
  media: atomisp: Remove second increment of count in
atomisp_subdev_probe
  media: atomisp: Remove unnecessary NULL checks in
ia_css_pipe_load_extension
  media: atomisp: Remove unnecessary NULL check in atomisp_param
  media: atomisp: Avoid overflow in compute_blending
  media: atomisp: Remove binary_supports_input_format

 drivers/staging/media/atomisp/Kconfig |1 +
 drivers/staging/media/atomisp/Makefile|9 +-
 drivers/staging/media/atomisp/TODO|7 +-
 drivers/staging/media/atomisp/i2c/Kconfig |3 +-
 .../media/atomisp/i2c/atomisp-gc0310.c|2 +-
 .../media/atomisp/i2c/atomisp-gc2235.c|1 +
 .../atomisp/i2c/atomisp-libmsrlisthelper.c|1 +
 .../media/atomisp/i2c/atomisp-lm3554.c|1 +
 .../media/atomisp/i2c/atomisp-mt9m114.c   |1 +
 .../media/atomisp/i2c/atomisp-ov2680.c|3 +-
 .../media/atomisp/i2c/atomisp-ov2722.c|1 +
 drivers/staging/media/atomisp/i2c/gc0310.h|1 +
 drivers/staging/media/atomisp/i2c/gc2235.h|1 +
 drivers/staging/media/atomisp/i2c/mt9m114.h   |1 +
 drivers/staging/media/atomisp/i2c/ov2680.h|3 +
 drivers/staging/media/atomisp/i2c/ov2722.h|1 +
 .../staging/media/atomisp/i2c/ov5693/Kconfig  |1 +
 .../staging/media/atomisp/i2c/ov5693/ad5823.h |1 +
 .../media/atomisp/i2c/ov5693/atomisp-ov5693.c |5 +-
 .../staging/media/atomisp/i2c/ov5693/ov5693.h |1 +
 .../staging/media/atomisp/include/hmm/hmm.h   |8 +-
 .../media/atomisp/include/hmm/hmm_bo.h|   12 +-
 .../media/atomisp/include/hmm/hmm_common.h|1 +
 .../media/atomisp/include/hmm/hmm_pool.h  |1 +
 .../media/atomisp/include/linux/atomisp.h |5 +-
 .../include/linux/atomisp_gmin_platform.h |1 +
 .../atomisp/include/linux/atomisp_platform.h  |1 +
 .../atomisp/include/linux/libmsrlisthelper.h  |1 +
 .../media/atomisp/include/media/lm3554.h  |1 +
 

[PATCH v2 28/41] media: atomisp: remove some trivial wrappers from compat css20

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  5 +-
 .../media/atomisp/pci/atomisp_compat.h| 10 +--
 .../media/atomisp/pci/atomisp_compat_css20.c  | 72 ++-
 .../media/atomisp/pci/atomisp_compat_css20.h  |  6 --
 .../staging/media/atomisp/pci/atomisp_csi2.c  |  4 +-
 .../staging/media/atomisp/pci/atomisp_drvfs.c |  5 +-
 .../staging/media/atomisp/pci/atomisp_fops.c  |  2 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  4 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 15 ++--
 .../media/atomisp/pci/mmu/sh_mmu_mrfld.c  |  2 +-
 .../media/atomisp/pci/sh_css_firmware.c   |  8 +--
 11 files changed, 35 insertions(+), 98 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 5f34e7586ee4..2758c2da60da 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -57,6 +57,7 @@
 
 #include "ia_css_types.h"
 #include "ia_css_stream.h"
+#include "ia_css_debug.h"
 #include "error_support.h"
 #include "bits.h"
 
@@ -1503,8 +1504,8 @@ void atomisp_wdt_work(struct work_struct *work)
}
 
if (css_recover) {
-   atomisp_css_debug_dump_sp_sw_debug_info();
-   atomisp_css_debug_dump_debug_info(__func__);
+   ia_css_debug_dump_sp_sw_debug_info();
+   ia_css_debug_dump_debug_info(__func__);
for (i = 0; i < isp->num_of_streams; i++) {
struct atomisp_sub_device *asd = >asd[i];
 
diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat.h 
b/drivers/staging/media/atomisp/pci/atomisp_compat.h
index 8693f228a875..87677e1117ff 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat.h
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat.h
@@ -34,11 +34,7 @@ struct atomisp_metadata_buf {
struct list_head list;
 };
 
-void atomisp_css_debug_dump_sp_sw_debug_info(void);
-void atomisp_css_debug_dump_debug_info(const char *context);
-void atomisp_css_debug_set_dtrace_level(const unsigned int trace_level);
-
-void atomisp_store_uint32(hrt_address addr, uint32_t data);
+void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data);
 void atomisp_load_uint32(hrt_address addr, uint32_t *data);
 
 int atomisp_css_init(struct atomisp_device *isp);
@@ -84,9 +80,9 @@ int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device 
*asd,
enum atomisp_input_stream_id stream_id,
enum ia_css_pipe_id css_pipe_id);
 
-void atomisp_css_mmu_invalidate_cache(void);
+void ia_css_mmu_invalidate_cache(void);
 
-void atomisp_css_mmu_invalidate_tlb(void);
+void ia_css_mmu_invalidate_cache(void);
 
 int atomisp_css_start(struct atomisp_sub_device *asd,
  enum ia_css_pipe_id pipe_id, bool in_reset);
diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index f7c3fdd5f670..59228d711048 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -66,26 +66,6 @@ struct bayer_ds_factor {
unsigned int denominator;
 };
 
-void atomisp_css_debug_dump_sp_sw_debug_info(void)
-{
-   ia_css_debug_dump_sp_sw_debug_info();
-}
-
-void atomisp_css_debug_dump_debug_info(const char *context)
-{
-   ia_css_debug_dump_debug_info(context);
-}
-
-void atomisp_css_debug_set_dtrace_level(const unsigned int trace_level)
-{
-   ia_css_debug_set_dtrace_level(trace_level);
-}
-
-unsigned int atomisp_css_debug_get_dtrace_level(void)
-{
-   return dbg_level;
-}
-
 static void atomisp_css2_hw_store_8(hrt_address addr, uint8_t data)
 {
unsigned long flags;
@@ -104,7 +84,7 @@ static void atomisp_css2_hw_store_16(hrt_address addr, 
uint16_t data)
spin_unlock_irqrestore(_lock, flags);
 }
 
-static void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
+void atomisp_css2_hw_store_32(hrt_address addr, uint32_t data)
 {
unsigned long flags;
 
@@ -191,11 +171,6 @@ static int atomisp_css2_err_print(const char *fmt, va_list 
args)
return 0;
 }
 
-void atomisp_store_uint32(hrt_address addr, uint32_t data)
-{
-   atomisp_css2_hw_store_32(addr, data);
-}
-
 void atomisp_load_uint32(hrt_address addr, uint32_t *data)
 {
*data = atomisp_css2_hw_load_32(addr);
@@ -213,16 +188,6 @@ static int hmm_get_mmu_base_addr(unsigned int 
*mmu_base_addr)
return 0;
 }
 
-static void atomisp_isp_parameters_clean_up(
-struct ia_css_isp_config *config)
-{
-   /*
-* Set NULL to configs pointer to avoid they are set into isp again when
- 

[PATCH v2 07/41] media: atomisp: change the type returned by mmgr alloc

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../base/refcount/interface/ia_css_refcount.h | 13 ++--
 .../atomisp/pci/base/refcount/src/refcount.c  | 14 ++--
 .../pci/hive_isp_css_common/host/debug.c  |  4 +-
 .../hive_isp_css_include/host/debug_public.h  |  5 +-
 .../memory_access/memory_access.h | 10 +--
 .../staging/media/atomisp/pci/hive_types.h|  3 -
 .../media/atomisp/pci/ia_css_memory_access.c  |  2 +-
 .../staging/media/atomisp/pci/ia_css_pipe.h   |  2 +-
 .../isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.c |  2 +-
 .../isp/kernels/dvs/dvs_1.0/ia_css_dvs.host.h |  2 +-
 .../kernels/ref/ref_1.0/ia_css_ref_param.h|  4 +-
 .../kernels/tnr/tnr_1.0/ia_css_tnr_param.h|  2 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  2 +-
 .../frame/interface/ia_css_frame_comm.h   |  4 +-
 .../isp_param/interface/ia_css_isp_param.h|  2 +-
 .../pci/runtime/isp_param/src/isp_param.c |  4 +-
 .../runtime/rmgr/interface/ia_css_rmgr_vbuf.h |  3 +-
 .../runtime/spctrl/interface/ia_css_spctrl.h  |  2 +-
 .../atomisp/pci/runtime/spctrl/src/spctrl.c   | 10 +--
 drivers/staging/media/atomisp/pci/sh_css.c|  8 +-
 .../media/atomisp/pci/sh_css_firmware.c   |  4 +-
 .../media/atomisp/pci/sh_css_firmware.h   |  2 +-
 .../media/atomisp/pci/sh_css_internal.h   | 76 +--
 .../staging/media/atomisp/pci/sh_css_params.c | 76 +--
 .../staging/media/atomisp/pci/sh_css_params.h | 12 +--
 drivers/staging/media/atomisp/pci/sh_css_sp.c |  4 +-
 .../staging/media/atomisp/pci/sh_css_struct.h |  2 +-
 27 files changed, 137 insertions(+), 137 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h 
b/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
index 8cf3b0e0cc39..9f6e05b19262 100644
--- 
a/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
+++ 
b/drivers/staging/media/atomisp/pci/base/refcount/interface/ia_css_refcount.h
@@ -18,8 +18,9 @@
 #include 
 #include 
 #include 
+#include 
 
-typedef void (*clear_func)(hrt_vaddress ptr);
+typedef void (*clear_func)(ia_css_ptr ptr);
 
 /*! \brief Function for initializing refcount list
  *
@@ -38,9 +39,9 @@ void ia_css_refcount_uninit(void);
  *
  * \param[in]  id  ID of the object.
  * \param[in]  ptr Data of the object (ptr).
- * \return hrt_vaddress (saved address)
+ * \return ia_css_ptr (saved address)
  */
-hrt_vaddress ia_css_refcount_increment(s32 id, hrt_vaddress ptr);
+ia_css_ptr ia_css_refcount_increment(s32 id, ia_css_ptr ptr);
 
 /*! \brief Function for decrease reference by 1.
  *
@@ -50,7 +51,7 @@ hrt_vaddress ia_css_refcount_increment(s32 id, hrt_vaddress 
ptr);
  * - true, if it is successful.
  * - false, otherwise.
  */
-bool ia_css_refcount_decrement(s32 id, hrt_vaddress ptr);
+bool ia_css_refcount_decrement(s32 id, ia_css_ptr ptr);
 
 /*! \brief Function to check if reference count is 1.
  *
@@ -59,7 +60,7 @@ bool ia_css_refcount_decrement(s32 id, hrt_vaddress ptr);
  * - true, if it is successful.
  * - false, otherwise.
  */
-bool ia_css_refcount_is_single(hrt_vaddress ptr);
+bool ia_css_refcount_is_single(ia_css_ptr ptr);
 
 /*! \brief Function to clear reference list objects.
  *
@@ -78,6 +79,6 @@ void ia_css_refcount_clear(s32 id,
  *  - true, if valid
  *  - false, if invalid
  */
-bool ia_css_refcount_is_valid(hrt_vaddress ptr);
+bool ia_css_refcount_is_valid(ia_css_ptr ptr);
 
 #endif /* _IA_CSS_REFCOUNT_H_ */
diff --git a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c 
b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
index 8f0c94449ec9..52c40aaa1e52 100644
--- a/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
+++ b/drivers/staging/media/atomisp/pci/base/refcount/src/refcount.c
@@ -23,10 +23,10 @@
 #include "ia_css_debug.h"
 
 /* TODO: enable for other memory aswell
-now only for hrt_vaddress */
+now only for ia_css_ptr */
 struct ia_css_refcount_entry {
u32 count;
-   hrt_vaddress data;
+   ia_css_ptr data;
s32 id;
 };
 
@@ -37,7 +37,7 @@ struct ia_css_refcount_list {
 
 static struct ia_css_refcount_list myrefcount;
 
-static struct ia_css_refcount_entry *refcount_find_entry(hrt_vaddress ptr,
+static struct ia_css_refcount_entry *refcount_find_entry(ia_css_ptr ptr,
bool firstfree)
 {
u32 i;
@@ -121,7 +121,7 @@ void ia_css_refcount_uninit(void)
"ia_css_refcount_uninit() leave\n");
 }
 
-hrt_vaddress ia_css_refcount_increment(s32 id, hrt_vaddress ptr)
+ia_css_ptr ia_css_refcount_increment(s32 id, ia_css_ptr ptr)
 {
struct ia_css_refcount_entry *entry;
 
@@ -158,7 +158,7 @@ hrt_vaddress 

[PATCH v2 39/41] media: atomisp: add some debug messages when binaries are used

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../atomisp/pci/runtime/binary/src/binary.c   | 31 ---
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c 
b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
index c10a09ca1c52..cca0c6161350 100644
--- a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
+++ b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
@@ -29,6 +29,8 @@
 #include "sh_css_defs.h"
 #include "sh_css_legacy.h"
 
+#include "atomisp_internal.h"
+
 #include "vf/vf_1.0/ia_css_vf.host.h"
 #include "sc/sc_1.0/ia_css_sc.host.h"
 #include "sdis/sdis_1.0/ia_css_sdis.host.h"
@@ -36,7 +38,6 @@
 
 #include "camera/pipe/interface/ia_css_pipe_binarydesc.h"
 
-
 #include "assert_support.h"
 
 #define IMPLIES(a, b)   (!(a) || (b))   /* A => B */
@@ -1375,9 +1376,8 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo 
*xinfo,
return 0;
 }
 
-int
-ia_css_binary_find(struct ia_css_binary_descr *descr,
-  struct ia_css_binary *binary) {
+static int __ia_css_binary_find(struct ia_css_binary_descr *descr,
+   struct ia_css_binary *binary) {
int mode;
bool online;
bool two_ppc;
@@ -1793,9 +1793,32 @@ ia_css_binary_find(struct ia_css_binary_descr *descr,
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
"ia_css_binary_find() leave: return_err=%d\n", err);
 
+   if (!err && xcandidate)
+   dev_dbg(atomisp_dev,
+   "Using binary %s (id %d), type %d, mode %d, continuous 
%s\n",
+   xcandidate->blob->name,
+   xcandidate->sp.id,
+   xcandidate->type,
+   xcandidate->sp.pipeline.mode,
+   xcandidate->sp.enable.continuous ? "true" : "false");
+
+
return err;
 }
 
+int ia_css_binary_find(struct ia_css_binary_descr *descr,
+  struct ia_css_binary *binary)
+{
+   int ret = __ia_css_binary_find(descr, binary);
+
+   if (unlikely(ret)) {
+   dev_dbg(atomisp_dev, "Seeking for binary failed at:");
+   dump_stack();
+   }
+
+   return ret;
+}
+
 unsigned
 ia_css_binary_max_vf_width(void)
 {
-- 
2.26.2

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


[PATCH v2 38/41] media: atomisp: add a debug message at hmm free

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 670382c48034..25b92b2c4830 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -285,6 +285,8 @@ void hmm_free(ia_css_ptr virt)
 {
struct hmm_buffer_object *bo;
 
+   dev_dbg(atomisp_dev, "%s: free 0x%08x\n", __func__, virt);
+
WARN_ON(!virt);
 
bo = hmm_bo_device_search_start(_device, (unsigned int)virt);
-- 
2.26.2

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


[PATCH v2 06/41] media: atomisp: get rid of unused memory_realloc code

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/Makefile|  1 -
 .../pci/hive_isp_css_include/memory_realloc.h | 38 -
 .../media/atomisp/pci/memory_realloc.c| 80 ---
 .../staging/media/atomisp/pci/sh_css_params.c |  4 +-
 4 files changed, 1 insertion(+), 122 deletions(-)
 delete mode 100644 
drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_realloc.h
 delete mode 100644 drivers/staging/media/atomisp/pci/memory_realloc.c

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index 889227dcebfe..4a77d6d6910d 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -115,7 +115,6 @@ atomisp-objs += \
pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.o \
pci/isp/kernels/ynr/ynr_1.0/ia_css_ynr.host.o \
pci/isp/kernels/ynr/ynr_2/ia_css_ynr2.host.o \
-   pci/memory_realloc.o \
pci/mmu/isp_mmu.o \
pci/mmu/sh_mmu_mrfld.o \
pci/runtime/binary/src/binary.o \
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_realloc.h 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_realloc.h
deleted file mode 100644
index 546b93ca1186..
--- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_realloc.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-Support for Intel Camera Imaging ISP subsystem.
-Copyright (c) 2010 - 2015, Intel Corporation.
-
-This program is free software; you can redistribute it and/or modify it
-under the terms and conditions of the GNU General Public License,
-version 2, as published by the Free Software Foundation.
-
-This program is distributed in the hope it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-more details.
-*/
-#ifndef __MEMORY_REALLOC_H_INCLUDED__
-#define __MEMORY_REALLOC_H_INCLUDED__
-
-/*!
- * \brief
- * Define the internal reallocation of private css memory
- *
- */
-
-#include 
-/*
- * User provided file that defines the (sub)system address types:
- * - hrt_vaddress  a type that can hold the (sub)system virtual address 
range
- */
-#include "system_types.h"
-#include "ia_css_err.h"
-
-bool reallocate_buffer(
-hrt_vaddress *curr_buf,
-size_t *curr_size,
-size_t needed_size,
-bool force,
-enum ia_css_err *err);
-
-#endif /*__MEMORY_REALLOC_H_INCLUDED__*/
diff --git a/drivers/staging/media/atomisp/pci/memory_realloc.c 
b/drivers/staging/media/atomisp/pci/memory_realloc.c
deleted file mode 100644
index ec0a078e65f9..
--- a/drivers/staging/media/atomisp/pci/memory_realloc.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-Support for Intel Camera Imaging ISP subsystem.
-Copyright (c) 2010 - 2015, Intel Corporation.
-
-This program is free software; you can redistribute it and/or modify it
-under the terms and conditions of the GNU General Public License,
-version 2, as published by the Free Software Foundation.
-
-This program is distributed in the hope it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-more details.
-*/
-#include "memory_realloc.h"
-#include "ia_css_debug.h"
-#include "ia_css_refcount.h"
-#include "memory_access.h"
-
-static bool realloc_isp_css_mm_buf(
-hrt_vaddress *curr_buf,
-size_t *curr_size,
-size_t needed_size,
-bool force,
-enum ia_css_err *err,
-uint16_t mmgr_attribute);
-
-bool reallocate_buffer(
-hrt_vaddress *curr_buf,
-size_t *curr_size,
-size_t needed_size,
-bool force,
-enum ia_css_err *err)
-{
-   bool ret;
-
-   IA_CSS_ENTER_PRIVATE("void");
-
-   ret = realloc_isp_css_mm_buf(curr_buf,
-curr_size, needed_size, force, err, 0);
-
-   IA_CSS_LEAVE_PRIVATE("ret=%d", ret);
-   return ret;
-}
-
-static bool realloc_isp_css_mm_buf(
-hrt_vaddress *curr_buf,
-size_t *curr_size,
-size_t needed_size,
-bool force,
-enum ia_css_err *err,
-uint16_t mmgr_attribute)
-{
-   s32 id;
-
-   *err = IA_CSS_SUCCESS;
-   /* Possible optimization: add a function sh_css_isp_css_mm_realloc()
-* and implement on top of hmm. */
-
-   IA_CSS_ENTER_PRIVATE("void");
-
-   if (ia_css_refcount_is_single(*curr_buf) && !force &&
-   *curr_size >= needed_size) {
-   IA_CSS_LEAVE_PRIVATE("false");
-   return false;
-   }
-
-   id = IA_CSS_REFCOUNT_PARAM_BUFFER;
-   ia_css_refcount_decrement(id, *curr_buf);
-   *curr_buf = ia_css_refcount_increment(id, mmgr_alloc_attr(needed_size,
- mmgr_attribute));
-
-   

[PATCH v2 22/41] media: atomisp: Remove second increment of count in atomisp_subdev_probe

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 
Signed-off-by: Nathan Chancellor 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index c89d477a3948..374b1bb6c339 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1098,7 +1098,6 @@ static int atomisp_subdev_probe(struct atomisp_device 
*isp)
if (camera_count)
break;
msleep(SUBDEV_WAIT_TIMEOUT);
-   count++;
}
/* Wait more time to give more time for subdev init code to finish */
msleep(5 * SUBDEV_WAIT_TIMEOUT);
-- 
2.26.2

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


[PATCH v2 21/41] media: atomisp: Clean up if block in sh_css_sp_init_stage

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 (>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 
Signed-off-by: Nathan Chancellor 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/sh_css_sp.c | 27 +++
 1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c 
b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index db543c3fec51..4f58562fb389 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -1027,34 +1027,15 @@ sh_css_sp_init_stage(struct ia_css_binary *binary,
return err;
 
 #ifdef USE_INPUT_SYSTEM_VERSION_2401
-#ifndef ISP2401
-   if (args->in_frame)
-   {
+   if (stage == 0) {
pipe = 
find_pipe_by_num(sh_css_sp_group.pipe[thread_id].pipe_num);
if (!pipe)
return IA_CSS_ERR_INTERNAL_ERROR;
-   ia_css_get_crop_offsets(pipe, >in_frame->info);
-   } else if (>in_frame_info)
-   {
-   pipe = 
find_pipe_by_num(sh_css_sp_group.pipe[thread_id].pipe_num);
-   if (!pipe)
-   return IA_CSS_ERR_INTERNAL_ERROR;
-   ia_css_get_crop_offsets(pipe, >in_frame_info);
-#else
-   if (stage == 0)
-   {
-   if (args->in_frame) {
-   pipe = 
find_pipe_by_num(sh_css_sp_group.pipe[thread_id].pipe_num);
-   if (!pipe)
-   return IA_CSS_ERR_INTERNAL_ERROR;
+
+   if (args->in_frame)
ia_css_get_crop_offsets(pipe, >in_frame->info);
-   } else if (>in_frame_info) {
-   pipe = 
find_pipe_by_num(sh_css_sp_group.pipe[thread_id].pipe_num);
-   if (!pipe)
-   return IA_CSS_ERR_INTERNAL_ERROR;
+   else
ia_css_get_crop_offsets(pipe, >in_frame_info);
-   }
-#endif
}
 #else
(void)pipe; /*avoid build warning*/
-- 
2.26.2

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


[PATCH v2 20/41] media: atomisp: avoid OOPS due to non-existing ref_frames

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c   | 13 +
 drivers/staging/media/atomisp/pci/sh_css_sp.c   | 11 +++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c 
b/drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c
index 38594741321c..cbe3836419a2 100644
--- 
a/drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c
+++ 
b/drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c
@@ -29,10 +29,15 @@ ia_css_ref_config(
 {
unsigned int elems_a = ISP_VEC_NELEMS, i;
 
-   (void)size;
-   ia_css_dma_configure_from_info(>port_b, >ref_frames[0]->info);
-   to->width_a_over_b = elems_a / to->port_b.elems;
-   to->dvs_frame_delay = from->dvs_frame_delay;
+   if (from->ref_frames[0]) {
+   ia_css_dma_configure_from_info(>port_b, 
>ref_frames[0]->info);
+   to->width_a_over_b = elems_a / to->port_b.elems;
+   to->dvs_frame_delay = from->dvs_frame_delay;
+   } else {
+   to->width_a_over_b = 1;
+   to->dvs_frame_delay = 0;
+   to->port_b.elems = elems_a;
+   }
for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++) {
if (from->ref_frames[i]) {
to->ref_frame_addr_y[i] = from->ref_frames[i]->data +
diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c 
b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index 1ed060d6d855..db543c3fec51 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -839,6 +839,17 @@ configure_isp_from_args(
ia_css_dvs_configure(binary, >out_frame[0]->info);
ia_css_output_configure(binary, >out_frame[0]->info);
ia_css_raw_configure(pipeline, binary, >in_frame->info, 
>in_frame_info, two_ppc, deinterleaved);
+
+   /*
+* FIXME: args->delay_frames can be NULL here
+*
+* Somehow, the driver at the Intel Atom Yocto tree doesn't seem to
+* suffer from the same issue.
+*
+* Anyway, the function below should now handle a NULL delay_frames
+* without crashing, but the pipeline should likely be built without
+* adding it at the first place (or there are a hidden bug somewhere)
+*/
ia_css_ref_configure(binary, args->delay_frames, 
pipeline->dvs_frame_delay);
ia_css_tnr_configure(binary, args->tnr_frames);
ia_css_bayer_io_config(binary, args);
-- 
2.26.2

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


[PATCH v2 18/41] media: atomisp: add more comments about frame allocation

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 8783d4b59f6d..765e1a8c31fa 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -1052,7 +1052,7 @@ int __atomisp_reqbufs(struct file *file, void *fh,
atomisp_alloc_css_stat_bufs(asd, stream_id);
 
/*
-* for user pointer type, buffers are not really allcated here,
+* for user pointer type, buffers are not really allocated here,
 * buffers are setup in QBUF operation through v4l2_buffer structure
 */
if (req->memory == V4L2_MEMORY_USERPTR)
@@ -1225,6 +1225,10 @@ static int atomisp_qbuf(struct file *file, void *fh, 
struct v4l2_buffer *buf)
buf->flags |= V4L2_BUF_FLAG_MAPPED;
buf->flags |= V4L2_BUF_FLAG_QUEUED;
buf->flags &= ~V4L2_BUF_FLAG_DONE;
+
+   /*
+* For mmap, frames were allocated at request buffers
+*/
}
 
 done:
-- 
2.26.2

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


[PATCH v2 29/41] media: atomisp: do another round of coding style cleanup

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/TODO|  4 +--
 drivers/staging/media/atomisp/i2c/Kconfig |  2 +-
 .../media/atomisp/i2c/atomisp-gc0310.c|  1 -
 .../media/atomisp/i2c/atomisp-ov2680.c|  2 +-
 drivers/staging/media/atomisp/i2c/ov2680.h|  2 ++
 .../media/atomisp/i2c/ov5693/atomisp-ov5693.c |  4 +--
 .../staging/media/atomisp/include/hmm/hmm.h   |  2 +-
 .../media/atomisp/include/linux/atomisp.h |  2 +-
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  3 +-
 .../media/atomisp/pci/atomisp_gmin_platform.c |  5 ++--
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  5 ++--
 .../staging/media/atomisp/pci/atomisp_v4l2.c  |  4 ++-
 .../css_2400_system/hive/ia_css_isp_states.c  |  2 +-
 .../css_2401_system/hive/ia_css_isp_configs.c |  1 -
 .../css_2401_system/hive/ia_css_isp_states.c  |  2 +-
 .../pci/css_2401_system/isys_dma_global.h |  1 +
 drivers/staging/media/atomisp/pci/css_trace.h |  1 -
 .../pci/hive_isp_css_common/host/debug.c  |  1 -
 .../hive_isp_css_common/host/debug_private.h  |  1 -
 .../pci/hive_isp_css_include/string_support.h |  1 -
 .../media/atomisp/pci/ia_css_isp_states.h |  2 +-
 .../media/atomisp/pci/ia_css_pipe_public.h|  2 +-
 .../staging/media/atomisp/pci/ia_css_types.h  |  1 -
 .../isp/kernels/anr/anr_2/ia_css_anr2_param.h |  2 +-
 .../pci/isp/kernels/bnlm/ia_css_bnlm.host.c   |  2 +-
 .../macc/macc1_5/ia_css_macc1_5_param.h   |  2 +-
 .../sdis/common/ia_css_sdis_common.host.h |  4 +--
 .../media/atomisp/pci/isp2400_system_local.h  |  5 
 .../media/atomisp/pci/isp2401_system_local.h  |  5 
 .../atomisp/pci/runtime/event/src/event.c |  1 -
 .../atomisp/pci/runtime/frame/src/frame.c |  9 +++---
 drivers/staging/media/atomisp/pci/sh_css.c| 29 ---
 .../staging/media/atomisp/pci/sh_css_defs.h   |  3 --
 .../staging/media/atomisp/pci/sh_css_params.c |  6 +++-
 .../staging/media/atomisp/pci/sh_css_struct.h |  1 +
 35 files changed, 67 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/media/atomisp/TODO 
b/drivers/staging/media/atomisp/TODO
index 9456ffbfe4aa..e58643a9de43 100644
--- a/drivers/staging/media/atomisp/TODO
+++ b/drivers/staging/media/atomisp/TODO
@@ -173,8 +173,8 @@ Limitations
device but can also be extracted from the upgrade kit if you've managed
to lose them somehow.
 
-2. Without a 3A libary the capture behaviour is not very good. To take a good
-   picture, you need tune ISP parameters by IOCTL functions or use a 3A libary
+2. Without a 3A library the capture behaviour is not very good. To take a good
+   picture, you need tune ISP parameters by IOCTL functions or use a 3A library
such as libxcam.
 
 3. The driver is intended to drive the PCI exposed versions of the device.
diff --git a/drivers/staging/media/atomisp/i2c/Kconfig 
b/drivers/staging/media/atomisp/i2c/Kconfig
index f7f7177b9b37..caf712c7d1f2 100644
--- a/drivers/staging/media/atomisp/i2c/Kconfig
+++ b/drivers/staging/media/atomisp/i2c/Kconfig
@@ -57,7 +57,7 @@ config VIDEO_ATOMISP_GC0310
---help---
  This is a Video4Linux2 sensor-level driver for the Galaxycore
  GC0310 0.3MP sensor.
-
+
 config VIDEO_ATOMISP_OV2680
tristate "Omnivision OV2680 sensor support"
depends on ACPI
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c 
b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
index ad1bd7d6a02b..799383b1101d 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-gc0310.c
@@ -1321,7 +1321,6 @@ static int gc0310_probe(struct i2c_client *client)
__func__, acpi_device_bid(adev), acpi_device_hid(adev));
// FIXME: may need to release resources allocated by 
acpi_bus_get_device()
 
-
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c 
b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
index 1b60f6a9c0e0..df6d3f82fba7 100644
--- a/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
+++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2680.c
@@ -703,7 +703,7 @@ static int power_ctrl(struct v4l2_subdev *sd, bool flag)
if (!dev || !dev->platform_data)
return -ENODEV;
 
-   dev_dbg(>dev, "%s: %s", __func__, flag? "on" : "off");
+   dev_dbg(>dev, "%s: %s", __func__, flag ? "on" : "off");
 
if (flag) {
ret |= dev->platform_data->v1p8_ctrl(sd, 1);
diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h 
b/drivers/staging/media/atomisp/i2c/ov2680.h
index 034e1032f6c0..f4e618062e9c 100644
--- a/drivers/staging/media/atomisp/i2c/ov2680.h

[PATCH v2 01/41] media: atomisp: simplify hive_isp_css_mm_hrt wrapper

2020-05-30 Thread Mauro Carvalho Chehab
The code there is a wrapper for hmm/ wrapper. Simplify it,
and get rid of ION-specific code.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/Makefile|  5 --
 .../media/atomisp/include/hmm/hmm_bo.h|  9 ---
 .../staging/media/atomisp/pci/atomisp_acc.c   |  2 +-
 .../staging/media/atomisp/pci/atomisp_ioctl.c | 35 -
 .../media/atomisp/pci/atomisp_subdev.c|  5 --
 .../atomisp/pci/hrt/hive_isp_css_mm_hrt.c | 77 +++
 .../atomisp/pci/hrt/hive_isp_css_mm_hrt.h | 12 ---
 .../media/atomisp/pci/ia_css_memory_access.c  |  1 -
 8 files changed, 13 insertions(+), 133 deletions(-)

diff --git a/drivers/staging/media/atomisp/Makefile 
b/drivers/staging/media/atomisp/Makefile
index c7a55d059425..b48eb7946a58 100644
--- a/drivers/staging/media/atomisp/Makefile
+++ b/drivers/staging/media/atomisp/Makefile
@@ -327,11 +327,6 @@ INCLUDES_cht += \
 #  -I$(atomisp)/pci/css_2401_system/hrt/ \
 #  -I$(atomisp)/pci/css_2401_system/hive_isp_css_2401_system_generated/ \
 
-
-ifeq ($(CONFIG_ION),y)
-INCLUDES += -I$(srctree)/drivers/staging/android/ion
-endif
-
 DEFINES := -DHRT_HW -DHRT_ISP_CSS_CUSTOM_HOST -DHRT_USE_VIR_ADDRS -D__HOST__
 #DEFINES += -DUSE_DYNAMIC_BIN
 #DEFINES += -DISP_POWER_GATING
diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h 
b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
index f847d1de860e..7fcb93b6c0f5 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
@@ -77,9 +77,6 @@ enum hmm_bo_type {
HMM_BO_PRIVATE,
HMM_BO_SHARE,
HMM_BO_USER,
-#ifdef CONFIG_ION
-   HMM_BO_ION,
-#endif
HMM_BO_LAST,
 };
 
@@ -111,9 +108,6 @@ struct hmm_bo_device {
 
/* list lock is used to protect the entire_bo_list */
spinlock_t  list_lock;
-#ifdef CONFIG_ION
-   struct ion_client   *iclient;
-#endif
int flag;
 
/* linked list for entire buffer object */
@@ -142,9 +136,6 @@ struct hmm_buffer_object {
struct hmm_page_object  *page_obj;  /* physical pages */
int from_highmem;
int mmap_count;
-#ifdef CONFIG_ION
-   struct ion_handle   *ihandle;
-#endif
int status;
int mem_type;
void*vmap_addr; /* kernel virtual address by vmap */
diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c 
b/drivers/staging/media/atomisp/pci/atomisp_acc.c
index 21337c23bfa8..bb1f60fab786 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_acc.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c
@@ -355,7 +355,7 @@ int atomisp_acc_map(struct atomisp_sub_device *asd, struct 
atomisp_acc_map *map)
pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE);
cssptr = hrt_isp_css_mm_alloc_user_ptr(map->length,
   map->user_ptr,
-  pgnr, HRT_USR_PTR,
+  pgnr,
   (map->flags & 
ATOMISP_MAP_FLAG_CACHED));
} else {
/* Allocate private buffer. */
diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c 
b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
index 39400a8677aa..8aea90ecd508 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
@@ -1205,41 +1205,6 @@ static int atomisp_qbuf(struct file *file, void *fh, 
struct v4l2_buffer *buf)
}
 
attributes.pgnr = pgnr;
-   attributes.type = HRT_USR_PTR;
-#ifdef CONFIG_ION
-   if (!atomisp_hw_is_isp2401) {
-   if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_ION)
-   attributes.type = HRT_USR_ION;
-   } else {
-   if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_ION) {
-   attributes.type = HRT_USR_ION;
-   if (asd->ion_dev_fd->val !=  ION_FD_UNSET) {
-   dev_dbg(isp->dev, "ION buffer queued, 
share_fd=%lddev_fd=%d.\n",
-   buf->m.userptr, 
asd->ion_dev_fd->val);
-   /*
-   * Make sure the shared fd we just got
-   * from user space isn't larger than
-   * the space we have for it.
-   */
-   if ((buf->m.userptr &
-   (ATOMISP_ION_DEVICE_FD_MASK)) != 0) 
{
-   dev_err(isp->dev,
-   "Error: v4l2 buffer 
fd:0X%0lX > 

[PATCH v2 25/41] media: atomisp: Avoid overflow in compute_blending

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 
Signed-off-by: Mauro Carvalho Chehab 
---
 .../atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c 
b/drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c
index a9db6366d20b..629f07faf20a 100644
--- 
a/drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c
+++ 
b/drivers/staging/media/atomisp/pci/isp/kernels/xnr/xnr_3.0/ia_css_xnr3.host.c
@@ -126,7 +126,7 @@ compute_blending(int strength)
 * exactly as s0.11 fixed point, but -1.0 can.
 */
isp_strength = -(((strength * isp_scale) + offset) / host_scale);
-   return MAX(MIN(isp_strength, 0), -XNR_BLENDING_SCALE_FACTOR);
+   return MAX(MIN(isp_strength, 0), -isp_scale);
 }
 
 void
-- 
2.26.2

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


[PATCH v2 32/41] media: atomisp: don't cause a warn if probe failed

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index c8a6e2d6e498..670382c48034 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -208,6 +208,8 @@ int hmm_init(void)
 
 void hmm_cleanup(void)
 {
+   if (!dummy_ptr)
+   return;
sysfs_remove_group(_dev->kobj, atomisp_attribute_group);
 
/* free dummy memory first */
-- 
2.26.2

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


[PATCH v2 23/41] media: atomisp: Remove unnecessary NULL checks in ia_css_pipe_load_extension

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 (>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 (>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 
Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/sh_css.c | 19 +++
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css.c 
b/drivers/staging/media/atomisp/pci/sh_css.c
index 6e18841db58a..4269c16ad4f1 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -8491,22 +8491,9 @@ ia_css_pipe_load_extension(struct ia_css_pipe *pipe,
}
 
if (firmware->info.isp.type == IA_CSS_ACC_OUTPUT)
-   {
-   if (>output_stage)
-   append_firmware(>output_stage, firmware);
-   else {
-   IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_ERR_INTERNAL_ERROR);
-   return IA_CSS_ERR_INTERNAL_ERROR;
-   }
-   } else if (firmware->info.isp.type == IA_CSS_ACC_VIEWFINDER)
-   {
-   if (>vf_stage)
-   append_firmware(>vf_stage, firmware);
-   else {
-   IA_CSS_LEAVE_ERR_PRIVATE(IA_CSS_ERR_INTERNAL_ERROR);
-   return IA_CSS_ERR_INTERNAL_ERROR;
-   }
-   }
+   append_firmware(>output_stage, firmware);
+   else if (firmware->info.isp.type == IA_CSS_ACC_VIEWFINDER)
+   append_firmware(>vf_stage, firmware);
err = acc_load_extension(firmware);
 
IA_CSS_LEAVE_ERR_PRIVATE(err);
-- 
2.26.2

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


[PATCH v2 11/41] media: atomisp: use Yocto Aero default hmm pool sizes

2020-05-30 Thread Mauro Carvalho Chehab
Yocto Aero driver has a different default for hmm pools.

Use the definitions there.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c 
b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index d795fe49130c..b30a2e54067c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -56,21 +56,21 @@ module_param(skip_fwload, uint, 0644);
 MODULE_PARM_DESC(skip_fwload, "Skip atomisp firmware load");
 
 /* set reserved memory pool size in page */
-static unsigned int repool_pgnr;
+static unsigned int repool_pgnr = 32768;
 module_param(repool_pgnr, uint, 0644);
 MODULE_PARM_DESC(repool_pgnr,
-"Set the reserved memory pool size in page (default:0)");
+"Set the reserved memory pool size in page (default:32768)");
 
 /* set dynamic memory pool size in page */
 unsigned int dypool_pgnr = UINT_MAX;
 module_param(dypool_pgnr, uint, 0644);
 MODULE_PARM_DESC(dypool_pgnr,
-"Set the dynamic memory pool size in page (default:0)");
+"Set the dynamic memory pool size in page (default: 
unlimited)");
 
-bool dypool_enable;
+bool dypool_enable = true;
 module_param(dypool_enable, bool, 0644);
 MODULE_PARM_DESC(dypool_enable,
-"dynamic memory pool enable/disable (default:disable)");
+"dynamic memory pool enable/disable (default:enabled)");
 
 /* memory optimization: deferred firmware loading */
 bool defer_fw_load;
-- 
2.26.2

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


[PATCH v2 17/41] media: atomisp: add debug functions for received events

2020-05-30 Thread Mauro Carvalho Chehab
For debugging purposes, it helps to know what event
was actually received.

Signed-off-by: Mauro Carvalho Chehab 
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
index 5718010a0bf6..f7c3fdd5f670 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
@@ -4523,6 +4523,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
atomisp_css_temp_pipe_to_pipe_id(asd, _event);
switch (current_event.event.type) {
case IA_CSS_EVENT_TYPE_OUTPUT_FRAME_DONE:
+   dev_dbg(isp->dev, "event: Output frame done");
frame_done_found[asd->index] = true;
atomisp_buf_done(asd, 0, 
IA_CSS_BUFFER_TYPE_OUTPUT_FRAME,
 current_event.pipe, true, stream_id);
@@ -4531,6 +4532,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
 
break;
case IA_CSS_EVENT_TYPE_SECOND_OUTPUT_FRAME_DONE:
+   dev_dbg(isp->dev, "event: Second output frame done");
frame_done_found[asd->index] = true;
atomisp_buf_done(asd, 0, 
IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME,
 current_event.pipe, true, stream_id);
@@ -4539,18 +4541,21 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
 
break;
case IA_CSS_EVENT_TYPE_3A_STATISTICS_DONE:
+   dev_dbg(isp->dev, "event: 3A stats frame done");
atomisp_buf_done(asd, 0,
 IA_CSS_BUFFER_TYPE_3A_STATISTICS,
 current_event.pipe,
 false, stream_id);
break;
case IA_CSS_EVENT_TYPE_METADATA_DONE:
+   dev_dbg(isp->dev, "event: metadata frame done");
atomisp_buf_done(asd, 0,
 IA_CSS_BUFFER_TYPE_METADATA,
 current_event.pipe,
 false, stream_id);
break;
case IA_CSS_EVENT_TYPE_VF_OUTPUT_FRAME_DONE:
+   dev_dbg(isp->dev, "event: VF output frame done");
atomisp_buf_done(asd, 0,
 IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME,
 current_event.pipe, true, stream_id);
@@ -4559,6 +4564,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
 
break;
case IA_CSS_EVENT_TYPE_SECOND_VF_OUTPUT_FRAME_DONE:
+   dev_dbg(isp->dev, "event: second VF output frame done");
atomisp_buf_done(asd, 0,
 IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME,
 current_event.pipe, true, stream_id);
@@ -4566,15 +4572,18 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
 
break;
case IA_CSS_EVENT_TYPE_DIS_STATISTICS_DONE:
+   dev_dbg(isp->dev, "event: dis stats frame done");
atomisp_buf_done(asd, 0,
 IA_CSS_BUFFER_TYPE_DIS_STATISTICS,
 current_event.pipe,
 false, stream_id);
break;
case IA_CSS_EVENT_TYPE_PIPELINE_DONE:
+   dev_dbg(isp->dev, "event: pipeline done");
css_pipe_done[asd->index] = true;
break;
case IA_CSS_EVENT_TYPE_ACC_STAGE_COMPLETE:
+   dev_dbg(isp->dev, "event: acc stage done");
atomisp_acc_done(asd, current_event.event.fw_handle);
break;
default:
-- 
2.26.2

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


[PATCH v2 03/41] media: atomisp: reduce abstraction at ia_css_memory_access

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 .../staging/media/atomisp/include/hmm/hmm.h   |  3 -
 .../memory_access/memory_access.h | 61 +--
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  2 +-
 .../media/atomisp/pci/ia_css_memory_access.c  | 45 +-
 .../kernels/sdis/sdis_1.0/ia_css_sdis.host.c  |  2 +-
 .../kernels/sdis/sdis_2/ia_css_sdis2.host.c   |  2 +-
 .../media/atomisp/pci/memory_realloc.c|  3 +-
 .../pci/runtime/debug/src/ia_css_debug.c  |  2 +-
 .../atomisp/pci/runtime/frame/src/frame.c | 23 ---
 .../pci/runtime/isp_param/src/isp_param.c |  2 +-
 .../atomisp/pci/runtime/rmgr/src/rmgr_vbuf.c  |  4 +-
 .../atomisp/pci/runtime/spctrl/src/spctrl.c   |  2 +-
 .../media/atomisp/pci/sh_css_firmware.c   |  2 +-
 .../staging/media/atomisp/pci/sh_css_params.c | 41 +++--
 14 files changed, 51 insertions(+), 143 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/hmm/hmm.h 
b/drivers/staging/media/atomisp/include/hmm/hmm.h
index 254a71442451..e2149b16c9fd 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm.h
@@ -28,9 +28,6 @@
 #include "hmm/hmm_pool.h"
 #include "ia_css_types.h"
 
-#define HMM_CACHED true
-#define HMM_UNCACHED false
-
 int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type);
 void hmm_pool_unregister(enum hmm_pool_type pool_type);
 
diff --git 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
index cdba741dfdf2..c8a41e5d8dab 100644
--- 
a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
+++ 
b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h
@@ -76,37 +76,12 @@
  * within the allocation referencable from the
  * returned pointer/address.
  */
-#define MMGR_ATTRIBUTE_MASK0x000f
 #define MMGR_ATTRIBUTE_CACHED  0x0001
 #define MMGR_ATTRIBUTE_CONTIGUOUS  0x0002
-#define MMGR_ATTRIBUTE_PAGEALIGN   0x0004
 #define MMGR_ATTRIBUTE_CLEARED 0x0008
-#define MMGR_ATTRIBUTE_UNUSED  0xfff0
 
-/* #define MMGR_ATTRIBUTE_DEFAULT  (MMGR_ATTRIBUTE_CACHED) */
-#define MMGR_ATTRIBUTE_DEFAULT 0
-
-extern const hrt_vaddress  mmgr_NULL;
-extern const hrt_vaddress  mmgr_EXCEPTION;
-
-/*! Return the address of an allocation in memory
-
- \paramsize[in]Size in bytes of the allocation
- \paramcaller_func[in] Caller function name
- \paramcaller_line[in] Caller function line number
-
- \return vaddress
- */
-hrt_vaddress mmgr_malloc(const size_t size);
-
-/*! Return the address of a zero initialised allocation in memory
-
- \paramN[in]   Horizontal dimension of array
- \paramsize[in]Vertical dimension of array  Total size 
is N*size
-
- \return vaddress
- */
-hrt_vaddress mmgr_calloc(const size_t N, const size_t size);
+#define mmgr_NULL  ((hrt_vaddress)0)
+#define mmgr_EXCEPTION ((hrt_vaddress)-1)
 
 /*! Return the address of an allocation in memory
 
@@ -119,38 +94,6 @@ hrt_vaddress mmgr_calloc(const size_t N, const size_t size);
 
 hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attribute);
 
-/*! Return the address of a mapped existing allocation in memory
-
- \paramptr[in] Pointer to an allocation in a different
-   virtual memory page table, but the same
-   physical memory
- \param size[in]   Size of the memory of the pointer
- \paramattribute[in]   Bit vector specifying the properties
-   of the allocation
- \param contextPointer of a context provided by
-   client/driver for additional parameters
-   needed by the implementation
- \Note
-   This interface is tentative, limited to the desired function
-   the actual interface may require furhter parameters
-
- \return vaddress
- */
-hrt_vaddress mmgr_mmap(
-const void __user *ptr,
-const size_t size,
-u16 attribute,
-unsigned int pgnr);
-
-/*! Zero initialise an allocation in memory
-
- \paramvaddr[in]   Address of an allocation
- \paramsize[in]Size in bytes of the area to be cleared
-
- \return none
- */
-void mmgr_clear(hrt_vaddress vaddr, const size_t   size);
-
 /*! Read an array of bytes from a virtual memory address
 
  \paramvaddr[in]   Address of an allocation
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 

[PATCH v2 15/41] media: atomisp: add debug for hmm alloc

2020-05-30 Thread Mauro Carvalho Chehab
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 
---
 drivers/staging/media/atomisp/pci/hmm/hmm.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index 5e983442ca80..c8a6e2d6e498 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -253,7 +253,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
goto alloc_page_err;
}
 
-   /* Combind the virtual address and pages togather */
+   /* Combine the virtual address and pages together */
ret = hmm_bo_bind(bo);
if (ret) {
dev_err(atomisp_dev, "hmm_bo_bind failed.\n");
@@ -265,6 +265,10 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
if (attrs & ATOMISP_MAP_FLAG_CLEARED)
hmm_set(bo->start, 0, bytes);
 
+   dev_dbg(atomisp_dev,
+   "%s: pages: 0x%08x (%ld bytes), type: %d from highmem %d, user ptr 
%p, cached %d\n",
+   __func__, bo->start, bytes, type, from_highmem, userptr, cached);
+
return bo->start;
 
 bind_err:
-- 
2.26.2

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


[PATCH v2 14/41] media: atomisp: use pin_user_pages() for memory allocation

2020-05-30 Thread Mauro Carvalho Chehab
Instead of using a hacked version of an old copy of
get_user_pages(), use pin_user_pages().

Signed-off-by: Mauro Carvalho Chehab 
---
 .../media/atomisp/include/hmm/hmm_bo.h|   2 +
 .../staging/media/atomisp/pci/hmm/hmm_bo.c| 145 +++---
 2 files changed, 24 insertions(+), 123 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h 
b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
index 7fcb93b6c0f5..39aea0cb2d33 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
@@ -130,6 +130,8 @@ struct hmm_buffer_object {
struct list_headlist;
struct kref kref;
 
+   struct page **pages;
+
/* mutex protecting this BO */
struct mutexmutex;
enum hmm_bo_typetype;
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c 
b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
index b6dcd246d7af..64bf6b8fc7cc 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
@@ -854,109 +854,20 @@ static void free_private_pages(struct hmm_buffer_object 
*bo,
kfree(bo->page_obj);
 }
 
-/*
- * Hacked from kernel function __get_user_pages in mm/memory.c
- *
- * Handle buffers allocated by other kernel space driver and mmaped into user
- * space, function Ignore the VM_PFNMAP and VM_IO flag in VMA structure
- *
- * Get physical pages from user space virtual address and update into page list
- */
-static int __get_pfnmap_pages(struct task_struct *tsk, struct mm_struct *mm,
- unsigned long start, int nr_pages,
- unsigned int gup_flags, struct page **pages,
- struct vm_area_struct **vmas)
+static void free_user_pages(struct hmm_buffer_object *bo)
 {
-   int i, ret;
-   unsigned long vm_flags;
-
-   if (nr_pages <= 0)
-   return 0;
-
-   VM_BUG_ON(!!pages != !!(gup_flags & FOLL_GET));
-
-   /*
-* Require read or write permissions.
-* If FOLL_FORCE is set, we only require the "MAY" flags.
-*/
-   vm_flags  = (gup_flags & FOLL_WRITE) ?
-   (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
-   vm_flags &= (gup_flags & FOLL_FORCE) ?
-   (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
-   i = 0;
-
-   do {
-   struct vm_area_struct *vma;
-
-   vma = find_vma(mm, start);
-   if (!vma) {
-   dev_err(atomisp_dev, "find_vma failed\n");
-   return i ? : -EFAULT;
-   }
-
-   if (is_vm_hugetlb_page(vma)) {
-   /*
-   i = follow_hugetlb_page(mm, vma, pages, vmas,
-   , _pages, i, gup_flags);
-   */
-   continue;
-   }
-
-   do {
-   struct page *page;
-   unsigned long pfn;
-
-   /*
-* If we have a pending SIGKILL, don't keep faulting
-* pages and potentially allocating memory.
-*/
-   if (unlikely(fatal_signal_pending(current))) {
-   dev_err(atomisp_dev,
-   "fatal_signal_pending in %s\n",
-   __func__);
-   return i ? i : -ERESTARTSYS;
-   }
-
-   ret = follow_pfn(vma, start, );
-   if (ret) {
-   dev_err(atomisp_dev, "follow_pfn() failed\n");
-   return i ? : -EFAULT;
-   }
-
-   page = pfn_to_page(pfn);
-   if (IS_ERR(page))
-   return i ? i : PTR_ERR(page);
-   if (pages) {
-   pages[i] = page;
-   get_page(page);
-   flush_anon_page(vma, page, start);
-   flush_dcache_page(page);
-   }
-   if (vmas)
-   vmas[i] = vma;
-   i++;
-   start += PAGE_SIZE;
-   nr_pages--;
-   } while (nr_pages && start < vma->vm_end);
-   } while (nr_pages);
-
-   return i;
-}
-
-static int get_pfnmap_pages(struct task_struct *tsk, struct mm_struct *mm,
-   unsigned long start, int nr_pages, int write, int 
force,
-   struct page **pages, struct vm_area_struct **vmas)
-{
-   int flags = FOLL_TOUCH;
-
-   if (pages)
-   flags |= FOLL_GET;
-   if (write)
-   flags 

[PATCH v2 26/41] media: atomisp: Remove binary_supports_input_format

2020-05-30 Thread Mauro Carvalho Chehab
From: Nathan Chancellor 

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 
Signed-off-by: Mauro Carvalho Chehab 
---
 .../atomisp/pci/runtime/binary/src/binary.c   | 21 ---
 1 file changed, 21 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c 
b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
index fd4ecd697868..85e8b45d5416 100644
--- a/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
+++ b/drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
@@ -859,18 +859,6 @@ binary_supports_output_format(const struct 
ia_css_binary_xinfo *info,
return false;
 }
 
-#ifdef ISP2401
-static bool
-binary_supports_input_format(const struct ia_css_binary_xinfo *info,
-enum atomisp_input_format format)
-{
-   assert(info);
-   (void)format;
-
-   return true;
-}
-#endif
-
 static bool
 binary_supports_vf_format(const struct ia_css_binary_xinfo *info,
  enum ia_css_frame_format format)
@@ -1701,15 +1689,6 @@ ia_css_binary_find(struct ia_css_binary_descr *descr,

binary_supports_output_format(xcandidate, req_bin_out_info->format));
continue;
}
-#ifdef ISP2401
-   if (!binary_supports_input_format(xcandidate, 
descr->stream_format)) {
-   ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
-   "ia_css_binary_find() [%d] 
continue: !%d\n",
-   __LINE__,
-   
binary_supports_input_format(xcandidate, req_in_info->format));
-   continue;
-   }
-#endif
if (xcandidate->num_output_pins > 1 &&
/* in case we have a second output pin, */
req_vf_info   && /* and we need vf output. 
*/
-- 
2.26.2

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