Skip to content

Commit 7c4574e

Browse files
bibo-maoKexyBiscuit
authored andcommitted
FROMGIT: LoongArch: KVM: Replace eiointc_enable_irq() with eiointc_update_irq()
Function eiointc_enable_irq() checks mask value with char type, and call eiointc_update_irq() eventually. Function eiointc_update_irq() will update one single irq status directly. Here it can check mask value with unsigned long type and call function eiointc_update_irq(), that is simple and direct. Signed-off-by: Bibo Mao <[email protected]> Signed-off-by: Huacai Chen <[email protected]> (cherry picked from commit 9c79c95 https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git loongarch-next) Signed-off-by: Kexy Biscuit <[email protected]>
1 parent a1b4e8c commit 7c4574e

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

arch/loongarch/kvm/intc/eiointc.c

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,6 @@ void eiointc_set_irq(struct loongarch_eiointc *s, int irq, int level)
111111
spin_unlock_irqrestore(&s->lock, flags);
112112
}
113113

114-
static inline void eiointc_enable_irq(struct kvm_vcpu *vcpu,
115-
struct loongarch_eiointc *s, int index, u8 mask, int level)
116-
{
117-
u8 val;
118-
int irq;
119-
120-
val = mask & s->isr.reg_u8[index];
121-
irq = ffs(val);
122-
while (irq != 0) {
123-
/*
124-
* enable bit change from 0 to 1,
125-
* need to update irq by pending bits
126-
*/
127-
eiointc_update_irq(s, irq - 1 + index * 8, level);
128-
val &= ~BIT(irq - 1);
129-
irq = ffs(val);
130-
}
131-
}
132-
133114
static int loongarch_eiointc_read(struct kvm_vcpu *vcpu, struct loongarch_eiointc *s,
134115
gpa_t addr, unsigned long *val)
135116
{
@@ -222,7 +203,7 @@ static int loongarch_eiointc_write(struct kvm_vcpu *vcpu,
222203
struct loongarch_eiointc *s,
223204
gpa_t addr, u64 value, u64 field_mask)
224205
{
225-
int i, index, irq, bits, ret = 0;
206+
int index, irq, ret = 0;
226207
u8 cpu;
227208
u64 data, old, mask;
228209
gpa_t offset;
@@ -257,18 +238,20 @@ static int loongarch_eiointc_write(struct kvm_vcpu *vcpu,
257238
* update irq when isr is set.
258239
*/
259240
data = s->enable.reg_u64[index] & ~old & s->isr.reg_u64[index];
260-
for (i = 0; i < sizeof(data); i++) {
261-
u8 mask = (data >> (i * 8)) & 0xff;
262-
eiointc_enable_irq(vcpu, s, index * 8 + i, mask, 1);
241+
while (data) {
242+
irq = __ffs(data);
243+
eiointc_update_irq(s, irq + index * 64, 1);
244+
data &= ~BIT_ULL(irq);
263245
}
264246
/*
265247
* 0: disable irq.
266248
* update irq when isr is set.
267249
*/
268250
data = ~s->enable.reg_u64[index] & old & s->isr.reg_u64[index];
269-
for (i = 0; i < sizeof(data); i++) {
270-
u8 mask = (data >> (i * 8)) & 0xff;
271-
eiointc_enable_irq(vcpu, s, index * 8 + i, mask, 0);
251+
while (data) {
252+
irq = __ffs(data);
253+
eiointc_update_irq(s, irq + index * 64, 0);
254+
data &= ~BIT_ULL(irq);
272255
}
273256
break;
274257
case EIOINTC_BOUNCE_START ... EIOINTC_BOUNCE_END:
@@ -285,12 +268,10 @@ static int loongarch_eiointc_write(struct kvm_vcpu *vcpu,
285268
/* write 1 to clear interrupt */
286269
s->coreisr.reg_u64[cpu][index] = old & ~data;
287270
data &= old;
288-
bits = sizeof(data) * 8;
289-
irq = find_first_bit((void *)&data, bits);
290-
while (irq < bits) {
291-
eiointc_update_irq(s, irq + index * bits, 0);
292-
bitmap_clear((void *)&data, irq, 1);
293-
irq = find_first_bit((void *)&data, bits);
271+
while (data) {
272+
irq = __ffs(data);
273+
eiointc_update_irq(s, irq + index * 64, 0);
274+
data &= ~BIT_ULL(irq);
294275
}
295276
break;
296277
case EIOINTC_COREMAP_START ... EIOINTC_COREMAP_END:

0 commit comments

Comments
 (0)