 27c9d80f51
			
		
	
	27c9d80f51
	
	
		
			
	
		
	
	
		
			Some checks failed
		
		
	
	Build Kernel / Build all affected Kernels (push) Has been cancelled
				
			Build all core packages / Build all core packages for selected target (push) Has been cancelled
				
			Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
				
			Build Toolchains / Build Toolchains for each target (push) Has been cancelled
				
			Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
				
			Coverity scan build / Coverity x86/64 build (push) Has been cancelled
				
			
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 4dd2cc9b91ecb25f278a2c55e07e6455e9000e6b Mon Sep 17 00:00:00 2001
 | |
| From: Daniel Golle <daniel@makrotopia.org>
 | |
| Date: Sat, 22 Apr 2023 01:21:14 +0100
 | |
| Subject: [PATCH] net: phy: realtek: make sure paged read is protected by mutex
 | |
| 
 | |
| As we cannot rely on phy_read_paged function before the PHY is
 | |
| identified, the paged read in rtlgen_supports_2_5gbps needs to be open
 | |
| coded as it is being called by the match_phy_device function, ie. before
 | |
| .read_page and .write_page have been populated.
 | |
| 
 | |
| Make sure it is also protected by the MDIO bus mutex and use
 | |
| rtl821x_write_page instead of 3 individually locked MDIO bus operations.
 | |
| 
 | |
| Signed-off-by: Daniel Golle <daniel@makrotopia.org>
 | |
| ---
 | |
|  drivers/net/phy/realtek.c | 8 +++++---
 | |
|  1 file changed, 5 insertions(+), 3 deletions(-)
 | |
| 
 | |
| --- a/drivers/net/phy/realtek.c
 | |
| +++ b/drivers/net/phy/realtek.c
 | |
| @@ -765,9 +765,11 @@ static bool rtlgen_supports_2_5gbps(stru
 | |
|  {
 | |
|  	int val;
 | |
|  
 | |
| -	phy_write(phydev, RTL821x_PAGE_SELECT, 0xa61);
 | |
| -	val = phy_read(phydev, 0x13);
 | |
| -	phy_write(phydev, RTL821x_PAGE_SELECT, 0);
 | |
| +	mutex_lock(&phydev->mdio.bus->mdio_lock);
 | |
| +	rtl821x_write_page(phydev, 0xa61);
 | |
| +	val = __phy_read(phydev, 0x13);
 | |
| +	rtl821x_write_page(phydev, 0);
 | |
| +	mutex_unlock(&phydev->mdio.bus->mdio_lock);
 | |
|  
 | |
|  	return val >= 0 && val & RTL_SUPPORTS_2500FULL;
 | |
|  }
 |