Skip to contentSkip to conversation

Add AST2600 LPC PCC support

PATCH Superseded Kevin Chen 4 participants 16 messages Feb 17, 2025 – Feb 26, 2025

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Kevin Chen

author
#0 lore raw

cover Add AST2600 LPC PCC support

The AST2600 has PCC controller in LPC, placed in LPC node. As a result, add LPC PCC controller driver to support POST code capture.

--
v1:
- Change pachset from 1.
- Remove properties in pcc driver.

Kevin Chen (3):
dt-binding: aspeed: Add LPC PCC controller
ARM: dts: aspeed-g6: Add AST2600 LPC PCC support
soc: aspeed: lpc-pcc: Add PCC controller support

 .../devicetree/bindings/mfd/aspeed-lpc.yaml   |  36 ++
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi       |   7 +
 drivers/soc/aspeed/Kconfig                    |  10 +
 drivers/soc/aspeed/Makefile                   |   1 +
 drivers/soc/aspeed/aspeed-lpc-pcc.c           | 439 ++++++++++++++++++
 5 files changed, 493 insertions(+)
 create mode 100644 drivers/soc/aspeed/aspeed-lpc-pcc.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/3 dt-binding: aspeed: Add LPC PCC controller

Add dt-bindings for Aspeed for Aspeed LPC POST code capture controller.

---
 .../devicetree/bindings/mfd/aspeed-lpc.yaml   | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
Documentation/devicetree/bindings/mfd/aspeed-lpc.yaml +36 -0
index 5dfe77aca167..367847bd7e75 100644
@@ -149,6 +149,35 @@ patternProperties:
       - interrupts
       - snoop-ports
 
+  "^lpc-pcc@[0-9a-f]+$":
+    type: object
+    additionalProperties: false
+
+    description:
+      The LPC pcc interface allows the BMC to listen on and record the data
+      bytes written by the Host to the targeted LPC I/O pots.
+
+    properties:
+      compatible:
+        items:
+          - enum:
+              - aspeed,ast2600-lpc-pcc
+
+      reg:
+        maxItems: 1
+
+      interrupts:
+        maxItems: 1
+
+      pcc-ports:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description: The LPC I/O ports to pcc
+
+    required:
+      - compatible
+      - interrupts
+      - pcc-ports
+
   "^uart-routing@[0-9a-f]+$":
     $ref: /schemas/soc/aspeed/uart-routing.yaml#
     description: The UART routing control under LPC register space
@@ -176,6 +205,13 @@ examples:
         #size-cells = <1>;
         ranges = <0x0 0x1e789000 0x1000>;
 
+        lpc_pcc: lpc-pcc@0 {
+            compatible = "aspeed,ast2600-lpc-pcc";
+            reg = <0x0 0x140>;
+            interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
+            pcc-ports = <0x80>;
+        };
+
         lpc_ctrl: lpc-ctrl@80 {
             compatible = "aspeed,ast2600-lpc-ctrl";
             reg = <0x80 0x80>;
Signature · 1 line
2.34.1
author
#3 lore raw

PATCH 2/3 ARM: dts: aspeed-g6: Add AST2600 LPC PCC support

In reply to Kevin Chen

The AST2600 has PCC controller in LPC, placed in LPC node.

---
 arch/arm/boot/dts/aspeed/aspeed-g6.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/aspeed/aspeed-g6.dtsi +7 -0
index 8ed715bd53aa..87dcacb78692 100644
@@ -626,6 +626,13 @@ lpc_snoop: lpc-snoop@80 {
 					status = "disabled";
 				};
 
+				lpc_pcc: lpc-pcc@0 {
+					compatible = "aspeed,ast2600-lpc-pcc";
+					reg = <0x0 0x140>;
+					interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
+					status = "disabled";
+				};
+
 				lhc: lhc@a0 {
 					compatible = "aspeed,ast2600-lhc";
 					reg = <0xa0 0x24 0xc8 0x8>;
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH 3/3 soc: aspeed: lpc-pcc: Add PCC controller support

In reply to Kevin Chen

Add LPC PCC controller driver to support POST code capture.

---
 drivers/soc/aspeed/Kconfig          |  10 +
 drivers/soc/aspeed/Makefile         |   1 +
 drivers/soc/aspeed/aspeed-lpc-pcc.c | 439 ++++++++++++++++++++++++++++
 3 files changed, 450 insertions(+)
 create mode 100644 drivers/soc/aspeed/aspeed-lpc-pcc.c
drivers/soc/aspeed/Kconfig +10 -0
index f579ee0b5afa..dff1a82f4201 100644
@@ -52,6 +52,16 @@ config ASPEED_SOCINFO
 	help
 	  Say yes to support decoding of ASPEED BMC information.
 
+config ASPEED_LPC_PCC
+	tristate "Aspeed Post Code Capture support"
+	select REGMAP
+	select MFD_SYSCON
+	default ARCH_ASPEED
+	help
+	  Provides a driver to control the LPC PCC interface,
+	  allowing the BMC to capture post code written by the
+	  the host to an arbitrary LPC I/O port.
+
 endmenu
 
 endif
drivers/soc/aspeed/Makefile +1 -0
index b35d74592964..1692350b3512 100644
@@ -4,3 +4,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)		+= aspeed-lpc-snoop.o
 obj-$(CONFIG_ASPEED_UART_ROUTING)	+= aspeed-uart-routing.o
 obj-$(CONFIG_ASPEED_P2A_CTRL)		+= aspeed-p2a-ctrl.o
 obj-$(CONFIG_ASPEED_SOCINFO)		+= aspeed-socinfo.o
+obj-$(CONFIG_ASPEED_LPC_PCC)		+= aspeed-lpc-pcc.o
drivers/soc/aspeed/aspeed-lpc-pcc.c new file +439 -0

439 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v1 1/3] dt-binding: aspeed: Add LPC PCC controller

In reply to Kevin Chen
Quoted 5 lines · Kevin Chen

Add dt-bindings for Aspeed for Aspeed LPC POST code capture controller.

---
 .../devicetree/bindings/mfd/aspeed-lpc.yaml   | 36 +++++++++++++++++++

Nothing improved. You will not get different review.

Also, provide detailed changelog explaining how you fixed here previously reported issues.

<form letter>
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC. It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.

Tools like b4 or scripts/get_maintainer.pl provide you proper list of people, so fix your workflow. Tools might also fail if you work on some ancient tree (don't, instead use mainline) or work on fork of kernel (don't, instead use mainline). Just use b4 and everything should be fine, although remember about b4 prep --auto-to-cc if you added new patches to the patchset.

You missed at least devicetree list (maybe more), so this won't be tested by automated tooling. Performing review on untested code might be a waste of time.

Please kindly resend and include all necessary To/Cc entries. </form letter>

Best regards,
Krzysztof

#5 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

In reply to Kevin Chen

drivers/soc/aspeed/aspeed-lpc-pcc.c line 391

Quoted 11 lines · Kevin Chen
drivers/soc/aspeed/aspeed-lpc-pcc.c new file +11 -0
+
+	pcc->mdev.parent = dev;
+	pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+	pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME,
+					pcc->mdev_id);
+	pcc->mdev.fops = &pcc_fops;
+	rc = misc_register(&pcc->mdev);
+	if (rc) {
+		dev_err(dev, "Couldn't register misc device\n");
+		goto err_free_kfifo;
+	}

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/[email protected]/
and more discussions on LKML

Best regards,
Krzysztof

maintainer
#6 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 14 lines · Krzysztof Kozlowski
Quoted 4 lines · Kevin Chen

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",

Quoted 8 lines

DEVICE_NAME,
+                                       pcc->mdev_id); +       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n"); +               goto err_free_kfifo;
+       }

Quoted 6 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/[email protected]/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Kevin: Did you consider reworking it?

Nuvoton have a similar capability in their NPCM BMC SoC(s) with the "BPC" ("BIOS POST Code" controller). There should be some consensus on the binding and userspace interface.

Andrew

author
#7 lore raw

RE: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 24 lines · Krzysztof Kozlowski
Quoted 7 lines · Kevin Chen
Quoted 6 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 7 lines
Quoted 6 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n"); +               goto err_free_kfifo;
+       }

Quoted 7 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/[email protected]
astmail.com/
and more discussions on LKML

Quoted 6 lines

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled. PCC is used for port I/O byte snooping over eSPI.

Quoted 6 lines

Nuvoton have a similar capability in their NPCM BMC SoC(s) with the "BPC" ("BIOS POST Code" controller). There should be some consensus on the binding and userspace interface.

Andrew

maintainer
#8 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 28 lines · Kevin Chen
Quoted 28 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 8 lines
Quoted 7 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n");
+               goto err_free_kfifo;
+       }

Quoted 7 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/[email protected]
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

Quoted 8 lines
Quoted 4 lines

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled.

Hmm, I think OpenBMC's history regarding POST code support caused some confusion on my part. For whatever reason, the snoop device was used as a source of POST codes despite the existence of the dedicated POST code hardware since at least the AST2400, but...

Quoted 1 line

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware features (PCC has DMA)? My impression is that the snoop device could also be used over eSPI?

Quoted 8 lines
Quoted 8 lines

Nuvoton have a similar capability in their NPCM BMC SoC(s) with the "BPC"
("BIOS POST Code" controller). There should be some consensus on the binding
and userspace interface.

This is still the case.

Andrew

author
#9 lore raw

RE: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 41 lines · Kevin Chen
Quoted 10 lines
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 23 lines
Quoted 23 lines
Quoted 8 lines
Quoted 7 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n");
+               goto err_free_kfifo;
+       }

Quoted 8 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/bc5118f2-8982-46ff-bc75-d0c71475e909@a
pp.f
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/c
ommit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Quoted 5 lines
Quoted 1 line

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled.

Quoted 4 lines

Hmm, I think OpenBMC's history regarding POST code support caused some confusion on my part. For whatever reason, the snoop device was used as a source of POST codes despite the existence of the dedicated POST code hardware since at least the AST2400, but...

What I know about the dedicated POST code hardware in ASPEED should be the same one in LPC module.

Quoted 6 lines
Quoted 2 lines

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware features (PCC has DMA)? My impression is that the snoop device could also be used over eSPI?

Yes, PCC has DMA to capture the POST code.
And snoop device also can be used over eSPI.

These two devices of PCC and snoop use the same port I/O of 80h and 81h.
But, in current usage of PCC, it can support a continuous, 4-bytes maximum region from port I/O 80h to 83h. What I know about PCC or snoop usage, depends on INTEL platform or AMD platform.

For ASPEED, we want to upstream the PCC driver for the PCC usage.

Quoted 12 lines
Quoted 8 lines
Quoted 8 lines

Nuvoton have a similar capability in their NPCM BMC SoC(s) with the "BPC"
("BIOS POST Code" controller). There should be some consensus on the binding and userspace interface.

This is still the case.

Andrew

maintainer
#10 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 64 lines · Kevin Chen
Quoted 43 lines · Kevin Chen
Quoted 10 lines
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 23 lines
Quoted 23 lines
Quoted 8 lines
Quoted 7 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n");
+               goto err_free_kfifo;
+       }

Quoted 8 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:
https://lore.kernel.org/all/bc5118f2-8982-46ff-bc75-d0c71475e909@a
pp.f
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/c
ommit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Quoted 7 lines
Quoted 1 line

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver
using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort
if snoop is enabled.

Quoted 7 lines

Hmm, I think OpenBMC's history regarding POST code support caused some
confusion on my part. For whatever reason, the snoop device was used as a
source of POST codes despite the existence of the dedicated POST code
hardware since at least the AST2400, but...

What I know about the dedicated POST code hardware in ASPEED should be the same one in LPC module.

Quoted 8 lines
Quoted 2 lines

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware
features (PCC has DMA)? My impression is that the snoop device could also be
used over eSPI?

Yes, PCC has DMA to capture the POST code.
And snoop device also can be used over eSPI.

Quoted 8 lines

These two devices of PCC and snoop use the same port I/O of 80h and 81h.
But, in current usage of PCC, it can support a continuous, 4-bytes maximum region from port I/O 80h to 83h.
What I know about PCC or snoop usage, depends on INTEL platform or AMD platform.

For ASPEED, we want to upstream the PCC driver for the PCC usage.

Yeah, that's fine, but I think some work needs to be done to provide coherence in the devicetree binding and userspace APIs across both the ASPEED snoop and PCC bits, as well as the Nuvoton BPC. Bespoke designs create pain.

The PCC driver above reads the data out of the DMA ring-buffer straight into the kfifo hooked up the the miscdev read callback. The datasheet
notes: "the data structure of the FIFO is mode dependent" in the description of PCCR3, but no in-band or out-of-band mechanism (sysfs, ioctl) is provided for userspace to query whether it's 1B, 2B, 4B or "full" mode.

The situation with the snoop driver is similar (1 or 2 1B channels multiplexed into the one data stream). It also looks a bit quirky with multiple channels enabled, as what userspace reads will depend on the host access patterns, but no metadata is provided to userspace about what it's reading.

This should be fixed so userspace can have some certainty and a useful API to work against (one that provides a direct description of what's being read out).

I expect we could similarly consolidate the devicetree bindings, covering what IO port range to attach to.

Andrew

author
#11 lore raw

RE: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 68 lines · Kevin Chen
Quoted 12 lines
Quoted 12 lines · Kevin Chen
Quoted 10 lines
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 54 lines
Quoted 31 lines
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 7 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n");
+               goto err_free_kfifo;
+       }

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

Quoted 6 lines

See:
https://lore.kernel.org/all/bc5118f2-8982-46ff-bc75-d0c71475e9
09@a
pp.f
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g
it/c
ommit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Quoted 5 lines
Quoted 1 line

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled.

Quoted 4 lines

Hmm, I think OpenBMC's history regarding POST code support caused some confusion on my part. For whatever reason, the snoop device was used as a source of POST codes despite the existence of the dedicated POST code hardware since at least the AST2400, but...

What I know about the dedicated POST code hardware in ASPEED should be the same one in LPC module.

Quoted 6 lines
Quoted 2 lines

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware features (PCC has DMA)? My impression is that the snoop device could also be used over eSPI?

Yes, PCC has DMA to capture the POST code.
And snoop device also can be used over eSPI.

These two devices of PCC and snoop use the same port I/O of 80h and 81h.
But, in current usage of PCC, it can support a continuous, 4-bytes maximum region from port I/O 80h to 83h.
What I know about PCC or snoop usage, depends on INTEL platform or AMD platform.

Quoted 5 lines
Quoted 1 line

For ASPEED, we want to upstream the PCC driver for the PCC usage.

Yeah, that's fine, but I think some work needs to be done to provide coherence in the devicetree binding and userspace APIs across both the ASPEED snoop and PCC bits, as well as the Nuvoton BPC. Bespoke designs create pain.

https://lore.kernel.org/linux-kernel//[email protected]/T/
Andrew, I find the "NPCM BPC driver" to get the link. Are these patches match what you mentioned?

Quoted 6 lines

The PCC driver above reads the data out of the DMA ring-buffer straight into the kfifo hooked up the the miscdev read callback. The datasheet
notes: "the data structure of the FIFO is mode dependent" in the description of PCCR3, but no in-band or out-of-band mechanism (sysfs,
ioctl) is provided for userspace to query whether it's 1B, 2B, 4B or "full" mode.

For the data structure in PCCR3, I checked with designer. We only need 2B mode to get the information about data and related addresses.
For example, from espi master send the port 80h~83h with first data 0x11223344 and second data 0x55667788. The PCC kfifo would be written in the following output from hexdump.

# hexdump  /dev/aspeed-lpc-pcc0
0000000 4044 4133 4222 4311 4088 4177 4266 4355
Quoted 5 lines

The situation with the snoop driver is similar (1 or 2 1B channels multiplexed into the one data stream). It also looks a bit quirky with multiple channels enabled, as what userspace reads will depend on the host access patterns, but no metadata is provided to userspace about what it's reading.

Yes, for the snoop driver and PCC driver, some mechanism is the same. But snoop only supports 2 bytes data from the 2 1B channels multiplexed. So, we need to add PCC driver to upstream for customer's 4 Bytes POST code capture usage even the PCC driver needs to check the snoop enabled or not. Or, could you please give us come comments about how I can upstream the PCC driver.

Quoted 8 lines

This should be fixed so userspace can have some certainty and a useful API to work against (one that provides a direct description of what's being read out).

I expect we could similarly consolidate the devicetree bindings, covering what IO port range to attach to.

Andrew

maintainer
#12 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Quoted 68 lines · Kevin Chen
Quoted 68 lines · Kevin Chen
Quoted 12 lines
Quoted 12 lines · Kevin Chen
Quoted 10 lines
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines

+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL, "%s%d",
DEVICE_NAME,

+                                       pcc->mdev_id);

Quoted 54 lines
Quoted 31 lines
Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 7 lines

+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc device\n");
+               goto err_free_kfifo;
+       }

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

Quoted 6 lines

See:
https://lore.kernel.org/all/bc5118f2-8982-46ff-bc75-d0c71475e9
09@a
pp.f
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g
it/c
ommit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Quoted 5 lines
Quoted 1 line

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled.

Quoted 4 lines

Hmm, I think OpenBMC's history regarding POST code support caused some confusion on my part. For whatever reason, the snoop device was used as a source of POST codes despite the existence of the dedicated POST code hardware since at least the AST2400, but...

What I know about the dedicated POST code hardware in ASPEED should be the same one in LPC module.

Quoted 6 lines
Quoted 2 lines

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware features (PCC has DMA)? My impression is that the snoop device could also be used over eSPI?

Yes, PCC has DMA to capture the POST code.
And snoop device also can be used over eSPI.

These two devices of PCC and snoop use the same port I/O of 80h and 81h.
But, in current usage of PCC, it can support a continuous, 4-bytes maximum region from port I/O 80h to 83h.
What I know about PCC or snoop usage, depends on INTEL platform or AMD platform.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

For ASPEED, we want to upstream the PCC driver for the PCC usage.

Yeah, that's fine, but I think some work needs to be done to provide coherence in the devicetree binding and userspace APIs across both the ASPEED snoop and PCC bits, as well as the Nuvoton BPC. Bespoke designs create pain.

https://lore.kernel.org/linux-kernel//[email protected]/T/
Andrew, I find the "NPCM BPC driver" to get the link. Are these patches match what you mentioned?

That looks about right.

Note Rob's response there about disparate bindings:

https://lore.kernel.org/linux-kernel//[email protected]/

Quoted 11 lines
Quoted 7 lines

The PCC driver above reads the data out of the DMA ring-buffer straight into the kfifo hooked up the the miscdev read callback. The datasheet
notes: "the data structure of the FIFO is mode dependent" in the description of PCCR3, but no in-band or out-of-band mechanism (sysfs,
ioctl) is provided for userspace to query whether it's 1B, 2B, 4B or "full" mode.

For the data structure in PCCR3, I checked with designer. We only need 2B mode to get the information about data and related addresses.
For example, from espi master send the port 80h~83h with first data 0x11223344 and second data 0x55667788. The PCC kfifo would be written in the following output from hexdump. # hexdump  /dev/aspeed-lpc-pcc0
0000000 4044 4133 4222 4311 4088 4177 4266 4355

Right, but that's different to how the Aspeed snoop chardev behaves. Both the snoop and PCC features can be used to present the same data (POST codes) to userspace. There should be a unified chardev behaviour for POST codes so we don't end up with a mess in userspace to deal with the differences in hardware capabilities.

If we've got a chardev it would feel idiomatic to me to have ioctls to configure the hardware to the required capture mode for the platform.

Quoted 7 lines
Quoted 5 lines

The situation with the snoop driver is similar (1 or 2 1B channels multiplexed into the one data stream). It also looks a bit quirky with multiple channels enabled, as what userspace reads will depend on the host access patterns, but no metadata is provided to userspace about what it's reading.

Yes, for the snoop driver and PCC driver, some mechanism is the same. But snoop only supports 2 bytes data from the 2 1B channels multiplexed. So, we need to add PCC driver to upstream for customer's 4 Bytes POST code capture usage even the PCC driver needs to check the snoop enabled or not.

I understand.

Quoted 1 line

Or, could you please give us come comments about how I can upstream the PCC driver.

Essentially I don't think it's okay that each driver implement a bespoke chardev, or that the devices don't share a common devicetree binding. I think what's needed is a small abstraction that provides common chardev semantics to userspace (e.g. /dev/postcodeN) that can be connected to the different backends provided by the hardware (Aspeed snoop and PCC, Nuvoton BPC) and act on the needs of userspace (1, 2, 4- byte POST codes, configured using ioctls).

Andrew

#13 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Hi Andrew,

I agree that a small layer of abstraction is needed to provide common chardev semantics to userspace. I think that effort can come where both Nuvoton and Aspeed unify their design and agree on a common abstraction layer.

I think such efforts may take some time for both to unify, is it possible to get this upstreamed (after addressing all other comments) while both parties work on an agreed unified abstraction layer?

Thank you,
Mo

Quoted 150 lines · Andrew Jeffery
Quoted 22 lines · Kevin Chen
Quoted 22 lines · Kevin Chen
Quoted 12 lines
Quoted 12 lines · Kevin Chen
Quoted 10 lines
Quoted 10 lines · Krzysztof Kozlowski
Quoted 8 lines · Kevin Chen
Quoted 7 lines
(quoted diff) +4 -0
+
+       pcc->mdev.parent = dev;
+       pcc->mdev.minor = MISC_DYNAMIC_MINOR;
+       pcc->mdev.name = devm_kasprintf(dev, GFP_KERNEL,

"%s%d",
DEVICE_NAME,

+ pcc->mdev_id);

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
(quoted diff) +4 -0
+       pcc->mdev.fops = &pcc_fops;
+       rc = misc_register(&pcc->mdev);
+       if (rc) {
+               dev_err(dev, "Couldn't register misc

device\n");

(quoted diff) +2 -0
+               goto err_free_kfifo;
+       }
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

You cannot expose user-space interfaces from SoC drivers. Use appropriate subsystem for this with proper ABI documentation.

See:

https://lore.kernel.org/all/bc5118f2-8982-46ff-bc75-d0c71475e9

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

09@a
pp.f
astmail.com/
and more discussions on LKML

Further, drivers/misc/aspeed-lpc-snoop.c already exists:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.g

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

it/c
ommit/?id=
9f4f9ae81d0affc182f54dd00285ddb90e0b3ae1

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Kevin: Did you consider reworking it?

Andrew: No, I do not rework it but add the post code capture driver using the SNOOP registers. As a result, I add some code in aspeed_a2600_15 to check the SNOOP enable bit. PCC driver probe abort if snoop is enabled.

Hmm, I think OpenBMC's history regarding POST code support caused some confusion on my part. For whatever reason, the snoop device

was

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

used as a source of POST codes despite the existence of the dedicated POST code hardware since at least the AST2400, but...

What I know about the dedicated POST code hardware in ASPEED should

be

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

the same one in LPC module.

Quoted 5 lines
Quoted 2 lines

PCC is used for port I/O byte snooping over eSPI.

... it seems that they're largely interchangeable, just with different hardware features (PCC has DMA)? My impression is that

the

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 1 line

snoop device could also be used over eSPI?

Yes, PCC has DMA to capture the POST code.
And snoop device also can be used over eSPI.

These two devices of PCC and snoop use the same port I/O of 80h and 81h.
But, in current usage of PCC, it can support a continuous, 4-bytes maximum region from port I/O 80h to 83h.
What I know about PCC or snoop usage, depends on INTEL platform or

AMD

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

platform.

For ASPEED, we want to upstream the PCC driver for the PCC usage.

Yeah, that's fine, but I think some work needs to be done to provide

coherence

Quoted 1 line
Quoted 1 line

in the devicetree binding and userspace APIs across both the ASPEED

snoop

Quoted 2 lines
Quoted 1 line

and PCC bits, as well as the Nuvoton BPC. Bespoke designs create pain.

https://lore.kernel.org/linux-kernel//[email protected]/T/

Quoted 1 line

Andrew, I find the "NPCM BPC driver" to get the link. Are these patches

match what you mentioned?

That looks about right.

Note Rob's response there about disparate bindings:

https://lore.kernel.org/linux-kernel//[email protected]/

Quoted 3 lines
Quoted 3 lines

The PCC driver above reads the data out of the DMA ring-buffer

straight into

Quoted 2 lines
Quoted 2 lines

the kfifo hooked up the the miscdev read callback. The datasheet
notes: "the data structure of the FIFO is mode dependent" in the

description of

Quoted 2 lines
Quoted 2 lines

PCCR3, but no in-band or out-of-band mechanism (sysfs, ioctl) is provided for userspace to query whether it's 1B, 2B, 4B or

"full" mode.

Quoted 1 line

For the data structure in PCCR3, I checked with designer. We only need

2B mode to get the information about data and related addresses.

Quoted 1 line

For example, from espi master send the port 80h~83h with first data

0x11223344 and second data 0x55667788. The PCC kfifo would be written in the following output from hexdump.

Quoted 2 lines
# hexdump  /dev/aspeed-lpc-pcc0
0000000 4044 4133 4222 4311 4088 4177 4266 4355

Right, but that's different to how the Aspeed snoop chardev behaves. Both the snoop and PCC features can be used to present the same data (POST codes) to userspace. There should be a unified chardev behaviour for POST codes so we don't end up with a mess in userspace to deal with the differences in hardware capabilities.

If we've got a chardev it would feel idiomatic to me to have ioctls to configure the hardware to the required capture mode for the platform.

Quoted 2 lines
Quoted 2 lines

The situation with the snoop driver is similar (1 or 2 1B channels

multiplexed

Quoted 1 line
Quoted 1 line

into the one data stream). It also looks a bit quirky with multiple

channels

Quoted 1 line
Quoted 1 line

enabled, as what userspace reads will depend on the host access

patterns, but

Quoted 2 lines
Quoted 1 line

no metadata is provided to userspace about what it's reading.

Yes, for the snoop driver and PCC driver, some mechanism is the same.

But snoop only supports 2 bytes data from the 2 1B channels multiplexed.

Quoted 1 line

So, we need to add PCC driver to upstream for customer's 4 Bytes POST

code capture usage even the PCC driver needs to check the snoop enabled or not.

I understand.

Quoted 1 line

Or, could you please give us come comments about how I can upstream the

PCC driver.

Essentially I don't think it's okay that each driver implement a bespoke chardev, or that the devices don't share a common devicetree binding. I think what's needed is a small abstraction that provides common chardev semantics to userspace (e.g. /dev/postcodeN) that can be connected to the different backends provided by the hardware (Aspeed snoop and PCC, Nuvoton BPC) and act on the needs of userspace (1, 2, 4- byte POST codes, configured using ioctls).

Andrew

maintainer
#14 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Hi Mo,

Quoted 11 lines · Mo Elbadry

Hi Andrew,

I agree that a small layer of abstraction is needed to provide common chardev semantics to userspace. I think that effort can come where both Nuvoton and Aspeed unify their design and agree on a common abstraction layer.

I think such efforts may take some time for both to unify, is it possible to get this upstreamed (after addressing all other comments) while both parties work on an agreed unified abstraction layer?

Given Arnd doesn't want bespoke userspace interfaces in the SoC drivers this will need to go elsewhere, perhaps drivers/char or drivers/misc. Greg and Arnd maintain both, so the patch needs to make a convincing argument to them. For my part, my comments are just opinions based on my understanding of the use-cases and the SoCs involved, and the desire for reasonable devicetree and userspace interfaces.

I don't think it's right to try to rush things as devicetree and userspace interfaces can be tricky to change or remove. Rushing tends to be painful for all involved in the long run.

Cheers,

Andrew

#15 lore raw

Re: [PATCH v1 3/3] soc: aspeed: lpc-pcc: Add PCC controller support

Hi Andrew,

Understood, your comments do make sense and are the right way to go.

I agree on not rushing, we want to see things moving forward but properly as well.

Thank you for your help,
Mo

Quoted 30 lines · Andrew Jeffery

Hi Mo,

Quoted 11 lines · Mo Elbadry

Hi Andrew,

I agree that a small layer of abstraction is needed to provide common chardev semantics to userspace. I think that effort can come where both Nuvoton and Aspeed unify their design and agree on a common abstraction layer.

I think such efforts may take some time for both to unify, is it possible to get this upstreamed (after addressing all other comments) while both parties work on an agreed unified abstraction layer?

Given Arnd doesn't want bespoke userspace interfaces in the SoC drivers this will need to go elsewhere, perhaps drivers/char or drivers/misc. Greg and Arnd maintain both, so the patch needs to make a convincing argument to them. For my part, my comments are just opinions based on my understanding of the use-cases and the SoCs involved, and the desire for reasonable devicetree and userspace interfaces.

I don't think it's right to try to rush things as devicetree and userspace interfaces can be tricky to change or remove. Rushing tends to be painful for all involved in the long run.

Cheers,

Andrew