 scsi: smartpqi: Correct device removal for multi-actuator devices · gregkh/linux@d1c8b86 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 676 Star 636 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit d1c8b86 Browse files Browse files Kumar Meiyappan authored and gregkh committed scsi: smartpqi: Correct device removal for multi-actuator devices [ Upstream commit cc9befc ] Correct device count for multi-actuator drives which can cause kernel panics. Reviewed-by: Scott Benesh &lt;scott.benesh@microchip.com&gt; Reviewed-by: Scott Teel &lt;scott.teel@microchip.com&gt; Reviewed-by: Mike Mcgowan &lt;mike.mcgowan@microchip.com&gt; Reviewed-by: Kevin Barnett &lt;kevin.barnett@microchip.com&gt; Signed-off-by: Kumar Meiyappan &lt;Kumar.Meiyappan@microchip.com&gt; Signed-off-by: Don Brace &lt;don.brace@microchip.com&gt; Link: https://lore.kernel.org/r/166793531872.322537.9003385780343419275.stgit@brunhilda Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt; Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt; 1 parent 41d8a93 commit d1c8b86 Copy full SHA for d1c8b86 2 file s changed + 25 - 10 Lines changed: 25 additions &amp; 10 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options drivers/scsi/smartpqi smartpqi.h smartpqi_init.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ drivers/scsi/smartpqi/smartpqi.h ‎ Copy file name to clipboard Expand all lines: drivers/scsi/smartpqi/smartpqi.h + 1 - 1 Lines changed: 1 addition &amp; 1 deletion Original file line number Diff line number Diff line change @@ -1130,7 +1130,7 @@ struct pqi_scsi_dev { 1130 1130 u8 phy_id ; 1131 1131 u8 ncq_prio_enable ; 1132 1132 u8 ncq_prio_support ; 1133 - u8 multi_lun_device_lun_count ; 1133 + u8 lun_count ; 1134 1134 bool raid_bypass_configured ; /* RAID bypass configured */ 1135 1135 bool raid_bypass_enabled ; /* RAID bypass enabled */ 1136 1136 u32 next_bypass_group [ RAID_MAP_MAX_DATA_DISKS_PER_ROW ]; Collapse file ‎ drivers/scsi/smartpqi/smartpqi_init.c ‎ Copy file name to clipboard Expand all lines: drivers/scsi/smartpqi/smartpqi_init.c + 24 - 9 Lines changed: 24 additions &amp; 9 deletions Original file line number Diff line number Diff line change @@ -1610,9 +1610,7 @@ static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info, 1610 1610 &amp; id_phys -&gt; alternate_paths_phys_connector , 1611 1611 sizeof ( device -&gt; phys_connector )); 1612 1612 device -&gt; bay = id_phys -&gt; phys_bay_in_box ; 1613 - device -&gt; multi_lun_device_lun_count = id_phys -&gt; multi_lun_device_lun_count ; 1614 - if (! device -&gt; multi_lun_device_lun_count ) 1615 - device -&gt; multi_lun_device_lun_count = 1 ; 1613 + device -&gt; lun_count = id_phys -&gt; multi_lun_device_lun_count ; 1616 1614 if (( id_phys -&gt; even_more_flags &amp; PQI_DEVICE_PHY_MAP_SUPPORTED ) &amp;&amp; 1617 1615 id_phys -&gt; phy_count ) 1618 1616 device -&gt; phy_id = @@ -1746,7 +1744,7 @@ static bool pqi_keep_device_offline(struct pqi_ctrl_info *ctrl_info, 1746 1744 return offline ; 1747 1745 } 1748 1746 1749 - static int pqi_get_device_info ( struct pqi_ctrl_info * ctrl_info , 1747 + static int pqi_get_device_info_phys_logical ( struct pqi_ctrl_info * ctrl_info , 1750 1748 struct pqi_scsi_dev * device , 1751 1749 struct bmic_identify_physical_device * id_phys ) 1752 1750 { @@ -1763,6 +1761,20 @@ static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info, 1763 1761 return rc ; 1764 1762 } 1765 1763 1764 + static int pqi_get_device_info ( struct pqi_ctrl_info * ctrl_info , 1765 + struct pqi_scsi_dev * device , 1766 + struct bmic_identify_physical_device * id_phys ) 1767 + { 1768 + int rc ; 1769 + 1770 + rc = pqi_get_device_info_phys_logical ( ctrl_info , device , id_phys ); 1771 + 1772 + if ( rc == 0 &amp;&amp; device -&gt; lun_count == 0 ) 1773 + device -&gt; lun_count = 1 ; 1774 + 1775 + return rc ; 1776 + } 1777 + 1766 1778 static void pqi_show_volume_status ( struct pqi_ctrl_info * ctrl_info , 1767 1779 struct pqi_scsi_dev * device ) 1768 1780 { @@ -1897,7 +1909,7 @@ static inline void pqi_remove_device(struct pqi_ctrl_info *ctrl_info, struct pqi 1897 1909 int rc ; 1898 1910 int lun ; 1899 1911 1900 - for ( lun = 0 ; lun &lt; device -&gt; multi_lun_device_lun_count ; lun ++ ) { 1912 + for ( lun = 0 ; lun &lt; device -&gt; lun_count ; lun ++ ) { 1901 1913 rc = pqi_device_wait_for_pending_io ( ctrl_info , device , lun , 1902 1914 PQI_REMOVE_DEVICE_PENDING_IO_TIMEOUT_MSECS ); 1903 1915 if ( rc ) @@ -2076,6 +2088,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info, 2076 2088 existing_device -&gt; sas_address = new_device -&gt; sas_address ; 2077 2089 existing_device -&gt; queue_depth = new_device -&gt; queue_depth ; 2078 2090 existing_device -&gt; device_offline = false; 2091 + existing_device -&gt; lun_count = new_device -&gt; lun_count ; 2079 2092 2080 2093 if ( pqi_is_logical_device ( existing_device )) { 2081 2094 existing_device -&gt; is_external_raid_device = new_device -&gt; is_external_raid_device ; @@ -2108,10 +2121,6 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info, 2108 2121 existing_device -&gt; phy_connected_dev_type = new_device -&gt; phy_connected_dev_type ; 2109 2122 memcpy ( existing_device -&gt; box , new_device -&gt; box , sizeof ( existing_device -&gt; box )); 2110 2123 memcpy ( existing_device -&gt; phys_connector , new_device -&gt; phys_connector , sizeof ( existing_device -&gt; phys_connector )); 2111 - 2112 - existing_device -&gt; multi_lun_device_lun_count = new_device -&gt; multi_lun_device_lun_count ; 2113 - if ( existing_device -&gt; multi_lun_device_lun_count == 0 ) 2114 - existing_device -&gt; multi_lun_device_lun_count = 1 ; 2115 2124 } 2116 2125 } 2117 2126 @@ -6484,6 +6493,12 @@ static void pqi_slave_destroy(struct scsi_device *sdev) 6484 6493 return ; 6485 6494 } 6486 6495 6496 + device -&gt; lun_count -- ; 6497 + if ( device -&gt; lun_count &gt; 0 ) { 6498 + mutex_unlock ( &amp; ctrl_info -&gt; scan_mutex ); 6499 + return ; 6500 + } 6501 + 6487 6502 spin_lock_irqsave ( &amp; ctrl_info -&gt; scsi_device_list_lock , flags ); 6488 6503 list_del ( &amp; device -&gt; scsi_device_list_entry ); 6489 6504 spin_unlock_irqrestore ( &amp; ctrl_info -&gt; scsi_device_list_lock , flags ); 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 