Skip to contentSkip to conversation

clk: bcm: rpi: Add support for three more clocks

PATCH Superseded Ivan T. Ivanov 7 participants 18 messages Apr 28, 2022 – Aug 23, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover clk: bcm: rpi: Add support for three more clocks

Add missing clock required by RPiVid video decoder and provide more reliable and accurate source for HDMI pixel and video encoder clocks.

Changes since v3
- Put back support for VEC clock, which was actually one of reasons for this patch-set [1]. I mixed "HEVC" vs. "VEC", sorry.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1198942

Changes since v2
- Added Acks from Maxime Ripard and Dave Stevenson

Changes since v1
- Drop RPI_FIRMWARE_VEC_CLK_ID clock it doesn't seems to be used.
- Rework downstream changes on top of recent Maxime changes.

Dom Cobley (1):
clk: bcm: rpi: Add support for VEC clock

Ivan T. Ivanov (2):
clk: bcm: rpi: Add support HEVC clock
clk: bcm: rpi: Handle pixel clock in firmware

 drivers/clk/bcm/clk-raspberrypi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/3 clk: bcm: rpi: Add support HEVC clock

Export clock required for RPiVid video decoder hardware.

---
 drivers/clk/bcm/clk-raspberrypi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +3 -0
index 9d09621549b9..2e2491d85835 100644
@@ -129,6 +129,9 @@ raspberrypi_clk_variants[RPI_FIRMWARE_NUM_CLK_ID] = {
 	[RPI_FIRMWARE_V3D_CLK_ID] = {
 		.export = true,
 	},
+	[RPI_FIRMWARE_HEVC_CLK_ID] = {
+		.export = true,
+	},
 	[RPI_FIRMWARE_PIXEL_BVB_CLK_ID] = {
 		.export = true,
 	},
Signature · 1 line
2.34.1
#2 lore raw

PATCH v4 2/3 clk: bcm: rpi: Handle pixel clock in firmware

In reply to Ivan T. Ivanov

The clk-bcm2835 handling of the pixel clock does not function correctly when the HDMI power domain is disabled.

The firmware supports it correctly, so add it to the firmware clock driver.

---
 drivers/clk/bcm/clk-raspberrypi.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +3 -0
index 2e2491d85835..530820d13104 100644
@@ -129,6 +129,9 @@ raspberrypi_clk_variants[RPI_FIRMWARE_NUM_CLK_ID] = {
 	[RPI_FIRMWARE_V3D_CLK_ID] = {
 		.export = true,
 	},
+	[RPI_FIRMWARE_PIXEL_CLK_ID] = {
+		.export = true,
+	},
 	[RPI_FIRMWARE_HEVC_CLK_ID] = {
 		.export = true,
 	},
Signature · 1 line
2.34.1
#3 lore raw

PATCH v4 3/3 clk: bcm: rpi: Add support for VEC clock

In reply to Ivan T. Ivanov

From: Dom Cobley <[email protected]>

Platform driver clk-bcm2835 gets an inaccurate clock for VEC (107MHz). Export VEC clock trough clk-raspberrypi which uses the right PLL to get an accurate 108MHz.

[iivanov: Adapted on top of v5.17-rc6]
---
 drivers/clk/bcm/clk-raspberrypi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/bcm/clk-raspberrypi.c +5 -0
index 530820d13104..d1dd01580573 100644
@@ -33,6 +33,7 @@ enum rpi_firmware_clk_id {
 	RPI_FIRMWARE_EMMC2_CLK_ID,
 	RPI_FIRMWARE_M2MC_CLK_ID,
 	RPI_FIRMWARE_PIXEL_BVB_CLK_ID,
+	RPI_FIRMWARE_VEC_CLK_ID,
 	RPI_FIRMWARE_NUM_CLK_ID,
 };
 
@@ -51,6 +52,7 @@ static char *rpi_firmware_clk_names[] = {
 	[RPI_FIRMWARE_EMMC2_CLK_ID]	= "emmc2",
 	[RPI_FIRMWARE_M2MC_CLK_ID]	= "m2mc",
 	[RPI_FIRMWARE_PIXEL_BVB_CLK_ID]	= "pixel-bvb",
+	[RPI_FIRMWARE_VEC_CLK_ID]	= "vec",
 };
 
 #define RPI_FIRMWARE_STATE_ENABLE_BIT	BIT(0)
@@ -138,6 +140,9 @@ raspberrypi_clk_variants[RPI_FIRMWARE_NUM_CLK_ID] = {
 	[RPI_FIRMWARE_PIXEL_BVB_CLK_ID] = {
 		.export = true,
 	},
+	[RPI_FIRMWARE_VEC_CLK_ID] = {
+		.export = true,
+	},
 };
 
 /*
Signature · 1 line
2.34.1
Acked-by on v4 3/3
#4 lore raw

Re: [PATCH v4 3/3] clk: bcm: rpi: Add support for VEC clock

Quoted 9 lines · Ivan T. Ivanov

From: Dom Cobley <[email protected]>

Platform driver clk-bcm2835 gets an inaccurate clock for VEC (107MHz). Export VEC clock trough clk-raspberrypi which uses the right PLL to get an accurate 108MHz.

[iivanov: Adapted on top of v5.17-rc6]

Maxime

#5 lore raw
In reply to Ivan T. Ivanov

Hi,

May I ask what's the status/plan of this patch series?

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18. And, this looks like to be a good candidate for a backport to stable kernels.

Thanks,
Guillaume

Quoted 35 lines

-----Original Message-----
From: Ivan T. Ivanov <[email protected]>
Sent: 28 April 2022 08:58
To: Michael Turquette <[email protected]>; Stephen Boyd <[email protected]>; Nicolas Saenz Julienne <[email protected]>
Cc: Maxime Ripard <[email protected]>; Dave Stevenson <[email protected]>; Guillaume Gardet <[email protected]>; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; Ivan T. Ivanov <[email protected]>
Subject: [PATCH v4 0/3] clk: bcm: rpi: Add support for three more clocks

Add missing clock required by RPiVid video decoder and provide more reliable and accurate source for HDMI pixel and video encoder clocks.

Changes since v3
- Put back support for VEC clock, which was actually one of reasons for this patch-set [1]. I mixed "HEVC" vs. "VEC", sorry.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1198942

Changes since v2
- Added Acks from Maxime Ripard and Dave Stevenson

Changes since v1
- Drop RPI_FIRMWARE_VEC_CLK_ID clock it doesn't seems to be used.
- Rework downstream changes on top of recent Maxime changes.

Dom Cobley (1):
clk: bcm: rpi: Add support for VEC clock

Ivan T. Ivanov (2):
clk: bcm: rpi: Add support HEVC clock
clk: bcm: rpi: Handle pixel clock in firmware

Quoted 5 lines
 drivers/clk/bcm/clk-raspberrypi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

--
2.34.1

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

#6 lore raw

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

Quoted 2 lines

And, this looks like to be a good candidate for a backport to stable kernels.

This is not going to be trivial to backmerge, it depends on 12c90f3f27bb that isn't marked for stable

maxime

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

#7 lore raw

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 9 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

This seems to be a "fix" for the Frankenstone scenario: mainline kernel + vendor DT

Quoted 4 lines
Quoted 2 lines

And, this looks like to be a good candidate for a backport to stable kernels.

This is not going to be trivial to backmerge, it depends on 12c90f3f27bb that isn't marked for stable

I don't think this is a good idea to backmerge these changes.

Best regards

Quoted 7 lines

maxime

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

#8 lore raw
Quoted 5 lines · Stefan Wahren

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 4 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

Quoted 8 lines
Quoted 5 lines

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

This seems to be a "fix" for the Frankenstone scenario: mainline kernel + vendor DT

Did we ever support this?

I don't think we did, so even though it can be nice to improve that situation, I don't think it's worth sending this to stable

Maxime

#9 lore raw

Hi,

Quoted 14 lines · Maxime Ripard
Quoted 11 lines · Stefan Wahren

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 9 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

Quoted 7 lines
Quoted 2 lines

This seems to be a "fix" for the Frankenstone scenario: mainline kernel + vendor DT

Did we ever support this?

I don't think we did, so even though it can be nice to improve that situation, I don't think it's worth sending this to stable

Yes, maybe not stable material, but considering support for devices which are shipped with upstream Linux and vendor device tree blobs, saved somewhere on them, should be pretty normal to expect, right?

Regards,
Ivan

#10 lore raw
Quoted 19 lines · Ivan Ivanov

Hi,

Quoted 17 lines · Maxime Ripard
Quoted 13 lines · Stefan Wahren

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 9 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

This seems to be a "fix" for the Frankenstone scenario: mainline kernel + vendor DT

Quoted 8 lines
Quoted 4 lines

Did we ever support this?

I don't think we did, so even though it can be nice to improve that situation, I don't think it's worth sending this to stable

Yes, maybe not stable material, but considering support for devices which are shipped with upstream Linux and vendor device tree blobs, saved somewhere on them, should be pretty normal to expect, right?

Not really?

If the vendor in question uses a binding that has never been reviewed, accepted, and supported by upstream, then I don't see what upstream should be doing to accommodate for that situation?

Maxime

#11 lore raw

Hi,

Quoted 31 lines · Maxime Ripard
Quoted 19 lines · Ivan Ivanov

Hi,

Quoted 17 lines · Maxime Ripard
Quoted 13 lines · Stefan Wahren

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 9 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

This seems to be a "fix" for the Frankenstone scenario: mainline kernel + vendor DT

Quoted 8 lines
Quoted 4 lines

Did we ever support this?

I don't think we did, so even though it can be nice to improve that situation, I don't think it's worth sending this to stable

Yes, maybe not stable material, but considering support for devices which are shipped with upstream Linux and vendor device tree blobs, saved somewhere on them, should be pretty normal to expect, right?

Quoted 5 lines

Not really?

If the vendor in question uses a binding that has never been reviewed, accepted, and supported by upstream, then I don't see what upstream should be doing to accommodate for that situation?

Ok, let do not generalise this discussion too much :-)

I bringed above as example that some times device tree could not be changed and it is provided by board supplier, not by Linux OS supplier.

In this particular case vendor device tree blob is using standard clock bindings. Just upstream Linux clock driver don’t have support for some of the clocks. This is what these patches fix.

Regards,
Ivan

#12 lore raw
In reply to Maxime Ripard

Hi,

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 9 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

i think this series (or at least parts of it) is a workaround for this issue [1].

We better fix the root cause of the potential out of bounds access in clk-raspberrypi properly. I will send a patch soon.

[1] - https://github.com/raspberrypi/firmware/issues/1688

Quoted 12 lines
Quoted 3 lines

And, this looks like to be a good candidate for a backport to stable kernels.

This is not going to be trivial to backmerge, it depends on 12c90f3f27bb that isn't marked for stable

maxime

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

#13 lore raw

Hi,

Quoted 7 lines · Stefan Wahren

Hi,

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 4 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

Quoted 8 lines
Quoted 5 lines

As far as I know it hasn't been merged yet.

Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

i think this series (or at least parts of it) is a workaround for this issue [1].

No, not really. Bug which this patch set fixes is this one [2]. When using downstream dtb and up to date bootloader index 15 is valid id RPI_FIRMWARE_VEC_CLK_ID which is used by vc4 module.

Quoted 3 lines

We better fix the root cause of the potential out of bounds access in clk-raspberrypi properly. I will send a patch soon.

If not mistaken after last rework driver already handle this properly. clk-raspberrypi.c:362

Regards,
Ivan

Quoted 2 lines

[1] - https://github.com/raspberrypi/firmware/issues/1688

[2] https://bugzilla.suse.com/show_bug.cgi?id=1196632

#14 lore raw

Hi,

Am 11.07.22 um 09:02 schrieb Ivan T. Ivanov:

Quoted 13 lines

Hi,

Quoted 9 lines · Stefan Wahren

Hi,

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 6 lines

Hi,

Quoted 1 line · Guillaume Gardet

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

i think this series (or at least parts of it) is a workaround for this issue [1].

No, not really. Bug which this patch set fixes is this one [2].

Both are related. In your case the device tree defines a clock ID which isn't define in the kernel driver. So the behavior (abort probing in case of invalid DTB) is correct to me. But the log message isn't helpful to end users.

This is broken by design, since we need to synchronize videocore firmware, kernel and DTB at the same time. Maybe this works for Raspberry Pi OS, but not for all users.

We need to fix this driver before add new clocks.

Quoted 2 lines

When using downstream dtb and up to date bootloader index 15 is valid id RPI_FIRMWARE_VEC_CLK_ID which is used by vc4 module.

I think this only applies to the downstream kernel. AFAIK the bcm2835-clk is still used for VEC in mainline.

Quoted 7 lines
Quoted 4 lines

We better fix the root cause of the potential out of bounds access in clk-raspberrypi properly. I will send a patch soon.

If not mistaken after last rework driver already handle this properly. clk-raspberrypi.c:362

No, this doesn't prevent the possible out of bounds access, what i mean. It's the condition of the while loop.

Best regards

Quoted 14 lines

Regards,
Ivan

Quoted 2 lines

[1] - https://github.com/raspberrypi/firmware/issues/1688

[2] https://bugzilla.suse.com/show_bug.cgi?id=1196632

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

maintainer
#15 lore raw

Quoting Stefan Wahren (2022-07-11 04:55:36)

Quoted 21 lines

Am 11.07.22 um 09:02 schrieb Ivan T. Ivanov:

Quoted 6 lines · Stefan Wahren
Quoted 5 lines

Am 10.05.22 um 15:30 schrieb Maxime Ripard:

Quoted 4 lines · Guillaume Gardet
Quoted 1 line

May I ask what's the status/plan of this patch series?

As far as I know it hasn't been merged yet.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

It seems it has not been merged yet, and I know we are a bit late in the 5.18 schedule, but I think this is a good fix for 5.18.

Fix for what? I don't think this series fix any bug?

i think this series (or at least parts of it) is a workaround for this issue [1].

No, not really. Bug which this patch set fixes is this one [2].

Both are related. In your case the device tree defines a clock ID which isn't define in the kernel driver. So the behavior (abort probing in case of invalid DTB) is correct to me. But the log message isn't helpful to end users.

Quoted 6 lines

This is broken by design, since we need to synchronize videocore firmware, kernel and DTB at the same time. Maybe this works for Raspberry Pi OS, but not for all users.

We need to fix this driver before add new clocks.

Please resend this series. I didn't follow the discussion.

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

#16 lore raw
In reply to Ivan T. Ivanov
Quoted 12 lines · Ivan T. Ivanov

Date: Thu, 28 Apr 2022 09:57:40 +0300
From: "Ivan T. Ivanov" <[email protected]>
To: Michael Turquette <[email protected]>, Stephen Boyd
<[email protected]>, Nicolas Saenz Julienne <[email protected]>
Cc: Maxime Ripard <[email protected]>, Dave Stevenson
<[email protected]>, Guillaume GARDET <[email protected]>, [email protected], [email protected], [email protected], [email protected], "Ivan T. Ivanov" <[email protected]>
Subject: [PATCH v4 0/3] clk: bcm: rpi: Add support for three more clocks
Message-Id: <[email protected]>

Quoted 3 lines

Add missing clock required by RPiVid video decoder and provide more reliable and accurate source for HDMI pixel and video encoder clocks.

Hi Stephen, Michael. What is the plan for this series of patches?

Regards,
Ivan

Quoted 26 lines

Changes since v3
- Put back support for VEC clock, which was actually one of reasons for this patch-set [1]. I mixed "HEVC" vs. "VEC", sorry.

[1] https://bugzilla.suse.com/show_bug.cgi?id=1198942

Changes since v2
- Added Acks from Maxime Ripard and Dave Stevenson

Changes since v1
- Drop RPI_FIRMWARE_VEC_CLK_ID clock it doesn't seems to be used.
- Rework downstream changes on top of recent Maxime changes.

Dom Cobley (1):
clk: bcm: rpi: Add support for VEC clock

Ivan T. Ivanov (2):
clk: bcm: rpi: Add support HEVC clock
clk: bcm: rpi: Handle pixel clock in firmware

 drivers/clk/bcm/clk-raspberrypi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Signature · 1 line
2.34.1
#17 lore raw
Quoted 13 lines · Ivan T. Ivanov
Quoted 12 lines · Ivan T. Ivanov

Date: Thu, 28 Apr 2022 09:57:40 +0300
From: "Ivan T. Ivanov" <[email protected]>
To: Michael Turquette <[email protected]>, Stephen Boyd
<[email protected]>, Nicolas Saenz Julienne <[email protected]>
Cc: Maxime Ripard <[email protected]>, Dave Stevenson
<[email protected]>, Guillaume GARDET <[email protected]>, [email protected], [email protected], [email protected], [email protected], "Ivan T. Ivanov" <[email protected]>
Subject: [PATCH v4 0/3] clk: bcm: rpi: Add support for three more clocks
Message-Id: <[email protected]>

Quoted 5 lines
Quoted 3 lines

Add missing clock required by RPiVid video decoder and provide more reliable and accurate source for HDMI pixel and video encoder clocks.

Hi Stephen, Michael. What is the plan for this series of patches?

Ping?

Signature · 1 line
Florian