staging: media: ipu3-imgu: Ensure correct binary selection
Subsystems (3)
Sakari Ailus
maintainerPATCH 1/1 staging: media: ipu3-imgu: Ensure correct binary selection
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.
Take this account in binary selection.
---
Hi Ricardo,
I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Compile tested only.
- Sakari
drivers/staging/media/ipu3/ipu3-css.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/staging/media/ipu3/ipu3-css.c +6 -0
@@ -1613,6 +1613,12 @@ static int imgu_css_find_binary(struct imgu_css *css, in->height > bi->info.isp.sp.input.max_height)continue ; +/* Check the striping overlap isn't wider than the stripe. */ +if (bi->info.isp.sp.iterator.num_stripes >1 && + rects[IPU3_CSS_RECT_BDS ].width < +4 *IPU3_UAPI_ISP_VEC_ELEMS *2 ) +continue ; +if (imgu_css_queue_enabled (&queue[IPU3_CSS_QUEUE_OUT ])) {if (bi->info.isp.num_output_pins <=0 )continue ;
Signature · 1 line
2.47.3
Hi Sakari
Quoted 8 lines · Sakari Ailus
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.Take this account in binary selection.
Quoted 7 lines
Signed-off-by Sakari Ailus <[email protected]>---
Hi Ricardo,I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Smatch should be calmed now:
But if you want to add more tests, you are of course welcome :)
Quoted 28 lines
Compile tested only.
- Sakari
drivers/staging/media/ipu3/ipu3-css.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/staging/media/ipu3/ipu3-css.c +6
-1@@ -1613,6 +1613,12 @@ static int imgu_css_find_binary(struct imgu_css *css, in->height > bi->info.isp.sp.input.max_height)continue ; +/* Check the striping overlap isn't wider than the stripe. */ +if (bi->info.isp.sp.iterator.num_stripes >1 && + rects[IPU3_CSS_RECT_BDS ].width < +4 *IPU3_UAPI_ISP_VEC_ELEMS *2 ) +continue ; +if (imgu_css_queue_enabled (&queue[IPU3_CSS_QUEUE_OUT ])) {if (bi->info.isp.num_output_pins <=0 )continue ; --2.47.3
Signature · 1 line
Ricardo Ribalda
Sakari Ailus
maintainerHi Ricardo,
Quoted 17 lines · Ricardo Ribalda
Hi Sakari
Quoted 12 lines · Sakari Ailus
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.Take this account in binary selection.
Signed-off-by Sakari Ailus <[email protected]>---
Hi Ricardo,
Quoted 7 lines
Quoted 3 lines
I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Smatch should be calmed now:
I dislike that because it's written simply to appease smatch and does not properly even try to address a problem. Can you try to revert it once this patch is merged? At the very least we need a comment on why that check is there.
Quoted 28 lines
But if you want to add more tests, you are of course welcome :)
Quoted 25 lines
Compile tested only.
- Sakari
drivers/staging/media/ipu3/ipu3-css.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/staging/media/ipu3/ipu3-css.c +6
-0@@ -1613,6 +1613,12 @@ static int imgu_css_find_binary(struct imgu_css *css, in->height > bi->info.isp.sp.input.max_height)continue ; +/* Check the striping overlap isn't wider than the stripe. */ +if (bi->info.isp.sp.iterator.num_stripes >1 && + rects[IPU3_CSS_RECT_BDS ].width < +4 *IPU3_UAPI_ISP_VEC_ELEMS *2 ) +continue ; +if (imgu_css_queue_enabled (&queue[IPU3_CSS_QUEUE_OUT ])) {if (bi->info.isp.num_output_pins <=0 )continue ;
Signature · 3 lines
Regards, Sakari Ailus
Hi Sakari
Quoted 25 lines · Sakari Ailus
Hi Ricardo,
Quoted 21 lines · Ricardo Ribalda
Hi Sakari
Quoted 15 lines · Sakari Ailus
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.Take this account in binary selection.
Signed-off-by Sakari Ailus <[email protected]>---
Hi Ricardo,I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Quoted 8 lines
Quoted 3 lines
Smatch should be calmed now:
I dislike that because it's written simply to appease smatch and does not properly even try to address a problem. Can you try to revert it once this patch is merged? At the very least we need a comment on why that check is there.
I think instead of reverting the patch, I think it would make more sense to do:
- if (offset > 65535)
+ if (WARN_ON(offset > 65535))
I believe it would be safer, that way if the condition changes in the caller we will catch this error earlier.
Quoted 34 lines
Quoted 20 lines
But if you want to add more tests, you are of course welcome :)
Quoted 16 lines
Compile tested only.
- Sakari
drivers/staging/media/ipu3/ipu3-css.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/staging/media/ipu3/ipu3-css.c +0
-0@@ -1613,6 +1613,12 @@ static int imgu_css_find_binary(struct imgu_css *css, in->height > bi->info.isp.sp.input.max_height)continue ;Quoted 9 lines
drivers/staging/media/ipu3/ipu3-css.c static int imgu_css_find_binary(struct imgu_css *css, · line 1624
Quoted 9 lines
drivers/staging/media/ipu3/ipu3-css.c +6
-0+/* Check the striping overlap isn't wider than the stripe. */ +if (bi->info.isp.sp.iterator.num_stripes >1 && + rects[IPU3_CSS_RECT_BDS ].width < +4 *IPU3_UAPI_ISP_VEC_ELEMS *2 ) +continue ; +if (imgu_css_queue_enabled (&queue[IPU3_CSS_QUEUE_OUT ])) {if (bi->info.isp.num_output_pins <=0 )continue ;--
Regards,Sakari Ailus
Signature · 1 line
Ricardo Ribalda
Sakari Ailus
maintainerHi Ricardo,
Quoted 37 lines · Ricardo Ribalda
Hi Sakari
Quoted 25 lines · Sakari Ailus
Hi Ricardo,
Quoted 21 lines · Ricardo Ribalda
Hi Sakari
Quoted 15 lines · Sakari Ailus
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.Take this account in binary selection.
Signed-off-by Sakari Ailus <[email protected]>---
Hi Ricardo,I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Quoted 8 lines
Quoted 3 lines
Smatch should be calmed now:
I dislike that because it's written simply to appease smatch and does not properly even try to address a problem. Can you try to revert it once this patch is merged? At the very least we need a comment on why that check is there.
Quoted 7 lines
I think instead of reverting the patch, I think it would make more sense to do:
- if (offset > 65535)
+ if (WARN_ON(offset > 65535))I believe it would be safer, that way if the condition changes in the caller we will catch this error earlier.
Is there a need for an extra check in the code if smatch can perform it at build time?
Signature · 3 lines
Regards, Sakari Ailus
Hi Sakari
Quoted 43 lines · Sakari Ailus
Hi Ricardo,
Quoted 39 lines · Ricardo Ribalda
Hi Sakari
Quoted 25 lines · Sakari Ailus
Hi Ricardo,
Quoted 21 lines · Ricardo Ribalda
Hi Sakari
Quoted 15 lines · Sakari Ailus
The ImgU has two sets of binaries, those that support striping (fixed at
2) and those that don't. There's overlap between the stripes and so that implies a minimum width for the images themselves, or the Bayer downscale rectangle in particular.Take this account in binary selection.
Signed-off-by Sakari Ailus <[email protected]>---
Hi Ricardo,I'm not sure if this makes smatch happy but it somehow addresses the issue it found. In the end it's up to the userspace to configure this correctly...
Quoted 8 lines
Quoted 3 lines
Smatch should be calmed now:
I dislike that because it's written simply to appease smatch and does not properly even try to address a problem. Can you try to revert it once this patch is merged? At the very least we need a comment on why that check is there.
I think instead of reverting the patch, I think it would make more sense to do:
Quoted 8 lines
Quoted 5 lines
- if (offset > 65535)
+ if (WARN_ON(offset > 65535))I believe it would be safer, that way if the condition changes in the caller we will catch this error earlier.
Is there a need for an extra check in the code if smatch can perform it at build time?
There are no guarantees regarding how smatch will behave in future versions.
Also, smatch stops testing the code after some "effort", if the code is more complex it will not test it.
The only way to be sure there are no errors is with asserts.
Quoted 5 lines
--
Regards,Sakari Ailus
Signature · 1 line
Ricardo Ribalda