[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADEbmW0jfmgYH-jXRDRj3_AUs17+q3eJ5Ea_U9xidjuvjQDQkA@mail.gmail.com>
Date: Thu, 20 Jun 2024 08:06:20 +0200
From: Michal Schmidt <mschmidt@...hat.com>
To: Sergey Temerkhanov <sergey.temerkhanov@...el.com>
Cc: intel-wired-lan@...ts.osuosl.org, netdev@...r.kernel.org,
Przemek Kitszel <przemyslaw.kitszel@...el.com>
Subject: Re: [RFC PATCH iwl-next v1 2/4] ice: Add ice_get_ctrl_ptp() wrapper
to simplify the code
On Tue, Jun 18, 2024 at 3:53 PM Sergey Temerkhanov
<sergey.temerkhanov@...el.com> wrote:
> Add ice_get_ctrl_ptp() wrapper to simplify the PTP support code
> in the functions that do not use ctrl_pf directly
>
> Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@...el.com>
> Signed-off-by: Sergey Temerkhanov <sergey.temerkhanov@...el.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 57e1e5a5da4a..a2578bc2af54 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -16,6 +16,18 @@ static const struct ptp_pin_desc ice_pin_desc_e810t[] = {
> { "U.FL2", UFL2, PTP_PF_NONE, 2, { 0, } },
> };
>
> +static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf)
> +{
> + return !pf->adapter ? NULL : pf->adapter->ctrl_pf;
> +}
> +
> +static struct ice_ptp *ice_get_ctrl_ptp(struct ice_pf *pf)
> +{
> + struct ice_pf *ctrl_pf = ice_get_ctrl_pf(pf);
> +
> + return !ctrl_pf ? NULL : &ctrl_pf->ptp;
> +}
> +
> /**
> * ice_get_sma_config_e810t
> * @hw: pointer to the hw struct
> --
> 2.43.0
The patch order is incorrect. Here you access the ctrl_pf member,
which is added later in the subsequent patch.
But more importantly, it looks unsafe to access another ice_pf this
way. The administrator may unbind a PF from the driver in any order.
Can the shared objects be moved into struct ice_adapter itself so that
cross-ice_pf access becomes unnecessary?
Michal
Powered by blists - more mailing lists