@@ -1495,7 +1495,7 @@ static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance)
14951495static void ahci_remap_check (struct pci_dev * pdev , int bar ,
14961496 struct ahci_host_priv * hpriv )
14971497{
1498- int i , count = 0 ;
1498+ int i ;
14991499 u32 cap ;
15001500
15011501 /*
@@ -1516,13 +1516,14 @@ static void ahci_remap_check(struct pci_dev *pdev, int bar,
15161516 continue ;
15171517
15181518 /* We've found a remapped device */
1519- count ++ ;
1519+ hpriv -> remapped_nvme ++ ;
15201520 }
15211521
1522- if (!count )
1522+ if (!hpriv -> remapped_nvme )
15231523 return ;
15241524
1525- dev_warn (& pdev -> dev , "Found %d remapped NVMe devices.\n" , count );
1525+ dev_warn (& pdev -> dev , "Found %u remapped NVMe devices.\n" ,
1526+ hpriv -> remapped_nvme );
15261527 dev_warn (& pdev -> dev ,
15271528 "Switch your BIOS from RAID to AHCI mode to use them.\n" );
15281529
@@ -1642,6 +1643,18 @@ static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hp
16421643 }
16431644}
16441645
1646+ static ssize_t remapped_nvme_show (struct device * dev ,
1647+ struct device_attribute * attr ,
1648+ char * buf )
1649+ {
1650+ struct ata_host * host = dev_get_drvdata (dev );
1651+ struct ahci_host_priv * hpriv = host -> private_data ;
1652+
1653+ return sprintf (buf , "%u\n" , hpriv -> remapped_nvme );
1654+ }
1655+
1656+ static DEVICE_ATTR_RO (remapped_nvme );
1657+
16451658static int ahci_init_one (struct pci_dev * pdev , const struct pci_device_id * ent )
16461659{
16471660 unsigned int board_id = ent -> driver_data ;
@@ -1745,6 +1758,10 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
17451758 /* detect remapped nvme devices */
17461759 ahci_remap_check (pdev , ahci_pci_bar , hpriv );
17471760
1761+ sysfs_add_file_to_group (& pdev -> dev .kobj ,
1762+ & dev_attr_remapped_nvme .attr ,
1763+ NULL );
1764+
17481765 /* must set flag prior to save config in order to take effect */
17491766 if (ahci_broken_devslp (pdev ))
17501767 hpriv -> flags |= AHCI_HFLAG_NO_DEVSLP ;
@@ -1896,6 +1913,9 @@ static void ahci_shutdown_one(struct pci_dev *pdev)
18961913
18971914static void ahci_remove_one (struct pci_dev * pdev )
18981915{
1916+ sysfs_remove_file_from_group (& pdev -> dev .kobj ,
1917+ & dev_attr_remapped_nvme .attr ,
1918+ NULL );
18991919 pm_runtime_get_noresume (& pdev -> dev );
19001920 ata_pci_remove_one (pdev );
19011921}
0 commit comments