Page MenuHomeFreeBSD

Fix clock source in the API safe_pause_*() in e1000 driver
Needs ReviewPublic

Authored by joyul_juniper.net on Dec 6 2023, 12:28 AM.
Tags
None
Referenced Files
F83210175: D42920.diff
Tue, May 7, 6:11 PM
Unknown Object (File)
Mar 15 2024, 4:21 AM
Unknown Object (File)
Jan 20 2024, 2:00 PM
Unknown Object (File)
Dec 26 2023, 8:11 PM
Subscribers
None

Details

Reviewers
kbowling
jhibbits
Summary

Based on sysinit_sub_id, SI_SUB_CLOCKS is after SI_SUB_CONFIGURE.
SI_SUB_CONFIGURE  = 0x3800000,  /* Configure devices */   At this stage, the variable “cold” will be set to 0.
SI_SUB_CLOCKS    = 0x4800000,  /* real-time and stat clocks*/ At this stage, the clock configuration will be done, and the real-time clock can be used.

In the e1000 driver, if the API safe_pause_* are called between SI_SUB_CONFIGURE and SI_SUB_CLOCKS stages, it will choose the wrong clock source. The API safe_pause_* uses “cold,” the value of which is updated in SI_SUB_CONFIGURE, to decide if the real-time clock source is ready. However, the real-time clock is not ready till the SI_SUB_CLOCKS routines are done.

Test Plan
  1. Replicate the issue:

We create a new sysinit for example SI_SUB_INTERNAL_CONFIGURE with sysinit_sub_id 0x4000000.
It will reconfigure/reset the network interface and call e1000_reset_hw_82540.

Inside e1000_reset_hw_82540, msec_delay(x), which refers to safe_pause_*, will be called.
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/e1000/e1000_82540.c#L288
Then, the system hangs.

  1. Verify the patch:

We apply this patch and rerun our SI_SUB_INTERNAL_CONFIGURE; the system can boot up without a hang.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joyul_juniper.net created this revision.
sys/dev/e1000/e1000_osdep.c
40

I think we need a better name, "flip_clock_source" doesn't convey what is done here. Maybe "enable_pause_delay" instead.