Re: [EXTERNAL] MSI CPU affinity for ARM64

From: Andrew Turner <andrew_at_fubar.geek.nz>
Date: Tue, 10 Jan 2023 09:49:27 UTC

> On 9 Jan 2023, at 15:24, Souradeep Chakrabarti <schakrabarti@microsoft.com> wrote:
> 
> 
> 
> 
>> -----Original Message-----
>> From: Andrew Turner <andrew@fubar.geek.nz>
>> Sent: Monday, January 9, 2023 5:14 PM
>> To: Souradeep Chakrabarti <schakrabarti@microsoft.com>
>> Cc: freebsd-arm@FreeBSD.org; Li-Wen Hsu <lwhsu@freebsd.org>; Wei Hu
>> <weh@microsoft.com>
>> Subject: [EXTERNAL] Re: MSI CPU affinity for ARM64
>> 
>> Hello Souradeep,
>> 
>> In what driver do you need to query the CPU affinity? In the GICv3 driver you can
>> read the set of CPUs from isrc->isrc_cpu. In other drivers it appears to be more
>> difficult.
>> 
>> Andrew
> [Souradeep] 
> I am trying to get the CPU id from vmbus_pcib driver.
> I need to find for the MSI interrupt, what is the CPUid.

If the MSI is for a child of vmbus_pcib you might be able to get this by implementing the bus_bind_intr method, however I don’t think you’ll see the default CPU assignment.

Why do you need the CPU ID in the vmbus_pcib driver? It’s stored in struct intr_event which could be found by adding a bus_setup_intr method that extracts it from the cookie passed back to the driver. This does require the driver to know the type for the cookie. On arm64 it should be a struct intr_handler that contains a pointer to a struct intr_event that has either the CPU the interrupt is assigned to or NOCPU. Having said that I’m not sure how safe it is to assume the cookie is a pointer to the intr_handler.

Andrew