Skip to content

Commit 4338bda

Browse files
committed
drivers: dwc_otg: move FIQ locking functions to header file
Also declare as static inline, as they should be. Signed-off-by: Jonathan Bell <[email protected]>
1 parent 92f2750 commit 4338bda

File tree

2 files changed

+65
-69
lines changed

2 files changed

+65
-69
lines changed

drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.c

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -74,70 +74,6 @@ void notrace _fiq_print(enum fiq_debug_level dbg_lvl, volatile struct fiq_state
7474
}
7575
}
7676

77-
78-
#ifdef CONFIG_ARM64
79-
80-
inline void fiq_fsm_spin_lock(fiq_lock_t *lock)
81-
{
82-
spin_lock((spinlock_t *)lock);
83-
}
84-
85-
inline void fiq_fsm_spin_unlock(fiq_lock_t *lock)
86-
{
87-
spin_unlock((spinlock_t *)lock);
88-
}
89-
90-
#else
91-
92-
/**
93-
* fiq_fsm_spin_lock() - ARMv6+ bare bones spinlock
94-
* Must be called with local interrupts and FIQ disabled.
95-
*/
96-
#if defined(CONFIG_ARCH_BCM2835) && defined(CONFIG_SMP)
97-
inline void fiq_fsm_spin_lock(fiq_lock_t *lock)
98-
{
99-
unsigned long tmp;
100-
uint32_t newval;
101-
fiq_lock_t lockval;
102-
/* Nested locking, yay. If we are on the same CPU as the fiq, then the disable
103-
* will be sufficient. If we are on a different CPU, then the lock protects us. */
104-
prefetchw(&lock->slock);
105-
asm volatile (
106-
"1: ldrex %0, [%3]\n"
107-
" add %1, %0, %4\n"
108-
" strex %2, %1, [%3]\n"
109-
" teq %2, #0\n"
110-
" bne 1b"
111-
: "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
112-
: "r" (&lock->slock), "I" (1 << 16)
113-
: "cc");
114-
115-
while (lockval.tickets.next != lockval.tickets.owner) {
116-
wfe();
117-
lockval.tickets.owner = READ_ONCE(lock->tickets.owner);
118-
}
119-
smp_mb();
120-
}
121-
#else
122-
inline void fiq_fsm_spin_lock(fiq_lock_t *lock) { }
123-
#endif
124-
125-
/**
126-
* fiq_fsm_spin_unlock() - ARMv6+ bare bones spinunlock
127-
*/
128-
#if defined(CONFIG_ARCH_BCM2835) && defined(CONFIG_SMP)
129-
inline void fiq_fsm_spin_unlock(fiq_lock_t *lock)
130-
{
131-
smp_mb();
132-
lock->tickets.owner++;
133-
dsb_sev();
134-
}
135-
#else
136-
inline void fiq_fsm_spin_unlock(fiq_lock_t *lock) { }
137-
#endif
138-
139-
#endif
140-
14177
/**
14278
* fiq_fsm_restart_channel() - Poke channel enable bit for a split transaction
14379
* @channel: channel to re-enable

drivers/usb/host/dwc_otg/dwc_otg_fiq_fsm.h

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ typedef spinlock_t fiq_lock_t;
135135

136136
#else
137137

138+
#define TICKET_SHIFT 16
138139
typedef struct {
139140
union {
140141
uint32_t slock;
@@ -143,7 +144,70 @@ typedef struct {
143144
uint16_t next;
144145
} tickets;
145146
};
146-
} fiq_lock_t;
147+
} __aligned(4) fiq_lock_t;
148+
149+
#endif
150+
151+
#ifdef CONFIG_ARM64
152+
153+
static inline void fiq_fsm_spin_lock(fiq_lock_t *lock)
154+
{
155+
spin_lock((spinlock_t *)lock);
156+
}
157+
158+
static inline void fiq_fsm_spin_unlock(fiq_lock_t *lock)
159+
{
160+
spin_unlock((spinlock_t *)lock);
161+
}
162+
163+
#else
164+
165+
/**
166+
* fiq_fsm_spin_lock() - ARMv6+ bare bones spinlock
167+
* Must be called with local interrupts and FIQ disabled.
168+
*/
169+
#if defined(CONFIG_ARCH_BCM2835) && defined(CONFIG_SMP)
170+
static inline void fiq_fsm_spin_lock(fiq_lock_t *lock)
171+
{
172+
unsigned long tmp;
173+
uint32_t newval;
174+
fiq_lock_t lockval;
175+
/* Nested locking, yay. If we are on the same CPU as the fiq, then the disable
176+
* will be sufficient. If we are on a different CPU, then the lock protects us. */
177+
prefetchw(&lock->slock);
178+
asm volatile (
179+
"1: ldrex %0, [%3]\n"
180+
" add %1, %0, %4\n"
181+
" strex %2, %1, [%3]\n"
182+
" teq %2, #0\n"
183+
" bne 1b"
184+
: "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
185+
: "r" (&lock->slock), "I" (1 << TICKET_SHIFT)
186+
: "cc");
187+
188+
while (lockval.tickets.next != lockval.tickets.owner) {
189+
wfe();
190+
lockval.tickets.owner = READ_ONCE(lock->tickets.owner);
191+
}
192+
smp_mb();
193+
}
194+
#else
195+
static inline void fiq_fsm_spin_lock(fiq_lock_t *lock) { }
196+
#endif
197+
198+
/**
199+
* fiq_fsm_spin_unlock() - ARMv6+ bare bones spinunlock
200+
*/
201+
#if defined(CONFIG_ARCH_BCM2835) && defined(CONFIG_SMP)
202+
static inline void fiq_fsm_spin_unlock(fiq_lock_t *lock)
203+
{
204+
smp_mb();
205+
lock->tickets.owner++;
206+
dsb_sev();
207+
}
208+
#else
209+
static inline void fiq_fsm_spin_unlock(fiq_lock_t *lock) { }
210+
#endif
147211

148212
#endif
149213

@@ -380,10 +444,6 @@ extern void local_fiq_disable(void);
380444

381445
#endif
382446

383-
extern void fiq_fsm_spin_lock(fiq_lock_t *lock);
384-
385-
extern void fiq_fsm_spin_unlock(fiq_lock_t *lock);
386-
387447
extern int fiq_fsm_too_late(struct fiq_state *st, int n);
388448

389449
extern int fiq_fsm_tt_in_use(struct fiq_state *st, int num_channels, int n);

0 commit comments

Comments
 (0)