net: dsa: mv88e6xxx: remove redundant ptp/timestamping code
Subsystems (4)
cover net: dsa: mv88e6xxx: remove redundant ptp/timestamping code
Hi,
mv88e6xxx as accumulated some unused data structures and code over the years. This series removes it and simplifies the code. See the patches for each change.
drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/chip.h | 2 -- drivers/net/dsa/mv88e6xxx/ptp.c | 55 ++++++---------------------------------- drivers/net/dsa/mv88e6xxx/ptp.h | 2 -- 4 files changed, 9 insertions(+), 52 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/4 net: dsa: mv88e6xxx: remove mv88e6250_ptp_ops
mv88e6250_ptp_ops and mv88e6352_ptp_ops are identical since commit 7e3c18097a70 ("net: dsa: mv88e6xxx: read cycle counter period from hardware"). Remove the unnecessary duplication.
--- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- drivers/net/dsa/mv88e6xxx/ptp.c | 23 ----------------------- drivers/net/dsa/mv88e6xxx/ptp.h | 2 -- 3 files changed, 1 insertion(+), 26 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +1 -1
@@ -5088,7 +5088,7 @@ static const struct mv88e6xxx_ops mv88e6250_ops = { .vtu_getnext = mv88e6185_g1_vtu_getnext, .vtu_loadpurge = mv88e6185_g1_vtu_loadpurge, .avb_ops = &mv88e6352_avb_ops, - .ptp_ops = &mv88e6250_ptp_ops, + .ptp_ops = &mv88e6352_ptp_ops, .phylink_get_caps = mv88e6250_phylink_get_caps, .set_max_frame_size = mv88e6185_g1_set_max_frame_size, };
drivers/net/dsa/mv88e6xxx/ptp.c +0 -23
@@ -413,29 +413,6 @@ const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = { (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ), }; -const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = { - .clock_read = mv88e6352_ptp_clock_read, - .ptp_enable = mv88e6352_ptp_enable, - .ptp_verify = mv88e6352_ptp_verify, - .event_work = mv88e6352_tai_event_work, - .port_enable = mv88e6352_hwtstamp_port_enable, - .port_disable = mv88e6352_hwtstamp_port_disable, - .n_ext_ts =1 , - .arr0_sts_reg =MV88E6XXX_PORT_PTP_ARR0_STS , - .arr1_sts_reg =MV88E6XXX_PORT_PTP_ARR1_STS , - .dep_sts_reg =MV88E6XXX_PORT_PTP_DEP_STS , - .rx_filters = (1 <<HWTSTAMP_FILTER_NONE ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L4_EVENT ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L4_SYNC ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L2_EVENT ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L2_SYNC ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_EVENT ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_SYNC ) | - (1 <<HWTSTAMP_FILTER_PTP_V2_DELAY_REQ ), -}; -const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = { .clock_read = mv88e6352_ptp_clock_read, .ptp_enable = mv88e6352_ptp_enable,
drivers/net/dsa/mv88e6xxx/ptp.h +0 -2
@@ -149,7 +149,6 @@ void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip); ptp_clock_info) extern const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops; -extern const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops;extern const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops;extern const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops;
@@ -170,7 +169,6 @@ static inline void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip) }static const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {}; -static const struct mv88e6xxx_ptp_ops mv88e6250_ptp_ops = {};static const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {};static const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {};
Signature · 1 line
2.47.3
Re: [PATCH net-next 1/4] net: dsa: mv88e6xxx: remove mv88e6250_ptp_ops
Quoted 5 lines · Russell King (Oracle)
mv88e6250_ptp_opsandmv88e6352_ptp_opsare identical since commit7e3c18097a70("net: dsa: mv88e6xxx: read cycle counter period from hardware"). Remove the unnecessary duplication.Signed-off-by Russell King (Oracle) <[email protected]>
PATCH 2/4 net: dsa: mv88e6xxx: remove chip->trig_config
In reply to Russell King (Oracle)chip->trig_config is never written, and thus takes the value zero. Remove this struct member and its single reader.
--- drivers/net/dsa/mv88e6xxx/chip.h | 1 - drivers/net/dsa/mv88e6xxx/ptp.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +0 -1
@@ -424,7 +424,6 @@ struct mv88e6xxx_chip {struct ptp_clock_info ptp_clock_info;struct delayed_work tai_event_work;struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO ]; -u16 trig_config;u16 evcap_config;u16 enable_count;
drivers/net/dsa/mv88e6xxx/ptp.c +1 -1
@@ -184,7 +184,7 @@ static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,if (!rising) chip->evcap_config |=MV88E6XXX_TAI_CFG_EVREQ_FALLING ; - global_config = (chip->evcap_config | chip->trig_config); + global_config = chip->evcap_config; err =mv88e6xxx_tai_write (chip,MV88E6XXX_TAI_CFG , global_config);if (err)return err;
Signature · 1 line
2.47.3
Re: [PATCH net-next 2/4] net: dsa: mv88e6xxx: remove chip->trig_config
Quoted 4 lines · Russell King (Oracle)
chip->trig_configis never written, and thus takes the value zero. Remove this struct member and its single reader.Signed-off-by Russell King (Oracle) <[email protected]>
PATCH 3/4 net: dsa: mv88e6xxx: remove chip->evcap_config
In reply to Russell King (Oracle)evcap_config is only read and written in mv88e6352_config_eventcap(), so it makes little sense to store it in the global chip struct. Make it a local variable instead.
--- drivers/net/dsa/mv88e6xxx/chip.h | 1 - drivers/net/dsa/mv88e6xxx/ptp.c | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.h +0 -1
@@ -424,7 +424,6 @@ struct mv88e6xxx_chip {struct ptp_clock_info ptp_clock_info;struct delayed_work tai_event_work;struct ptp_pin_desc pin_config[MV88E6XXX_MAX_GPIO ]; -u16 evcap_config;u16 enable_count;/* Current ingress and egress monitor ports */
drivers/net/dsa/mv88e6xxx/ptp.c +5 -6
@@ -175,17 +175,16 @@ static u64 mv88e6165_ptp_clock_read(struct cyclecounter *cc)static int mv88e6352_config_eventcap (struct mv88e6xxx_chip *chip,int event,int rising) { -u16 global_config; +u16 evap_config;u16 cap_config;int err; - chip->evcap_config =MV88E6XXX_TAI_CFG_CAP_OVERWRITE | -MV88E6XXX_TAI_CFG_CAP_CTR_START ; + evcap_config =MV88E6XXX_TAI_CFG_CAP_OVERWRITE | +MV88E6XXX_TAI_CFG_CAP_CTR_START ;if (!rising) - chip->evcap_config |=MV88E6XXX_TAI_CFG_EVREQ_FALLING ; + evcap_config |=MV88E6XXX_TAI_CFG_EVREQ_FALLING ; - global_config = chip->evcap_config; - err =mv88e6xxx_tai_write (chip,MV88E6XXX_TAI_CFG , global_config); + err =mv88e6xxx_tai_write (chip,MV88E6XXX_TAI_CFG , evcap_config);if (err)return err;
Signature · 1 line
2.47.3
Re: [PATCH net-next 3/4] net: dsa: mv88e6xxx: remove chip->evcap_config
Quoted 5 lines · Russell King (Oracle)
evcap_configis only read and written inmv88e6352_config_eventcap(), so it makes little sense to store it in the global chip struct. Make it a local variable instead.Signed-off-by Russell King (Oracle) <[email protected]>
kernel test robot
build botRe: [PATCH net-next 3/4] net: dsa: mv88e6xxx: remove chip->evcap_config
In reply to Russell King (Oracle)kernel test robot noticed the following build errors:
Hi Russell,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Russell-King-Oracle/net-dsa-mv88e6xxx-remove-mv88e6250_ptp_ops/20250910-034838 base: net-next/main patch link: https://lore.kernel.org/r/E1uw0Xk-00000004IOC-1EJd%40rmk-PC.armlinux.org.uk patch subject: [PATCH net-next 3/4] net: dsa: mv88e6xxx: remove chip->evcap_config config: i386-buildonly-randconfig-004-20250910 (https://download.01.org/0day-ci/archive/20250910/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250910/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/dsa/mv88e6xxx/ptp.c:182:2: error: use of undeclared identifier 'evcap_config'; did you mean 'evap_config'?
182 | evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
| ^~~~~~~~~~~~
| evap_config
drivers/net/dsa/mv88e6xxx/ptp.c:178:6: note: 'evap_config' declared here
178 | u16 evap_config;
| ^
drivers/net/dsa/mv88e6xxx/ptp.c:185:3: error: use of undeclared identifier 'evcap_config'; did you mean 'evap_config'?
185 | evcap_config |= MV88E6XXX_TAI_CFG_EVREQ_FALLING;
| ^~~~~~~~~~~~
| evap_config
drivers/net/dsa/mv88e6xxx/ptp.c:178:6: note: 'evap_config' declared here
178 | u16 evap_config;
| ^
drivers/net/dsa/mv88e6xxx/ptp.c:187:53: error: use of undeclared identifier 'evcap_config'; did you mean 'evap_config'?
187 | err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_CFG, evcap_config);
| ^~~~~~~~~~~~
| evap_config
drivers/net/dsa/mv88e6xxx/ptp.c:178:6: note: 'evap_config' declared here
178 | u16 evap_config;
| ^3 errors generated.
vim +182 drivers/net/dsa/mv88e6xxx/ptp.c
168
169 /* mv88e6352_config_eventcap - configure TAI event capture
170 * @event: PTP_CLOCK_PPS (internal) or PTP_CLOCK_EXTTS (external)
171 * @rising: zero for falling-edge trigger, else rising-edge trigger
172 *
173 * This will also reset the capture sequence counter.
174 */
175 static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,
176 int rising)
177 {
178 u16 evap_config;
179 u16 cap_config;
180 int err;
181
> 182 evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
183 MV88E6XXX_TAI_CFG_CAP_CTR_START;
184 if (!rising)
185 evcap_config |= MV88E6XXX_TAI_CFG_EVREQ_FALLING;
186
187 err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_CFG, evcap_config);
188 if (err)
189 return err;
190
191 if (event == PTP_CLOCK_PPS) {
192 cap_config = MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG;
193 } else if (event == PTP_CLOCK_EXTTS) {
194 /* if STATUS_CAP_TRIG is unset we capture PTP_EVREQ events */
195 cap_config = 0;
196 } else {
197 return -EINVAL;
198 }
199
200 /* Write the capture config; this also clears the capture counter */
201 err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_EVENT_STATUS,
202 cap_config);
203
204 return err;
205 }
206
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next 3/4] net: dsa: mv88e6xxx: remove chip->evcap_config
In reply to Russell King (Oracle)kernel test robot noticed the following build errors:
Hi Russell,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Russell-King-Oracle/net-dsa-mv88e6xxx-remove-mv88e6250_ptp_ops/20250910-034838 base: net-next/main patch link: https://lore.kernel.org/r/E1uw0Xk-00000004IOC-1EJd%40rmk-PC.armlinux.org.uk patch subject: [PATCH net-next 3/4] net: dsa: mv88e6xxx: remove chip->evcap_config config: i386-buildonly-randconfig-002-20250910 (https://download.01.org/0day-ci/archive/20250910/[email protected]/config) compiler: gcc-13 (Debian 13.3.0-16) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250910/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
drivers/net/dsa/mv88e6xxx/ptp.c: In function 'mv88e6352_config_eventcap':
>> drivers/net/dsa/mv88e6xxx/ptp.c:182:9: error: 'evcap_config' undeclared (first use in this function); did you mean 'evap_config'?
182 | evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
| ^~~~~~~~~~~~
| evap_config
drivers/net/dsa/mv88e6xxx/ptp.c:182:9: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/net/dsa/mv88e6xxx/ptp.c:178:13: warning: unused variable 'evap_config' [-Wunused-variable]
178 | u16 evap_config;
| ^~~~~~~~~~~vim +182 drivers/net/dsa/mv88e6xxx/ptp.c
168
169 /* mv88e6352_config_eventcap - configure TAI event capture
170 * @event: PTP_CLOCK_PPS (internal) or PTP_CLOCK_EXTTS (external)
171 * @rising: zero for falling-edge trigger, else rising-edge trigger
172 *
173 * This will also reset the capture sequence counter.
174 */
175 static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,
176 int rising)
177 {
> 178 u16 evap_config; 179 u16 cap_config; 180 int err; 181 > 182 evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
183 MV88E6XXX_TAI_CFG_CAP_CTR_START;
184 if (!rising)
185 evcap_config |= MV88E6XXX_TAI_CFG_EVREQ_FALLING;
186
187 err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_CFG, evcap_config);
188 if (err)
189 return err;
190
191 if (event == PTP_CLOCK_PPS) {
192 cap_config = MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG;
193 } else if (event == PTP_CLOCK_EXTTS) {
194 /* if STATUS_CAP_TRIG is unset we capture PTP_EVREQ events */
195 cap_config = 0;
196 } else {
197 return -EINVAL;
198 }
199
200 /* Write the capture config; this also clears the capture counter */
201 err = mv88e6xxx_tai_write(chip, MV88E6XXX_TAI_EVENT_STATUS,
202 cap_config);
203
204 return err;
205 }
206
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH 4/4 net: dsa: mv88e6xxx: remove unused support for PPS event capture
In reply to Russell King (Oracle)mv88e6352_config_eventcap() is documented as handling both EXTTS and PPS capture modes, but nothing ever calls it for PPS capture. Remove the unused PPS capture mode support.
--- drivers/net/dsa/mv88e6xxx/ptp.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c +3 -18
@@ -167,16 +167,13 @@ static u64 mv88e6165_ptp_clock_read(struct cyclecounter *cc) }/* mv88e6352_config_eventcap - configure TAI event capture -* @event: PTP_CLOCK_PPS (internal) or PTP_CLOCK_EXTTS (external) * @rising: zero for falling-edge trigger, else rising-edge trigger * * This will also reset the capture sequence counter. */ -static int mv88e6352_config_eventcap (struct mv88e6xxx_chip *chip,int event, -int rising) +static int mv88e6352_config_eventcap (struct mv88e6xxx_chip *chip,int rising) {u16 evap_config; -u16 cap_config;int err; evcap_config = MV88E6XXX_TAI_CFG_CAP_OVERWRITE |
@@ -188,20 +185,8 @@ static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,if (err)return err; -if (event ==PTP_CLOCK_PPS ) { - cap_config =MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG ; - }else if (event ==PTP_CLOCK_EXTTS ) { -/* if STATUS_CAP_TRIG is unset we capture PTP_EVREQ events */ - cap_config =0 ; - }else { -return -EINVAL ; - } -/* Write the capture config; this also clears the capture counter */ - err =mv88e6xxx_tai_write (chip,MV88E6XXX_TAI_EVENT_STATUS , - cap_config); - -return err; +return mv88e6xxx_tai_write (chip,MV88E6XXX_TAI_EVENT_STATUS ,0 ); }static void mv88e6352_tai_event_work (struct work_struct *ugly)
@@ -354,7 +339,7 @@ static int mv88e6352_ptp_enable_extts(struct mv88e6xxx_chip *chip,schedule_delayed_work (&chip->tai_event_work,TAI_EVENT_WORK_INTERVAL ); - err =mv88e6352_config_eventcap (chip,PTP_CLOCK_EXTTS , rising); + err =mv88e6352_config_eventcap (chip, rising); }else { func =MV88E6352_G2_SCRATCH_GPIO_PCTL_GPIO ;
Signature · 1 line
2.47.3
Re: [PATCH net-next 4/4] net: dsa: mv88e6xxx: remove unused support for PPS event capture
Quoted 8 lines · Russell King (Oracle)
mv88e6352_config_eventcap()is documented as handling both EXTTS and PPS capture modes, but nothing ever calls it for PPS capture. Remove the unused PPS capture mode support.Signed-off-by Russell King (Oracle) <[email protected]>--- drivers/net/dsa/mv88e6xxx/ptp.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
drivers/net/dsa/mv88e6xxx/ptp.c static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event, · line 192
Quoted 7 lines
drivers/net/dsa/mv88e6xxx/ptp.c +0
-2@@ -188,20 +185,8 @@ static int mv88e6352_config_eventcap(struct mv88e6xxx_chip *chip, int event,if (err)return err; -if (event ==PTP_CLOCK_PPS ) { - cap_config =MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG ;
nit: with this change MV88E6XXX_TAI_EVENT_STATUS_CAP_TRIG becomes unused macro.