linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: bhelgaas@google.com
Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>,
	Aaron Ma <aaron.ma@canonical.com>, Arnd Bergmann <arnd@arndb.de>,
	linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list),
	linux-arch@vger.kernel.org (open list:GENERIC INCLUDE/ASM HEADER
	FILES)
Subject: [PATCH 1/3] PCI: Introduce quirk hook after driver shutdown callback
Date: Fri, 26 Feb 2021 01:40:38 +0800	[thread overview]
Message-ID: <20210225174041.405739-1-kai.heng.feng@canonical.com> (raw)

It can be useful to apply quirk after device shutdown callback, like
putting device into a different power state.

This will be used by later patches.

Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/pci/pci-driver.c          | 2 ++
 drivers/pci/quirks.c              | 7 +++++++
 include/asm-generic/vmlinux.lds.h | 3 +++
 include/linux/pci.h               | 4 ++++
 4 files changed, 16 insertions(+)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index ec44a79e951a..7941f6190815 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -498,6 +498,8 @@ static void pci_device_shutdown(struct device *dev)
 	 */
 	if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
 		pci_clear_master(pci_dev);
+
+	pci_fixup_device(pci_fixup_shutdown, pci_dev);
 }
 
 #ifdef CONFIG_PM
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 653660e3ba9e..1f94fafc6920 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -93,6 +93,8 @@ extern struct pci_fixup __start_pci_fixups_suspend[];
 extern struct pci_fixup __end_pci_fixups_suspend[];
 extern struct pci_fixup __start_pci_fixups_suspend_late[];
 extern struct pci_fixup __end_pci_fixups_suspend_late[];
+extern struct pci_fixup __start_pci_fixups_shutdown[];
+extern struct pci_fixup __end_pci_fixups_shutdown[];
 
 static bool pci_apply_fixup_final_quirks;
 
@@ -143,6 +145,11 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
 		end = __end_pci_fixups_suspend_late;
 		break;
 
+	case pci_fixup_shutdown:
+		start = __start_pci_fixups_shutdown;
+		end = __end_pci_fixups_shutdown;
+		break;
+
 	default:
 		/* stupid compiler warning, you would think with an enum... */
 		return;
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index c54adce8f6f6..aba43fc2f7b1 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -472,6 +472,9 @@
 		__start_pci_fixups_suspend_late = .;			\
 		KEEP(*(.pci_fixup_suspend_late))			\
 		__end_pci_fixups_suspend_late = .;			\
+		__start_pci_fixups_shutdown = .;			\
+		KEEP(*(.pci_fixup_shutdown))				\
+		__end_pci_fixups_shutdown = .;				\
 	}								\
 									\
 	/* Built-in firmware blobs */					\
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 86c799c97b77..7cbe9b21e049 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1923,6 +1923,7 @@ enum pci_fixup_pass {
 	pci_fixup_suspend,	/* pci_device_suspend() */
 	pci_fixup_resume_early, /* pci_device_resume_early() */
 	pci_fixup_suspend_late,	/* pci_device_suspend_late() */
+	pci_fixup_shutdown,	/* pci_device_shutdown() */
 };
 
 #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
@@ -2028,6 +2029,9 @@ enum pci_fixup_pass {
 #define DECLARE_PCI_FIXUP_SUSPEND_LATE(vendor, device, hook)		\
 	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend_late,		\
 		suspend_late##hook, vendor, device, PCI_ANY_ID, 0, hook)
+#define DECLARE_PCI_FIXUP_SHUTDOWN(vendor, device, hook)		\
+	DECLARE_PCI_FIXUP_SECTION(.pci_fixup_shutdown,			\
+		shutdown##hook, vendor, device, PCI_ANY_ID, 0, hook)
 
 #ifdef CONFIG_PCI_QUIRKS
 void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
-- 
2.30.0


             reply	other threads:[~2021-02-25 17:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 17:40 Kai-Heng Feng [this message]
2021-02-25 17:40 ` [PATCH 2/3] PCI: Set AMD Renoir USB controller to D3 when shutdown Kai-Heng Feng
2021-02-25 17:40 ` [PATCH 3/3] PCI: Convert rtw88 power cycle quirk to shutdown quirk Kai-Heng Feng
2021-02-26  7:12   ` Kalle Valo
2021-02-26 12:10     ` Heiner Kallweit
2021-02-26 12:18       ` Kai-Heng Feng
2021-02-26 13:31         ` Heiner Kallweit
2021-02-26 13:40           ` Kalle Valo
2021-02-26 18:16           ` Bjorn Helgaas
2021-03-04  6:07             ` Kai-Heng Feng
2021-03-04 16:02               ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210225174041.405739-1-kai.heng.feng@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=aaron.ma@canonical.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).