Skip to content

Commit 7150db2

Browse files
committed
lib: utils: Fix irqchip registration for PLIC and APLIC
Currently, the same irqchip instance is registered for multiple PLIC and APLIC instances which causes the sbi_list_for_each_entry() loop in the sbi_irqchip_init() to hang at boot-time. To address the above issue, register a separate irqchip instance for each PLIC and APLIC instance. Fixes: 2dd6eaf ("lib: sbi_irqchip: Call driver warm_init from SBI core") Reported-by: Himanshu Chauhan <[email protected]> Signed-off-by: Anup Patel <[email protected]> Reviewed-by: Himanshu Chauhan <[email protected]>
1 parent 551ac0f commit 7150db2

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

include/sbi_utils/irqchip/aplic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#define __IRQCHIP_APLIC_H__
1313

1414
#include <sbi/sbi_types.h>
15+
#include <sbi/sbi_irqchip.h>
1516

1617
#define APLIC_MAX_DELEGATE 16
1718

@@ -30,6 +31,9 @@ struct aplic_delegate_data {
3031
};
3132

3233
struct aplic_data {
34+
/* Private members */
35+
struct sbi_irqchip_device irqchip;
36+
/* Public members */
3337
unsigned long addr;
3438
unsigned long size;
3539
unsigned long num_idc;

include/sbi_utils/irqchip/plic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
#define __IRQCHIP_PLIC_H__
1212

1313
#include <sbi/sbi_types.h>
14+
#include <sbi/sbi_irqchip.h>
1415

1516
struct plic_data {
17+
/* Private members */
18+
struct sbi_irqchip_device irqchip;
19+
/* Public members */
1620
unsigned long addr;
1721
unsigned long size;
1822
unsigned long num_src;

lib/utils/irqchip/aplic.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <sbi/sbi_console.h>
1313
#include <sbi/sbi_domain.h>
1414
#include <sbi/sbi_error.h>
15-
#include <sbi/sbi_irqchip.h>
1615
#include <sbi_utils/irqchip/aplic.h>
1716

1817
#define APLIC_MAX_IDC (1UL << 14)
@@ -166,9 +165,6 @@ static int aplic_check_msicfg(struct aplic_msicfg_data *msicfg)
166165
return 0;
167166
}
168167

169-
static struct sbi_irqchip_device aplic_device = {
170-
};
171-
172168
int aplic_cold_irqchip_init(struct aplic_data *aplic)
173169
{
174170
int rc;
@@ -280,7 +276,7 @@ int aplic_cold_irqchip_init(struct aplic_data *aplic)
280276
}
281277

282278
/* Register irqchip device */
283-
sbi_irqchip_add_device(&aplic_device);
279+
sbi_irqchip_add_device(&aplic->irqchip);
284280

285281
return 0;
286282
}

lib/utils/irqchip/plic.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <sbi/sbi_domain.h>
1616
#include <sbi/sbi_error.h>
1717
#include <sbi/sbi_heap.h>
18-
#include <sbi/sbi_irqchip.h>
1918
#include <sbi/sbi_string.h>
2019
#include <sbi_utils/irqchip/plic.h>
2120

@@ -221,10 +220,6 @@ static int plic_warm_irqchip_init(struct sbi_irqchip_device *dev)
221220
return 0;
222221
}
223222

224-
static struct sbi_irqchip_device plic_device = {
225-
.warm_init = plic_warm_irqchip_init,
226-
};
227-
228223
int plic_cold_irqchip_init(struct plic_data *plic)
229224
{
230225
int i, ret;
@@ -284,7 +279,8 @@ int plic_cold_irqchip_init(struct plic_data *plic)
284279
}
285280

286281
/* Register irqchip device */
287-
sbi_irqchip_add_device(&plic_device);
282+
plic->irqchip.warm_init = plic_warm_irqchip_init;
283+
sbi_irqchip_add_device(&plic->irqchip);
288284

289285
return 0;
290286
}

0 commit comments

Comments
 (0)