[Xenomai] [PATCH 3/3] kernel: rtdm: gpio: Add support for GPIO_RTIOC_IRQAFF.

Philippe Gerum rpm at xenomai.org
Sun Oct 29 18:36:55 CET 2017


On 10/23/2017 04:59 PM, Christoph Muellner wrote:
> To set a GPIO interrupt's CPU affinity, we simply call
> rtdm_irq_affinity() with a proper bitmask.
> 
> Signed-off-by: Christoph Muellner <christoph.muellner at theobroma-systems.com>
> ---
>  kernel/drivers/gpio/gpio-core.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
> index 55594f6ae..84153a937 100644
> --- a/kernel/drivers/gpio/gpio-core.c
> +++ b/kernel/drivers/gpio/gpio-core.c
> @@ -118,6 +118,23 @@ static void release_gpio_irq(unsigned int gpio, struct rtdm_gpio_pin *pin,
>  	chan->requested = false;
>  }
>  
> +static int set_gpio_irq_affinity(struct rtdm_gpio_pin *pin, int val)
> +{
> +	cpumask_t tgt;
> +	unsigned int i = 0;
> +
> +	cpumask_clear(&tgt);
> +
> +	while (val) {
> +		if (val & (1 << i))
> +			cpumask_set_cpu(i, &tgt);
> +		val &= ~(1 << i);
> +		i++;
> +	}
> +
> +	return rtdm_irq_affinity(&pin->irqh, tgt);
> +}
> +

Reflecting the change from int -> cpu_set_t in the ABI, we could have
something along these lines instead:

static int set_gpio_irq_affinity(struct rtdm_gpio_pin *pin, unsigned
long __user *u_set, size_t setsize)
{
	cpumask_var_t mask;
	int ret;

	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
		return -ENOMEM;

	ret = get_user_cpu_mask(u_set, setsize, mask);
	if (ret == 0)
		ret = do_set_gpio_affinity(pin, mask);

	free_cpumask_var(mask);

	...
-- 
Philippe.



More information about the Xenomai mailing list