Commit 80351fde authored by Jan Kiszka's avatar Jan Kiszka
Browse files

cobalt/intr: Enhance xnintr_attach with an initial cpumask



This allows to start up interrupts with a specific affinity already set.
Will be used by a new RTDM service.
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 502f94fb
......@@ -116,7 +116,7 @@ int xnintr_init(struct xnintr *intr,
void xnintr_destroy(struct xnintr *intr);
int xnintr_attach(struct xnintr *intr,
void *cookie);
void *cookie, const cpumask_t *cpumask);
void xnintr_detach(struct xnintr *intr);
......
......@@ -83,15 +83,24 @@ void xnintr_destroy(struct xnintr *intr)
}
EXPORT_SYMBOL_GPL(xnintr_destroy);
int xnintr_attach(struct xnintr *intr, void *cookie)
int xnintr_attach(struct xnintr *intr, void *cookie, const cpumask_t *cpumask)
{
cpumask_t tmp_mask, *effective_mask;
int ret;
secondary_mode_only();
intr->cookie = cookie;
ret = irq_set_affinity_hint(intr->irq, &xnsched_realtime_cpus);
if (!cpumask) {
effective_mask = &xnsched_realtime_cpus;
} else {
effective_mask = &tmp_mask;
cpumask_and(effective_mask, &xnsched_realtime_cpus, cpumask);
if (cpumask_empty(effective_mask))
return -EINVAL;
}
ret = irq_set_affinity_hint(intr->irq, effective_mask);
if (ret)
return ret;
......
......@@ -828,6 +828,9 @@ EXPORT_SYMBOL_GPL(xnintr_destroy);
* @param cookie A user-defined opaque value which is stored into the
* descriptor for further retrieval by the interrupt handler.
*
* @param cpumask Initial CPU affinity of the interrupt. If NULL, affinity is
* set to all real-time CPUs.
*
* @return 0 is returned on success. Otherwise:
*
* - -EINVAL is returned if an error occurred while attaching the
......@@ -843,8 +846,11 @@ EXPORT_SYMBOL_GPL(xnintr_destroy);
* @note Attaching an interrupt descriptor resets the tracked number
* of IRQ receipts to zero.
*/
int xnintr_attach(struct xnintr *intr, void *cookie)
int xnintr_attach(struct xnintr *intr, void *cookie, const cpumask_t *cpumask)
{
#ifdef CONFIG_SMP
cpumask_t tmp_mask, *effective_mask;
#endif
int ret;
secondary_mode_only();
......@@ -854,7 +860,17 @@ int xnintr_attach(struct xnintr *intr, void *cookie)
clear_irqstats(intr);
#ifdef CONFIG_SMP
ipipe_set_irq_affinity(intr->irq, xnsched_realtime_cpus);
if (!cpumask) {
effective_mask = &xnsched_realtime_cpus;
} else {
effective_mask = &tmp_mask;
cpumask_and(effective_mask, &xnsched_realtime_cpus, cpumask);
if (cpumask_empty(effective_mask))
return -EINVAL;
}
ret = ipipe_set_irq_affinity(intr->irq, *effective_mask);
if (ret)
return ret;
#endif /* CONFIG_SMP */
raw_spin_lock(&intr->lock);
......
......@@ -1455,7 +1455,7 @@ int rtdm_irq_request(rtdm_irq_t *irq_handle, unsigned int irq_no,
if (err)
return err;
err = xnintr_attach(irq_handle, arg);
err = xnintr_attach(irq_handle, arg, NULL);
if (err) {
xnintr_destroy(irq_handle);
return err;
......
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