Commit 38708c2a authored by Federico Vaga's avatar Federico Vaga

kernel: use dedicated spinlock for VIC vector

The irq_lock is a SVEC spinlock, but we must protect VIC variables. In order
to make the VIC code independent, use a dedicated VIC spinlock
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 79fa5ba7
......@@ -24,6 +24,8 @@
/* A Vectored Interrupt Controller object */
struct vic_irq_controller {
/* It protects the handlers' vector */
spinlock_t vec_lock;
/* already-initialized flag */
int initialized;
/* Base address (FPGA-relative) */
......@@ -78,6 +80,7 @@ static int svec_vic_init(struct svec_dev *svec, struct fmc_device *fmc)
if (!vic)
return -ENOMEM;
spin_lock_init(&vic->vec_lock);
vic->kernel_va = svec->map[MAP_REG]->kernel_va + vic_base;
vic->base = (uint32_t) vic_base;
......@@ -161,15 +164,14 @@ int svec_vic_irq_request(struct svec_dev *svec, struct fmc_device *fmc,
for (i = 0; i < VIC_MAX_VECTORS; i++) {
/* find the vector in the stored table, assign handler and enable the line if exists */
if (vic->vectors[i].saved_id == id) {
spin_lock(&svec->irq_lock);
spin_lock(&svec->vic->vec_lock);
vic_writel(vic, i, VIC_IVT_RAM_BASE + 4 * i);
vic->vectors[i].requestor = fmc;
vic->vectors[i].handler = handler;
vic_writel(vic, (1 << i), VIC_REG_IER);
spin_unlock(&svec->irq_lock);
spin_unlock(&svec->vic->vec_lock);
return 0;
}
......@@ -201,13 +203,13 @@ int svec_vic_irq_free(struct svec_dev *svec, unsigned long id)
for (i = 0; i < VIC_MAX_VECTORS; i++) {
uint32_t vec = svec->vic->vectors[i].saved_id;
if (vec == id) {
spin_lock(&svec->irq_lock);
spin_lock(&svec->vic->vec_lock);
vic_writel(svec->vic, 1 << i, VIC_REG_IDR);
vic_writel(svec->vic, vec, VIC_IVT_RAM_BASE + 4 * i);
svec->vic->vectors[i].handler = NULL;
spin_unlock(&svec->irq_lock);
spin_unlock(&svec->vic->vec_lock);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment