Skip to contentSkip to conversation

usb: dwc2: USB on Agilex platform broken after commit 50fb0c128b6e

DISCUSSION Minas Harutyunyan 3 participants 8 messages Dec 13, 2021 – Dec 16, 2021 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi Dinh,

Quoted 46 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT)
[    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90
[    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr
[    1.625541] [<00000000255d793a>] dwc2_hsotg_irq
[    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d

Author: Artur Petrosyan<[email protected]>
Date:   Tue Apr 13 11:37:15 2021 +0400

usb: dwc2: Add clock gating entering flow by system suspend

If not hibernation nor partial power down are supported, clock gating is used to save power.

Adds a new flow of entering clock gating when PC is suspended.

Quoted 7 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

Thanks,
Minas

Quoted 5 lines

Do you have a suggestion on possible solution?

Thanks,
Dinh

#2 lore raw

Hi Minas,

Thanks for replying!

Quoted 49 lines · Minas Harutyunyan

Hi Dinh,

Quoted 46 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT)
[    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90
[    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr
[    1.625541] [<00000000255d793a>] dwc2_hsotg_irq
[    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d

Author: Artur Petrosyan<[email protected]>
Date:   Tue Apr 13 11:37:15 2021 +0400

usb: dwc2: Add clock gating entering flow by system suspend

If not hibernation nor partial power down are supported, clock gating is used to save power.

Adds a new flow of entering clock gating when PC is suspended.

Quoted 9 lines
Quoted 7 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 : 0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 : 0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C : 0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 : 0xFE0F0020

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

Dinh

#3 lore raw
Quoted 63 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 48 lines · Minas Harutyunyan

Hi Dinh,

Quoted 45 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT) [    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90 [    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr [    1.625541] [<00000000255d793a>] dwc2_hsotg_irq [    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d
Author: Artur Petrosyan<[email protected]> Date:   Tue Apr 13 11:37:15 2021 +0400

      usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
      Adds a new flow of entering clock gating when PC is suspended.

Quoted 9 lines
Quoted 7 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

Quoted 8 lines

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 : 0x00000000 [    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 : 0x238FFC90 [    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C : 0x1F8002E8 [    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 : 0xFE0F0020

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Dinh

#4 lore raw

Hi Dinh,

Quoted 81 lines · Dinh Nguyen
Quoted 72 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 49 lines · Minas Harutyunyan

Hi Dinh,

Quoted 46 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT) [    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90 [    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr [    1.625541] [<00000000255d793a>] dwc2_hsotg_irq [    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d
Author: Artur Petrosyan<[email protected]> Date:   Tue Apr 13 11:37:15 2021 +0400

      usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
      Adds a new flow of entering clock gating when PC is suspended.

Quoted 7 lines
Quoted 5 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 :
0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 :
0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C :
0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 :
0xFE0F0020

Quoted 5 lines

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

Quoted 4 lines

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Dinh

Could you please disable clock gating by adding to dwc2_set_default_params() function follow line:
p->no_clock_gating = true;
like in dwc2_set_s3c6400_params() function.

Thanks,
Minas

#5 lore raw
Quoted 87 lines · Minas Harutyunyan

Hi Dinh,

Quoted 84 lines · Dinh Nguyen
Quoted 72 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 49 lines · Minas Harutyunyan

Hi Dinh,

Quoted 46 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT) [    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90 [    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr [    1.625541] [<00000000255d793a>] dwc2_hsotg_irq [    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d
Author: Artur Petrosyan<[email protected]> Date:   Tue Apr 13 11:37:15 2021 +0400

      usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
      Adds a new flow of entering clock gating when PC is suspended.

Quoted 7 lines
Quoted 5 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 :
0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 :
0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C :
0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 :
0xFE0F0020

Quoted 5 lines

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Quoted 7 lines
Quoted 1 line

Dinh

Could you please disable clock gating by adding to dwc2_set_default_params() function follow line:
p->no_clock_gating = true;
like in dwc2_set_s3c6400_params() function.

That did not fix the issue. However, if I remove the line:

+ /* After entering suspend, hardware is not accessible */
+ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);

Then the issue gets fixed.

Dinh

#6 lore raw
Quoted 99 lines · Dinh Nguyen
Quoted 88 lines · Minas Harutyunyan

Hi Dinh,

Quoted 85 lines · Dinh Nguyen
Quoted 73 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 50 lines · Minas Harutyunyan

Hi Dinh,

Quoted 47 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT) [    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90 [    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr [    1.625541] [<00000000255d793a>] dwc2_hsotg_irq [    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d
Author: Artur Petrosyan<[email protected]> Date:   Tue Apr 13 11:37:15 2021 +0400

       usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
       Adds a new flow of entering clock gating when PC is suspended.

Quoted 7 lines
Quoted 5 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 :
0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 :
0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C :
0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 :
0xFE0F0020

Quoted 5 lines

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Quoted 7 lines
Quoted 1 line

Dinh

Could you please disable clock gating by adding to dwc2_set_default_params() function follow line:
p->no_clock_gating = true;
like in dwc2_set_s3c6400_params() function.

Quoted 7 lines

That did not fix the issue. However, if I remove the line:

+               /* After entering suspend, hardware is not accessible */ +               clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);

Then the issue gets fixed.

I don't see _dwc2_hcd_resume() getting called.

Dinh

#7 lore raw
Quoted 106 lines · Dinh Nguyen
Quoted 102 lines · Dinh Nguyen
Quoted 89 lines · Minas Harutyunyan

Hi Dinh,

Quoted 86 lines · Dinh Nguyen
Quoted 71 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 50 lines · Minas Harutyunyan

Hi Dinh,

Quoted 47 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT)
[    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90
[    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr
[    1.625541] [<00000000255d793a>] dwc2_hsotg_irq
[    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d

Author: Artur Petrosyan<[email protected]>
Date:   Tue Apr 13 11:37:15 2021 +0400

usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
Adds a new flow of entering clock gating when PC is suspended.

Quoted 8 lines
Quoted 5 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 :
0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 :
0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C :
0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 :
Quoted 8 lines

0xFE0F0020

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Quoted 7 lines
Quoted 1 line

Dinh

Could you please disable clock gating by adding to dwc2_set_default_params() function follow line:
p->no_clock_gating = true;
like in dwc2_set_s3c6400_params() function.

That did not fix the issue. However, if I remove the line:

Quoted 8 lines
Quoted 5 lines
(quoted diff) +2 -0
+               /* After entering suspend, hardware is not accessible */
+               clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);

Then the issue gets fixed.

I don't see _dwc2_hcd_resume() getting called.

This fixes it:

drivers/usb/dwc2/hcd.c +4 -3
index 13c779a28e94..f63a27d11fac 100644
@@ -4399,11 +4399,12 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
                 * If not hibernation nor partial power down are supported,
                 * clock gating is used to save power.
                 */
-               if (!hsotg->params.no_clock_gating)
+               if (!hsotg->params.no_clock_gating) {
                        dwc2_host_enter_clock_gating(hsotg);
 
-               /* After entering suspend, hardware is not accessible */
-               clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+                       /* After entering suspend, hardware is not accessible */
+                       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+               }
                break;
        default:
                goto skip_power_saving;
drivers/usb/dwc2/params.c +0 -0
index d300ae3d9274..9102fe8f6021 100644
@@ -440,6 +440,7 @@ static void dwc2_set_default_params(struct

dwc2_hsotg *hsotg)

                p->g_np_tx_fifo_size = 1024;
                dwc2_set_param_tx_fifo_sizes(hsotg);
        }

+ p->no_clock_gating = true;
}

#8 lore raw

Hi Dinh,

Quoted 128 lines · Dinh Nguyen
Quoted 106 lines · Dinh Nguyen
Quoted 102 lines · Dinh Nguyen
Quoted 89 lines · Minas Harutyunyan

Hi Dinh,

Quoted 86 lines · Dinh Nguyen
Quoted 71 lines · Dinh Nguyen

Hi Minas,

Thanks for replying!

Quoted 50 lines · Minas Harutyunyan

Hi Dinh,

Quoted 47 lines · Dinh Nguyen

Hi Arthur,

The usb driver is getting this error:

[    1.539856] Hardware name: SoCFPGA Agilex SoCDK (DT)
[    1.544799] Call trace:
[    1.547233]  dump_backtrace+0x0/0x1c0
[    1.550897]  show_stack+0x18/0x68
[    1.554202]  dump_stack+0xd8/0x134
[    1.557597]  __report_bad_irq+0x38/0xf0
[    1.561423]  note_interrupt+0x31c/0x3e8
[    1.565244]  handle_irq_event_percpu+0x60/0x90
[    1.569671]  handle_irq_event+0x48/0xe0
[    1.573491]  handle_fasteoi_irq+0xb0/0x138
[    1.577574]  generic_handle_irq+0x30/0x48
[    1.581567]  __handle_domain_irq+0x60/0xb8
[    1.585646]  gic_handle_irq+0xb4/0xd0
[    1.589300]  el1_irq+0xb8/0x150
[    1.592428]  arch_cpu_idle+0x18/0x28
[    1.595992]  default_idle_call+0x24/0x5c
[    1.599899]  do_idle+0x1f4/0x290
[    1.603118]  cpu_startup_entry+0x28/0x68
[    1.607026]  rest_init+0xd8/0xe8
[    1.610242]  arch_call_rest_init+0x10/0x1c
[    1.614329]  start_kernel+0x50c/0x544
[    1.617980] handlers:
[    1.620241] [<00000000ae601aac>] dwc2_handle_common_intr
[    1.625541] [<00000000255d793a>] dwc2_hsotg_irq
[    1.630056] [<000000000bc68ab4>] usb_hcd_irq
[    1.634312] Disabling IRQ #33

After a git-bisect, the result is this commit:

commit 50fb0c128b6e8df62200ba85c05ecd6b1396476d

Author: Artur Petrosyan<[email protected]>
Date:   Tue Apr 13 11:37:15 2021 +0400

usb: dwc2: Add clock gating entering flow by system suspend If not hibernation nor partial power down are supported, clock gating is used to save power.
Adds a new flow of entering clock gating when PC is suspended.

Quoted 8 lines
Quoted 5 lines

The DWC2 USB version on the Agilex platform is
0x4F54330A

Could you please provide HW configuration registers values (GHWCFG1-4).

[    0.987779] dwc2 ffb00000.usb: GHWCFG1    @0xFFFF800012940044 :
0x00000000
[    0.994644] dwc2 ffb00000.usb: GHWCFG2    @0xFFFF800012940048 :
0x238FFC90
[    1.001498] dwc2 ffb00000.usb: GHWCFG3    @0xFFFF80001294004C :
0x1F8002E8
[    1.008350] dwc2 ffb00000.usb: GHWCFG4    @0xFFFF800012940050 :
Quoted 8 lines

0xFE0F0020

I did a little debugging, and noticed that the GINTSTS_PRTINT is firing, so the dwc2_handle_common_intr() is getting called continuously. There's doesn't seem to be way to handle the GINTSTS_PRTINT bit, because there's a check for device_mode().

It looks like the LPMMode bit is disabled in the GHWCFG3. Could that be the reason why?

Quoted 7 lines
Quoted 1 line

Dinh

Could you please disable clock gating by adding to dwc2_set_default_params() function follow line:
p->no_clock_gating = true;
like in dwc2_set_s3c6400_params() function.

That did not fix the issue. However, if I remove the line:

Quoted 8 lines
Quoted 5 lines
drivers/usb/dwc2/hcd.c +2 -0
+               /* After entering suspend, hardware is not accessible */
+               clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);

Then the issue gets fixed.

I don't see _dwc2_hcd_resume() getting called.

This fixes it:

drivers/usb/dwc2/hcd.c +1 -1
index 13c779a28e94..f63a27d11fac 100644
@@ -4399,11 +4399,12 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd)
                  * If not hibernation nor partial power down are supported,
                  * clock gating is used to save power.
                  */
-               if (!hsotg->params.no_clock_gating)
+               if (!hsotg->params.no_clock_gating) {

drivers/usb/dwc2/hcd.c static int _dwc2_hcd_suspend(struct usb_hcd *hcd) · line 4410

Quoted 10 lines
drivers/usb/dwc2/hcd.c +3 -2
                         dwc2_host_enter_clock_gating(hsotg);
 
-               /* After entering suspend, hardware is not accessible */
-               clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+                       /* After entering suspend, hardware is not accessible */
+                       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+               }
                 break;
         default:
                 goto skip_power_saving;

Good, this patch acceptable.

drivers/usb/dwc2/params.c static void dwc2_set_default_params(struct · line 444

Quoted 10 lines
drivers/usb/dwc2/params.c +1 -0
index d300ae3d9274..9102fe8f6021 100644
@@ -440,6 +440,7 @@ static void dwc2_set_default_params(struct
 dwc2_hsotg *hsotg)
                 p->g_np_tx_fifo_size = 1024;
                 dwc2_set_param_tx_fifo_sizes(hsotg);
         }
+       p->no_clock_gating = true;

Can be your platform Agilex included in list of capabilities device and "p->no_clock_gating = true;" peformed inside to platform specific settings function instead of dwc2_set_default_params()?

Thanks,
Minas

Quoted 1 line
drivers/usb/dwc2/params.c +0 -0
  }