* Re: drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection [not found] ` <ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b> @ 2025-11-22 6:29 ` Nathan Chancellor 2025-11-23 22:29 ` Sakari Ailus 0 siblings, 1 reply; 5+ messages in thread From: Nathan Chancellor @ 2025-11-22 6:29 UTC (permalink / raw) To: Josh Poimboeuf Cc: kernel test robot, oe-kbuild-all, linux-kernel, Ingo Molnar, Sakari Ailus, linux-media On Fri, Nov 21, 2025 at 09:51:33PM -0800, Josh Poimboeuf wrote: > On Fri, Nov 21, 2025 at 06:34:14PM -0700, Nathan Chancellor wrote: > > On Sat, Nov 22, 2025 at 08:41:37AM +0800, kernel test robot wrote: > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > head: 2eba5e05d9bcf4cdea995ed51b0f07ba0275794a > > > commit: 188d90f817e13b66e03e110eb6f82e8f5f0d654b objtool: Append "()" to function name in "unexpected end of section" warning > > > date: 8 months ago > > > :::::: branch date: 4 hours ago > > > :::::: commit date: 8 months ago > > > config: x86_64-randconfig-101-20251122 (https://download.01.org/0day-ci/archive/20251122/202511220717.5HHMLUHG-lkp@intel.com/config) > > > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251122/202511220717.5HHMLUHG-lkp@intel.com/reproduce) > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > the same patch/commit), kindly add following tags > > > | Reported-by: kernel test robot <lkp@intel.com> > > > | Closes: https://lore.kernel.org/r/202511220717.5HHMLUHG-lkp@intel.com/ > > > > > > All errors (new ones prefixed by >>): > > > > > > >> drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection > > > > That change obviously does not result in this warning/error. This > > appears to be another divide by zero issue but based on my analysis so > > far, I do not understand how... > > > > https://github.com/ClangBuiltLinux/linux/issues/2129 > > Here ya go :-) After looking at a gazillion of these I can often spot > these pretty easily. I'm not sure what the correct fix is here but this > made the error go away. > > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c > index 1c889c878abd..2429c05bffb3 100644 > --- a/drivers/media/i2c/ccs/ccs-core.c > +++ b/drivers/media/i2c/ccs/ccs-core.c > @@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, > * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; > max_m = crops[CCS_PAD_SINK]->width > * CCS_LIM(sensor, SCALER_N_MIN) > - / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); > + / (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ? : 1); > > a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), > CCS_LIM(sensor, SCALER_M_MAX)); Aha! Thanks a lot :) I had thought it might be something with CCS_LIM() since ccs_get_limit() returns zero if ccs_limit_ptr() errors and in the default case of the switch statement. There are a lot of unchecked divides with the result of CCS_LIM() throughout this driver so I figured if that was it, there would be other instances of this warning... oh well. Something like the following diff also fixes it since LLVM no longer sees 0 as a possible divisor, which seems a little better to me since it seems like one of the other uses could turn problematic with other optimizations. Given these cases are both errors and have visible WARNs in case they are hit, it seems like it is better to use a valid divisor instead of 0. Just one more warning to tackle in my personal configuration then I can enable CONFIG_OBJTOOL_WERROR to make new warnings from LLVM uprevs more obvious :) https://github.com/ClangBuiltLinux/linux/issues/2130 diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 1c889c878abd..05c3da29f14c 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -137,7 +137,7 @@ u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, ret = ccs_limit_ptr(sensor, limit, offset, &ptr); if (ret) - return 0; + return 1; switch (CCI_REG_WIDTH_BYTES(ccs_limits[ccs_limit_offsets[limit].info].reg)) { case sizeof(u8): @@ -151,7 +151,7 @@ u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, break; default: WARN_ON(1); - return 0; + return 1; } return ccs_reg_conv(sensor, ccs_limits[limit].reg, val); ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection 2025-11-22 6:29 ` drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection Nathan Chancellor @ 2025-11-23 22:29 ` Sakari Ailus 2025-11-24 18:44 ` Nathan Chancellor 0 siblings, 1 reply; 5+ messages in thread From: Sakari Ailus @ 2025-11-23 22:29 UTC (permalink / raw) To: Nathan Chancellor Cc: Josh Poimboeuf, kernel test robot, oe-kbuild-all, linux-kernel, Ingo Molnar, linux-media Hi folks, On Fri, Nov 21, 2025 at 11:29:46PM -0700, Nathan Chancellor wrote: > On Fri, Nov 21, 2025 at 09:51:33PM -0800, Josh Poimboeuf wrote: > > On Fri, Nov 21, 2025 at 06:34:14PM -0700, Nathan Chancellor wrote: > > > On Sat, Nov 22, 2025 at 08:41:37AM +0800, kernel test robot wrote: > > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > > > > head: 2eba5e05d9bcf4cdea995ed51b0f07ba0275794a > > > > commit: 188d90f817e13b66e03e110eb6f82e8f5f0d654b objtool: Append "()" to function name in "unexpected end of section" warning > > > > date: 8 months ago > > > > :::::: branch date: 4 hours ago > > > > :::::: commit date: 8 months ago > > > > config: x86_64-randconfig-101-20251122 (https://download.01.org/0day-ci/archive/20251122/202511220717.5HHMLUHG-lkp@intel.com/config) > > > > compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) > > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251122/202511220717.5HHMLUHG-lkp@intel.com/reproduce) > > > > > > > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > > > > the same patch/commit), kindly add following tags > > > > | Reported-by: kernel test robot <lkp@intel.com> > > > > | Closes: https://lore.kernel.org/r/202511220717.5HHMLUHG-lkp@intel.com/ > > > > > > > > All errors (new ones prefixed by >>): > > > > > > > > >> drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection > > > > > > That change obviously does not result in this warning/error. This > > > appears to be another divide by zero issue but based on my analysis so > > > far, I do not understand how... > > > > > > https://github.com/ClangBuiltLinux/linux/issues/2129 > > > > Here ya go :-) After looking at a gazillion of these I can often spot > > these pretty easily. I'm not sure what the correct fix is here but this > > made the error go away. > > > > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c > > index 1c889c878abd..2429c05bffb3 100644 > > --- a/drivers/media/i2c/ccs/ccs-core.c > > +++ b/drivers/media/i2c/ccs/ccs-core.c > > @@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, > > * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; > > max_m = crops[CCS_PAD_SINK]->width > > * CCS_LIM(sensor, SCALER_N_MIN) > > - / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); > > + / (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ? : 1); Thanks for cc'ing me. I prefer this as there's no guarantee the value read via ccs_get_limit() would be non-zero. Presumably it is (and has been so far as no-one has hit this to my knowledge), but we shouldn't rely on that. I can post a patch as well. > > > > a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), > > CCS_LIM(sensor, SCALER_M_MAX)); > > Aha! Thanks a lot :) I had thought it might be something with CCS_LIM() > since ccs_get_limit() returns zero if ccs_limit_ptr() errors and in the > default case of the switch statement. There are a lot of unchecked > divides with the result of CCS_LIM() throughout this driver so I figured > if that was it, there would be other instances of this warning... oh > well. > > Something like the following diff also fixes it since LLVM no longer > sees 0 as a possible divisor, which seems a little better to me since it > seems like one of the other uses could turn problematic with other > optimizations. Given these cases are both errors and have visible WARNs > in case they are hit, it seems like it is better to use a valid divisor > instead of 0. > > Just one more warning to tackle in my personal configuration then I can > enable CONFIG_OBJTOOL_WERROR to make new warnings from LLVM uprevs more > obvious :) > > https://github.com/ClangBuiltLinux/linux/issues/2130 > > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c > index 1c889c878abd..05c3da29f14c 100644 > --- a/drivers/media/i2c/ccs/ccs-core.c > +++ b/drivers/media/i2c/ccs/ccs-core.c > @@ -137,7 +137,7 @@ u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, > > ret = ccs_limit_ptr(sensor, limit, offset, &ptr); > if (ret) > - return 0; > + return 1; > > switch (CCI_REG_WIDTH_BYTES(ccs_limits[ccs_limit_offsets[limit].info].reg)) { > case sizeof(u8): > @@ -151,7 +151,7 @@ u32 ccs_get_limit(struct ccs_sensor *sensor, unsigned int limit, > break; > default: > WARN_ON(1); > - return 0; > + return 1; > } > > return ccs_reg_conv(sensor, ccs_limits[limit].reg, val); -- Kind regards, Sakari Ailus ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection 2025-11-23 22:29 ` Sakari Ailus @ 2025-11-24 18:44 ` Nathan Chancellor 2025-11-24 23:00 ` [PATCH 1/1] media: ccs: Avoid possible division by zero Sakari Ailus 0 siblings, 1 reply; 5+ messages in thread From: Nathan Chancellor @ 2025-11-24 18:44 UTC (permalink / raw) To: Sakari Ailus Cc: Josh Poimboeuf, kernel test robot, oe-kbuild-all, linux-kernel, Ingo Molnar, linux-media Hi Sakari, On Mon, Nov 24, 2025 at 12:29:06AM +0200, Sakari Ailus wrote: > Thanks for cc'ing me. > > I prefer this as there's no guarantee the value read via ccs_get_limit() > would be non-zero. Presumably it is (and has been so far as no-one has hit > this to my knowledge), but we shouldn't rely on that. Ah, that makes sense. I misread some of the other places I thought were using the value of CCS_LIM() as a divisor, guess I forgot my elementary order of operations :) This appears to be the only overt one that I can see. > I can post a patch as well. If you have time, that would be great (I am happy to build test and review it). Otherwise, I can get to it soon. Cheers, Nathan ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/1] media: ccs: Avoid possible division by zero 2025-11-24 18:44 ` Nathan Chancellor @ 2025-11-24 23:00 ` Sakari Ailus 2025-11-25 23:24 ` Nathan Chancellor 0 siblings, 1 reply; 5+ messages in thread From: Sakari Ailus @ 2025-11-24 23:00 UTC (permalink / raw) To: linux-media; +Cc: Nathan Chancellor, Josh Poimboeuf, Ingo Molnar, linux-kernel Calculating maximum M for scaler configuration involves dividing by MIN_X_OUTPUT_SIZE limit register's value. Albeit the value is presumably non-zero, the driver was missing the check it in fact was. Fix this. Reported-by: Josh Poimboeuf <jpoimboe@kernel.org> Closes: https://lore.kernel.org/all/ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b/ Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver") Cc: stable@vger.kernel.org # for 5.15 and later Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- Not tested but what could go wrong here? :-) drivers/media/i2c/ccs/ccs-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index f8523140784c..dadff8c50679 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; max_m = crops[CCS_PAD_SINK]->width * CCS_LIM(sensor, SCALER_N_MIN) - / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); + / (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ?: 1); a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), CCS_LIM(sensor, SCALER_M_MAX)); -- 2.47.3 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] media: ccs: Avoid possible division by zero 2025-11-24 23:00 ` [PATCH 1/1] media: ccs: Avoid possible division by zero Sakari Ailus @ 2025-11-25 23:24 ` Nathan Chancellor 0 siblings, 0 replies; 5+ messages in thread From: Nathan Chancellor @ 2025-11-25 23:24 UTC (permalink / raw) To: Sakari Ailus; +Cc: linux-media, Josh Poimboeuf, Ingo Molnar, linux-kernel On Tue, Nov 25, 2025 at 01:00:45AM +0200, Sakari Ailus wrote: > Calculating maximum M for scaler configuration involves dividing by > MIN_X_OUTPUT_SIZE limit register's value. Albeit the value is presumably > non-zero, the driver was missing the check it in fact was. Fix this. > > Reported-by: Josh Poimboeuf <jpoimboe@kernel.org> > Closes: https://lore.kernel.org/all/ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b/ > Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver") > Cc: stable@vger.kernel.org # for 5.15 and later > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> > --- This clears up the objtool warning for me. Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> # build > drivers/media/i2c/ccs/ccs-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c > index f8523140784c..dadff8c50679 100644 > --- a/drivers/media/i2c/ccs/ccs-core.c > +++ b/drivers/media/i2c/ccs/ccs-core.c > @@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, > * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height; > max_m = crops[CCS_PAD_SINK]->width > * CCS_LIM(sensor, SCALER_N_MIN) > - / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE); > + / (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ?: 1); > > a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN), > CCS_LIM(sensor, SCALER_M_MAX)); > -- > 2.47.3 > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-25 23:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <aSEGwejeD3f7lnUL@rli9-mobl>
[not found] ` <20251122013414.GA3094872@ax162>
[not found] ` <ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b>
2025-11-22 6:29 ` drivers/media/i2c/ccs/ccs.o: error: objtool: ccs_set_selection(): unexpected end of section .text.ccs_set_selection Nathan Chancellor
2025-11-23 22:29 ` Sakari Ailus
2025-11-24 18:44 ` Nathan Chancellor
2025-11-24 23:00 ` [PATCH 1/1] media: ccs: Avoid possible division by zero Sakari Ailus
2025-11-25 23:24 ` Nathan Chancellor
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox