On Thu, Mar 30, 2023 at 03:03:44AM +0200, Martin Pecka wrote:
> I have a suspicion regarding the code in sk.c:
> 
> ```c++
>     cfg.flags = HWTSTAMP_FLAG_BONDED_PHC_INDEX;
>     /* Fall back without flag if user run new build on old kernel */
>     if (ioctl(fd, SIOCGHWTSTAMP, &ifreq) == -EINVAL)
>         init_ifreq(&ifreq, &cfg, device);
> ```
> 
> The eqos driver returns EINVAL if any flag is set in the ioctl handler: 
> https://github.com/OE4T/linux-tegra-4.9/blob/oe4t-patches-l4t-r32.7.3/nvidia/drivers/net/ethernet/nvidia/eqos/drv.c#L3760
> .
> 
> However, the ioctl call has result -1, which is not -EINVAL, but -EPERM.

Yes, this part is weird. I saw the eqos_ioctl -> eqos_handle_hwtstamp_ioctl()
do return -EINVAL when there has config.flags.

> There is no EPERM in the ioctl handler code. So I'm not sure what mechanism
> kicks in that either doesn't even let the ioctl bubble to the driver, or
> that changes the return code. The consequence is that the fallback code is
> not called and thus the following ioctls try to first get PTP_V2_EVENT
> timestamping with the bond flag (timestamping mode is supported, but bonding
> is not), and then tries the rx_filter2, which is in this case
> PTP_V2_L2_EVENT (which is not supported by the driver).
> 
> Anyways, the fix for me would be checking the ioctl result also for -EPERM
> instead of just -EINVAL. Or, would there be any downside to just testing if

When I add this part, I made this checking strict to make sure it's a config
flag error. If it's other errors, we don't need to remove the flag and do
init_ifreq() again. I think we'd better find out why you got -1 return value
instead of change the return value checking blindly.

Richard, what do you think?

Thanks
Hangbin

> the ioctl result is negative? I've tested the code with this fix and it
> works for me. I have no idea about how it could or could not influence
> bonds.
> 
> Thanks for your help, Erez.
> 
> Martin
> 




_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to