Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [linux-next:master 13398/13940] drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3'
[not found] <202008060723.1gNgVvUi%lkp@intel.com>
@ 2020-08-06 18:17 ` Edward Cree
2020-08-10 15:51 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Edward Cree @ 2020-08-06 18:17 UTC (permalink / raw)
To: kernel test robot; +Cc: kbuild-all, netdev, linux-kernel
On 06/08/2020 00:48, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: d15fe4ec043588beee823781602ddb51d0bc84c8
> commit: adcfc3482ffff813fa2c34e5902005853f79c2aa [13398/13940] sfc_ef100: read Design Parameters at probe time
> config: microblaze-randconfig-r032-20200805 (attached as .config)
> compiler: microblaze-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> git checkout adcfc3482ffff813fa2c34e5902005853f79c2aa
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
> microblaze-linux-ld: drivers/net/ethernet/sfc/ef100_nic.o: in function `ef100_process_design_param':
>>> drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3'
> 605 /* Our TXQ and RXQ sizes are always power-of-two and thus divisible by
> 606 * EFX_MIN_DMAQ_SIZE, so we just need to check that
> 607 * EFX_MIN_DMAQ_SIZE is divisible by GRANULARITY.
> 608 * This is very unlikely to fail.
> 609 */
> > 610 if (EFX_MIN_DMAQ_SIZE % reader->value) {
So, this is (unsigned long) % (u64), whichI guess doesn't go quite
as smoothly 32-bit microcontrollers (though the thought of plugging
a 100-gig smartNIC into a microblaze boggles the mind a little ;).
And none of the math64.h functions seem to have the shape we want —
div_u64_rem() wants to write the remainder through a pointer, and
do_div() wants to modify the dividend (which is a constant in this
case). So whatever I do, it's gonna be ugly :(
Maybe I should add a
static inline u32 mod_u64(u64 dividend, u32 divisor)
{
return do_div(dividend, divisor);
}
to include/linux/math64.h? At least that way the ugly is centralised
in the header file.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 13398/13940] drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3'
2020-08-06 18:17 ` [linux-next:master 13398/13940] drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3' Edward Cree
@ 2020-08-10 15:51 ` Guenter Roeck
2020-08-11 8:55 ` Edward Cree
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2020-08-10 15:51 UTC (permalink / raw)
To: Edward Cree; +Cc: kernel test robot, kbuild-all, netdev, linux-kernel
On Thu, Aug 06, 2020 at 07:17:43PM +0100, Edward Cree wrote:
> On 06/08/2020 00:48, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head: d15fe4ec043588beee823781602ddb51d0bc84c8
> > commit: adcfc3482ffff813fa2c34e5902005853f79c2aa [13398/13940] sfc_ef100: read Design Parameters at probe time
> > config: microblaze-randconfig-r032-20200805 (attached as .config)
> > compiler: microblaze-linux-gcc (GCC) 9.3.0
> > reproduce (this is a W=1 build):
> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> > chmod +x ~/bin/make.cross
> > git checkout adcfc3482ffff813fa2c34e5902005853f79c2aa
> > # save the attached .config to linux build tree
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
> >
> > microblaze-linux-ld: drivers/net/ethernet/sfc/ef100_nic.o: in function `ef100_process_design_param':
> >>> drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3'
> > 605 /* Our TXQ and RXQ sizes are always power-of-two and thus divisible by
> > 606 * EFX_MIN_DMAQ_SIZE, so we just need to check that
> > 607 * EFX_MIN_DMAQ_SIZE is divisible by GRANULARITY.
> > 608 * This is very unlikely to fail.
> > 609 */
> > > 610 if (EFX_MIN_DMAQ_SIZE % reader->value) {
> So, this is (unsigned long) % (u64), whichI guess doesn't go quite
> as smoothly 32-bit microcontrollers (though the thought of plugging
> a 100-gig smartNIC into a microblaze boggles the mind a little ;).
> And none of the math64.h functions seem to have the shape we want —
> div_u64_rem() wants to write the remainder through a pointer, and
> do_div() wants to modify the dividend (which is a constant in this
> case). So whatever I do, it's gonna be ugly :(
>
> Maybe I should add a
>
> static inline u32 mod_u64(u64 dividend, u32 divisor)
> {
> return do_div(dividend, divisor);
> }
Your proposed function is an exact replicate of do_div() and thus doesn't
make much sense. Also, in your case, divisor is a 64-bit value, which is
causing the problem to start with. You could try something like
if (reader->value > EFX_MIN_DMAQ_SIZE || EFX_MIN_DMAQ_SIZE % (u32)reader->value)
If EFX_MIN_DMAQ_SIZE is indeed known to be a power of 2, you could also use
the knowledge that a 2^n value can only be divided by a smaller 2^n value,
meaning that reader->value must have exactly one bit set. This would also
avoid divide-by-0 issues if reader->value can be 0.
if (reader->value > EFX_MIN_DMAQ_SIZE || hweight64(reader->value) != 1)
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 13398/13940] drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3'
2020-08-10 15:51 ` Guenter Roeck
@ 2020-08-11 8:55 ` Edward Cree
0 siblings, 0 replies; 3+ messages in thread
From: Edward Cree @ 2020-08-11 8:55 UTC (permalink / raw)
To: Guenter Roeck; +Cc: kernel test robot, kbuild-all, netdev, linux-kernel
On 10/08/2020 16:51, Guenter Roeck wrote:
> On Thu, Aug 06, 2020 at 07:17:43PM +0100, Edward Cree wrote:
>> Maybe I should add a
>>
>> static inline u32 mod_u64(u64 dividend, u32 divisor)
>> {
>> return do_div(dividend, divisor);
>> }
> Your proposed function is an exact replicate of do_div()
No, because do_div() is a macro that modifies 'dividend', whereas by
wrapping it in an inline function mod_u64() implicitly creates a
local variable. Thus do_div() cannot be used on a constant, whereas
mod_u64() can.
> You could try something like
>
> if (reader->value > EFX_MIN_DMAQ_SIZE || EFX_MIN_DMAQ_SIZE % (u32)reader->value)
I considered that. It's ugly, so while it will work I think it's
worthlooking to see if there's a better way.
> If EFX_MIN_DMAQ_SIZE is indeed known to be a power of 2, you could also use
> the knowledge that a 2^n value can only be divided by a smaller 2^n value,
> meaning that reader->value must have exactly one bit set. This would also
> avoid divide-by-0 issues if reader->value can be 0.
>
> if (reader->value > EFX_MIN_DMAQ_SIZE || hweight64(reader->value) != 1)
This is also ugly and I don't like relying on the power-of-twoness —
it just feels fragile.
But you're right to point out that there's a div/0 issue, and if I'm
going to have to check for that, then ugliness is unavoidable. So
I think the least painful option available is probably
if (!reader->value || reader->value > EFX_MIN_DMAQ_SIZE ||
EFX_MIN_DMAQ_SIZE % (u32)reader->value)
which only assumes EFX_MIN_DMAQ_SIZE <= U32_MAX, an assumption I'm
comfortable with baking in.
I'll put together a formal patch with that.
Thanks for the help.
-ed
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-11 8:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <202008060723.1gNgVvUi%lkp@intel.com>
2020-08-06 18:17 ` [linux-next:master 13398/13940] drivers/net/ethernet/sfc/ef100_nic.c:610: undefined reference to `__umoddi3' Edward Cree
2020-08-10 15:51 ` Guenter Roeck
2020-08-11 8:55 ` Edward Cree
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).