Skip to contentSkip to conversation

media: atomisp: Misc. cleanups / fixes

PATCH In review Hans de Goede 2 participants 33 messages Nov 20, 2022 – Nov 21, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover media: atomisp: Misc. cleanups / fixes

Hi All,

Here is another round of atomisp cleanups / fixes + preparation work for getting rid of the ugly PCI power-management errors in dmesg when doing (runtime)suspend/resume.

Regards,

Hans

Hans de Goede (20):
media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat
which has exp_id xx' log messages
media: atomisp: Remove accelerator pipe creation code
media: atomisp: Remove unused QOS defines / structure member
media: atomisp: Flush queue on atomisp_css_start() error
media: atomisp: Log an error on failing to alloc private-mem
media: atomisp: Fix deadlock when the /dev/video# node is closed while
still streaming
media: atomisp: Remove 2 unused accelerator mode related functions
media: atomisp: Remove atomisp_css_yuvpp_configure_viewfinder()
function
media: atomisp: Remove unused ia_css_frame_*() functions
media: atomisp: Drop userptr support from hmm
media: atomisp: Remove double atomisp_mrfld_power_down()/_up() calls
from atomisp_reset()
media: atomisp: Remove atomisp_mrfld_power_down()/_up()
media: atomisp: Remove clearing of config from atomisp_css_uninit()
media: atomisp: Remove atomisp_css_suspend()/_resume()
media: atomisp: Remove sw_contex.power_state checks
media: atomisp: Remove duplication between runtime-pm and normal-pm
code
media: atomisp: Move calling of css_[un]init() to power_on()/_off()
media: atomisp: Remove atomisp_ospm_dphy_down() call from probe error
path
media: atomisp: Remove atomisp_ospm_dphy_up()/_down() functions
media: atomisp_ov2680: Fix 1280x720 -> 1296x736 resolution

 drivers/staging/media/atomisp/i2c/ov2680.h    |  46 +-
 .../staging/media/atomisp/include/hmm/hmm.h   |   1 -
 .../media/atomisp/include/hmm/hmm_bo.h        |   2 -
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  76 +--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |   8 +-
 .../media/atomisp/pci/atomisp_compat.h        |  11 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  88 +--
 .../staging/media/atomisp/pci/atomisp_fops.c  |  34 +-
 .../media/atomisp/pci/atomisp_internal.h      |   1 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  80 ++-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 104 +--
 .../pipe/interface/ia_css_pipe_stagedesc.h    |   5 -
 .../pci/camera/pipe/src/pipe_stagedesc.c      |  21 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  19 +-
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    |  54 +-
 .../media/atomisp/pci/ia_css_frame_public.h   |  74 ---
 .../staging/media/atomisp/pci/ia_css_pipe.h   |   3 +-
 .../media/atomisp/pci/ia_css_pipe_public.h    |  69 --
 .../pci/runtime/debug/src/ia_css_debug.c      |   7 -
 .../atomisp/pci/runtime/frame/src/frame.c     | 121 ----
 .../pipeline/interface/ia_css_pipeline.h      |   2 -
 .../pci/runtime/pipeline/src/pipeline.c       |   8 -
 drivers/staging/media/atomisp/pci/sh_css.c    | 608 +-----------------
 .../media/atomisp/pci/sh_css_internal.h       |  13 -
 .../staging/media/atomisp/pci/sh_css_legacy.h |   1 -
 drivers/staging/media/atomisp/pci/sh_css_sp.c |   2 +-
 26 files changed, 121 insertions(+), 1337 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH 1/20 media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat which has exp_id xx' log messages

Standard v4l2 userspace apps do not consume the s3a statistics block data. Until we have a userspace consumer for this (libcamera), which might also involve changing the API for this, lower the log level of these messages to dev_dbg() to avoid them filling up the logs.

---
 drivers/staging/media/atomisp/pci/atomisp_fops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -2
index f3f5b54bd347..21ca276831ce 100644
@@ -181,8 +181,8 @@ static int atomisp_q_one_s3a_buffer(struct atomisp_sub_device *asd,
 	} else {
 		list_add_tail(&s3a_buf->list, &asd->s3a_stats_in_css);
 		if (s3a_list == &asd->s3a_stats_ready)
-			dev_warn(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
-				 __func__, exp_id);
+			dev_dbg(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
+				__func__, exp_id);
 	}
 
 	asd->s3a_bufs_in_css[css_pipe_id]++;
Signature · 1 line
2.38.1
maintainer
#2 lore raw

Re: [PATCH 01/20] media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat which has exp_id xx' log messages

Quoted 4 lines · Hans de Goede

Standard v4l2 userspace apps do not consume the s3a statistics block data. Until we have a userspace consumer for this (libcamera), which might also involve changing the API for this, lower the log level of these messages to dev_dbg() to avoid them filling up the logs.

...

drivers/staging/media/atomisp/pci/atomisp_fops.c static int atomisp_q_one_s3a_buffer(struct atomisp_sub_device *asd, · line 185

Quoted 4 lines
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -2
-			dev_warn(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
-				 __func__, exp_id);
+			dev_dbg(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
+				__func__, exp_id);

Please, drop __func__ as well. Most probably this can be run on the systems with Dynamic Debug enabled, meaning that __func__ and __LINE__ can be enabled at runtime.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH 01/20] media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat which has exp_id xx' log messages

Hi,

Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Hans de Goede

Standard v4l2 userspace apps do not consume the s3a statistics block data. Until we have a userspace consumer for this (libcamera), which might also involve changing the API for this, lower the log level of these messages to dev_dbg() to avoid them filling up the logs.

...

Quoted 8 lines

drivers/staging/media/atomisp/pci/atomisp_fops.c static int atomisp_q_one_s3a_buffer(struct atomisp_sub_device *asd, · line 185

Quoted 4 lines
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -2
-			dev_warn(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
-				 __func__, exp_id);
+			dev_dbg(asd->isp->dev, "%s: drop one s3a stat which has exp_id %d!\n",
+				__func__, exp_id);

Please, drop __func__ as well. Most probably this can be run on the systems with Dynamic Debug enabled, meaning that __func__ and __LINE__ can be enabled at runtime.

Fixed in my media-atomisp branch.

Regards,

Hans

#4 lore raw

PATCH 2/20 media: atomisp: Remove accelerator pipe creation code

In reply to Hans de Goede

The ATOMISP_ACC_* custom ioctls and the ACC device node have been removed in commit a5c17adbadcb ("media: atomisp: Remove the ACC device node").

This means that pipe_configs[pipe_id].acc_extension now never gets set which causes atomisp_compat_css20.c: __create_pipe() to always skip creation of pipes with a pipe_id of IA_CSS_PIPE_ID_ACC / a mode of IA_CSS_PIPE_MODE_ACC.

This allows removing of the acc_pipe creation / handling code from mainly sh_css.c and a bunch of other places.

---
 .../media/atomisp/pci/atomisp_compat_css20.c  |  27 +-
 .../staging/media/atomisp/pci/ia_css_pipe.h   |   3 +-
 .../media/atomisp/pci/ia_css_pipe_public.h    |  69 --
 .../pci/runtime/debug/src/ia_css_debug.c      |   7 -
 .../pci/runtime/pipeline/src/pipeline.c       |   8 -
 drivers/staging/media/atomisp/pci/sh_css.c    | 599 +-----------------
 .../media/atomisp/pci/sh_css_internal.h       |   1 -
 .../staging/media/atomisp/pci/sh_css_legacy.h |   1 -
 8 files changed, 6 insertions(+), 709 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -25
index f282572d69da..c59f9e6b1e2b 100644
@@ -236,18 +236,6 @@ static void __dump_pipe_config(struct atomisp_sub_device *asd,
 		dev_dbg(isp->dev,
 			"pipe_config.isp_pipe_version:%d.\n",
 			p_config->isp_pipe_version);
-		dev_dbg(isp->dev,
-			"pipe_config.acc_extension=%p.\n",
-			p_config->acc_extension);
-		dev_dbg(isp->dev,
-			"pipe_config.acc_stages=%p.\n",
-			p_config->acc_stages);
-		dev_dbg(isp->dev,
-			"pipe_config.num_acc_stages=%d.\n",
-			p_config->num_acc_stages);
-		dev_dbg(isp->dev,
-			"pipe_config.acc_num_execs=%d.\n",
-			p_config->acc_num_execs);
 		dev_dbg(isp->dev,
 			"pipe_config.default_capture_config.capture_mode=%d.\n",
 			p_config->default_capture_config.mode);
@@ -629,10 +617,6 @@ static void __apply_additional_pipe_config(
 		else
 			stream_env->pipe_configs[pipe_id].enable_dz = false;
 		break;
-	case IA_CSS_PIPE_ID_ACC:
-		stream_env->pipe_configs[pipe_id].mode = IA_CSS_PIPE_MODE_ACC;
-		stream_env->pipe_configs[pipe_id].enable_dz = false;
-		break;
 	default:
 		break;
 	}
@@ -644,7 +628,7 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 	if (!asd)
 		return false;
 
-	if (pipe_id == IA_CSS_PIPE_ID_ACC || pipe_id == IA_CSS_PIPE_ID_YUVPP)
+	if (pipe_id == IA_CSS_PIPE_ID_YUVPP)
 		return true;
 
 	if (asd->vfpp) {
@@ -718,12 +702,7 @@ static int __create_pipe(struct atomisp_sub_device *asd,
 	if (pipe_id >= IA_CSS_PIPE_ID_NUM)
 		return -EINVAL;
 
-	if (pipe_id != IA_CSS_PIPE_ID_ACC &&
-	    !stream_env->pipe_configs[pipe_id].output_info[0].res.width)
-		return 0;
-
-	if (pipe_id == IA_CSS_PIPE_ID_ACC &&
-	    !stream_env->pipe_configs[pipe_id].acc_extension)
+	if (!stream_env->pipe_configs[pipe_id].output_info[0].res.width)
 		return 0;
 
 	if (!is_pipe_valid_to_current_run_mode(asd, pipe_id))
@@ -2141,8 +2120,6 @@ static enum ia_css_pipe_mode __pipe_id_to_pipe_mode(
 		return IA_CSS_PIPE_MODE_CAPTURE;
 	case IA_CSS_PIPE_ID_VIDEO:
 		return IA_CSS_PIPE_MODE_VIDEO;
-	case IA_CSS_PIPE_ID_ACC:
-		return IA_CSS_PIPE_MODE_ACC;
 	case IA_CSS_PIPE_ID_YUVPP:
 		return IA_CSS_PIPE_MODE_YUVPP;
 	default:
drivers/staging/media/atomisp/pci/ia_css_pipe.h +1 -2
index fb58535bff40..22522968b9e6 100644
@@ -37,7 +37,6 @@ struct ia_css_preview_settings {
 
 	struct ia_css_pipe *copy_pipe;
 	struct ia_css_pipe *capture_pipe;
-	struct ia_css_pipe *acc_pipe;
 };
 
 #define IA_CSS_DEFAULT_PREVIEW_SETTINGS { \
@@ -156,7 +155,7 @@ 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) */ \
+	.mode			= IA_CSS_PIPE_ID_VIDEO, /* (pipe_id) */ \
 	.pipeline		= DEFAULT_PIPELINE, \
 	.output_info		= {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
 	.bds_output_info	= IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
drivers/staging/media/atomisp/pci/ia_css_pipe_public.h +0 -69

110 lines not on this page · raw message

drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +0 -7
index c10c2c598179..bb6204cb42c5 100644
@@ -133,7 +133,6 @@ static const char *const pipe_id_to_str[] = {
 	/* [IA_CSS_PIPE_ID_VIDEO]     =*/ "video",
 	/* [IA_CSS_PIPE_ID_CAPTURE]   =*/ "capture",
 	/* [IA_CSS_PIPE_ID_YUVPP]     =*/ "yuvpp",
-	/* [IA_CSS_PIPE_ID_ACC]       =*/ "accelerator"
 };
 
 static char dot_id_input_bin[SH_CSS_MAX_BINARY_NAME + 10];
@@ -2989,16 +2988,10 @@ ia_css_debug_dump_pipe_config(
 		ia_css_debug_dump_frame_info(&config->vf_output_info[i],
 					     "vf_output_info");
 	}
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "acc_extension: %p\n",
-			    config->acc_extension);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "num_acc_stages: %d\n",
-			    config->num_acc_stages);
 	ia_css_debug_dump_capture_config(&config->default_capture_config);
 	ia_css_debug_dump_resolution(&config->dvs_envelope, "dvs_envelope");
 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "dvs_frame_delay: %d\n",
 			    config->dvs_frame_delay);
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "acc_num_execs: %d\n",
-			    config->acc_num_execs);
 	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "enable_dz: %d\n",
 			    config->enable_dz);
 	IA_CSS_LEAVE_PRIVATE("");
drivers/staging/media/atomisp/pci/runtime/pipeline/src/pipeline.c +0 -8
index dfc50247ea8e..e9e187649a65 100644
@@ -774,14 +774,6 @@ ia_css_pipeline_configure_inout_port(struct ia_css_pipeline *me,
 					    (uint8_t)SH_CSS_PORT_OUTPUT,
 					    (uint8_t)SH_CSS_HOST_TYPE, 1);
 		break;
-	case IA_CSS_PIPE_ID_ACC:
-		SH_CSS_PIPE_PORT_CONFIG_SET(me->inout_port_config,
-					    (uint8_t)SH_CSS_PORT_INPUT,
-					    (uint8_t)SH_CSS_HOST_TYPE, 1);
-		SH_CSS_PIPE_PORT_CONFIG_SET(me->inout_port_config,
-					    (uint8_t)SH_CSS_PORT_OUTPUT,
-					    (uint8_t)SH_CSS_HOST_TYPE, 1);
-		break;
 	default:
 		break;
 	}
drivers/staging/media/atomisp/pci/sh_css.c +3 -596

871 lines not on this page · raw message

drivers/staging/media/atomisp/pci/sh_css_internal.h +0 -1
index 435b3cedd1c3..98267707a5fc 100644
@@ -497,7 +497,6 @@ ia_css_metadata_free_multiple(unsigned int num_bufs,
 #define SH_CSS_QOS_STAGE_IS_ALL_DISABLED(pipe) ((pipe)->pipe_qos_config == QOS_ALL_STAGES_DISABLED)
 #define SH_CSS_QOS_MODE_PIPE_ADD(mode, pipe)    ((mode) |= (0x1 << (pipe)->pipe_id))
 #define SH_CSS_QOS_MODE_PIPE_REMOVE(mode, pipe) ((mode) &= ~(0x1 << (pipe)->pipe_id))
-#define SH_CSS_IS_QOS_ONLY_MODE(mode)           ((mode) == (0x1 << IA_CSS_PIPE_ID_ACC))
 
 /* Information for a pipeline */
 struct sh_css_sp_pipeline {
drivers/staging/media/atomisp/pci/sh_css_legacy.h +0 -1
index 567c8d6dcc2c..cdf239b070a8 100644
@@ -32,7 +32,6 @@ enum ia_css_pipe_id {
 	IA_CSS_PIPE_ID_VIDEO,
 	IA_CSS_PIPE_ID_CAPTURE,
 	IA_CSS_PIPE_ID_YUVPP,
-	IA_CSS_PIPE_ID_ACC,
 	IA_CSS_PIPE_ID_NUM
 };
 
Signature · 1 line
2.38.1
#5 lore raw

PATCH 3/20 media: atomisp: Remove unused QOS defines / structure member

In reply to Hans de Goede

Withe the accel code gone this is unused, remove it.

---
 .../pci/runtime/pipeline/interface/ia_css_pipeline.h     | 2 --
 drivers/staging/media/atomisp/pci/sh_css_internal.h      | 9 ---------
 drivers/staging/media/atomisp/pci/sh_css_sp.c            | 2 +-
 3 files changed, 1 insertion(+), 12 deletions(-)
drivers/staging/media/atomisp/pci/runtime/pipeline/interface/ia_css_pipeline.h +0 -2
index de2c526a58ae..222c381ff3b9 100644
@@ -54,7 +54,6 @@ struct ia_css_pipeline {
 	unsigned int inout_port_config;
 	int num_execs;
 	bool acquire_isp_each_stage;
-	u32 pipe_qos_config;
 };
 
 #define DEFAULT_PIPELINE { \
@@ -65,7 +64,6 @@ struct ia_css_pipeline {
 	.dvs_frame_delay	= IA_CSS_FRAME_DELAY_1, \
 	.num_execs		= -1, \
 	.acquire_isp_each_stage	= true, \
-	.pipe_qos_config	= QOS_INVALID \
 }
 
 /* Stage descriptor used to create a new stage in the pipeline */
drivers/staging/media/atomisp/pci/sh_css_internal.h +0 -9
index 98267707a5fc..0441d4fec551 100644
@@ -488,15 +488,6 @@ ia_css_metadata_free_multiple(unsigned int num_bufs,
 
 /* Macro for handling pipe_qos_config */
 #define QOS_INVALID                  (~0U)
-#define QOS_ALL_STAGES_DISABLED      (0U)
-#define QOS_STAGE_MASK(num)          (0x00000001 << num)
-#define SH_CSS_IS_QOS_PIPE(pipe)               ((pipe)->pipe_qos_config != QOS_INVALID)
-#define SH_CSS_QOS_STAGE_ENABLE(pipe, num)     ((pipe)->pipe_qos_config |= QOS_STAGE_MASK(num))
-#define SH_CSS_QOS_STAGE_DISABLE(pipe, num)    ((pipe)->pipe_qos_config &= ~QOS_STAGE_MASK(num))
-#define SH_CSS_QOS_STAGE_IS_ENABLED(pipe, num) ((pipe)->pipe_qos_config & QOS_STAGE_MASK(num))
-#define SH_CSS_QOS_STAGE_IS_ALL_DISABLED(pipe) ((pipe)->pipe_qos_config == QOS_ALL_STAGES_DISABLED)
-#define SH_CSS_QOS_MODE_PIPE_ADD(mode, pipe)    ((mode) |= (0x1 << (pipe)->pipe_id))
-#define SH_CSS_QOS_MODE_PIPE_REMOVE(mode, pipe) ((mode) &= ~(0x1 << (pipe)->pipe_id))
 
 /* Information for a pipeline */
 struct sh_css_sp_pipeline {
drivers/staging/media/atomisp/pci/sh_css_sp.c +1 -1
index c301298b8ee4..0dd58a7fe2cc 100644
@@ -1266,7 +1266,7 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me,
 	sh_css_sp_group.pipe[thread_id].thread_id = thread_id;
 	sh_css_sp_group.pipe[thread_id].pipe_num = pipe_num;
 	sh_css_sp_group.pipe[thread_id].num_execs = me->num_execs;
-	sh_css_sp_group.pipe[thread_id].pipe_qos_config = me->pipe_qos_config;
+	sh_css_sp_group.pipe[thread_id].pipe_qos_config = QOS_INVALID;
 	sh_css_sp_group.pipe[thread_id].required_bds_factor = required_bds_factor;
 	sh_css_sp_group.pipe[thread_id].input_system_mode
 	= (uint32_t)input_mode;
Signature · 1 line
2.38.1
#6 lore raw

PATCH 4/20 media: atomisp: Flush queue on atomisp_css_start() error

In reply to Hans de Goede

I managed to trigger an atomisp_css_start() error by pushing my test system towards an OOM situation, this triggered the following WARN_ON() in __vb2_queue_cancel() in videobuf2-core.c:

/*
* If you see this warning, then the driver isn't cleaning up properly
* after a failed start_streaming(). See the start_streaming()
* documentation in videobuf2-core.h for more information how buffers
* should be returned to vb2 in start_streaming().
*/
if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {

Fix this by calling atomisp_flush_video_pipe() to return any queued buffers back to the videobuf2-core on an atomisp_css_start() error.

---
 drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +3 -1
index 83710af7690f..43e899457b91 100644
@@ -1353,8 +1353,10 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)
 	asd->params.dvs_6axis = NULL;
 
 	ret = atomisp_css_start(asd, css_pipe_id, false);
-	if (ret)
+	if (ret) {
+		atomisp_flush_video_pipe(pipe, true);
 		goto out_unlock;
+	}
 
 	spin_lock_irqsave(&isp->lock, irqflags);
 	asd->streaming = ATOMISP_DEVICE_STREAMING_ENABLED;
Signature · 1 line
2.38.1
#7 lore raw

PATCH 5/20 media: atomisp: Log an error on failing to alloc private-mem

In reply to Hans de Goede

I managed to trigger an atomisp_css_start() error by pushing my test system towards an OOM situation, this resulted in the following errors:

atomisp-isp2 0000:00:03.0: alloc pages err... atomisp-isp2 0000:00:03.0: hmm_bo_alloc_pages failed. atomisp-isp2 0000:00:03.0: stream[0] start error.

But it is not entirely clear what the root cause of the "alloc pages err..." error is. I suspect the root cause is alloc_pages_bulk_array() failing. Add a log message to make the root cause more clear if this is hit again.

---
 drivers/staging/media/atomisp/pci/hmm/hmm_bo.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +1 -0
index 465ba837f2ed..3c150268db51 100644
@@ -637,6 +637,7 @@ static int alloc_private_pages(struct hmm_buffer_object *bo)
 
 	ret = alloc_pages_bulk_array(gfp, bo->pgnr, bo->pages);
 	if (ret != bo->pgnr) {
+		dev_err(atomisp_dev, "alloc_pages_bulk_array() failed\n");
 		free_pages_bulk_array(ret, bo->pages);
 		return -ENOMEM;
 	}
Signature · 1 line
2.38.1
maintainer
#8 lore raw

Re: [PATCH 05/20] media: atomisp: Log an error on failing to alloc private-mem

Quoted 11 lines · Hans de Goede

I managed to trigger an atomisp_css_start() error by pushing my test system towards an OOM situation, this resulted in the following errors:

atomisp-isp2 0000:00:03.0: alloc pages err... atomisp-isp2 0000:00:03.0: hmm_bo_alloc_pages failed. atomisp-isp2 0000:00:03.0: stream[0] start error.

But it is not entirely clear what the root cause of the "alloc pages err..." error is. I suspect the root cause is alloc_pages_bulk_array() failing. Add a log message to make the root cause more clear if this is hit again.

...

drivers/staging/media/atomisp/pci/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo) · line 640

Quoted 1 line
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +1 -0
+		dev_err(atomisp_dev, "alloc_pages_bulk_array() failed\n");

I would put it after calling the below function, but I'm not sure about side effects (if the below can hang or something else).

Quoted 2 lines
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +0 -0
 		free_pages_bulk_array(ret, bo->pages);
 		return -ENOMEM;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 05/20] media: atomisp: Log an error on failing to alloc private-mem

Hi,

Quoted 13 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede

I managed to trigger an atomisp_css_start() error by pushing my test system towards an OOM situation, this resulted in the following errors:

atomisp-isp2 0000:00:03.0: alloc pages err... atomisp-isp2 0000:00:03.0: hmm_bo_alloc_pages failed. atomisp-isp2 0000:00:03.0: stream[0] start error.

But it is not entirely clear what the root cause of the "alloc pages err..." error is. I suspect the root cause is alloc_pages_bulk_array() failing. Add a log message to make the root cause more clear if this is hit again.

Quoted 10 lines

...

drivers/staging/media/atomisp/pci/hmm/hmm_bo.c static int alloc_private_pages(struct hmm_buffer_object *bo) · line 640

Quoted 1 line
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +1 -0
+		dev_err(atomisp_dev, "alloc_pages_bulk_array() failed\n");

I would put it after calling the below function, but I'm not sure about side effects (if the below can hang or something else).

Quoted 2 lines
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +0 -0
 		free_pages_bulk_array(ret, bo->pages);
 		return -ENOMEM;

Fixed in my media-atomisp branch.

Regards,

Hans

#10 lore raw

PATCH 6/20 media: atomisp: Fix deadlock when the /dev/video# node is closed while still streaming

In reply to Hans de Goede

atomisp_release() was taking pipe->vb_queue_mutex + isp->mutex at the same time. But if the /dev/video# node is closed while still streaming then vb2_queue_release() will call atomisp_stop_streaming() which takes isp->mutex itself, leading to a deadlock.

To fix this only take isp->mutex after cleaning up the v4l2_fh / the vb2_queue. While at it switch to vb2_fop_release() which will take pipe->vb_queue_mutex for us, which also resolves a FIXME comment.

---
 .../staging/media/atomisp/pci/atomisp_fops.c  | 21 +++++--------------
 1 file changed, 5 insertions(+), 16 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +5 -16
index 21ca276831ce..8cff26d42b82 100644
@@ -861,23 +861,14 @@ static int atomisp_release(struct file *file)
 
 	v4l2_fh_init(&fh.vfh, vdev);
 
-	mutex_lock(&pipe->vb_queue_mutex);
-	mutex_lock(&isp->mutex);
-
 	dev_dbg(isp->dev, "release device %s\n", vdev->name);
 
 	asd->subdev.devnode = vdev;
 
-	/*
-	 * FIXME This if is copied from _vb2_fop_release, this cannot use that
-	 * because that calls v4l2_fh_release() earlier then this function.
-	 * Maybe we can release the fh earlier though, it does not look like
-	 * anything needs it after this.
-	 */
-	if (file->private_data == vdev->queue->owner) {
-		vb2_queue_release(vdev->queue);
-		vdev->queue->owner = NULL;
-	}
+	/* Note file must not be used after this! */
+	vb2_fop_release(file);
+
+	mutex_lock(&isp->mutex);
 
 	pipe->users--;
 	if (pipe->users)
@@ -940,9 +931,7 @@ static int atomisp_release(struct file *file)
 				     V4L2_SEL_TGT_COMPOSE, 0,
 				     &clear_compose);
 	mutex_unlock(&isp->mutex);
-	mutex_unlock(&pipe->vb_queue_mutex);
-
-	return v4l2_fh_release(file);
+	return 0;
 }
 
 const struct v4l2_file_operations atomisp_fops = {
Signature · 1 line
2.38.1
#11 lore raw

PATCH 7/20 media: atomisp: Remove 2 unused accelerator mode related functions

In reply to Hans de Goede

Remove ia_css_pipe_get_acc_stage_desc() and sh_css_flush(), after removing the accelerator /dev/video# node and related ioctls these are no longer used.

---
 .../pipe/interface/ia_css_pipe_stagedesc.h    |  5 -----
 .../pci/camera/pipe/src/pipe_stagedesc.c      | 21 -------------------
 drivers/staging/media/atomisp/pci/sh_css.c    |  9 --------
 .../media/atomisp/pci/sh_css_internal.h       |  3 ---
 4 files changed, 38 deletions(-)
drivers/staging/media/atomisp/pci/camera/pipe/interface/ia_css_pipe_stagedesc.h +0 -5
index 40c8145a0797..7a0c988d89ee 100644
@@ -38,11 +38,6 @@ void ia_css_pipe_get_firmwares_stage_desc(
     const struct ia_css_fw_info *fw,
     unsigned int mode);
 
-void ia_css_pipe_get_acc_stage_desc(
-    struct ia_css_pipeline_stage_desc *stage_desc,
-    struct ia_css_binary *binary,
-    struct ia_css_fw_info *fw);
-
 void ia_css_pipe_get_sp_func_stage_desc(
     struct ia_css_pipeline_stage_desc *stage_desc,
     struct ia_css_frame *out_frame,
drivers/staging/media/atomisp/pci/camera/pipe/src/pipe_stagedesc.c +0 -21
index 82a24aabe8ce..6c93fa1c683b 100644
@@ -74,27 +74,6 @@ void ia_css_pipe_get_firmwares_stage_desc(
 	stage_desc->vf_frame = vf_frame;
 }
 
-void ia_css_pipe_get_acc_stage_desc(
-    struct ia_css_pipeline_stage_desc *stage_desc,
-    struct ia_css_binary *binary,
-    struct ia_css_fw_info *fw)
-{
-	unsigned int i;
-
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE,
-			    "ia_css_pipe_get_acc_stage_desc() enter:\n");
-	stage_desc->binary = binary;
-	stage_desc->firmware = fw;
-	stage_desc->sp_func = IA_CSS_PIPELINE_NO_FUNC;
-	stage_desc->max_input_width = 0;
-	stage_desc->mode = IA_CSS_BINARY_MODE_VF_PP;
-	stage_desc->in_frame = NULL;
-	for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
-		stage_desc->out_frame[i] = NULL;
-	}
-	stage_desc->vf_frame = NULL;
-}
-
 void ia_css_pipe_get_sp_func_stage_desc(
     struct ia_css_pipeline_stage_desc *stage_desc,
     struct ia_css_frame *out_frame,
drivers/staging/media/atomisp/pci/sh_css.c +0 -9
index 33348a43c1de..726cb7aa4ecd 100644
@@ -1629,15 +1629,6 @@ ia_css_enable_isys_event_queue(bool enable)
 	return 0;
 }
 
-/* For Acceleration API: Flush FW (shared buffer pointer) arguments */
-void
-sh_css_flush(struct ia_css_acc_fw *fw)
-{
-	ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "sh_css_flush() enter:\n");
-	if ((fw) && (my_css.flush))
-		my_css.flush(fw);
-}
-
 /*
  * Mapping sp threads. Currently, this is done when a stream is created and
  * pipelines are ready to be converted to sp pipelines. Be careful if you are
drivers/staging/media/atomisp/pci/sh_css_internal.h +0 -3
index 0441d4fec551..d98f1323441e 100644
@@ -897,9 +897,6 @@ sh_css_params_init(void);
 void
 sh_css_params_uninit(void);
 
-/* For Acceleration API: Flush FW (shared buffer pointer) arguments */
-void sh_css_flush(struct ia_css_acc_fw *fw);
-
 void
 sh_css_binary_args_reset(struct sh_css_binary_args *args);
 
Signature · 1 line
2.38.1
#12 lore raw

PATCH 8/20 media: atomisp: Remove atomisp_css_yuvpp_configure_viewfinder() function

In reply to Hans de Goede

Remove atomisp_css_yuvpp_configure_viewfinder(), it is not used anywhere.

---
 .../media/atomisp/pci/atomisp_compat.h        |  7 ------
 .../media/atomisp/pci/atomisp_compat_css20.c  | 23 -------------------
 2 files changed, 30 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat.h +0 -7
index d1893a0deec1..f73801197dd7 100644
@@ -257,13 +257,6 @@ int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd,
 				       unsigned int padded_width,
 				       enum ia_css_frame_format format);
 
-int atomisp_css_yuvpp_configure_viewfinder(
-    struct atomisp_sub_device *asd,
-    unsigned int stream_index,
-    unsigned int width, unsigned int height,
-    unsigned int min_width,
-    enum ia_css_frame_format format);
-
 int atomisp_css_yuvpp_get_output_frame_info(
     struct atomisp_sub_device *asd,
     unsigned int stream_index,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -23
index c59f9e6b1e2b..adf77c9e481e 100644
@@ -2742,29 +2742,6 @@ int atomisp_css_yuvpp_configure_output(struct atomisp_sub_device *asd,
 	return 0;
 }
 
-int atomisp_css_yuvpp_configure_viewfinder(
-    struct atomisp_sub_device *asd,
-    unsigned int stream_index,
-    unsigned int width, unsigned int height,
-    unsigned int min_width,
-    enum ia_css_frame_format format)
-{
-	struct atomisp_stream_env *stream_env =
-		    &asd->stream_env[stream_index];
-	enum ia_css_pipe_id pipe_id = IA_CSS_PIPE_ID_YUVPP;
-
-	stream_env->pipe_configs[pipe_id].mode =
-	    __pipe_id_to_pipe_mode(asd, pipe_id);
-	stream_env->update_pipe[pipe_id] = true;
-
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.width = width;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].res.height = height;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].format = format;
-	stream_env->pipe_configs[pipe_id].vf_output_info[0].padded_width =
-	    min_width;
-	return 0;
-}
-
 int atomisp_css_yuvpp_get_output_frame_info(
     struct atomisp_sub_device *asd,
     unsigned int stream_index,
Signature · 1 line
2.38.1
#13 lore raw

PATCH 9/20 media: atomisp: Remove unused ia_css_frame_*() functions

In reply to Hans de Goede

After the conversion to videobuf2 a bunch of ia_css_frame_*() functions are unused, remove them.

---
 .../media/atomisp/pci/ia_css_frame_public.h   |  74 -----------
 .../atomisp/pci/runtime/frame/src/frame.c     | 121 ------------------
 2 files changed, 195 deletions(-)
drivers/staging/media/atomisp/pci/ia_css_frame_public.h +0 -74
index 32d6d9699c37..7ba464abf447 100644
@@ -205,15 +205,6 @@ struct ia_css_frame {
 	.flash_state		= IA_CSS_FRAME_FLASH_STATE_NONE, \
 }
 
-/* @brief Fill a frame with zeros
- *
- * @param	frame		The frame.
- * @return	None
- *
- * Fill a frame with pixel values of zero
- */
-void ia_css_frame_zero(struct ia_css_frame *frame);
-
 /* @brief Allocate a CSS frame structure
  *
  * @param	frame		The allocated frame.
@@ -270,71 +261,6 @@ ia_css_frame_allocate_from_info(struct ia_css_frame **frame,
 void
 ia_css_frame_free(struct ia_css_frame *frame);
 
-/* @brief Allocate a CSS frame structure using a frame info structure.
- *
- * @param	frame	The allocated frame.
- * @param[in]	info	The frame info structure.
- * @return		The error code.
- *
- * Allocate an empty CSS frame with no data buffer using the parameters
- * in the frame info.
- */
-int
-ia_css_frame_create_from_info(struct ia_css_frame **frame,
-			      const struct ia_css_frame_info *info);
-
-/* @brief Set a mapped data buffer to a CSS frame
- *
- * @param[in]	frame       Valid CSS frame pointer
- * @param[in]	mapped_data  Mapped data buffer to be assigned to the CSS frame
- * @param[in]	data_size_bytes  Size of the mapped_data in bytes
- * @return      The error code.
- *
- * Sets a mapped data buffer to this frame. This function can be called multiple
- * times with different buffers or NULL to reset the data pointer. This API
- * would not try free the mapped_data and its the callers responsiblity to
- * free the mapped_data buffer. However if ia_css_frame_free() is called and
- * the frame had a valid data buffer, it would be freed along with the frame.
- */
-int
-ia_css_frame_set_data(struct ia_css_frame *frame,
-		      const ia_css_ptr   mapped_data,
-		      size_t data_size_bytes);
-
-/* @brief Map an existing frame data pointer to a CSS frame.
- *
- * @param	frame		Pointer to the frame to be initialized
- * @param[in]	info		The frame info.
- * @param[in]	data		Pointer to the allocated frame data.
- * @param[in]	attribute	Attributes to be passed to mmgr_mmap.
- * @param[in]	context		Pointer to the a context to be passed to mmgr_mmap.
- * @return			The allocated frame structure.
- *
- * This function maps a pre-allocated pointer into a CSS frame. This can be
- * used when an upper software layer is responsible for allocating the frame
- * data and it wants to share that frame pointer with the CSS code.
- * This function will fill the CSS frame structure just like
- * ia_css_frame_allocate() does, but instead of allocating the memory, it will
- * map the pre-allocated memory into the CSS address space.
- */
-int
-ia_css_frame_map(struct ia_css_frame **frame,
-		 const struct ia_css_frame_info *info,
-		 const void __user *data,
-		 unsigned int pgnr);
-
-/* @brief Unmap a CSS frame structure.
- *
- * @param[in]	frame	Pointer to the CSS frame.
- * @return	None
- *
- * This function unmaps the frame data pointer within a CSS frame and
- * then frees the CSS frame structure. Use this for frame pointers created
- * using ia_css_frame_map().
- */
-void
-ia_css_frame_unmap(struct ia_css_frame *frame);
-
 static inline const struct ia_css_frame_info *
 ia_css_frame_get_info(const struct ia_css_frame *frame)
 {
drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c +0 -121

133 lines not on this page · raw message

Signature · 1 line
2.38.1
#14 lore raw

PATCH 10/20 media: atomisp: Drop userptr support from hmm

In reply to Hans de Goede

After the conversion to videobuf2 userptr support is no longer needed, drop it.

---
 .../staging/media/atomisp/include/hmm/hmm.h   |  1 -
 .../media/atomisp/include/hmm/hmm_bo.h        |  2 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   | 19 +++----
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 53 +------------------
 4 files changed, 7 insertions(+), 68 deletions(-)
drivers/staging/media/atomisp/include/hmm/hmm.h +0 -1
index b81b8580d405..2bc323b34f89 100644
@@ -37,7 +37,6 @@ int hmm_init(void);
 void hmm_cleanup(void);
 
 ia_css_ptr hmm_alloc(size_t bytes);
-ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr);
 ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr);
 
 void hmm_free(ia_css_ptr ptr);
drivers/staging/media/atomisp/include/hmm/hmm_bo.h +0 -2
index a51d89f0b5cc..b4c03e0ca9c0 100644
@@ -74,7 +74,6 @@
 enum hmm_bo_type {
 	HMM_BO_PRIVATE,
 	HMM_BO_VMALLOC,
-	HMM_BO_USER,
 	HMM_BO_LAST,
 };
 
@@ -208,7 +207,6 @@ int hmm_bo_allocated(struct hmm_buffer_object *bo);
  */
 int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
 		       enum hmm_bo_type type,
-		       const void __user *userptr,
 		       void *vmalloc_addr);
 void hmm_bo_free_pages(struct hmm_buffer_object *bo);
 int hmm_bo_page_allocated(struct hmm_buffer_object *bo);
drivers/staging/media/atomisp/pci/hmm/hmm.c +6 -13
index a262477104fc..e266628be332 100644
@@ -42,9 +42,8 @@ static bool hmm_initialized;
 /*
  * p: private
  * v: vmalloc
- * u: user
  */
-static const char hmm_bo_type_string[] = "pvu";
+static const char hmm_bo_type_string[] = "pv";
 
 static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
 		       char *buf, struct list_head *bo_list, bool active)
@@ -168,7 +167,6 @@ void hmm_cleanup(void)
 }
 
 static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
-			      const void __user *userptr,
 			      void *vmalloc_addr)
 {
 	unsigned int pgnr;
@@ -193,7 +191,7 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 	}
 
 	/* Allocate pages for memory */
-	ret = hmm_bo_alloc_pages(bo, type, userptr, vmalloc_addr);
+	ret = hmm_bo_alloc_pages(bo, type, vmalloc_addr);
 	if (ret) {
 		dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
 		goto alloc_page_err;
@@ -207,8 +205,8 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 	}
 
 	dev_dbg(atomisp_dev,
-		"%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
-		__func__, bo->start, bytes, type, userptr);
+		"%s: pages: 0x%08x (%zu bytes), type: %d, vmalloc %p\n",
+		__func__, bo->start, bytes, type, vmalloc);
 
 	return bo->start;
 
@@ -222,17 +220,12 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 
 ia_css_ptr hmm_alloc(size_t bytes)
 {
-	return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL, NULL);
+	return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL);
 }
 
 ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr)
 {
-	return __hmm_alloc(bytes, HMM_BO_VMALLOC, NULL, vmalloc_addr);
-}
-
-ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr)
-{
-	return __hmm_alloc(bytes, HMM_BO_USER, userptr, NULL);
+	return __hmm_alloc(bytes, HMM_BO_VMALLOC, vmalloc_addr);
 }
 
 void hmm_free(ia_css_ptr virt)
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c +1 -52

82 lines not on this page · raw message

Signature · 1 line
2.38.1
maintainer
#15 lore raw

Re: [PATCH 10/20] media: atomisp: Drop userptr support from hmm

Quoted 2 lines · Hans de Goede

After the conversion to videobuf2 userptr support is no longer needed, drop it.

...

drivers/staging/media/atomisp/pci/hmm/hmm.c static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, · line 209

Quoted 5 lines
drivers/staging/media/atomisp/pci/hmm/hmm.c +2 -2
 	dev_dbg(atomisp_dev,
-		"%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
-		__func__, bo->start, bytes, type, userptr);
+		"%s: pages: 0x%08x (%zu bytes), type: %d, vmalloc %p\n",
+		__func__, bo->start, bytes, type, vmalloc);

I believe we may drop __func__ here as well.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw

Re: [PATCH 10/20] media: atomisp: Drop userptr support from hmm

Hi,

Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Hans de Goede

After the conversion to videobuf2 userptr support is no longer needed, drop it.

...

Quoted 7 lines

drivers/staging/media/atomisp/pci/hmm/hmm.c static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, · line 209

Quoted 5 lines
drivers/staging/media/atomisp/pci/hmm/hmm.c +2 -2
 	dev_dbg(atomisp_dev,
-		"%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
-		__func__, bo->start, bytes, type, userptr);
+		"%s: pages: 0x%08x (%zu bytes), type: %d, vmalloc %p\n",
+		__func__, bo->start, bytes, type, vmalloc);

I believe we may drop __func__ here as well.

Fixed in my media-atomisp branch.

Regards,

Hans

#17 lore raw

PATCH 11/20 media: atomisp: Remove double atomisp_mrfld_power_down()/_up() calls from atomisp_reset()

In reply to Hans de Goede

atomisp_reset() calls atomisp_mrfld_power_down() after calling atomisp_runtime_suspend(), which already calls atomisp_mrfld_power_down() itself.

And the some goes for atomisp_runtime_resume() / atomisp_mrfld_power_up().

---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c  | 16 +++++-----------
 drivers/staging/media/atomisp/pci/atomisp_cmd.h  |  2 --
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c |  4 ++--
 3 files changed, 7 insertions(+), 15 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +5 -11
index 7f33a2f1e3fc..c69a646aa4d5 100644
@@ -311,17 +311,11 @@ int atomisp_reset(struct atomisp_device *isp)
 	ret = atomisp_runtime_suspend(isp->dev);
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_runtime_suspend failed, %d\n", ret);
-	ret = atomisp_mrfld_power_down(isp);
-	if (ret < 0) {
-		dev_err(isp->dev, "can not disable ISP power\n");
-	} else {
-		ret = atomisp_mrfld_power_up(isp);
-		if (ret < 0)
-			dev_err(isp->dev, "can not enable ISP power\n");
-		ret = atomisp_runtime_resume(isp->dev);
-		if (ret < 0)
-			dev_err(isp->dev, "atomisp_runtime_resume failed, %d\n", ret);
-	}
+
+	ret = atomisp_runtime_resume(isp->dev);
+	if (ret < 0)
+		dev_err(isp->dev, "atomisp_runtime_resume failed, %d\n", ret);
+
 	ret = atomisp_css_resume(isp);
 	if (ret)
 		isp->isp_fatal_error = true;
drivers/staging/media/atomisp/pci/atomisp_cmd.h +0 -2
index d9110bba8c28..61cbdc1215de 100644
@@ -341,8 +341,6 @@ int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
 int atomisp_get_invalid_frame_num(struct video_device *vdev,
 				  int *invalid_frame_num);
 
-int atomisp_mrfld_power_up(struct atomisp_device *isp);
-int atomisp_mrfld_power_down(struct atomisp_device *isp);
 int atomisp_runtime_suspend(struct device *dev);
 int atomisp_runtime_resume(struct device *dev);
 #endif /* __ATOMISP_CMD_H__ */
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +2 -2
index d5bb9906ca6f..d7fb700252fa 100644
@@ -725,13 +725,13 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, bool enable)
 }
 
 /* Workaround for pmu_nc_set_power_state not ready in MRFLD */
-int atomisp_mrfld_power_down(struct atomisp_device *isp)
+static int atomisp_mrfld_power_down(struct atomisp_device *isp)
 {
 	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)
+static int atomisp_mrfld_power_up(struct atomisp_device *isp)
 {
 	return atomisp_mrfld_power(isp, true);
 }
Signature · 1 line
2.38.1
#18 lore raw

PATCH 12/20 media: atomisp: Remove atomisp_mrfld_power_down()/_up()

In reply to Hans de Goede

atomisp_mrfld_power_down()/_up() are unnecessary wrappers around atomisp_mrfld_power() remove them and just call atomisp_mrfld_power() directly.

---
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 22 +++++--------------
 1 file changed, 5 insertions(+), 17 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +5 -17
index d7fb700252fa..f009a1bfd3ea 100644
@@ -724,18 +724,6 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, bool enable)
 	return -EBUSY;
 }
 
-/* Workaround for pmu_nc_set_power_state not ready in MRFLD */
-static int atomisp_mrfld_power_down(struct atomisp_device *isp)
-{
-	return atomisp_mrfld_power(isp, false);
-}
-
-/* Workaround for pmu_nc_set_power_state not ready in MRFLD */
-static int atomisp_mrfld_power_up(struct atomisp_device *isp)
-{
-	return atomisp_mrfld_power(isp, true);
-}
-
 int atomisp_runtime_suspend(struct device *dev)
 {
 	struct atomisp_device *isp = (struct atomisp_device *)
@@ -751,7 +739,7 @@ int atomisp_runtime_suspend(struct device *dev)
 	if (ret)
 		return ret;
 	cpu_latency_qos_update_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-	return atomisp_mrfld_power_down(isp);
+	return atomisp_mrfld_power(isp, false);
 }
 
 int atomisp_runtime_resume(struct device *dev)
@@ -760,7 +748,7 @@ int atomisp_runtime_resume(struct device *dev)
 				     dev_get_drvdata(dev);
 	int ret;
 
-	ret = atomisp_mrfld_power_up(isp);
+	ret = atomisp_mrfld_power(isp, true);
 	if (ret)
 		return ret;
 
@@ -817,7 +805,7 @@ static int __maybe_unused atomisp_suspend(struct device *dev)
 		return ret;
 	}
 	cpu_latency_qos_update_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
-	return atomisp_mrfld_power_down(isp);
+	return atomisp_mrfld_power(isp, false);
 }
 
 static int __maybe_unused atomisp_resume(struct device *dev)
@@ -826,7 +814,7 @@ static int __maybe_unused atomisp_resume(struct device *dev)
 				     dev_get_drvdata(dev);
 	int ret;
 
-	ret = atomisp_mrfld_power_up(isp);
+	ret = atomisp_mrfld_power(isp, true);
 	if (ret)
 		return ret;
 
@@ -1726,7 +1714,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	atomisp_ospm_dphy_down(isp);
 
 	/* Address later when we worry about the ...field chips */
-	if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power_down(isp))
+	if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power(isp, false))
 		dev_err(&pdev->dev, "Failed to switch off ISP\n");
 
 atomisp_dev_alloc_fail:
Signature · 1 line
2.38.1
#19 lore raw

PATCH 13/20 media: atomisp: Remove clearing of config from atomisp_css_uninit()

In reply to Hans de Goede

atomisp_css_uninit() only runs when all streams are stopped and atomisp_css_stop() already clears the config, so the clearing of the config can be dropped from atomisp_css_uninit().

---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -9
index adf77c9e481e..3237585d3044 100644
@@ -864,15 +864,6 @@ int atomisp_css_load_firmware(struct atomisp_device *isp)
 
 void atomisp_css_uninit(struct atomisp_device *isp)
 {
-	struct atomisp_sub_device *asd;
-	unsigned int i;
-
-	for (i = 0; i < isp->num_of_streams; i++) {
-		asd = &isp->asd[i];
-		memset(&asd->params.config, 0, sizeof(asd->params.config));
-		asd->params.css_update_params_needed = false;
-	}
-
 	isp->css_initialized = false;
 	ia_css_uninit();
 }
Signature · 1 line
2.38.1
#20 lore raw

PATCH 14/20 media: atomisp: Remove atomisp_css_suspend()/_resume()

In reply to Hans de Goede

atomisp_css_suspend() is a 1:1 copy of atomisp_css_uninit() and atomisp_css_resume() is a 1:1 copy of atomisp_css_init().

Remove the 2 copies and have their one caller just call atomisp_css_uninit() / atomisp_css_init() instead.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  4 +--
 .../media/atomisp/pci/atomisp_compat.h        |  4 ---
 .../media/atomisp/pci/atomisp_compat_css20.c  | 29 -------------------
 3 files changed, 2 insertions(+), 35 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +2 -2
index c69a646aa4d5..e80038e46e0e 100644
@@ -307,7 +307,7 @@ int atomisp_reset(struct atomisp_device *isp)
 	int ret = 0;
 
 	dev_dbg(isp->dev, "%s\n", __func__);
-	atomisp_css_suspend(isp);
+	atomisp_css_uninit(isp);
 	ret = atomisp_runtime_suspend(isp->dev);
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_runtime_suspend failed, %d\n", ret);
@@ -316,7 +316,7 @@ int atomisp_reset(struct atomisp_device *isp)
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_runtime_resume failed, %d\n", ret);
 
-	ret = atomisp_css_resume(isp);
+	ret = atomisp_css_init(isp);
 	if (ret)
 		isp->isp_fatal_error = true;
 
drivers/staging/media/atomisp/pci/atomisp_compat.h +0 -4
index f73801197dd7..7316eb9f974a 100644
@@ -41,10 +41,6 @@ int atomisp_css_init(struct atomisp_device *isp);
 
 void atomisp_css_uninit(struct atomisp_device *isp);
 
-void atomisp_css_suspend(struct atomisp_device *isp);
-
-int atomisp_css_resume(struct atomisp_device *isp);
-
 void atomisp_css_init_struct(struct atomisp_sub_device *asd);
 
 int atomisp_css_irq_translate(struct atomisp_device *isp,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -29
index 3237585d3044..9d6008659e02 100644
@@ -868,35 +868,6 @@ void atomisp_css_uninit(struct atomisp_device *isp)
 	ia_css_uninit();
 }
 
-void atomisp_css_suspend(struct atomisp_device *isp)
-{
-	isp->css_initialized = false;
-	ia_css_uninit();
-}
-
-int atomisp_css_resume(struct atomisp_device *isp)
-{
-	unsigned int mmu_base_addr;
-	int ret;
-
-	ret = hmm_get_mmu_base_addr(isp->dev, &mmu_base_addr);
-	if (ret) {
-		dev_err(isp->dev, "get base address error.\n");
-		return -EINVAL;
-	}
-
-	ret = ia_css_init(isp->dev, &isp->css_env.isp_css_env, NULL,
-			  mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
-	if (ret) {
-		dev_err(isp->dev, "re-init css failed.\n");
-		return -EINVAL;
-	}
-	ia_css_enable_isys_event_queue(true);
-
-	isp->css_initialized = true;
-	return 0;
-}
-
 int atomisp_css_irq_translate(struct atomisp_device *isp,
 			      unsigned int *infos)
 {
Signature · 1 line
2.38.1
#21 lore raw

PATCH 15/20 media: atomisp: Remove sw_contex.power_state checks

In reply to Hans de Goede

Remove the unnecessary sw_contex.power_state checks:

1. atomisp_freq_scaling() and atomisp_stop_streaming() only run when the ISP is powered up through runtime-pm, so the checkes are not necessary

2. atomisp_mrfld_pre_power_down() and atomisp_runtime_resume() are only called through the driver-core pm handling code which already guarantees they are not called when already powered down / up.

3. atomisp_isr() also checks isp->css_initialized which only gets set by atomisp_css_init() which runs *after* powering up the ISP and which gets cleared by atomisp_css_uninit() *before* before powering down the ISP.

So all the checks are unnecessary, remove them as well as the sw_contex.power_state field itself.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 20 +----
 .../media/atomisp/pci/atomisp_internal.h      |  1 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c | 75 +++++++++----------
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 19 ++---
 4 files changed, 43 insertions(+), 72 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +2 -18
index e80038e46e0e..475ba82b858b 100644
@@ -207,11 +207,6 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 	int i, ret;
 	unsigned short fps = 0;
 
-	if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP) {
-		dev_err(isp->dev, "DFS cannot proceed due to no power.\n");
-		return -EINVAL;
-	}
-
 	if ((pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
 	    ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
 		isp->dfs = &dfs_config_cht_soc;
@@ -511,8 +506,8 @@ irqreturn_t atomisp_isr(int irq, void *dev)
 	int err;
 
 	spin_lock_irqsave(&isp->lock, flags);
-	if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP ||
-	    !isp->css_initialized) {
+
+	if (!isp->css_initialized) {
 		spin_unlock_irqrestore(&isp->lock, flags);
 		return IRQ_HANDLED;
 	}
@@ -5503,7 +5498,6 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
 int atomisp_ospm_dphy_down(struct atomisp_device *isp)
 {
 	struct pci_dev *pdev = to_pci_dev(isp->dev);
-	unsigned long flags;
 	u32 reg;
 
 	dev_dbg(isp->dev, "%s\n", __func__);
@@ -5515,9 +5509,6 @@ int atomisp_ospm_dphy_down(struct atomisp_device *isp)
 	if (!atomisp_dev_users(isp))
 		goto done;
 
-	spin_lock_irqsave(&isp->lock, flags);
-	isp->sw_contex.power_state = ATOM_ISP_POWER_DOWN;
-	spin_unlock_irqrestore(&isp->lock, flags);
 done:
 	/*
 	 * MRFLD IUNIT DPHY is located in an always-power-on island
@@ -5533,14 +5524,7 @@ int atomisp_ospm_dphy_down(struct atomisp_device *isp)
 /*Turn on ISP dphy */
 int atomisp_ospm_dphy_up(struct atomisp_device *isp)
 {
-	unsigned long flags;
-
 	dev_dbg(isp->dev, "%s\n", __func__);
-
-	spin_lock_irqsave(&isp->lock, flags);
-	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
-	spin_unlock_irqrestore(&isp->lock, flags);
-
 	return 0;
 }
 
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -1
index d9d158cdf09e..653e6d74a966 100644
@@ -195,7 +195,6 @@ struct atomisp_regs {
 };
 
 struct atomisp_sw_contex {
-	int power_state;
 	int running_freq;
 };
 
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +35 -40

94 lines not on this page · raw message

drivers/staging/media/atomisp/pci/atomisp_v4l2.c +6 -13
index f009a1bfd3ea..579cbf502fd1 100644
@@ -573,11 +573,7 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp)
 	unsigned long flags;
 
 	spin_lock_irqsave(&isp->lock, flags);
-	if (isp->sw_contex.power_state == ATOM_ISP_POWER_DOWN) {
-		spin_unlock_irqrestore(&isp->lock, flags);
-		dev_dbg(isp->dev, "<%s %d.\n", __func__, __LINE__);
-		return 0;
-	}
+
 	/*
 	 * MRFLD HAS requirement: cannot power off i-unit if
 	 * ISP has IRQ not serviced.
@@ -753,13 +749,11 @@ int atomisp_runtime_resume(struct device *dev)
 		return ret;
 
 	cpu_latency_qos_update_request(&isp->pm_qos, isp->max_isr_latency);
-	if (isp->sw_contex.power_state == ATOM_ISP_POWER_DOWN) {
-		/*Turn on ISP d-phy */
-		ret = atomisp_ospm_dphy_up(isp);
-		if (ret) {
-			dev_err(isp->dev, "Failed to power up ISP!.\n");
-			return -EINVAL;
-		}
+	/*Turn on ISP d-phy */
+	ret = atomisp_ospm_dphy_up(isp);
+	if (ret) {
+		dev_err(isp->dev, "Failed to power up ISP!.\n");
+		return -EINVAL;
 	}
 
 	/*restore register values for iUnit and iUnitPHY registers*/
@@ -1447,7 +1441,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	isp->dev = &pdev->dev;
 	isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
-	isp->sw_contex.power_state = ATOM_ISP_POWER_UP;
 	isp->saved_regs.ispmmadr = start;
 
 	dev_dbg(&pdev->dev, "atomisp mmio base: %p\n", isp->base);
Signature · 1 line
2.38.1
maintainer
#22 lore raw

Re: [PATCH 15/20] media: atomisp: Remove sw_contex.power_state checks

Quoted 16 lines · Hans de Goede

Remove the unnecessary sw_contex.power_state checks:

1. atomisp_freq_scaling() and atomisp_stop_streaming() only run when the ISP is powered up through runtime-pm, so the checkes are not necessary

2. atomisp_mrfld_pre_power_down() and atomisp_runtime_resume() are only called through the driver-core pm handling code which already guarantees they are not called when already powered down / up.

3. atomisp_isr() also checks isp->css_initialized which only gets set by atomisp_css_init() which runs *after* powering up the ISP and which gets cleared by atomisp_css_uninit() *before* before powering down the ISP.

So all the checks are unnecessary, remove them as well as the sw_contex.power_state field itself.

...

drivers/staging/media/atomisp/pci/atomisp_v4l2.c int atomisp_runtime_resume(struct device *dev) · line 752

Quoted 1 line
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +1 -0
+	/*Turn on ISP d-phy */

While at it, you may add a whitespace after /*.

Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +4 -0
+	ret = atomisp_ospm_dphy_up(isp);
+	if (ret) {
+		dev_err(isp->dev, "Failed to power up ISP!.\n");
+		return -EINVAL;
 	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#23 lore raw

Re: [PATCH 15/20] media: atomisp: Remove sw_contex.power_state checks

Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Hans de Goede

Remove the unnecessary sw_contex.power_state checks:

1. atomisp_freq_scaling() and atomisp_stop_streaming() only run when the ISP is powered up through runtime-pm, so the checkes are not necessary

2. atomisp_mrfld_pre_power_down() and atomisp_runtime_resume() are only called through the driver-core pm handling code which already guarantees they are not called when already powered down / up.

3. atomisp_isr() also checks isp->css_initialized which only gets set by atomisp_css_init() which runs *after* powering up the ISP and which gets cleared by atomisp_css_uninit() *before* before powering down the ISP.

Quoted 8 lines
Quoted 2 lines

So all the checks are unnecessary, remove them as well as the sw_contex.power_state field itself.

...

drivers/staging/media/atomisp/pci/atomisp_v4l2.c int atomisp_runtime_resume(struct device *dev) · line 752

Quoted 1 line
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +1 -0
+	/*Turn on ISP d-phy */

While at it, you may add a whitespace after /*.

Okay, it's going to be removed by one of the following changes. No need to amend.

Quoted 5 lines
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +4 -0
+	ret = atomisp_ospm_dphy_up(isp);
+	if (ret) {
+		dev_err(isp->dev, "Failed to power up ISP!.\n");
+		return -EINVAL;
 	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#24 lore raw

PATCH 16/20 media: atomisp: Remove duplication between runtime-pm and normal-pm code

In reply to Hans de Goede

atomisp_suspend() contains a 1:1 copy of atomisp_runtime_suspend() and the same goes for the resume() functions.

Rename the runtime functions to atomisp_power_on()/_off() and use these as runtime-pm handlers as well as helper in other places to remove the code duplication.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  8 ++--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |  4 +-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 46 +++----------------
 3 files changed, 12 insertions(+), 46 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +4 -4
index 475ba82b858b..dac19db55625 100644
@@ -303,13 +303,13 @@ int atomisp_reset(struct atomisp_device *isp)
 
 	dev_dbg(isp->dev, "%s\n", __func__);
 	atomisp_css_uninit(isp);
-	ret = atomisp_runtime_suspend(isp->dev);
+	ret = atomisp_power_off(isp->dev);
 	if (ret < 0)
-		dev_err(isp->dev, "atomisp_runtime_suspend failed, %d\n", ret);
+		dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
 
-	ret = atomisp_runtime_resume(isp->dev);
+	ret = atomisp_power_on(isp->dev);
 	if (ret < 0)
-		dev_err(isp->dev, "atomisp_runtime_resume failed, %d\n", ret);
+		dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
 
 	ret = atomisp_css_init(isp);
 	if (ret)
drivers/staging/media/atomisp/pci/atomisp_cmd.h +2 -2
index 61cbdc1215de..f7647edb25fb 100644
@@ -341,6 +341,6 @@ int atomisp_inject_a_fake_event(struct atomisp_sub_device *asd, int *event);
 int atomisp_get_invalid_frame_num(struct video_device *vdev,
 				  int *invalid_frame_num);
 
-int atomisp_runtime_suspend(struct device *dev);
-int atomisp_runtime_resume(struct device *dev);
+int atomisp_power_off(struct device *dev);
+int atomisp_power_on(struct device *dev);
 #endif /* __ATOMISP_CMD_H__ */
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +6 -40

80 lines not on this page · raw message

Signature · 1 line
2.38.1
#25 lore raw

PATCH 17/20 media: atomisp: Move calling of css_[un]init() to power_on()/_off()

In reply to Hans de Goede

atomisp_css_init() is always called after calling atomisp_power_on() either directly or through getting a runtime-pm reference.

Likewise atomisp_css_uninit() is always called after calling atomisp_power_off().

Move the call site of these 2 functions to inside atomisp_power_on() / atomisp_power_off() to make this more explicit.

---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c  | 8 +++-----
 drivers/staging/media/atomisp/pci/atomisp_fops.c | 9 ---------
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 5 ++++-
 3 files changed, 7 insertions(+), 15 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +3 -5
index dac19db55625..7821bbd1e8da 100644
@@ -302,18 +302,16 @@ int atomisp_reset(struct atomisp_device *isp)
 	int ret = 0;
 
 	dev_dbg(isp->dev, "%s\n", __func__);
-	atomisp_css_uninit(isp);
+
 	ret = atomisp_power_off(isp->dev);
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
 
 	ret = atomisp_power_on(isp->dev);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
-
-	ret = atomisp_css_init(isp);
-	if (ret)
 		isp->isp_fatal_error = true;
+	}
 
 	return ret;
 }
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -9
index 8cff26d42b82..0123429d94f4 100644
@@ -809,13 +809,6 @@ static int atomisp_open(struct file *file)
 		goto error;
 	}
 
-	/* Init ISP */
-	if (atomisp_css_init(isp)) {
-		ret = -EINVAL;
-		/* Need to clean up CSS init if it fails. */
-		goto css_error;
-	}
-
 	atomisp_dev_init_struct(isp);
 
 	ret = v4l2_subdev_call(isp->flash, core, s_power, 1);
@@ -840,7 +833,6 @@ static int atomisp_open(struct file *file)
 	return 0;
 
 css_error:
-	atomisp_css_uninit(isp);
 	pm_runtime_put(vdev->v4l2_dev->dev);
 error:
 	mutex_unlock(&isp->mutex);
@@ -909,7 +901,6 @@ static int atomisp_release(struct file *file)
 		goto done;
 
 	atomisp_destroy_pipes_stream_force(asd);
-	atomisp_css_uninit(isp);
 
 	if (defer_fw_load) {
 		ia_css_unload_firmware();
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +4 -1
index f670517bc141..f46046d7ef50 100644
@@ -726,6 +726,8 @@ int atomisp_power_off(struct device *dev)
 				     dev_get_drvdata(dev);
 	int ret;
 
+	atomisp_css_uninit(isp);
+
 	ret = atomisp_mrfld_pre_power_down(isp);
 	if (ret)
 		return ret;
@@ -761,7 +763,8 @@ int atomisp_power_on(struct device *dev)
 		atomisp_restore_iunit_reg(isp);
 
 	atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
-	return 0;
+
+	return atomisp_css_init(isp);
 }
 
 static int __maybe_unused atomisp_suspend(struct device *dev)
Signature · 1 line
2.38.1
maintainer
#26 lore raw

Re: [PATCH 17/20] media: atomisp: Move calling of css_[un]init() to power_on()/_off()

Quoted 8 lines · Hans de Goede

atomisp_css_init() is always called after calling atomisp_power_on() either directly or through getting a runtime-pm reference.

Likewise atomisp_css_uninit() is always called after calling atomisp_power_off().

Move the call site of these 2 functions to inside atomisp_power_on() / atomisp_power_off() to make this more explicit.

...

Quoted 6 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -1
 	dev_dbg(isp->dev, "%s\n", __func__);
-	atomisp_css_uninit(isp);
+
 	ret = atomisp_power_off(isp->dev);
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);

drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_reset(struct atomisp_device *isp)

Quoted 10 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -4
 
 	ret = atomisp_power_on(isp->dev);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
-
-	ret = atomisp_css_init(isp);
-	if (ret)
 
 		isp->isp_fatal_error = true;

This was only set when css_init() failed, now it may be set even when power_on() fails. Why is it not a problem? Commit message doesn't shed a light on this change.

Quoted 1 line
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -0
+	}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#27 lore raw

Re: [PATCH 17/20] media: atomisp: Move calling of css_[un]init() to power_on()/_off()

Hi,

Quoted 27 lines · Andy Shevchenko
Quoted 8 lines · Hans de Goede

atomisp_css_init() is always called after calling atomisp_power_on() either directly or through getting a runtime-pm reference.

Likewise atomisp_css_uninit() is always called after calling atomisp_power_off().

Move the call site of these 2 functions to inside atomisp_power_on() / atomisp_power_off() to make this more explicit.

...

Quoted 14 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +2 -5
 	dev_dbg(isp->dev, "%s\n", __func__);
-	atomisp_css_uninit(isp);
+
 	ret = atomisp_power_off(isp->dev);
 	if (ret < 0)
 		dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
 
 	ret = atomisp_power_on(isp->dev);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
-
-	ret = atomisp_css_init(isp);
-	if (ret)
Quoted 5 lines
Quoted 1 line

isp->isp_fatal_error = true;

This was only set when css_init() failed, now it may be set even when power_on() fails. Why is it not a problem? Commit message doesn't shed a light on this change.

Failing to power-on the device is pretty fatal too, but this is indeed a behavior change. I have updated the commit message to reflect this.

Regards,

Hans

#28 lore raw

PATCH 18/20 media: atomisp: Remove atomisp_ospm_dphy_down() call from probe error path

In reply to Hans de Goede

The only thing which atomisp_ospm_dphy_down() does is disable the CSI pins, but if we failed to probe the ISP then these will never have been enabled (because the ISP never started streaming).

So the atomisp_ospm_dphy_down() call in the probe error path is unnecessary, remove it.

---
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2 --
 1 file changed, 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -2
index f46046d7ef50..9cb1363abe72 100644
@@ -1673,8 +1673,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 
 	atomisp_msi_irq_uninit(isp);
 
-	atomisp_ospm_dphy_down(isp);
-
 	/* Address later when we worry about the ...field chips */
 	if (IS_ENABLED(CONFIG_PM) && atomisp_mrfld_power(isp, false))
 		dev_err(&pdev->dev, "Failed to switch off ISP\n");
Signature · 1 line
2.38.1
#29 lore raw

PATCH 19/20 media: atomisp: Remove atomisp_ospm_dphy_up()/_down() functions

In reply to Hans de Goede

atomisp_ospm_dphy_up() is an empty function now and atomisp_ospm_dphy_down() contains a couple of checks + goto done statements which don't matter since the function always ends up at the done label regardless and then it does 1 pci-config write.

Move the single pci-config write directly to atomisp_power_off() and remove the atomisp_ospm_dphy_up()/_down() functions.

---
 .../staging/media/atomisp/pci/atomisp_cmd.c   | 34 -------------------
 .../staging/media/atomisp/pci/atomisp_cmd.h   |  2 --
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 24 ++++++-------
 3 files changed, 12 insertions(+), 48 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +0 -34
index 7821bbd1e8da..e9ce3b9b527c 100644
@@ -5492,40 +5492,6 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
 	return ret;
 }
 
-/*Turn off ISP dphy */
-int atomisp_ospm_dphy_down(struct atomisp_device *isp)
-{
-	struct pci_dev *pdev = to_pci_dev(isp->dev);
-	u32 reg;
-
-	dev_dbg(isp->dev, "%s\n", __func__);
-
-	/* if ISP timeout, we can force powerdown */
-	if (isp->isp_timeout)
-		goto done;
-
-	if (!atomisp_dev_users(isp))
-		goto done;
-
-done:
-	/*
-	 * MRFLD IUNIT DPHY is located in an always-power-on island
-	 * MRFLD HW design need all CSI ports are disabled before
-	 * powering down the IUNIT.
-	 */
-	pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &reg);
-	reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK;
-	pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, reg);
-	return 0;
-}
-
-/*Turn on ISP dphy */
-int atomisp_ospm_dphy_up(struct atomisp_device *isp)
-{
-	dev_dbg(isp->dev, "%s\n", __func__);
-	return 0;
-}
-
 int atomisp_exif_makernote(struct atomisp_sub_device *asd,
 			   struct atomisp_makernote_info *config)
 {
drivers/staging/media/atomisp/pci/atomisp_cmd.h +0 -2
index f7647edb25fb..b8911491581a 100644
@@ -273,8 +273,6 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
 int atomisp_offline_capture_configure(struct atomisp_sub_device *asd,
 				      struct atomisp_cont_capture_conf *cvf_config);
 
-int atomisp_ospm_dphy_down(struct atomisp_device *isp);
-int atomisp_ospm_dphy_up(struct atomisp_device *isp);
 int atomisp_exif_makernote(struct atomisp_sub_device *asd,
 			   struct atomisp_makernote_info *config);
 
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +12 -12
index 9cb1363abe72..e786b81921da 100644
@@ -722,9 +722,10 @@ static int atomisp_mrfld_power(struct atomisp_device *isp, bool enable)
 
 int atomisp_power_off(struct device *dev)
 {
-	struct atomisp_device *isp = (struct atomisp_device *)
-				     dev_get_drvdata(dev);
+	struct atomisp_device *isp = dev_get_drvdata(dev);
+	struct pci_dev *pdev = to_pci_dev(dev);
 	int ret;
+	u32 reg;
 
 	atomisp_css_uninit(isp);
 
@@ -732,10 +733,15 @@ int atomisp_power_off(struct device *dev)
 	if (ret)
 		return ret;
 
-	/*Turn off the ISP d-phy*/
-	ret = atomisp_ospm_dphy_down(isp);
-	if (ret)
-		return ret;
+	/*
+	 * MRFLD IUNIT DPHY is located in an always-power-on island
+	 * MRFLD HW design need all CSI ports are disabled before
+	 * powering down the IUNIT.
+	 */
+	pci_read_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, &reg);
+	reg |= MRFLD_ALL_CSI_PORTS_OFF_MASK;
+	pci_write_config_dword(pdev, MRFLD_PCI_CSI_CONTROL, reg);
+
 	cpu_latency_qos_update_request(&isp->pm_qos, PM_QOS_DEFAULT_VALUE);
 	return atomisp_mrfld_power(isp, false);
 }
@@ -751,12 +757,6 @@ int atomisp_power_on(struct device *dev)
 		return ret;
 
 	cpu_latency_qos_update_request(&isp->pm_qos, isp->max_isr_latency);
-	/*Turn on ISP d-phy */
-	ret = atomisp_ospm_dphy_up(isp);
-	if (ret) {
-		dev_err(isp->dev, "Failed to power up ISP!.\n");
-		return -EINVAL;
-	}
 
 	/*restore register values for iUnit and iUnitPHY registers*/
 	if (isp->saved_regs.pcicmdsts)
Signature · 1 line
2.38.1
#30 lore raw

PATCH 20/20 media: atomisp_ov2680: Fix 1280x720 -> 1296x736 resolution

In reply to Hans de Goede

The ov2680_720p_30fps register init list used for the 1296x736 resolution sets the hsize register to 1296 and the vsize register to 736.

This is actually the right thing to do when combined with the atomISP2 because the ISP requires 16 bytes padding leaving userspace to see 1280x720.

But the resolution list entries for this was incorrectly reporting the resolution being send to the ISP as already being 1280x720, leaving usespace to see 1274x704 as resolution.

Worse then userspace seeing a weird resolution selecting the 1280x720 sensor resolution (which in reality is sending 1296x736 to the ISP was causing the ISP to hang on Cherry Trail based tablets (Bay Trail works fine for some reason).

This commit also adds a bunch of comments annotating what the various register writes in the init lists are doing.

---
 drivers/staging/media/atomisp/i2c/ov2680.h | 46 +++++++++++-----------
 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/staging/media/atomisp/i2c/ov2680.h +23 -23
index 4e351196fe34..7ab337b859ad 100644
@@ -485,19 +485,19 @@ static struct ov2680_reg const ov2680_720x592_30fps[] = {
 static struct ov2680_reg const ov2680_800x600_30fps[] = {
 	{0x3086, 0x01},
 	{0x370a, 0x23},
-	{0x3801, 0x00},
+	{0x3801, 0x00}, /* hstart 0 */
 	{0x3802, 0x00},
-	{0x3803, 0x00},
+	{0x3803, 0x00}, /* vstart 0 */
 	{0x3804, 0x06},
-	{0x3805, 0x4f},
+	{0x3805, 0x4f}, /* hend 1615 */
 	{0x3806, 0x04},
-	{0x3807, 0xbf},
+	{0x3807, 0xbf}, /* vend 1215 */
 	{0x3808, 0x03},
-	{0x3809, 0x20},
+	{0x3809, 0x20}, /* hsize 800 */
 	{0x380a, 0x02},
-	{0x380b, 0x58},
+	{0x380b, 0x58}, /* vsize 600 */
 	{0x380c, 0x06},
-	{0x380d, 0xac},
+	{0x380d, 0xac}, /* htotal 1708 */
 	{0x3810, 0x00},
 	{0x3811, 0x00},
 	{0x3812, 0x00},
@@ -524,19 +524,19 @@ static struct ov2680_reg const ov2680_800x600_30fps[] = {
 static struct ov2680_reg const ov2680_720p_30fps[] = {
 	{0x3086, 0x00},
 	{0x370a, 0x21},
-	{0x3801, 0xa0},
+	{0x3801, 0xa0}, /* hstart 160 */
 	{0x3802, 0x00},
-	{0x3803, 0xf2},
+	{0x3803, 0xf2}, /* vstart 242 */
 	{0x3804, 0x05},
-	{0x3805, 0xbf},
+	{0x3805, 0xbf}, /* hend 1471 */
 	{0x3806, 0x03},
-	{0x3807, 0xdd},
+	{0x3807, 0xdd}, /* vend 989 */
 	{0x3808, 0x05},
-	{0x3809, 0x10},
+	{0x3809, 0x10}, /* hsize 1296 */
 	{0x380a, 0x02},
-	{0x380b, 0xe0},
+	{0x380b, 0xe0}, /* vsize 736 */
 	{0x380c, 0x06},
-	{0x380d, 0xa8},
+	{0x380d, 0xa8}, /* htotal 1704 */
 	{0x3810, 0x00},
 	{0x3811, 0x08},
 	{0x3812, 0x00},
@@ -563,19 +563,19 @@ static struct ov2680_reg const ov2680_720p_30fps[] = {
 static struct ov2680_reg const ov2680_1296x976_30fps[] = {
 	{0x3086, 0x00},
 	{0x370a, 0x21},
-	{0x3801, 0xa0},
+	{0x3801, 0xa0}, /* hstart 160 */
 	{0x3802, 0x00},
-	{0x3803, 0x78},
+	{0x3803, 0x78}, /* vstart 120 */
 	{0x3804, 0x05},
-	{0x3805, 0xbf},
+	{0x3805, 0xbf}, /* hend 1471 */
 	{0x3806, 0x04},
-	{0x3807, 0x57},
+	{0x3807, 0x57}, /* vend 1111 */
 	{0x3808, 0x05},
-	{0x3809, 0x10},
+	{0x3809, 0x10}, /* hsize 1296 */
 	{0x380a, 0x03},
-	{0x380b, 0xd0},
+	{0x380b, 0xd0}, /* vsize 976 */
 	{0x380c, 0x06},
-	{0x380d, 0xa8},
+	{0x380d, 0xa8}, /* htotal 1704 */
 	{0x3810, 0x00},
 	{0x3811, 0x08},
 	{0x3812, 0x00},
@@ -820,8 +820,8 @@ static struct ov2680_resolution ov2680_res_preview[] = {
 		.regs = ov2680_1296x976_30fps,
 	},
 	{
-		.width = 1280,
-		.height = 720,
+		.width = 1296,
+		.height = 736,
 		.fps = 60,
 		.pix_clk_freq = 66,
 		.pixels_per_line = 1698,//1704,
Signature · 1 line
2.38.1
maintainer Reviewed-by on the v1 series
#31 lore raw
In reply to Hans de Goede
Quoted 5 lines · Hans de Goede

Hi All,

Here is another round of atomisp cleanups / fixes + preparation work for getting rid of the ugly PCI power-management errors in dmesg when doing (runtime)suspend/resume.

As usual, for non-commented (by me) patches:

Quoted 64 lines

Regards,

Hans

Hans de Goede (20):
media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat
which has exp_id xx' log messages
media: atomisp: Remove accelerator pipe creation code
media: atomisp: Remove unused QOS defines / structure member
media: atomisp: Flush queue on atomisp_css_start() error
media: atomisp: Log an error on failing to alloc private-mem
media: atomisp: Fix deadlock when the /dev/video# node is closed while
still streaming
media: atomisp: Remove 2 unused accelerator mode related functions
media: atomisp: Remove atomisp_css_yuvpp_configure_viewfinder()
function
media: atomisp: Remove unused ia_css_frame_*() functions
media: atomisp: Drop userptr support from hmm
media: atomisp: Remove double atomisp_mrfld_power_down()/_up() calls
from atomisp_reset()
media: atomisp: Remove atomisp_mrfld_power_down()/_up()
media: atomisp: Remove clearing of config from atomisp_css_uninit()
media: atomisp: Remove atomisp_css_suspend()/_resume()
media: atomisp: Remove sw_contex.power_state checks
media: atomisp: Remove duplication between runtime-pm and normal-pm
code
media: atomisp: Move calling of css_[un]init() to power_on()/_off()
media: atomisp: Remove atomisp_ospm_dphy_down() call from probe error
path
media: atomisp: Remove atomisp_ospm_dphy_up()/_down() functions
media: atomisp_ov2680: Fix 1280x720 -> 1296x736 resolution

 drivers/staging/media/atomisp/i2c/ov2680.h    |  46 +-
 .../staging/media/atomisp/include/hmm/hmm.h   |   1 -
 .../media/atomisp/include/hmm/hmm_bo.h        |   2 -
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  76 +--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |   8 +-
 .../media/atomisp/pci/atomisp_compat.h        |  11 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  88 +--
 .../staging/media/atomisp/pci/atomisp_fops.c  |  34 +-
 .../media/atomisp/pci/atomisp_internal.h      |   1 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  80 ++-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 104 +--
 .../pipe/interface/ia_css_pipe_stagedesc.h    |   5 -
 .../pci/camera/pipe/src/pipe_stagedesc.c      |  21 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  19 +-
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    |  54 +-
 .../media/atomisp/pci/ia_css_frame_public.h   |  74 ---
 .../staging/media/atomisp/pci/ia_css_pipe.h   |   3 +-
 .../media/atomisp/pci/ia_css_pipe_public.h    |  69 --
 .../pci/runtime/debug/src/ia_css_debug.c      |   7 -
 .../atomisp/pci/runtime/frame/src/frame.c     | 121 ----
 .../pipeline/interface/ia_css_pipeline.h      |   2 -
 .../pci/runtime/pipeline/src/pipeline.c       |   8 -
 drivers/staging/media/atomisp/pci/sh_css.c    | 608 +-----------------
 .../media/atomisp/pci/sh_css_internal.h       |  13 -
 .../staging/media/atomisp/pci/sh_css_legacy.h |   1 -
 drivers/staging/media/atomisp/pci/sh_css_sp.c |   2 +-
 26 files changed, 121 insertions(+), 1337 deletions(-)
Signature · 1 line
2.38.1
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#32 lore raw

Hi,

Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Hans de Goede

Hi All,

Here is another round of atomisp cleanups / fixes + preparation work for getting rid of the ugly PCI power-management errors in dmesg when doing (runtime)suspend/resume.

As usual, for non-commented (by me) patches:

Thank you for all the reviews!

The patches with your suggested fixes + Reviewed-by have all been updated in my media-atomisp branch.

Regards,

Hans

Quoted 60 lines
Quoted 59 lines

Hans de Goede (20):
media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat
which has exp_id xx' log messages
media: atomisp: Remove accelerator pipe creation code
media: atomisp: Remove unused QOS defines / structure member
media: atomisp: Flush queue on atomisp_css_start() error
media: atomisp: Log an error on failing to alloc private-mem
media: atomisp: Fix deadlock when the /dev/video# node is closed while
still streaming
media: atomisp: Remove 2 unused accelerator mode related functions
media: atomisp: Remove atomisp_css_yuvpp_configure_viewfinder()
function
media: atomisp: Remove unused ia_css_frame_*() functions
media: atomisp: Drop userptr support from hmm
media: atomisp: Remove double atomisp_mrfld_power_down()/_up() calls
from atomisp_reset()
media: atomisp: Remove atomisp_mrfld_power_down()/_up()
media: atomisp: Remove clearing of config from atomisp_css_uninit()
media: atomisp: Remove atomisp_css_suspend()/_resume()
media: atomisp: Remove sw_contex.power_state checks
media: atomisp: Remove duplication between runtime-pm and normal-pm
code
media: atomisp: Move calling of css_[un]init() to power_on()/_off()
media: atomisp: Remove atomisp_ospm_dphy_down() call from probe error
path
media: atomisp: Remove atomisp_ospm_dphy_up()/_down() functions
media: atomisp_ov2680: Fix 1280x720 -> 1296x736 resolution

 drivers/staging/media/atomisp/i2c/ov2680.h    |  46 +-
 .../staging/media/atomisp/include/hmm/hmm.h   |   1 -
 .../media/atomisp/include/hmm/hmm_bo.h        |   2 -
 .../staging/media/atomisp/pci/atomisp_cmd.c   |  76 +--
 .../staging/media/atomisp/pci/atomisp_cmd.h   |   8 +-
 .../media/atomisp/pci/atomisp_compat.h        |  11 -
 .../media/atomisp/pci/atomisp_compat_css20.c  |  88 +--
 .../staging/media/atomisp/pci/atomisp_fops.c  |  34 +-
 .../media/atomisp/pci/atomisp_internal.h      |   1 -
 .../staging/media/atomisp/pci/atomisp_ioctl.c |  80 ++-
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 104 +--
 .../pipe/interface/ia_css_pipe_stagedesc.h    |   5 -
 .../pci/camera/pipe/src/pipe_stagedesc.c      |  21 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   |  19 +-
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    |  54 +-
 .../media/atomisp/pci/ia_css_frame_public.h   |  74 ---
 .../staging/media/atomisp/pci/ia_css_pipe.h   |   3 +-
 .../media/atomisp/pci/ia_css_pipe_public.h    |  69 --
 .../pci/runtime/debug/src/ia_css_debug.c      |   7 -
 .../atomisp/pci/runtime/frame/src/frame.c     | 121 ----
 .../pipeline/interface/ia_css_pipeline.h      |   2 -
 .../pci/runtime/pipeline/src/pipeline.c       |   8 -
 drivers/staging/media/atomisp/pci/sh_css.c    | 608 +-----------------
 .../media/atomisp/pci/sh_css_internal.h       |  13 -
 .../staging/media/atomisp/pci/sh_css_legacy.h |   1 -
 drivers/staging/media/atomisp/pci/sh_css_sp.c |   2 +-
 26 files changed, 121 insertions(+), 1337 deletions(-)
Signature · 1 line
2.38.1