Skip to contentSkip to conversation

staging: media: atomisp: Cleanup unused module parameters

PATCH Superseded Prajval Chaudhary 3 participants 7 messages Jul 21 – Oct 3

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover staging: media: atomisp: Cleanup unused module parameters

This series cleans up unused module parameters from the atomisp driver.

Patch 1 removes unused 'pad_w' and 'pad_h' module parameters. Patch 2 removes unused 'dbg_level' and 'dbg_func' module parameters, and updates ia_css_debug_vdtrace() to filter trace logging to WARNING level or below to avoid potential kernel log flooding.

Changes in v4:
- Fix macro constant name in ia_css_debug_vdtrace() to IA_CSS_DEBUG_WARNING.
- Guard vprintk() with level check to prevent log flooding.

Changes in v3:
- [Add brief note if applicable]

Changes in v2:
- [Add brief note if applicable]

Prajval Chaudhary (2):
staging: media: atomisp: Remove pad_w and pad_h module parameters
staging: media: atomisp: Remove dbg_level and dbg_func module
parameters

 .../staging/media/atomisp/pci/atomisp_common.h    |  6 ++----
 .../media/atomisp/pci/atomisp_compat_css20.c      | 12 +++---------
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c  | 15 ++-------------
 .../pci/runtime/debug/interface/ia_css_debug.h    |  7 +++----
 .../atomisp/pci/runtime/debug/src/ia_css_debug.c  |  4 ++--
 5 files changed, 12 insertions(+), 32 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/2 staging: media: atomisp: Remove pad_w and pad_h module parameters

Remove the 'pad_w' and 'pad_h' module parameters to prevent userspace from overriding internal ISP hardware padding boundaries. Convert them into internal driver constants instead.

---
 drivers/staging/media/atomisp/pci/atomisp_common.h | 4 ++--
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c   | 8 ++------
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_common.h +2 -2
index a2462fc306fb..7c6c0124ff72 100644
@@ -22,8 +22,8 @@
 
 extern int dbg_level;
 extern int dbg_func;
-extern int pad_w;
-extern int pad_h;
+extern const int pad_w;
+extern const int pad_h;
 
 /* Minimum padding requirements for ISP2400 (BYT) */
 #define ISP2400_MIN_PAD_W		12
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +2 -6
index 812230397409..d117fea2860c 100644
@@ -64,13 +64,9 @@ MODULE_PARM_DESC(dbg_func,
  * output res, and isp output res. however since we do not have this yet,
  * the chosen solution is the next best thing.
  */
-int pad_w = 16;
-module_param(pad_w, int, 0644);
-MODULE_PARM_DESC(pad_w, "extra data for ISP processing");
+const int pad_w = 16;
 
-int pad_h = 16;
-module_param(pad_h, int, 0644);
-MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
+const int pad_h = 16;
 
 /*
  * FIXME: this is a hack to make easier to support ISP2401 variant.
Signature · 1 line
2.34.1
reviewer
#2 lore raw

Re: [PATCH v4 1/2] staging: media: atomisp: Remove pad_w and pad_h module parameters

Hi Prajval,

Quoted 15 lines · Prajval Chaudhary

Remove the 'pad_w' and 'pad_h' module parameters to prevent userspace from overriding internal ISP hardware padding boundaries. Convert them into internal driver constants instead.

---
 drivers/staging/media/atomisp/pci/atomisp_common.h | 4 ++--
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c   | 8 ++------
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_common.h +0 -0
index a2462fc306fb..7c6c0124ff72 100644

drivers/staging/media/atomisp/pci/atomisp_common.h line 26

Quoted 7 lines
drivers/staging/media/atomisp/pci/atomisp_common.h +2 -2
@@ -22,8 +22,8 @@
 
 extern int dbg_level;
 extern int dbg_func;
-extern int pad_w;
-extern int pad_h;
+extern const int pad_w;
+extern const int pad_h;

Please switch to macros while at it, with an appropriate prefix, e.g. ATOMISP_PAD_[WH].

Quoted 23 lines
drivers/staging/media/atomisp/pci/atomisp_common.h +0 -0
 /* Minimum padding requirements for ISP2400 (BYT) */
 #define ISP2400_MIN_PAD_W		12
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +2 -6
index 812230397409..d117fea2860c 100644
@@ -64,13 +64,9 @@ MODULE_PARM_DESC(dbg_func,
  * output res, and isp output res. however since we do not have this yet,
  * the chosen solution is the next best thing.
  */
-int pad_w = 16;
-module_param(pad_w, int, 0644);
-MODULE_PARM_DESC(pad_w, "extra data for ISP processing");
+const int pad_w = 16;
 
-int pad_h = 16;
-module_param(pad_h, int, 0644);
-MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
+const int pad_h = 16;
 
 /*
  * FIXME: this is a hack to make easier to support ISP2401 variant.
Signature · 3 lines
Regards,

Sakari Ailus
#3 lore raw

PATCH v4 2/2 staging: media: atomisp: Remove dbg_level and dbg_func module parameters

In reply to Prajval Chaudhary

Remove the 'dbg_level' and 'dbg_func' module parameters to align the driver's debug facility with standard Linux kernel APIs (printk/vprintk).

The internal logic relying on custom debug parameters has been updated so that message logging and function tracing no longer depend on exposed userspace module parameters.

---
 drivers/staging/media/atomisp/pci/atomisp_common.h   |  2 --
 .../staging/media/atomisp/pci/atomisp_compat_css20.c | 12 +++---------
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c     |  7 -------
 .../pci/runtime/debug/interface/ia_css_debug.h       |  7 +++----
 .../atomisp/pci/runtime/debug/src/ia_css_debug.c     |  4 ++--
 5 files changed, 8 insertions(+), 24 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_common.h +0 -2
index 7c6c0124ff72..aa230c3708dd 100644
@@ -20,8 +20,6 @@
 
 #include "ia_css.h"
 
-extern int dbg_level;
-extern int dbg_func;
 extern const int pad_w;
 extern const int pad_h;
 
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +3 -9
index ea49ebe2da5c..647f6e7e2455 100644
@@ -784,7 +784,7 @@ int atomisp_css_load_firmware(struct atomisp_device *isp)
 	isp->css_env.isp_css_env.hw_access_env.load = atomisp_css2_hw_load;
 	isp->css_env.isp_css_env.hw_access_env.store = atomisp_css2_hw_store;
 
-	__set_css_print_env(isp, dbg_func);
+	__set_css_print_env(isp, 1);
 
 	isp->css_env.isp_css_env.print_env.error_print = atomisp_vprintk;
 
@@ -3372,18 +3372,12 @@ void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
 
 int atomisp_get_css_dbgfunc(void)
 {
-	return dbg_func;
+	return 1;
 }
 
 int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt)
 {
-	int ret;
-
-	ret = __set_css_print_env(isp, opt);
-	if (ret == 0)
-		dbg_func = opt;
-
-	return ret;
+	return __set_css_print_env(isp, opt);
 }
 
 void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable)
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -7
index d117fea2860c..55b3d4d3d6ad 100644
@@ -45,15 +45,8 @@
 #define CSTATE_EXIT_LATENCY_C1  1
 
 /* cross component debug message flag */
-int dbg_level;
-module_param(dbg_level, int, 0644);
-MODULE_PARM_DESC(dbg_level, "debug message level (default:0)");
 
 /* log function switch */
-int dbg_func = 1;
-module_param(dbg_func, int, 0644);
-MODULE_PARM_DESC(dbg_func,
-		 "log function switch non/printk (default:printk)");
 
 /*
  * Set to 16x16 since this is the amount of lines and pixels the sensor
drivers/staging/media/atomisp/pci/runtime/debug/interface/ia_css_debug.h +3 -4
index 2d0e906530af..029adbdca945 100644
@@ -8,7 +8,7 @@
 #define _IA_CSS_DEBUG_H_
 
 /*! \file */
-
+#include <linux/printk.h>
 #include <type_support.h>
 #include <linux/stdarg.h>
 #include <linux/bits.h>
@@ -39,7 +39,6 @@
 #define IA_CSS_DEBUG_INFO    9
 
 /* Global variable which controls the verbosity levels of the debug tracing */
-extern int dbg_level;
 
 /*! @brief Enum defining the different isp parameters to dump.
  *  Values can be combined to dump a combination of sets.
@@ -125,8 +124,8 @@ static inline void __printf(2, 0) ia_css_debug_vdtrace(unsigned int level,
 						       const char *fmt,
 						       va_list args)
 {
-	if (dbg_level >= level)
-		sh_css_vprint(fmt, args);
+	if (level <= IA_CSS_DEBUG_WARNING)
+		vprintk(fmt, args);
 }
 
 __printf(2, 3) void ia_css_debug_dtrace(unsigned int level,
drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +2 -2
index 5113aa5973f3..86b2cca2f441 100644
@@ -135,13 +135,13 @@ void ia_css_debug_dtrace(unsigned int level, const char *fmt, ...)
 
 void ia_css_debug_set_dtrace_level(const unsigned int trace_level)
 {
-	dbg_level = trace_level;
+	/* Trace level is now controlled dynamically via Linux kernel dynamic debug facility */
 	return;
 }
 
 unsigned int ia_css_debug_get_dtrace_level(void)
 {
-	return dbg_level;
+	return 0;
 }
 
 static const char *debug_stream_format2str(const enum atomisp_input_format
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH v4 2/2] staging: media: atomisp: Remove dbg_level and dbg_func module parameters

Quoted 6 lines · Prajval Chaudhary

Remove the 'dbg_level' and 'dbg_func' module parameters to align the driver's debug facility with standard Linux kernel APIs (printk/vprintk).

The internal logic relying on custom debug parameters has been updated so that message logging and function tracing no longer depend on exposed userspace module parameters.

...

drivers/staging/media/atomisp/pci/atomisp_v4l2.c line 50

Quoted 4 lines

/* cross component debug message flag */

drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -3
-int dbg_level;
-module_param(dbg_level, int, 0644);
-MODULE_PARM_DESC(dbg_level, "debug message level (default:0)");

And what level is the default now? What the difference with the other levels?

drivers/staging/media/atomisp/pci/atomisp_v4l2.c line 56

Quoted 5 lines

/* log function switch */

drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -4
-int dbg_func = 1;
-module_param(dbg_func, int, 0644);
-MODULE_PARM_DESC(dbg_func,
-		 "log function switch non/printk (default:printk)");

What are the other options?

...

Quoted 2 lines

/*! \file */
-

Stray blank line removal.

Quoted 1 line

+#include <linux/printk.h>

Locate it in the linux/*.h group below. But I agree that at some point this custom type_support should be moved down.

Quoted 3 lines

#include <type_support.h>
#include <linux/stdarg.h>
#include <linux/bits.h>

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

Re: [PATCH v4 2/2] staging: media: atomisp: Remove dbg_level and dbg_func module parameters

In reply to Prajval Chaudhary

Hi Prajval,

Quoted 43 lines · Prajval Chaudhary

Remove the 'dbg_level' and 'dbg_func' module parameters to align the driver's debug facility with standard Linux kernel APIs (printk/vprintk).

The internal logic relying on custom debug parameters has been updated so that message logging and function tracing no longer depend on exposed userspace module parameters.

---
 drivers/staging/media/atomisp/pci/atomisp_common.h   |  2 --
 .../staging/media/atomisp/pci/atomisp_compat_css20.c | 12 +++---------
 drivers/staging/media/atomisp/pci/atomisp_v4l2.c     |  7 -------
 .../pci/runtime/debug/interface/ia_css_debug.h       |  7 +++----
 .../atomisp/pci/runtime/debug/src/ia_css_debug.c     |  4 ++--
 5 files changed, 8 insertions(+), 24 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_common.h +0 -2
index 7c6c0124ff72..aa230c3708dd 100644
@@ -20,8 +20,6 @@
 
 #include "ia_css.h"
 
-extern int dbg_level;
-extern int dbg_func;
 extern const int pad_w;
 extern const int pad_h;
 
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -1
index ea49ebe2da5c..647f6e7e2455 100644
@@ -784,7 +784,7 @@ int atomisp_css_load_firmware(struct atomisp_device *isp)
 	isp->css_env.isp_css_env.hw_access_env.load = atomisp_css2_hw_load;
 	isp->css_env.isp_css_env.hw_access_env.store = atomisp_css2_hw_store;
 
-	__set_css_print_env(isp, dbg_func);
+	__set_css_print_env(isp, 1);
 
 	isp->css_env.isp_css_env.print_env.error_print = atomisp_vprintk;
 

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd, · line 3375

Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -1
@@ -3372,18 +3372,12 @@ void atomisp_css_set_isp_config_applied_frame(struct atomisp_sub_device *asd,
 
 int atomisp_get_css_dbgfunc(void)
 {
-	return dbg_func;
+	return 1;

Maybe you could switch to similar v4l2 macros?

Quoted 87 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -7
 }
 
 int atomisp_set_css_dbgfunc(struct atomisp_device *isp, int opt)
 {
-	int ret;
-
-	ret = __set_css_print_env(isp, opt);
-	if (ret == 0)
-		dbg_func = opt;
-
-	return ret;
+	return __set_css_print_env(isp, opt);
 }
 
 void atomisp_en_dz_capt_pipe(struct atomisp_sub_device *asd, bool enable)
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -7
index d117fea2860c..55b3d4d3d6ad 100644
@@ -45,15 +45,8 @@
 #define CSTATE_EXIT_LATENCY_C1  1
 
 /* cross component debug message flag */
-int dbg_level;
-module_param(dbg_level, int, 0644);
-MODULE_PARM_DESC(dbg_level, "debug message level (default:0)");
 
 /* log function switch */
-int dbg_func = 1;
-module_param(dbg_func, int, 0644);
-MODULE_PARM_DESC(dbg_func,
-		 "log function switch non/printk (default:printk)");
 
 /*
  * Set to 16x16 since this is the amount of lines and pixels the sensor
drivers/staging/media/atomisp/pci/runtime/debug/interface/ia_css_debug.h +3 -4
index 2d0e906530af..029adbdca945 100644
@@ -8,7 +8,7 @@
 #define _IA_CSS_DEBUG_H_
 
 /*! \file */
-
+#include <linux/printk.h>
 #include <type_support.h>
 #include <linux/stdarg.h>
 #include <linux/bits.h>
@@ -39,7 +39,6 @@
 #define IA_CSS_DEBUG_INFO    9
 
 /* Global variable which controls the verbosity levels of the debug tracing */
-extern int dbg_level;
 
 /*! @brief Enum defining the different isp parameters to dump.
  *  Values can be combined to dump a combination of sets.
@@ -125,8 +124,8 @@ static inline void __printf(2, 0) ia_css_debug_vdtrace(unsigned int level,
 						       const char *fmt,
 						       va_list args)
 {
-	if (dbg_level >= level)
-		sh_css_vprint(fmt, args);
+	if (level <= IA_CSS_DEBUG_WARNING)
+		vprintk(fmt, args);
 }
 
 __printf(2, 3) void ia_css_debug_dtrace(unsigned int level,
drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +2 -2
index 5113aa5973f3..86b2cca2f441 100644
@@ -135,13 +135,13 @@ void ia_css_debug_dtrace(unsigned int level, const char *fmt, ...)
 
 void ia_css_debug_set_dtrace_level(const unsigned int trace_level)
 {
-	dbg_level = trace_level;
+	/* Trace level is now controlled dynamically via Linux kernel dynamic debug facility */
 	return;
 }
 
 unsigned int ia_css_debug_get_dtrace_level(void)
 {
-	return dbg_level;
+	return 0;
 }
 
 static const char *debug_stream_format2str(const enum atomisp_input_format
Signature · 3 lines
Regards,

Sakari Ailus
#6 lore raw
In reply to Prajval Chaudhary
Quoted 6 lines · Prajval Chaudhary

This series cleans up unused module parameters from the atomisp driver.

Patch 1 removes unused 'pad_w' and 'pad_h' module parameters. Patch 2 removes unused 'dbg_level' and 'dbg_func' module parameters, and updates ia_css_debug_vdtrace() to filter trace logging to WARNING level or below to avoid potential kernel log flooding.

Have you run (or simulate behaviour of) this driver? Can you show the difference in the debug output before and after these patches?

Signature · 2 lines
With Best Regards,
Andy Shevchenko