Skip to content

PCI: dwc: Add common pme_turn_off message by using outbound iATU

Frank Li imx linux-devicetree linux-pci lkml 8 versions – Applied

Status from this message: Applied to controller/dwc, thank you!

Get series with b4
b4 am [email protected] change-id 20240130-pme_msg-dd2d81ee9886

Versions newest first

  1. v8 Latest5 patches 3 repliesApplied
  2. v75 patches 3 repliesSuperseded
  3. v65 patches 7 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v55 patches9 repliesSuperseded
v45 patches6 repliesSuperseded
v36 patches21 repliesSuperseded
v26 patches3 repliesSuperseded
v16 patches8 repliesSuperseded

Changes in v8 from the cover letter

- Total use devm_ manage msg_res. after read devres.c code to better understand release sequence. It use reverse order to release resource. So it is safe for msg_res.
- Add Reviewed tag of Manivannan Sadhasivam in patch 4/5
- Link to v7: https://lore.kernel.org/r/[email protected]

Patches in v8 Applied

#Subject and filesSizeRepliesApplied
1/5PCI: Add INTx Mechanism Messages macrosdrivers/pci/pci.h+18 -00 replies
2/5PCI: dwc: Consolidate args of dw_pcie_prog_outbound_atu() into a structuredrivers/pci/controller/dwc/pcie-designware-ep.c drivers/pci/controller/dwc/pcie-designware-host.c drivers/pci/controller/dwc/pcie-designware.c +1 more+77 -600 replies
3/5PCI: dwc: Add outbound MSG TLPs supportdrivers/pci/controller/dwc/pcie-designware.c drivers/pci/controller/dwc/pcie-designware.h+11 -20 replies
4/5PCI: Add PCIE_MSG_CODE_PME_TURN_OFF message macrodrivers/pci/pci.h+3 -00 replies
5/5PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspenddrivers/pci/controller/dwc/pcie-designware-host.c drivers/pci/controller/dwc/pcie-designware.h+93 -51 reply

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchSerge SeminManivannan SadhasivamBjorn Helgaas
1/5R-b R-b A-b
2/5R-b R-b
3/5R-b R-b
4/5R-b A-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v8 thread

Cover letter [PATCH v8 0/5] PCI: dwc: Add common pme_turn_off message by using outbound iATU

Involve an new and common mathod to send pme_turn_off() message. Previously pme_turn_off() implement by platform related special register to trigge it.

But Yoshihiro give good idea by using iATU to send out message. Previously Yoshihiro provide patches to raise INTx message by dummy write to outbound iATU.

Use similar mathod to send out pme_turn_off message.

Previous two patches is picked from Yoshihiro' big patch serialise.
PCI: dwc: Change arguments of dw_pcie_prog_outbound_atu()
PCI: Add INTx Mechanism Messages macros

PCI: Add PME_TURN_OFF message macro
dt-bindings: PCI: dwc: Add 'msg" register region, Add "msg" region to use to map PCI msg.

PCI: dwc: Add common pme_turn_off message method
Using common pme_turn_off() message if platform have not define their.

---
Changes in v8:
- Total use devm_ manage msg_res. after read devres.c code to better understand release sequence. It use reverse order to release resource. So it is safe for msg_res.
- Add Reviewed tag of Manivannan Sadhasivam in patch 4/5
- Link to v7: https://lore.kernel.org/r/[email protected]

Changes in v7:
patch 4/5 add
/* Power Management Messages; PCIe r6.0, sec 2.2.8.2 */ patch 1/5 change comment to
/* Message Routing (r[2:0]); PCIe r6.0, sec 2.2.8 */ /* INTx Mechanism Messages; PCIe r6.0, sec 2.2.8.1 */

order according to value.
Add Acked-by: Bjorn Helgaas <[email protected]> in patch 4/5

patch 5/5
Apply all mani's comments.

- Link to v6: https://lore.kernel.org/r/[email protected]

Changes in v6:
- Move PCIE_MSG_CODE_PME_TURN_OFF ahead before INTx to keep the codes sorted.
- Added reason why not alloc_resesource in commit messag.
- Change title PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend.
- Rework commit message
"Instead of relying on the vendor specific implementations to send the
PME_Turn_Off message, let's introduce a generic way of sending the message using the MSG TLP.

This is achieved by reserving a region for MSG TLP of size 'pci->region_align', at the end of the first IORESOURCE_MEM window of the host bridge. And then sending the PME_Turn_Off message during system suspend with the help of iATU.

It should be noted that this generic implementation is optional for the glue drivers and can be overridden by a custom 'pme_turn_off' callback.

- using devm_request_resource()
- using mani's suggest comments

/*
* Allocate the resource for MSG TLP before programming the iATU
* outbound window in dw_pcie_setup_rc(). Since the allocation depends
* on the value of 'region_align', this has to be done after
* dw_pcie_iatu_detect().
*/

- Add comments, about use_atu_msg, need glue driver set it.

- m -> mem in dw_pcie_pme_turn_off()

- remove redundant check() if (!atu.size) in dw_pcie_pme_turn_off().

- The reason can't adjust windows->end
This windows already reported to pci system before this function. It is not good to modify window-res-end. It just add child resource like below.

windows is root resource, which will create may child when call request_resource.

          bridge -> windows
		child1 -> msg
		child2 -> pci ep1
		child3 -> pci_ep2.
		...

Although you see whole bridge window, 'msg' already used and put under root resource, new pci devices will never use 'msg' resource.

If change windows->res->end here, I worry about it may broken resource tree.

Detail below thread:

- Link to v5: https://lore.kernel.org/r/[email protected]

Changes in v5:
- Default disable allocate TLP message memory windows. If driver need use this feature, need set use_atu_msg = true before call dw_host_init().

- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Remove dt-binding patch. Needn't change any dts file and binding doc. Reserve a region at end of first IORESOURCE_MEM window by call request_resource(). So PCIe stack will not use this reserve region to any
PCIe devices.
I tested it by reserve at begin of IORESOURCE_MEM window. PCIe stack
will skip it as expection.

Fixed a issue, forget set iATU index when sent PME_turn_off.

- Link to v3: https://lore.kernel.org/r/[email protected]

Changes in v3:
- fix 'MSG"
- Add pcie spec ref in head file
- using function name dw_pci_pme_turn_off()
- Using PCIE_ prefix macro
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Add my sign off at PCI: dwc: Add outbound MSG TLPs support
- Add Bjorn review tag at Add INTx Mechanism Messages macros
- using PME_Turn_Off match PCIe spec
- ref to pcie spec v6.1
- using section number.

- Link to v1: https://lore.kernel.org/r/[email protected]

---
Frank Li (2):
PCI: Add PCIE_MSG_CODE_PME_TURN_OFF message macro
PCI: dwc: Add generic MSG TLP support for sending PME_Turn_Off when system suspend

Yoshihiro Shimoda (3):
PCI: Add INTx Mechanism Messages macros
PCI: dwc: Consolidate args of dw_pcie_prog_outbound_atu() into a structure
PCI: dwc: Add outbound MSG TLPs support

 drivers/pci/controller/dwc/pcie-designware-ep.c   |  21 ++--
 drivers/pci/controller/dwc/pcie-designware-host.c | 145 +++++++++++++++++++---
 drivers/pci/controller/dwc/pcie-designware.c      |  54 ++++----
 drivers/pci/controller/dwc/pcie-designware.h      |  22 +++-
 drivers/pci/pci.h                                 |  21 ++++
 5 files changed, 199 insertions(+), 64 deletions(-)

---
base-commit: ef6a734484e939cf67bc41c45bc936a78ea210f0
change-id: 20240130-pme_msg-dd2d81ee9886

Best regards,
---
Frank Li <[email protected]>