Re: [v8] misc: pci_endpoint_test: Fix overflow of bar_size

Hans Zhang
2025-01-07T16:13:09Z

On 2025/1/7 23:57, Niklas Cassel wrote:>>> The error:
>>> drivers/misc/pci_endpoint_test.c:315: undefined reference to `__udivmoddi4'
>>> sounds like the compiler is using a specialized instruction to do both div
>>> and mod in one. By removing the mod in patch 1/2, I expect that patch 2/2
>>> will no longer get this error.
>>
>> The __udivmoddi4 may be the way div and mod are combined.
>>
>> Delete remain's patch 1/2 according to your suggestion. I compiled it as a
>> KO module for an experiment.
>>
>> There are still __udivdi3 errors, so the do_div API must be used.
>
> Ok. Looking at do_div(), it seems to be the correct API to use
> for this problem. Just change bar_size type to u64 (instead of casting)
> and use do_div() ? That is how it is seems to be used in other drivers.
>
> I still think that a patch that removes the "remainder" code is a good
> cleanup, so please send it as patch 1/2, you can be the author, just add:
> Suggested-by: Niklas Cassel <cassel@kernel.org>
>

Thank you very much for Niklas' discussion on this patch. I will
resubmit two patches in the future.

Best regards
Hans