Patch "platform/x86: p2sb: Don't init until unassigned resources have been assigned" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    platform/x86: p2sb: Don't init until unassigned resources have been assigned

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     platform-x86-p2sb-don-t-init-until-unassigned-resour.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d9db84ded02af9d3a8393a0f17ed58fe4ea87421
Author: Ben Fradella <bfradell@xxxxxxxxxx>
Date:   Thu May 9 16:49:34 2024 +0000

    platform/x86: p2sb: Don't init until unassigned resources have been assigned
    
    [ Upstream commit 2c6370e6607663fc5fa0fd9ed58e2e01014898c7 ]
    
    The P2SB could get an invalid BAR from the BIOS, and that won't be fixed
    up until pcibios_assign_resources(), which is an fs_initcall().
    
    - Move p2sb_fs_init() to an fs_initcall_sync(). This is still early
      enough to avoid a race with any dependent drivers.
    
    - Add a check for IORESOURCE_UNSET in p2sb_valid_resource() to catch
      unset BARs going forward.
    
    - Return error values from p2sb_fs_init() so that the 'initcall_debug'
      cmdline arg provides useful data.
    
    Signed-off-by: Ben Fradella <bfradell@xxxxxxxxxx>
    Acked-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
    Tested-by: Klara Modin <klarasmodin@xxxxxxxxx>
    Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
    Link: https://lore.kernel.org/r/20240509164905.41016-1-bcfradella@xxxxxxxxx
    Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/platform/x86/p2sb.c b/drivers/platform/x86/p2sb.c
index a64f56ddd4a44..053be5c5e0cad 100644
--- a/drivers/platform/x86/p2sb.c
+++ b/drivers/platform/x86/p2sb.c
@@ -56,12 +56,9 @@ static int p2sb_get_devfn(unsigned int *devfn)
 	return 0;
 }
 
-static bool p2sb_valid_resource(struct resource *res)
+static bool p2sb_valid_resource(const struct resource *res)
 {
-	if (res->flags)
-		return true;
-
-	return false;
+	return res->flags & ~IORESOURCE_UNSET;
 }
 
 /* Copy resource from the first BAR of the device in question */
@@ -220,16 +217,20 @@ EXPORT_SYMBOL_GPL(p2sb_bar);
 
 static int __init p2sb_fs_init(void)
 {
-	p2sb_cache_resources();
-	return 0;
+	return p2sb_cache_resources();
 }
 
 /*
- * pci_rescan_remove_lock to avoid access to unhidden P2SB devices can
- * not be locked in sysfs pci bus rescan path because of deadlock. To
- * avoid the deadlock, access to P2SB devices with the lock at an early
- * step in kernel initialization and cache required resources. This
- * should happen after subsys_initcall which initializes PCI subsystem
- * and before device_initcall which requires P2SB resources.
+ * pci_rescan_remove_lock() can not be locked in sysfs PCI bus rescan path
+ * because of deadlock. To avoid the deadlock, access P2SB devices with the lock
+ * at an early step in kernel initialization and cache required resources.
+ *
+ * We want to run as early as possible. If the P2SB was assigned a bad BAR,
+ * we'll need to wait on pcibios_assign_resources() to fix it. So, our list of
+ * initcall dependencies looks something like this:
+ *
+ * ...
+ * subsys_initcall (pci_subsys_init)
+ * fs_initcall     (pcibios_assign_resources)
  */
-fs_initcall(p2sb_fs_init);
+fs_initcall_sync(p2sb_fs_init);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux