 scsi: smartpqi: Correct device removal for multi-actuator devices · gregkh/linux@cc9befc · 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 cc9befc Browse files Browse files Kumar Meiyappan authored and martinkpetersen committed scsi: smartpqi: Correct device removal for multi-actuator devices 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; 1 parent cbe42ac commit cc9befc Copy full SHA for cc9befc 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 @@ -1623,9 +1623,7 @@ static int pqi_get_physical_device_info(struct pqi_ctrl_info *ctrl_info, 1623 1623 &amp; id_phys -&gt; alternate_paths_phys_connector , 1624 1624 sizeof ( device -&gt; phys_connector )); 1625 1625 device -&gt; bay = id_phys -&gt; phys_bay_in_box ; 1626 - device -&gt; multi_lun_device_lun_count = id_phys -&gt; multi_lun_device_lun_count ; 1627 - if (! device -&gt; multi_lun_device_lun_count ) 1628 - device -&gt; multi_lun_device_lun_count = 1 ; 1626 + device -&gt; lun_count = id_phys -&gt; multi_lun_device_lun_count ; 1629 1627 if (( id_phys -&gt; even_more_flags &amp; PQI_DEVICE_PHY_MAP_SUPPORTED ) &amp;&amp; 1630 1628 id_phys -&gt; phy_count ) 1631 1629 device -&gt; phy_id = @@ -1759,7 +1757,7 @@ static bool pqi_keep_device_offline(struct pqi_ctrl_info *ctrl_info, 1759 1757 return offline ; 1760 1758 } 1761 1759 1762 - static int pqi_get_device_info ( struct pqi_ctrl_info * ctrl_info , 1760 + static int pqi_get_device_info_phys_logical ( struct pqi_ctrl_info * ctrl_info , 1763 1761 struct pqi_scsi_dev * device , 1764 1762 struct bmic_identify_physical_device * id_phys ) 1765 1763 { @@ -1776,6 +1774,20 @@ static int pqi_get_device_info(struct pqi_ctrl_info *ctrl_info, 1776 1774 return rc ; 1777 1775 } 1778 1776 1777 + static int pqi_get_device_info ( struct pqi_ctrl_info * ctrl_info , 1778 + struct pqi_scsi_dev * device , 1779 + struct bmic_identify_physical_device * id_phys ) 1780 + { 1781 + int rc ; 1782 + 1783 + rc = pqi_get_device_info_phys_logical ( ctrl_info , device , id_phys ); 1784 + 1785 + if ( rc == 0 &amp;&amp; device -&gt; lun_count == 0 ) 1786 + device -&gt; lun_count = 1 ; 1787 + 1788 + return rc ; 1789 + } 1790 + 1779 1791 static void pqi_show_volume_status ( struct pqi_ctrl_info * ctrl_info , 1780 1792 struct pqi_scsi_dev * device ) 1781 1793 { @@ -1910,7 +1922,7 @@ static inline void pqi_remove_device(struct pqi_ctrl_info *ctrl_info, struct pqi 1910 1922 int rc ; 1911 1923 int lun ; 1912 1924 1913 - for ( lun = 0 ; lun &lt; device -&gt; multi_lun_device_lun_count ; lun ++ ) { 1925 + for ( lun = 0 ; lun &lt; device -&gt; lun_count ; lun ++ ) { 1914 1926 rc = pqi_device_wait_for_pending_io ( ctrl_info , device , lun , 1915 1927 PQI_REMOVE_DEVICE_PENDING_IO_TIMEOUT_MSECS ); 1916 1928 if ( rc ) @@ -2089,6 +2101,7 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info, 2089 2101 existing_device -&gt; sas_address = new_device -&gt; sas_address ; 2090 2102 existing_device -&gt; queue_depth = new_device -&gt; queue_depth ; 2091 2103 existing_device -&gt; device_offline = false; 2104 + existing_device -&gt; lun_count = new_device -&gt; lun_count ; 2092 2105 2093 2106 if ( pqi_is_logical_device ( existing_device )) { 2094 2107 existing_device -&gt; is_external_raid_device = new_device -&gt; is_external_raid_device ; @@ -2121,10 +2134,6 @@ static void pqi_scsi_update_device(struct pqi_ctrl_info *ctrl_info, 2121 2134 existing_device -&gt; phy_connected_dev_type = new_device -&gt; phy_connected_dev_type ; 2122 2135 memcpy ( existing_device -&gt; box , new_device -&gt; box , sizeof ( existing_device -&gt; box )); 2123 2136 memcpy ( existing_device -&gt; phys_connector , new_device -&gt; phys_connector , sizeof ( existing_device -&gt; phys_connector )); 2124 - 2125 - existing_device -&gt; multi_lun_device_lun_count = new_device -&gt; multi_lun_device_lun_count ; 2126 - if ( existing_device -&gt; multi_lun_device_lun_count == 0 ) 2127 - existing_device -&gt; multi_lun_device_lun_count = 1 ; 2128 2137 } 2129 2138 } 2130 2139 @@ -6502,6 +6511,12 @@ static void pqi_slave_destroy(struct scsi_device *sdev) 6502 6511 return ; 6503 6512 } 6504 6513 6514 + device -&gt; lun_count -- ; 6515 + if ( device -&gt; lun_count &gt; 0 ) { 6516 + mutex_unlock ( &amp; ctrl_info -&gt; scan_mutex ); 6517 + return ; 6518 + } 6519 + 6505 6520 spin_lock_irqsave ( &amp; ctrl_info -&gt; scsi_device_list_lock , flags ); 6506 6521 list_del ( &amp; device -&gt; scsi_device_list_entry ); 6507 6522 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. 