media: bcm2835-unicam: Fix log status runtime access
Subsystems (4)
PATCH v3 1/1 media: bcm2835-unicam: Fix log status runtime access
When requesting log status, the block might be powered off, but registers are being read.
Avoid reading the registers if the device is not resumed, thus also avoid powering up the device just for log status.
---
Changes in v3:
- Changed to check return value of pm_runtime_get_if_active() and only call pm_runtime_put() if the device is active.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- changed to use pm_runtime_get_if_active()
- add corresponding put()
- Link to v1: https://patch.msgid.link/[email protected]
To: Raspberry Pi Kernel Maintenance <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Florian Fainelli <[email protected]>
To: Ray Jui <[email protected]>
To: Scott Branden <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Sakari Ailus <[email protected]>
To: Jean-Michel Hautbois <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans Verkuil <[email protected]>
To: Naushir Patuck <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- drivers/media/platform/broadcom/bcm2835-unicam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/platform/broadcom/bcm2835-unicam.c +12 -0
@@ -2043,6 +2043,7 @@ static int unicam_log_status(struct file *file, void *fh)struct unicam_node *node =video_drvdata (file);struct unicam_device *unicam = node->dev;u32 reg; +int pm_active;/* status for sub devices */ v4l2_device_call_all (&unicam->v4l2_dev,0 , core, log_status);
@@ -2052,6 +2053,14 @@ static int unicam_log_status(struct file *file, void *fh) node->fmt.fmt.pix.width, node->fmt.fmt.pix.height);dev_info (unicam->dev,"V4L2 format: %08x\n" , node->fmt.fmt.pix.pixelformat); + + pm_active =pm_runtime_get_if_active (unicam->dev); +if (!pm_active) { +dev_info (unicam->dev, +"Live data N/A due to device inactive\n" ); +return 0 ; + } + reg =unicam_reg_read (unicam,UNICAM_IPIPE ); dev_info(unicam->dev, "Unpacking/packing: %u / %u\n", unicam_get_field(reg, UNICAM_PUM_MASK),
@@ -2065,6 +2074,9 @@ static int unicam_log_status(struct file *file, void *fh)dev_info (unicam->dev,"Write pointer: %08x\n" ,unicam_reg_read (unicam,UNICAM_IBWP )); +if (pm_active ==1 ) +pm_runtime_put (unicam->dev); +return 0 ; }
---
base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260521-bcmpipm-6c578e73239c
Best regards,
Signature · 1 line
Eugen Hristev <[email protected]>
Quoted 66 lines · Eugen Hristev
When requesting log status, the block might be powered off, but registers are being read.
Avoid reading the registers if the device is not resumed, thus also avoid powering up the device just for log status.Fixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>---
Changes in v3:
- Changed to check return value ofpm_runtime_get_if_active()and only callpm_runtime_put()if the device is active.
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- changed to usepm_runtime_get_if_active()
- add correspondingput()
- Link to v1: https://patch.msgid.link/[email protected]To: Raspberry Pi Kernel Maintenance <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Florian Fainelli <[email protected]>
To: Ray Jui <[email protected]>
To: Scott Branden <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Sakari Ailus <[email protected]>
To: Jean-Michel Hautbois <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans Verkuil <[email protected]>
To: Naushir Patuck <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/media/platform/broadcom/bcm2835-unicam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/media/platform/broadcom/bcm2835-unicam.c +9
-0@@ -2043,6 +2043,7 @@ static int unicam_log_status(struct file *file, void *fh)struct unicam_node *node =video_drvdata (file);struct unicam_device *unicam = node->dev;u32 reg; +int pm_active;/* status for sub devices */ v4l2_device_call_all (&unicam->v4l2_dev,0 , core, log_status);@@ -2052,6 +2053,14 @@ static int unicam_log_status(struct file *file, void *fh) node->fmt.fmt.pix.width, node->fmt.fmt.pix.height);dev_info (unicam->dev,"V4L2 format: %08x\n" , node->fmt.fmt.pix.pixelformat); + + pm_active =pm_runtime_get_if_active (unicam->dev); +if (!pm_active) { +dev_info (unicam->dev, +"Live data N/A due to device inactive\n" ); +return 0 ; + } + reg =unicam_reg_read (unicam,UNICAM_IPIPE ); dev_info(unicam->dev, "Unpacking/packing: %u / %u\n", unicam_get_field(reg, UNICAM_PUM_MASK),
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_log_status(struct file *file, void *fh) · line 2078
Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +2
-0@@ -2065,6 +2074,9 @@ static int unicam_log_status(struct file *file, void *fh)dev_info (unicam->dev,"Write pointer: %08x\n" ,unicam_reg_read (unicam,UNICAM_IBWP )); +if (pm_active ==1 ) +pm_runtime_put (unicam->dev);
As far as I understand, the discussion on v2 concluded there was no need to test pm_active here. Did I miss anything ?
Quoted 8 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1+return 0 ; } ---base-commit:
e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260521-bcmpipm-6c578e73239c
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 70 lines · Laurent Pinchart
Quoted 69 lines · Eugen Hristev
When requesting log status, the block might be powered off, but registers are being read.
Avoid reading the registers if the device is not resumed, thus also avoid powering up the device just for log status.Fixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>---
Changes in v3:
- Changed to check return value ofpm_runtime_get_if_active()and only callpm_runtime_put()if the device is active.
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- changed to usepm_runtime_get_if_active()
- add correspondingput()
- Link to v1: https://patch.msgid.link/[email protected]To: Raspberry Pi Kernel Maintenance <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Florian Fainelli <[email protected]>
To: Ray Jui <[email protected]>
To: Scott Branden <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Sakari Ailus <[email protected]>
To: Jean-Michel Hautbois <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans Verkuil <[email protected]>
To: Naushir Patuck <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/media/platform/broadcom/bcm2835-unicam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/media/platform/broadcom/bcm2835-unicam.c +9
-0@@ -2043,6 +2043,7 @@ static int unicam_log_status(struct file *file, void *fh)struct unicam_node *node =video_drvdata (file);struct unicam_device *unicam = node->dev;u32 reg; +int pm_active;/* status for sub devices */ v4l2_device_call_all (&unicam->v4l2_dev,0 , core, log_status);@@ -2052,6 +2053,14 @@ static int unicam_log_status(struct file *file, void *fh) node->fmt.fmt.pix.width, node->fmt.fmt.pix.height);dev_info (unicam->dev,"V4L2 format: %08x\n" , node->fmt.fmt.pix.pixelformat); + + pm_active =pm_runtime_get_if_active (unicam->dev); +if (!pm_active) { +dev_info (unicam->dev, +"Live data N/A due to device inactive\n" ); +return 0 ; + } + reg =unicam_reg_read (unicam,UNICAM_IPIPE ); dev_info(unicam->dev, "Unpacking/packing: %u / %u\n", unicam_get_field(reg, UNICAM_PUM_MASK),@@ -2065,6 +2074,9 @@ static int unicam_log_status(struct file *file, void *fh)dev_info (unicam->dev,"Write pointer: %08x\n" ,unicam_reg_read (unicam,UNICAM_IBWP ));
Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_log_status(struct file *file, void *fh) · line 2078
Quoted 2 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +2
-0+if (pm_active ==1 ) +pm_runtime_put (unicam->dev);As far as I understand, the discussion on v2 concluded there was no need to test
pm_activehere. Did I miss anything ?
Sorry, I saw the message from Sakari and he was pretty confident on the right way, he even mentioned that all sensors should be fixed, and has not come up with a follow up since.
If v2 is the right way, please disregard this v3
Eugen
Quoted 10 lines
Quoted 9 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1+return 0 ; } ---base-commit:
e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260521-bcmpipm-6c578e73239c
Quoted 77 lines · Eugen Hristev
Quoted 70 lines · Laurent Pinchart
Quoted 69 lines · Eugen Hristev
When requesting log status, the block might be powered off, but registers are being read.
Avoid reading the registers if the device is not resumed, thus also avoid powering up the device just for log status.Fixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>---
Changes in v3:
- Changed to check return value ofpm_runtime_get_if_active()and only callpm_runtime_put()if the device is active.
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- changed to usepm_runtime_get_if_active()
- add correspondingput()
- Link to v1: https://patch.msgid.link/[email protected]To: Raspberry Pi Kernel Maintenance <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Florian Fainelli <[email protected]>
To: Ray Jui <[email protected]>
To: Scott Branden <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Sakari Ailus <[email protected]>
To: Jean-Michel Hautbois <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans Verkuil <[email protected]>
To: Naushir Patuck <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/media/platform/broadcom/bcm2835-unicam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/media/platform/broadcom/bcm2835-unicam.c +9
-0@@ -2043,6 +2043,7 @@ static int unicam_log_status(struct file *file, void *fh)struct unicam_node *node =video_drvdata (file);struct unicam_device *unicam = node->dev;u32 reg; +int pm_active;/* status for sub devices */ v4l2_device_call_all (&unicam->v4l2_dev,0 , core, log_status);@@ -2052,6 +2053,14 @@ static int unicam_log_status(struct file *file, void *fh) node->fmt.fmt.pix.width, node->fmt.fmt.pix.height);dev_info (unicam->dev,"V4L2 format: %08x\n" , node->fmt.fmt.pix.pixelformat); + + pm_active =pm_runtime_get_if_active (unicam->dev); +if (!pm_active) { +dev_info (unicam->dev, +"Live data N/A due to device inactive\n" ); +return 0 ; + } + reg =unicam_reg_read (unicam,UNICAM_IPIPE ); dev_info(unicam->dev, "Unpacking/packing: %u / %u\n", unicam_get_field(reg, UNICAM_PUM_MASK),@@ -2065,6 +2074,9 @@ static int unicam_log_status(struct file *file, void *fh)dev_info (unicam->dev,"Write pointer: %08x\n" ,unicam_reg_read (unicam,UNICAM_IBWP ));Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_log_status(struct file *file, void *fh) · line 2078
Quoted 2 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +2
-0+if (pm_active ==1 ) +pm_runtime_put (unicam->dev);As far as I understand, the discussion on v2 concluded there was no need to test
pm_activehere. Did I miss anything ?
Quoted 4 lines
Sorry, I saw the message from Sakari and he was pretty confident on the right way, he even mentioned that all sensors should be fixed, and has not come up with a follow up since.
If v2 is the right way, please disregard this v3
Let's see what Sakari has to say :-)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1+return 0 ; } ---base-commit:
e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260521-bcmpipm-6c578e73239c
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 78 lines · Laurent Pinchart
Quoted 77 lines · Eugen Hristev
Quoted 75 lines · Laurent Pinchart
Quoted 66 lines · Eugen Hristev
When requesting log status, the block might be powered off, but registers are being read.
Avoid reading the registers if the device is not resumed, thus also avoid powering up the device just for log status.Fixes 392cd78d495f ("media: bcm2835-unicam: Add support for CCP2/CSI2 camera interface")Signed-off-by Eugen Hristev <[email protected]>---
Changes in v3:
- Changed to check return value ofpm_runtime_get_if_active()and only callpm_runtime_put()if the device is active.
- Link to v2: https://patch.msgid.link/[email protected]Changes in v2:
- changed to usepm_runtime_get_if_active()
- add correspondingput()
- Link to v1: https://patch.msgid.link/[email protected]To: Raspberry Pi Kernel Maintenance <[email protected]>
To: Mauro Carvalho Chehab <[email protected]>
To: Florian Fainelli <[email protected]>
To: Ray Jui <[email protected]>
To: Scott Branden <[email protected]>
To: Broadcom internal kernel review list <[email protected]>
To: Sakari Ailus <[email protected]>
To: Jean-Michel Hautbois <[email protected]>
To: Laurent Pinchart <[email protected]>
To: Hans Verkuil <[email protected]>
To: Naushir Patuck <[email protected]>
Cc: Dave Stevenson <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]--- drivers/media/platform/broadcom/bcm2835-unicam.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/media/platform/broadcom/bcm2835-unicam.c +9
-0@@ -2043,6 +2043,7 @@ static int unicam_log_status(struct file *file, void *fh)struct unicam_node *node =video_drvdata (file);struct unicam_device *unicam = node->dev;u32 reg; +int pm_active;/* status for sub devices */ v4l2_device_call_all (&unicam->v4l2_dev,0 , core, log_status);@@ -2052,6 +2053,14 @@ static int unicam_log_status(struct file *file, void *fh) node->fmt.fmt.pix.width, node->fmt.fmt.pix.height);dev_info (unicam->dev,"V4L2 format: %08x\n" , node->fmt.fmt.pix.pixelformat); + + pm_active =pm_runtime_get_if_active (unicam->dev); +if (!pm_active) { +dev_info (unicam->dev, +"Live data N/A due to device inactive\n" ); +return 0 ; + } + reg =unicam_reg_read (unicam,UNICAM_IPIPE ); dev_info(unicam->dev, "Unpacking/packing: %u / %u\n", unicam_get_field(reg, UNICAM_PUM_MASK),drivers/media/platform/broadcom/bcm2835-unicam.c static int unicam_log_status(struct file *file, void *fh) · line 2078
Quoted 5 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +2
-0@@ -2065,6 +2074,9 @@ static int unicam_log_status(struct file *file, void *fh)dev_info (unicam->dev,"Write pointer: %08x\n" ,unicam_reg_read (unicam,UNICAM_IBWP )); +if (pm_active ==1 ) +pm_runtime_put (unicam->dev);As far as I understand, the discussion on v2 concluded there was no need to test
pm_activehere. Did I miss anything ?
Quoted 6 lines
Quoted 4 lines
Sorry, I saw the message from Sakari and he was pretty confident on the right way, he even mentioned that all sensors should be fixed, and has not come up with a follow up since.
If v2 is the right way, please disregard this v3Let's see what Sakari has to say :-)
Hi Sakari,
Could you please let me know whether this v3 is the way you want this to move forward ?
I have some pending things on top of this. If something is not right let me know so I can send a v4.
Thanks,
Eugen
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/platform/broadcom/bcm2835-unicam.c +1
-1+return 0 ; } ---base-commit:
e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260521-bcmpipm-6c578e73239c