Skip to contentSkip to conversation

clk: add driver for the SiFive FU740

PATCH Applied Zong Li 5 participants 31 messages Dec 9, 2020 – May 21, 2021

Subsystems (4)
lore
Share & tools
lore

Zong Li

author
#0 lore raw

v7 cover clk: add driver for the SiFive FU740

Add a driver for the SiFive FU740 PRCI IP block, which handles more clocks than FU540. These patches also refactor the original implementation by spliting the dependent-code of fu540 and fu740 respectively.

We also add a separate patch for DT binding documentation of FU740 PRCI:
https://patchwork.kernel.org/project/linux-riscv/patch/[email protected]/

Changed in v7:
- Pick changes in v5 back up into this patch series.

Changed in v6:
- Modify the patch "Add clock enable and disable ops" by Pragnesh. The changes as follows:
- Remove spin lock in enable and disable functions
- Call enable_bypass() before PLL output disable
- Rebase code to Linux v5.10-rc7

Changed in v5:
- Fix copyright format
- Add a link of documentation in commit message
- Modify build dependency for sifive-prci.c
- Add enable and disable functions by Pragnesh Patel

Changed in v4:
- Fix the wrong enable bit field shift for FU540 and FU740.

Changed in v3:
- Fix the wrong enable bit field shift for FU740.

Changed in v2:
- Remove the macro definition for __prci_clock_array.
- Indicate the functional changes in commit message.
- Using option -M and -C to create patches.
- Rebase code to kernel v5.10-rc3.

Pragnesh Patel (1):
clk: sifive: Add clock enable and disable ops

Zong Li (4):
clk: sifive: Extract prci core to common base
clk: sifive: Use common name for prci configuration
clk: sifive: Add a driver for the SiFive FU740 PRCI IP block
clk: sifive: Fix the wrong bit field shift

 arch/riscv/Kconfig.socs                       |   2 +-
 drivers/clk/sifive/Kconfig                    |   8 +-
 drivers/clk/sifive/Makefile                   |   2 +-
 drivers/clk/sifive/fu540-prci.c               | 598 +-----------------
 drivers/clk/sifive/fu540-prci.h               |  21 +
 drivers/clk/sifive/fu740-prci.c               | 120 ++++
 drivers/clk/sifive/fu740-prci.h               |  21 +
 drivers/clk/sifive/sifive-prci.c              | 574 +++++++++++++++++
 drivers/clk/sifive/sifive-prci.h              | 299 +++++++++
 include/dt-bindings/clock/sifive-fu740-prci.h |  23 +
 10 files changed, 1091 insertions(+), 577 deletions(-)
 create mode 100644 drivers/clk/sifive/fu540-prci.h
 create mode 100644 drivers/clk/sifive/fu740-prci.c
 create mode 100644 drivers/clk/sifive/fu740-prci.h
 create mode 100644 drivers/clk/sifive/sifive-prci.c
 create mode 100644 drivers/clk/sifive/sifive-prci.h
 create mode 100644 include/dt-bindings/clock/sifive-fu740-prci.h
Signature · 7 lines
2.29.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#1 lore raw

PATCH v7 1/5 clk: sifive: Extract prci core to common base

Extract common core of prci driver to an independent file, it could allow other chips to reuse it. Separate SoCs-dependent code 'fu540' from prci core, then we can easily add 'fu740' later.

Almost these changes are code movement. The different is adding the private data for each SoC use, so it needs to get match data in probe callback function, then use the data for initialization.

---
 drivers/clk/sifive/Makefile                   |   2 +-
 drivers/clk/sifive/fu540-prci.c               | 592 +-----------------
 drivers/clk/sifive/fu540-prci.h               |  21 +
 .../sifive/{fu540-prci.c => sifive-prci.c}    | 401 +++---------
 drivers/clk/sifive/sifive-prci.h              | 201 ++++++
 5 files changed, 327 insertions(+), 890 deletions(-)
 create mode 100644 drivers/clk/sifive/fu540-prci.h
 copy drivers/clk/sifive/{fu540-prci.c => sifive-prci.c} (41%)
 create mode 100644 drivers/clk/sifive/sifive-prci.h
drivers/clk/sifive/Makefile +1 -1
index 0797f14fef6b..51b6ebc359e4 100644
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI)	+= fu540-prci.o
+obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI)	+= sifive-prci.o fu540-prci.o
drivers/clk/sifive/fu540-prci.c +21 -571

626 lines not on this page · raw message

drivers/clk/sifive/fu540-prci.h new file +21 -0
new file mode 100644
index 000000000000..c8271efa7bdc
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 SiFive, Inc.
+ * Zong Li
+ */
+
+#ifndef __SIFIVE_CLK_FU540_PRCI_H
+#define __SIFIVE_CLK_FU540_PRCI_H
+
+#include "sifive-prci.h"
+
+#define NUM_CLOCK_FU540	4
+
+extern struct __prci_clock __prci_init_clocks_fu540[NUM_CLOCK_FU540];
+
+static const struct prci_clk_desc prci_clk_fu540 = {
+	.clks = __prci_init_clocks_fu540,
+	.num_clks = ARRAY_SIZE(__prci_init_clocks_fu540),
+};
+
+#endif /* __SIFIVE_CLK_FU540_PRCI_H */
drivers/clk/sifive/sifive-prci.c renamed from drivers/clk/sifive/fu540-prci.c +83 -318

516 lines not on this page · raw message

drivers/clk/sifive/sifive-prci.h new file +201 -0

201 lines not on this page · raw message

Signature · 1 line
2.29.2
maintainer Applied
#2 lore raw

Re: [PATCH v7 1/5] clk: sifive: Extract prci core to common base

Quoting Zong Li (2020-12-09 01:49:12)

Quoted 4 lines

Extract common core of prci driver to an independent file, it could allow other chips to reuse it. Separate SoCs-dependent code 'fu540' from prci core, then we can easily add 'fu740' later.

Quoted 8 lines

Almost these changes are code movement. The different is adding the private data for each SoC use, so it needs to get match data in probe callback function, then use the data for initialization.

---

Applied to clk-next

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#3 lore raw

PATCH v7 2/5 clk: sifive: Use common name for prci configuration

In reply to Zong Li

Use generic name CLK_SIFIVE_PRCI instead of CLK_SIFIVE_FU540_PRCI. This patch is prepared for fu740 support.

---
 arch/riscv/Kconfig.socs     | 2 +-
 drivers/clk/sifive/Kconfig  | 6 +++---
 drivers/clk/sifive/Makefile | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/riscv/Kconfig.socs +1 -1
index 8a55f6156661..3284d5c291be 100644
@@ -5,7 +5,7 @@ config SOC_SIFIVE
 	select SERIAL_SIFIVE if TTY
 	select SERIAL_SIFIVE_CONSOLE if TTY
 	select CLK_SIFIVE
-	select CLK_SIFIVE_FU540_PRCI
+	select CLK_SIFIVE_PRCI
 	select SIFIVE_PLIC
 	help
 	  This enables support for SiFive SoC platform hardware.
drivers/clk/sifive/Kconfig +3 -3
index f3b4eb9cb0f5..ab48cf7e0105 100644
@@ -8,12 +8,12 @@ menuconfig CLK_SIFIVE
 
 if CLK_SIFIVE
 
-config CLK_SIFIVE_FU540_PRCI
-	bool "PRCI driver for SiFive FU540 SoCs"
+config CLK_SIFIVE_PRCI
+	bool "PRCI driver for SiFive SoCs"
 	select CLK_ANALOGBITS_WRPLL_CLN28HPC
 	help
 	  Supports the Power Reset Clock interface (PRCI) IP block found in
-	  FU540 SoCs.  If this kernel is meant to run on a SiFive FU540 SoC,
+	  FU540 SoCs. If this kernel is meant to run on a SiFive FU540 SoC,
 	  enable this driver.
 
 endif
drivers/clk/sifive/Makefile +1 -1
index 51b6ebc359e4..3074cdbc6009 100644
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI)	+= sifive-prci.o fu540-prci.o
+obj-$(CONFIG_CLK_SIFIVE_PRCI)	+= sifive-prci.o fu540-prci.o
Signature · 7 lines
2.29.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer Applied
#4 lore raw

Re: [PATCH v7 2/5] clk: sifive: Use common name for prci configuration

Quoting Zong Li (2020-12-09 01:49:13)

Quoted 8 lines

Use generic name CLK_SIFIVE_PRCI instead of CLK_SIFIVE_FU540_PRCI. This patch is prepared for fu740 support.

---

Applied to clk-next

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#5 lore raw

PATCH v7 3/5 clk: sifive: Add a driver for the SiFive FU740 PRCI IP block

In reply to Zong Li

Add driver code for the SiFive FU740 PRCI IP block. This IP block handles reset and clock control for the SiFive FU740 device and implements SoC-level clock tree controls and dividers.

The link of unmatched as follow, and the U740-C000 manual would be present in the same page as soon.
https://www.sifive.com/boards/hifive-unmatched

This driver contains bug fixes and contributions from Henry Styles <[email protected]>
Erik Danie <[email protected]>
Pragnesh Patel <[email protected]>

---
 drivers/clk/sifive/Kconfig                    |   4 +-
 drivers/clk/sifive/Makefile                   |   2 +-
 drivers/clk/sifive/fu740-prci.c               | 111 ++++++++++++++++
 drivers/clk/sifive/fu740-prci.h               |  21 +++
 drivers/clk/sifive/sifive-prci.c              | 120 ++++++++++++++++++
 drivers/clk/sifive/sifive-prci.h              |  88 +++++++++++++
 include/dt-bindings/clock/sifive-fu740-prci.h |  23 ++++
 7 files changed, 366 insertions(+), 3 deletions(-)
 create mode 100644 drivers/clk/sifive/fu740-prci.c
 create mode 100644 drivers/clk/sifive/fu740-prci.h
 create mode 100644 include/dt-bindings/clock/sifive-fu740-prci.h
drivers/clk/sifive/Kconfig +2 -2
index ab48cf7e0105..1c14eb20c066 100644
@@ -13,7 +13,7 @@ config CLK_SIFIVE_PRCI
 	select CLK_ANALOGBITS_WRPLL_CLN28HPC
 	help
 	  Supports the Power Reset Clock interface (PRCI) IP block found in
-	  FU540 SoCs. If this kernel is meant to run on a SiFive FU540 SoC,
-	  enable this driver.
+	  FU540/FU740 SoCs. If this kernel is meant to run on a SiFive FU540/
+	  FU740 SoCs, enable this driver.
 
 endif
drivers/clk/sifive/Makefile +1 -1
index 3074cdbc6009..7b06fc04e6b3 100644
@@ -1,2 +1,2 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-$(CONFIG_CLK_SIFIVE_PRCI)	+= sifive-prci.o fu540-prci.o
+obj-$(CONFIG_CLK_SIFIVE_PRCI)	+= sifive-prci.o fu540-prci.o fu740-prci.o
drivers/clk/sifive/fu740-prci.c new file +111 -0

111 lines not on this page · raw message

drivers/clk/sifive/fu740-prci.h new file +21 -0
new file mode 100644
index 000000000000..13ef971f7764
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 SiFive, Inc.
+ * Zong Li
+ */
+
+#ifndef __SIFIVE_CLK_FU740_PRCI_H
+#define __SIFIVE_CLK_FU740_PRCI_H
+
+#include "sifive-prci.h"
+
+#define NUM_CLOCK_FU740	8
+
+extern struct __prci_clock __prci_init_clocks_fu740[NUM_CLOCK_FU740];
+
+static const struct prci_clk_desc prci_clk_fu740 = {
+	.clks = __prci_init_clocks_fu740,
+	.num_clks = ARRAY_SIZE(__prci_init_clocks_fu740),
+};
+
+#endif /* __SIFIVE_CLK_FU740_PRCI_H */
drivers/clk/sifive/sifive-prci.c +120 -0

144 lines not on this page · raw message

drivers/clk/sifive/sifive-prci.h +88 -0

105 lines not on this page · raw message

include/dt-bindings/clock/sifive-fu740-prci.h new file +23 -0
new file mode 100644
index 000000000000..cd7706ea5677
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
+/*
+ * Copyright (C) 2019 SiFive, Inc.
+ * Wesley Terpstra
+ * Paul Walmsley
+ * Zong Li
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_SIFIVE_FU740_PRCI_H
+#define __DT_BINDINGS_CLOCK_SIFIVE_FU740_PRCI_H
+
+/* Clock indexes for use by Device Tree data and the PRCI driver */
+
+#define PRCI_CLK_COREPLL	       0
+#define PRCI_CLK_DDRPLL		       1
+#define PRCI_CLK_GEMGXLPLL	       2
+#define PRCI_CLK_DVFSCOREPLL	       3
+#define PRCI_CLK_HFPCLKPLL	       4
+#define PRCI_CLK_CLTXPLL	       5
+#define PRCI_CLK_TLCLK		       6
+#define PRCI_CLK_PCLK		       7
+
+#endif	/* __DT_BINDINGS_CLOCK_SIFIVE_FU740_PRCI_H */
Signature · 7 lines
2.29.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer Applied
#6 lore raw

Re: [PATCH v7 3/5] clk: sifive: Add a driver for the SiFive FU740 PRCI IP block

Quoting Zong Li (2020-12-09 01:49:14)

Quoted 13 lines

Add driver code for the SiFive FU740 PRCI IP block. This IP block handles reset and clock control for the SiFive FU740 device and implements SoC-level clock tree controls and dividers.

The link of unmatched as follow, and the U740-C000 manual would be present in the same page as soon.
https://www.sifive.com/boards/hifive-unmatched

This driver contains bug fixes and contributions from Henry Styles <[email protected]>
Erik Danie <[email protected]>
Pragnesh Patel <[email protected]>

Quoted 7 lines

---

Applied to clk-next

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

author
#7 lore raw

PATCH v7 4/5 clk: sifive: Fix the wrong bit field shift

In reply to Zong Li

The clk enable bit should be 31 instead of 24.

---
 drivers/clk/sifive/sifive-prci.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/sifive/sifive-prci.h +2 -2
index 7e509dfb72d1..88493f3b9edf 100644
@@ -59,7 +59,7 @@
 
 /* DDRPLLCFG1 */
 #define PRCI_DDRPLLCFG1_OFFSET		0x10
-#define PRCI_DDRPLLCFG1_CKE_SHIFT	24
+#define PRCI_DDRPLLCFG1_CKE_SHIFT	31
 #define PRCI_DDRPLLCFG1_CKE_MASK	(0x1 << PRCI_DDRPLLCFG1_CKE_SHIFT)
 
 /* GEMGXLPLLCFG0 */
@@ -81,7 +81,7 @@
 
 /* GEMGXLPLLCFG1 */
 #define PRCI_GEMGXLPLLCFG1_OFFSET	0x20
-#define PRCI_GEMGXLPLLCFG1_CKE_SHIFT	24
+#define PRCI_GEMGXLPLLCFG1_CKE_SHIFT	31
 #define PRCI_GEMGXLPLLCFG1_CKE_MASK	(0x1 << PRCI_GEMGXLPLLCFG1_CKE_SHIFT)
 
 /* CORECLKSEL */
Signature · 7 lines
2.29.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#9 lore raw

PATCH v7 5/5 clk: sifive: Add clock enable and disable ops

In reply to Zong Li

From: Pragnesh Patel <[email protected]>

Add new functions "sifive_prci_clock_enable(), sifive_prci_clock_disable() and sifive_clk_is_enabled()" to enable or disable the PRCI clock

---
 drivers/clk/sifive/fu540-prci.c  |  6 +++
 drivers/clk/sifive/fu740-prci.c  |  9 ++++
 drivers/clk/sifive/sifive-prci.c | 77 ++++++++++++++++++++++++++++----
 drivers/clk/sifive/sifive-prci.h | 10 +++++
 4 files changed, 93 insertions(+), 9 deletions(-)
drivers/clk/sifive/fu540-prci.c +6 -0
index e2353dee8c52..3b558835984b 100644
@@ -24,16 +24,19 @@
 
 static struct __prci_wrpll_data __prci_corepll_data = {
 	.cfg0_offs = PRCI_COREPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_COREPLLCFG1_OFFSET,
 	.enable_bypass = sifive_prci_coreclksel_use_hfclk,
 	.disable_bypass = sifive_prci_coreclksel_use_corepll,
 };
 
 static struct __prci_wrpll_data __prci_ddrpll_data = {
 	.cfg0_offs = PRCI_DDRPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_DDRPLLCFG1_OFFSET,
 };
 
 static struct __prci_wrpll_data __prci_gemgxlpll_data = {
 	.cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_GEMGXLPLLCFG1_OFFSET,
 };
 
 /* Linux clock framework integration */
@@ -42,6 +45,9 @@ static const struct clk_ops sifive_fu540_prci_wrpll_clk_ops = {
 	.set_rate = sifive_prci_wrpll_set_rate,
 	.round_rate = sifive_prci_wrpll_round_rate,
 	.recalc_rate = sifive_prci_wrpll_recalc_rate,
+	.enable = sifive_prci_clock_enable,
+	.disable = sifive_prci_clock_disable,
+	.is_enabled = sifive_clk_is_enabled,
 };
 
 static const struct clk_ops sifive_fu540_prci_wrpll_ro_clk_ops = {
drivers/clk/sifive/fu740-prci.c +9 -0
index 41ddd4431497..db8300223745 100644
@@ -12,32 +12,38 @@
 
 static struct __prci_wrpll_data __prci_corepll_data = {
 	.cfg0_offs = PRCI_COREPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_COREPLLCFG1_OFFSET,
 	.enable_bypass = sifive_prci_coreclksel_use_hfclk,
 	.disable_bypass = sifive_prci_coreclksel_use_final_corepll,
 };
 
 static struct __prci_wrpll_data __prci_ddrpll_data = {
 	.cfg0_offs = PRCI_DDRPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_DDRPLLCFG1_OFFSET,
 };
 
 static struct __prci_wrpll_data __prci_gemgxlpll_data = {
 	.cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_GEMGXLPLLCFG1_OFFSET,
 };
 
 static struct __prci_wrpll_data __prci_dvfscorepll_data = {
 	.cfg0_offs = PRCI_DVFSCOREPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_DVFSCOREPLLCFG1_OFFSET,
 	.enable_bypass = sifive_prci_corepllsel_use_corepll,
 	.disable_bypass = sifive_prci_corepllsel_use_dvfscorepll,
 };
 
 static struct __prci_wrpll_data __prci_hfpclkpll_data = {
 	.cfg0_offs = PRCI_HFPCLKPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_HFPCLKPLLCFG1_OFFSET,
 	.enable_bypass = sifive_prci_hfpclkpllsel_use_hfclk,
 	.disable_bypass = sifive_prci_hfpclkpllsel_use_hfpclkpll,
 };
 
 static struct __prci_wrpll_data __prci_cltxpll_data = {
 	.cfg0_offs = PRCI_CLTXPLLCFG0_OFFSET,
+	.cfg1_offs = PRCI_CLTXPLLCFG1_OFFSET,
 };
 
 /* Linux clock framework integration */
@@ -46,6 +52,9 @@ static const struct clk_ops sifive_fu740_prci_wrpll_clk_ops = {
 	.set_rate = sifive_prci_wrpll_set_rate,
 	.round_rate = sifive_prci_wrpll_round_rate,
 	.recalc_rate = sifive_prci_wrpll_recalc_rate,
+	.enable = sifive_prci_clock_enable,
+	.disable = sifive_prci_clock_disable,
+	.is_enabled = sifive_clk_is_enabled,
 };
 
 static const struct clk_ops sifive_fu740_prci_wrpll_ro_clk_ops = {
drivers/clk/sifive/sifive-prci.c +68 -9

127 lines not on this page · raw message

drivers/clk/sifive/sifive-prci.h +10 -0
index 88493f3b9edf..dbdbd1722688 100644
@@ -40,6 +40,11 @@
 #define PRCI_COREPLLCFG0_LOCK_SHIFT	31
 #define PRCI_COREPLLCFG0_LOCK_MASK	(0x1 << PRCI_COREPLLCFG0_LOCK_SHIFT)
 
+/* COREPLLCFG1 */
+#define PRCI_COREPLLCFG1_OFFSET		0x8
+#define PRCI_COREPLLCFG1_CKE_SHIFT	31
+#define PRCI_COREPLLCFG1_CKE_MASK	(0x1 << PRCI_COREPLLCFG1_CKE_SHIFT)
+
 /* DDRPLLCFG0 */
 #define PRCI_DDRPLLCFG0_OFFSET		0xc
 #define PRCI_DDRPLLCFG0_DIVR_SHIFT	0
@@ -220,6 +225,7 @@ struct __prci_data {
  * @enable_bypass: fn ptr to code to bypass the WRPLL (if applicable; else NULL)
  * @disable_bypass: fn ptr to code to not bypass the WRPLL (or NULL)
  * @cfg0_offs: WRPLL CFG0 register offset (in bytes) from the PRCI base address
+ * @cfg1_offs: WRPLL CFG1 register offset (in bytes) from the PRCI base address
  *
  * @enable_bypass and @disable_bypass are used for WRPLL instances
  * that contain a separate external glitchless clock mux downstream
@@ -230,6 +236,7 @@ struct __prci_wrpll_data {
 	void (*enable_bypass)(struct __prci_data *pd);
 	void (*disable_bypass)(struct __prci_data *pd);
 	u8 cfg0_offs;
+	u8 cfg1_offs;
 };
 
 /**
@@ -279,6 +286,9 @@ long sifive_prci_wrpll_round_rate(struct clk_hw *hw, unsigned long rate,
 				  unsigned long *parent_rate);
 int sifive_prci_wrpll_set_rate(struct clk_hw *hw, unsigned long rate,
 			       unsigned long parent_rate);
+int sifive_clk_is_enabled(struct clk_hw *hw);
+int sifive_prci_clock_enable(struct clk_hw *hw);
+void sifive_prci_clock_disable(struct clk_hw *hw);
 unsigned long sifive_prci_wrpll_recalc_rate(struct clk_hw *hw,
 					    unsigned long parent_rate);
 unsigned long sifive_prci_tlclksel_recalc_rate(struct clk_hw *hw,
Signature · 7 lines
2.29.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
maintainer Applied
#10 lore raw

Re: [PATCH v7 5/5] clk: sifive: Add clock enable and disable ops

Quoting Zong Li (2020-12-09 01:49:16)

Quoted 8 lines

From: Pragnesh Patel <[email protected]>

Add new functions "sifive_prci_clock_enable(), sifive_prci_clock_disable() and sifive_clk_is_enabled()" to enable or disable the PRCI clock

---

Applied to clk-next

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#11 lore raw
In reply to Zong Li
Quoted 4 lines · Zong Li

Add a driver for the SiFive FU740 PRCI IP block, which handles more clocks than FU540. These patches also refactor the original implementation by spliting the dependent-code of fu540 and fu740 respectively.

That breaks ethernet on the fu540.

Andreas.

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#12 lore raw
Quoted 10 lines · Andreas Schwab
Quoted 4 lines · Zong Li

Add a driver for the SiFive FU740 PRCI IP block, which handles more clocks than FU540. These patches also refactor the original implementation by spliting the dependent-code of fu540 and fu740 respectively.

That breaks ethernet on the fu540.

I would check that, thanks for the report.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

author
#13 lore raw
Quoted 10 lines · Zong Li
Quoted 8 lines · Andreas Schwab
Quoted 4 lines · Zong Li

Add a driver for the SiFive FU740 PRCI IP block, which handles more clocks than FU540. These patches also refactor the original implementation by spliting the dependent-code of fu540 and fu740 respectively.

Quoted 5 lines
Quoted 2 lines

That breaks ethernet on the fu540.

I would check that, thanks for the report.

Hi Andreas,

Could you please point me out how to test the ethernet from your side? I had tried to quick test by using iperf and wget, the ethernet seems to work fine to me.

Thanks.

Quoted 6 lines
Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#14 lore raw

HI Zong, Andreas:

Quoted 15 lines · Zong Li
Quoted 13 lines · Zong Li
Quoted 10 lines · Andreas Schwab
Quoted 4 lines · Zong Li

Add a driver for the SiFive FU740 PRCI IP block, which handles more clocks than FU540. These patches also refactor the original implementation by spliting the dependent-code of fu540 and fu740 respectively.

That breaks ethernet on the fu540.

Quoted 9 lines
Quoted 2 lines

I would check that, thanks for the report.

Hi Andreas,

Could you please point me out how to test the ethernet from your side? I had tried to quick test by using iperf and wget, the ethernet seems to work fine to me.

I will give it a shot during this weekend, since I'm facing the same issue..

Yixun Lan

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#15 lore raw
In reply to Zong Li
Quoted 1 line · Zong Li

Could you please point me out how to test the ethernet from your side?

Please use
<https://github.com/openSUSE/kernel-source/blob/stable/config/riscv64/default>.

Andreas.

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#16 lore raw

Were you able to reproduce the problem?

Andreas.

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#17 lore raw
Quoted 3 lines · Andreas Schwab

Were you able to reproduce the problem?

Hi Andreas,

Sorry, I'm not available past few days, I'm just coming back, I would take a look at this again. Could you also let me know which bootloader you used (FSBL or U-boot-SPL)? Thanks.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#18 lore raw
Quoted 2 lines · Zong Li

take a look at this again. Could you also let me know which bootloader you used (FSBL or U-boot-SPL)? Thanks.

U-Boot SPL

Please try this image:

http://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS-hifiveunleashed.riscv64.raw.xz

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
author
#19 lore raw
Quoted 12 lines · Andreas Schwab
Quoted 2 lines · Zong Li

take a look at this again. Could you also let me know which bootloader you used (FSBL or U-boot-SPL)? Thanks.

U-Boot SPL

Please try this image:

http://download.opensuse.org/ports/riscv/tumbleweed/images/openSUSE-Tumbleweed-RISC-V-JeOS-hifiveunleashed.riscv64.raw.xz

Hi Andreas,

The following is the result of the test so far. I would continue to see what happened there.

1. Boot on openSUSE-Tumbleweed-RISC-V-JeOS-hifiveunleashed.riscv64.raw.xz w/ plugging ethernet cable
- It seems that I encountered a different situation with you, my
system hung up and I didn't see the boot message you mentioned yet.

[  OK  ] Finished Generate issue file for login session.
[  OK  ] Finished Apply settings from /etc/sysconfig/keyboard.
[  OK  ] Started User Login Management.
[  *** ] (3 of 3) A start job is running for…upplicant service (58s / 1min 51s)

[** ] (3 of 3) A start job is running for…cant service (1min 28s / 1min 51s)
[ ***] (2 of 3) A start job is running for…cant service (1min 58s / 3min 21s)
[ ***] (1 of 3) A start job is running for…cant service (2min 28s / 3min 21s)
[** ] (3 of 3) A start job is running for…cant service (2min 58s / 3min 21s)
[ *** ] (2 of 3) A start job is running for…cant service (3min 28s / 4min 51s)
[ *] (1 of 3) A start job is running for…cant service (3min 58s / 4min 51s)
[ *** ] (3 of 3) A start job is running for…cant service (4min 28s / 4min 51s)
[*** ] (2 of 3) A start job is running for…cant service (4min 59s / 6min 22s)
[ **] (1 of 3) A start job is running for…cant service (5min 29s / 6min 22s)
[ *** ] (3 of 3) A start job is running for…cant service (5min 59s / 6min 22s)
[* ] (2 of 3) A start job is running for…cant service (6min 29s / 7min 52s)
[ *** ] (1 of 3) A start job is running for…cant service (6min 59s / 7min 52s)
[ **] (3 of 3) A start job is running for…cant service (7min 29s / 7min 52s)
[FAILED] Failed to start wicked AutoIPv4 supplicant service.
See 'systemctl status wickedd-auto4.service' for details.
[FAILED] Failed to start wicked DHCPv4 supplicant service.
See 'systemctl status wickedd-dhcp4.service' for details.
[FAILED] Failed to start wicked DHCPv6 supplicant service.
See 'systemctl status wickedd-dhcp6.service' for details.
Starting wicked network management service daemon...
[ **] A start job is running for wicked n…rvice daemon (7min 59s / 9min 22s)
[*** ] A start job is running for wicked n…rvice daemon (8min 29s / 9min 22s)

[  603.364988] BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0
nice=0 stuck for 36s!
[***   ] A start job is running for wicked n…rvice daemon (8min 59s / 9min 22s)
[  633.444986] BUG: workqueue lockup - pool cpus=1 node=0 flags=0x0
nice=0 stuck for 66s!
         Stopping Flush Journal to Persistent Storage...
[  OK  ] Stopped Flush Journal to Persistent Storage.
[  OK  ] Stopped Journal Service.

2. Boot on kernel image which built by opensuse defconfig with changing CONFIG_MACB to y instead of m
- Although I got some problem for mounting the root filesystem on
this image now, but I didn't hang up at the message you mentioned, I could go through after macb driver initialization

[    2.350309] libphy: Fixed MDIO Bus: probed
[    2.354476] macb 10090000.ethernet: Registered clk switch
'sifive-gemgxl-mgmt'
[    2.358752] macb 10090000.ethernet: GEM doesn't support hardware ptp.
[    2.361464] libphy: MACB_mii_bus: probed
[    2.366289] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109
at 0x10090000 irq 16 (70:b3:d5:92:f2:6c)
[    2.375570] e1000e: Intel(R) PRO/1000 Network Driver
[    2.380323] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    2.386338] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
...
[    2.687447] Waiting for root device /dev/mmcblk0p4...

3. I check the patch set of supporting fu740, it shouldn't impact fu540, I'm going to dump and comparing the prci content and give more testing.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#20 lore raw
Quoted 4 lines · Zong Li

1. Boot on openSUSE-Tumbleweed-RISC-V-JeOS-hifiveunleashed.riscv64.raw.xz w/ plugging ethernet cable
- It seems that I encountered a different situation with you, my
system hung up and I didn't see the boot message you mentioned yet.

That's exactly the issue. The process is stuck in D.

Andreas.

Signature · 8 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
author
#21 lore raw
Quoted 10 lines · Andreas Schwab
Quoted 4 lines · Zong Li

1. Boot on openSUSE-Tumbleweed-RISC-V-JeOS-hifiveunleashed.riscv64.raw.xz w/ plugging ethernet cable
- It seems that I encountered a different situation with you, my
system hung up and I didn't see the boot message you mentioned yet.

That's exactly the issue. The process is stuck in D.

Yes, I could get the network problem by using the defconfig you provided, the system hung up when executing 'ifconfig' immediately after installing macb driver module, the network can work by only reverting the commit 732374a0b440d9a79c8412f318a25cd37ba6f4e2. But the network is fine by using the mainline's defconfig, this is a little bit weird, I will check that and try to find the difference.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

#22 lore raw
Quoted 6 lines · Zong Li

Yes, I could get the network problem by using the defconfig you provided, the system hung up when executing 'ifconfig' immediately after installing macb driver module, the network can work by only reverting the commit 732374a0b440d9a79c8412f318a25cd37ba6f4e2. But the network is fine by using the mainline's defconfig, this is a little bit weird, I will check that and try to find the difference.

My guess would be that it is an init dependency problem between the phy driver and the clock driver, which causes the clock to be enabled too late.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
author
#23 lore raw
Quoted 10 lines · Andreas Schwab
Quoted 6 lines · Zong Li

Yes, I could get the network problem by using the defconfig you provided, the system hung up when executing 'ifconfig' immediately after installing macb driver module, the network can work by only reverting the commit 732374a0b440d9a79c8412f318a25cd37ba6f4e2. But the network is fine by using the mainline's defconfig, this is a little bit weird, I will check that and try to find the difference.

Quoted 4 lines

My guess would be that it is an init dependency problem between the phy driver and the clock driver, which causes the clock to be enabled too late.

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

By the way, I tried to disable CONFIG_PM on oenpsuse defconfig, the system didn't hang anymore, on the contrary, I enable CONFIG_PM on mainline's defconfig, I expect that the system would hang up as well, unfortunately, I cannot boot successfully by just enabling CONFIG_PM easily.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

#24 lore raw
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Does that mean that CONFIG_PM also affects the FU740?

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
author
#25 lore raw
Quoted 11 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Quoted 2 lines

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Quoted 6 lines

Andreas.

--
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."

#26 lore raw
Quoted 13 lines · Zong Li
Quoted 11 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Quoted 5 lines
Quoted 2 lines

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Just a mild ping, any progress regarding this issue?

Yxun

author
#27 lore raw
Quoted 15 lines · Yixun Lan
Quoted 13 lines · Zong Li
Quoted 11 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Just a mild ping, any progress regarding this issue?

Currently, if runtime power management is enabled, macb driver would go to sleep at the end of macb_probe, then the gigabit ethernet PLL would be disabled. During this period of time, the system would hang up if we try to access GEMGXL control registers, it means that we can't access GEMGXL control registers before the gigabit ethernet PLL is resumed again. There are some cases, for example, if we execute the 'ifconfig' command, it would eventually go to the macb_get_status to access GEMGXL control registers and cause the system to hang up. Give more example here, if we execute 'ip link set lo up & ip addr add 127.0.0.1/8 dev lo', it would cause the system to hang up, because these commands would try to query the interfaces and eventually go to macb_get_status as well. However, if we can resume the gigabit ethernet PLL first, such as 'ip link set eth0 up' or 'udhcpc', then everything goes well. I'm trying to figure out if there are some hooks that we can check the PLL status in the macb driver before it actually touches the control registers. If anyone has an idea about that, please feel free to point it out to me, thanks.

Quoted 2 lines

Yxun

#28 lore raw

Hi Zong,

Quoted 16 lines · Zong Li
Quoted 15 lines · Yixun Lan
Quoted 14 lines · Zong Li
Quoted 10 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Quoted 8 lines
Quoted 1 line

Just a mild ping, any progress regarding this issue?

Currently, if runtime power management is enabled, macb driver would go to sleep at the end of macb_probe, then the gigabit ethernet PLL would be disabled. During this period of time, the system would hang up if we try to access GEMGXL control registers, it means that we can't access GEMGXL control registers before the gigabit ethernet PLL is resumed again. There are some cases, for example, if we execute the

Sounds familiar.

Quoted 1 line

'ifconfig' command, it would eventually go to the macb_get_status to

Do you mean mac_get_stats()? macb_get_status() does not exist.

Quoted 10 lines

access GEMGXL control registers and cause the system to hang up. Give more example here, if we execute 'ip link set lo up & ip addr add 127.0.0.1/8 dev lo', it would cause the system to hang up, because these commands would try to query the interfaces and eventually go to macb_get_status as well. However, if we can resume the gigabit ethernet PLL first, such as 'ip link set eth0 up' or 'udhcpc', then everything goes well. I'm trying to figure out if there are some hooks that we can check the PLL status in the macb driver before it actually touches the control registers. If anyone has an idea about that, please feel free to point it out to me, thanks.

And you cannot call pm_runtime_get_sync(), as this is called from atomic contect. Other drivers avoid accessing the registers while the device is not up, cfr. e.g. commit 7fa2955ff70ce453 ("sh_eth:
Fix sleeping function called from invalid context").

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author
#29 lore raw
Quoted 29 lines · Geert Uytterhoeven

Hi Zong,

Quoted 16 lines · Zong Li
Quoted 15 lines · Yixun Lan
Quoted 14 lines · Zong Li
Quoted 10 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Quoted 8 lines
Quoted 1 line

Just a mild ping, any progress regarding this issue?

Currently, if runtime power management is enabled, macb driver would go to sleep at the end of macb_probe, then the gigabit ethernet PLL would be disabled. During this period of time, the system would hang up if we try to access GEMGXL control registers, it means that we can't access GEMGXL control registers before the gigabit ethernet PLL is resumed again. There are some cases, for example, if we execute the

Quoted 5 lines

Sounds familiar.

Quoted 1 line

'ifconfig' command, it would eventually go to the macb_get_status to

Do you mean mac_get_stats()? macb_get_status() does not exist.

Sorry for the typo, it should be macb_get_stats.

Quoted 12 lines
Quoted 11 lines

access GEMGXL control registers and cause the system to hang up. Give more example here, if we execute 'ip link set lo up & ip addr add 127.0.0.1/8 dev lo', it would cause the system to hang up, because these commands would try to query the interfaces and eventually go to macb_get_status as well. However, if we can resume the gigabit ethernet PLL first, such as 'ip link set eth0 up' or 'udhcpc', then everything goes well. I'm trying to figure out if there are some hooks that we can check the PLL status in the macb driver before it actually touches the control registers. If anyone has an idea about that, please feel free to point it out to me, thanks.

Quoted 5 lines

And you cannot call pm_runtime_get_sync(), as this is called from atomic contect. Other drivers avoid accessing the registers while the device is not up, cfr. e.g. commit 7fa2955ff70ce453 ("sh_eth:
Fix sleeping function called from invalid context").

Thanks for your help. I have done the similar modification by following the patch you provided. I also verified the bug that we use pm_runtime_get_sync there. I'm going to post the fix patch by adding the is_opened flag.

Thanks again.

Quoted 10 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#30 lore raw
Quoted 57 lines · Zong Li
Quoted 29 lines · Geert Uytterhoeven

Hi Zong,

Quoted 16 lines · Zong Li
Quoted 15 lines · Yixun Lan
Quoted 14 lines · Zong Li
Quoted 10 lines · Andreas Schwab
Quoted 7 lines · Zong Li

I found that the gemgxlpll was disabled immediately by power management after macb driver install. The mainline's defconfig doesn't enable CONFIG_PM, so the network is fine on it. The opensuse defconfig enables CONFIG_PM, and the patch 732374a0b440d9a79c8412f318a25cd37ba6f4e2 added the enable/disable callback functions, so the gemgxlpll PLL, I have no idea why power management disable it, I would keep trace it.

Does that mean that CONFIG_PM also affects the FU740?

Yes, we got the same problem on the FU740. We are checking the issue.

Quoted 8 lines
Quoted 1 line

Just a mild ping, any progress regarding this issue?

Currently, if runtime power management is enabled, macb driver would go to sleep at the end of macb_probe, then the gigabit ethernet PLL would be disabled. During this period of time, the system would hang up if we try to access GEMGXL control registers, it means that we can't access GEMGXL control registers before the gigabit ethernet PLL is resumed again. There are some cases, for example, if we execute the

Quoted 5 lines

Sounds familiar.

Quoted 1 line

'ifconfig' command, it would eventually go to the macb_get_status to

Do you mean mac_get_stats()? macb_get_status() does not exist.

Sorry for the typo, it should be macb_get_stats.

Quoted 12 lines
Quoted 11 lines

access GEMGXL control registers and cause the system to hang up. Give more example here, if we execute 'ip link set lo up & ip addr add 127.0.0.1/8 dev lo', it would cause the system to hang up, because these commands would try to query the interfaces and eventually go to macb_get_status as well. However, if we can resume the gigabit ethernet PLL first, such as 'ip link set eth0 up' or 'udhcpc', then everything goes well. I'm trying to figure out if there are some hooks that we can check the PLL status in the macb driver before it actually touches the control registers. If anyone has an idea about that, please feel free to point it out to me, thanks.

Quoted 5 lines

And you cannot call pm_runtime_get_sync(), as this is called from atomic contect. Other drivers avoid accessing the registers while the device is not up, cfr. e.g. commit 7fa2955ff70ce453 ("sh_eth:
Fix sleeping function called from invalid context").

Quoted 6 lines

Thanks for your help. I have done the similar modification by following the patch you provided. I also verified the bug that we use pm_runtime_get_sync there. I'm going to post the fix patch by adding the is_opened flag.

Thanks again.

I have posted a patch to fix this problem. Many thanks to all in this thread.

https://lore.kernel.org/netdev/[email protected]/T/#u

Quoted 11 lines
Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv