Page MenuHomeFreeBSD

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

Authored by joyul_juniper.net on Dec 6 2023, 12:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 10:50 PM
Unknown Object (File)
Thu, Nov 7, 6:43 AM
Unknown Object (File)
Thu, Nov 7, 6:39 AM
Unknown Object (File)
Thu, Nov 7, 6:31 AM
Unknown Object (File)
Tue, Nov 5, 10:10 AM
Unknown Object (File)
Thu, Oct 31, 3:50 PM
Unknown Object (File)
Sep 30 2024, 7:09 PM
Unknown Object (File)
Sep 30 2024, 9:22 AM
Subscribers

Details

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

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.

This revision is now accepted and ready to land.Sep 25 2024, 9:13 AM
Owners added a reviewer: Restricted Owners Package.Sep 25 2024, 9:38 AM