24
24
#include <net/switchdev.h>
25
25
#include "mv88e6xxx.h"
26
26
27
+ static void assert_smi_lock (struct dsa_switch * ds )
28
+ {
29
+ struct mv88e6xxx_priv_state * ps = ds_to_priv (ds );
30
+
31
+ if (unlikely (!mutex_is_locked (& ps -> smi_mutex ))) {
32
+ dev_err (ds -> master_dev , "SMI lock not held!\n" );
33
+ dump_stack ();
34
+ }
35
+ }
36
+
27
37
/* If the switch's ADDR[4:0] strap pins are strapped to zero, it will
28
38
* use all 32 SMI bus addresses on its SMI bus, and all switch registers
29
39
* will be directly accessible on some {device address,register address}
@@ -80,12 +90,13 @@ int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg)
80
90
return ret & 0xffff ;
81
91
}
82
92
83
- /* Must be called with SMI mutex held */
84
93
static int _mv88e6xxx_reg_read (struct dsa_switch * ds , int addr , int reg )
85
94
{
86
95
struct mii_bus * bus = dsa_host_dev_to_mii_bus (ds -> master_dev );
87
96
int ret ;
88
97
98
+ assert_smi_lock (ds );
99
+
89
100
if (bus == NULL )
90
101
return - EINVAL ;
91
102
@@ -143,12 +154,13 @@ int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr,
143
154
return 0 ;
144
155
}
145
156
146
- /* Must be called with SMI mutex held */
147
157
static int _mv88e6xxx_reg_write (struct dsa_switch * ds , int addr , int reg ,
148
158
u16 val )
149
159
{
150
160
struct mii_bus * bus = dsa_host_dev_to_mii_bus (ds -> master_dev );
151
161
162
+ assert_smi_lock (ds );
163
+
152
164
if (bus == NULL )
153
165
return - EINVAL ;
154
166
@@ -204,15 +216,13 @@ int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr)
204
216
return 0 ;
205
217
}
206
218
207
- /* Must be called with SMI mutex held */
208
219
static int _mv88e6xxx_phy_read (struct dsa_switch * ds , int addr , int regnum )
209
220
{
210
221
if (addr >= 0 )
211
222
return _mv88e6xxx_reg_read (ds , addr , regnum );
212
223
return 0xffff ;
213
224
}
214
225
215
- /* Must be called with SMI mutex held */
216
226
static int _mv88e6xxx_phy_write (struct dsa_switch * ds , int addr , int regnum ,
217
227
u16 val )
218
228
{
@@ -538,7 +548,6 @@ void mv88e6xxx_adjust_link(struct dsa_switch *ds, int port,
538
548
mutex_unlock (& ps -> smi_mutex );
539
549
}
540
550
541
- /* Must be called with SMI mutex held */
542
551
static int _mv88e6xxx_stats_wait (struct dsa_switch * ds )
543
552
{
544
553
int ret ;
@@ -553,7 +562,6 @@ static int _mv88e6xxx_stats_wait(struct dsa_switch *ds)
553
562
return - ETIMEDOUT ;
554
563
}
555
564
556
- /* Must be called with SMI mutex held */
557
565
static int _mv88e6xxx_stats_snapshot (struct dsa_switch * ds , int port )
558
566
{
559
567
int ret ;
@@ -576,7 +584,6 @@ static int _mv88e6xxx_stats_snapshot(struct dsa_switch *ds, int port)
576
584
return 0 ;
577
585
}
578
586
579
- /* Must be called with SMI mutex held */
580
587
static void _mv88e6xxx_stats_read (struct dsa_switch * ds , int stat , u32 * val )
581
588
{
582
589
u32 _val ;
@@ -789,7 +796,6 @@ void mv88e6xxx_get_regs(struct dsa_switch *ds, int port,
789
796
}
790
797
}
791
798
792
- /* Must be called with SMI lock held */
793
799
static int _mv88e6xxx_wait (struct dsa_switch * ds , int reg , int offset ,
794
800
u16 mask )
795
801
{
@@ -839,14 +845,12 @@ int mv88e6xxx_eeprom_busy_wait(struct dsa_switch *ds)
839
845
GLOBAL2_EEPROM_OP_BUSY );
840
846
}
841
847
842
- /* Must be called with SMI lock held */
843
848
static int _mv88e6xxx_atu_wait (struct dsa_switch * ds )
844
849
{
845
850
return _mv88e6xxx_wait (ds , REG_GLOBAL , GLOBAL_ATU_OP ,
846
851
GLOBAL_ATU_OP_BUSY );
847
852
}
848
853
849
- /* Must be called with SMI mutex held */
850
854
static int _mv88e6xxx_phy_read_indirect (struct dsa_switch * ds , int addr ,
851
855
int regnum )
852
856
{
@@ -865,7 +869,6 @@ static int _mv88e6xxx_phy_read_indirect(struct dsa_switch *ds, int addr,
865
869
return _mv88e6xxx_reg_read (ds , REG_GLOBAL2 , GLOBAL2_SMI_DATA );
866
870
}
867
871
868
- /* Must be called with SMI mutex held */
869
872
static int _mv88e6xxx_phy_write_indirect (struct dsa_switch * ds , int addr ,
870
873
int regnum , u16 val )
871
874
{
0 commit comments