lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240425182951.2iq2lqngkkoy2fvo@DEN-DL-M31836.microchip.com>
Date: Thu, 25 Apr 2024 20:29:51 +0200
From: Horatiu Vultur <horatiu.vultur@...rochip.com>
To: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
CC: <andrew@...n.ch>, <hkallweit1@...il.com>, <linux@...linux.org.uk>,
	<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
	<pabeni@...hat.com>, <richardcochran@...il.com>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] net: phy: micrel: Add support for PTP_PF_EXTTS
 for lan8814

The 04/25/2024 01:10, Vadim Fedorenko wrote:
> > > > +static int lan8814_ptp_extts(struct ptp_clock_info *ptpci,
> > > > +                          struct ptp_clock_request *rq, int on)
> > > > +{
> > > > +     struct lan8814_shared_priv *shared = container_of(ptpci, struct lan8814_shared_priv,
> > > > +                                                       ptp_clock_info);
> > > > +     struct phy_device *phydev = shared->phydev;
> > > > +     int pin;
> > > > +
> > > > +     if (rq->extts.flags & ~(PTP_ENABLE_FEATURE |
> > > > +                             PTP_EXTTS_EDGES |
> > > > +                             PTP_STRICT_FLAGS))
> > > > +             return -EOPNOTSUPP;
> > > > +
> > > > +     pin = ptp_find_pin(shared->ptp_clock, PTP_PF_EXTTS,
> > > > +                        rq->extts.index);
> > > > +     if (pin == -1 || pin != LAN8814_PTP_EXTTS_NUM)
> > > > +             return -EINVAL;
> > > 
> > > I'm not sure how will enable request pass this check?
> > > In lan8814_ptp_probe_once pins are initialized with PTP_PF_NONE,
> > > and ptp_find_pin will always return -1, which will end up with
> > > -EINVAL here and never hit lan8814_ptp_extts_on/lan8814_ptp_extts_off
> > > 
> > 
> > Why ptp_find_pin will always return -1? Because we can set the function
> > of the pin.
> 
> ah, I see, PTP_PIN_SETFUNC + PTP_EXTTS_REQUEST ioctls will do the
> configuration. Maybe make GPIO 3 as PTP_PF_EXTTS function by default?

I would like not to make GPIO 3 to have PTP_PF_EXTTS function by default
just to keep similar with the other driver in this file.

> 
> > ...
> > 
> >   >       }
> > > > @@ -3148,6 +3263,10 @@ static int lan8814_ptpci_verify(struct ptp_clock_info *ptp, unsigned int pin,
> > > >                if (pin >= LAN8814_PTP_PEROUT_NUM || pin != chan)
> > > >                        return -1;
> > > >                break;
> > > > +     case PTP_PF_EXTTS:
> > > > +             if (pin != LAN8814_PTP_EXTTS_NUM)
> > > 
> > > Here the check states that exactly GPIO 3 can have EXTTS function, but
> > > later in the config...
> > 
> > ...
> > > 
> > > > +                     return -1;
> > > > +             break;
> > > >        default:
> > > >                return -1;
> > > >        }
> > > > 
> > > > @@ -3541,7 +3721,7 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev)
> > > >        snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name);
> > > >        shared->ptp_clock_info.max_adj = 31249999;
> > > >        shared->ptp_clock_info.n_alarm = 0;
> > > > -     shared->ptp_clock_info.n_ext_ts = 0;
> > > > +     shared->ptp_clock_info.n_ext_ts = LAN8814_PTP_EXTTS_NUM;
> > > 
> > > Here ptp_clock is configured to have 3 pins supporting EXTTS.
> > > Looks like it should be n_ext_ts = 1;
> > 
> > Good point, let me have a look at this.
> 
> I have checked it while checking enable part. Conditions in ptp_ioctl
> give no options to limit lowest number of pin which supports EXTTS.
> 
> I think that the ptp_clock_info documentation is misleading here:
> 
> * @n_ext_ts:  The number of external time stamp channels.
> 
> should be replaced to something like "max index of external time
> stamp channel".
> 
> With all above the patch LGTM!

Thanks for looking at this.

> 
> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
> 
> > 
> > > 
> > > >        shared->ptp_clock_info.n_pins = LAN8814_PTP_GPIO_NUM;
> > > >        shared->ptp_clock_info.pps = 0;
> > > >        shared->ptp_clock_info.pin_config = shared->pin_config;
> > > 
> > > 
> > 
> 

-- 
/Horatiu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ