From: jsg Date: Mon, 28 Feb 2022 02:40:16 +0000 (+0000) Subject: add pcie_aspm_enabled() for the next linux 5.15.y release X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5276e8c8a75a92a0bf286f271dea929169199382;p=openbsd add pcie_aspm_enabled() for the next linux 5.15.y release --- diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c index fe7ca71a8a3..8ad9e61f0e4 100644 --- a/sys/dev/pci/drm/drm_linux.c +++ b/sys/dev/pci/drm/drm_linux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.c,v 1.90 2022/02/07 13:16:42 kettenis Exp $ */ +/* $OpenBSD: drm_linux.c,v 1.91 2022/02/28 02:40:16 jsg Exp $ */ /* * Copyright (c) 2013 Jonathan Gray * Copyright (c) 2015, 2016 Mark Kettenis @@ -2495,6 +2495,25 @@ pcie_get_width_cap(struct pci_dev *pdev) return PCIE_LNK_WIDTH_UNKNOWN; } +bool +pcie_aspm_enabled(struct pci_dev *pdev) +{ + pci_chipset_tag_t pc = pdev->pc; + pcitag_t tag = pdev->tag; + int pos ; + pcireg_t lcsr; + + if (!pci_get_capability(pc, tag, PCI_CAP_PCIEXPRESS, + &pos, NULL)) + return false; + + lcsr = pci_conf_read(pc, tag, pos + PCI_PCIE_LCSR); + if ((lcsr & (PCI_PCIE_LCSR_ASPM_L0S | PCI_PCIE_LCSR_ASPM_L1)) != 0) + return true; + + return false; +} + int autoremove_wake_function(struct wait_queue_entry *wqe, unsigned int mode, int sync, void *key) diff --git a/sys/dev/pci/drm/include/linux/pci.h b/sys/dev/pci/drm/include/linux/pci.h index 49f4befe924..b0920b2154e 100644 --- a/sys/dev/pci/drm/include/linux/pci.h +++ b/sys/dev/pci/drm/include/linux/pci.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci.h,v 1.8 2022/01/14 06:53:14 jsg Exp $ */ +/* $OpenBSD: pci.h,v 1.9 2022/02/28 02:40:16 jsg Exp $ */ /* * Copyright (c) 2015 Mark Kettenis * @@ -232,6 +232,8 @@ pci_pcie_cap(struct pci_dev *pdev) return pos; } +bool pcie_aspm_enabled(struct pci_dev *); + static inline bool pci_is_pcie(struct pci_dev *pdev) {