OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:48 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Need help: XHCI interrupter's pending bit not set
PostPosted: Thu Aug 25, 2022 7:42 am 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
Hello!
I'm making an XHCI driver for my os, and I met a strange problem.
I send a ENABLE_SLOT command to the xhci host controller, and the interrupt target is 0, after the command been executed I receive an irq from the controller. When I'm dealing with the interrupt, I found that the pending bit in the 'interrupt management register' of XHCI interrupter0 is NOT set by the controller. The value of the register is '0x2', which means the interrupt enable bit is set but the pending bit is not set.
And, I don't clear the event handler busy bit in the dequeue register, then write a new ENABLE_SLOT command into the command ring. After the write, I found that the pending bit has been set, and the irq handler not run.

My question is: Why the pending bit is not set by the controller at the first time?

Thanks for your help!


Top
 Profile  
 
 Post subject: Re: Need help: XHCI interrupter's pending bit not set
PostPosted: Fri Aug 26, 2022 11:23 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Is there another device using the same interrupt vector?

Is the XHCI MMIO range mapped with an appropriate memory type?


Top
 Profile  
 
 Post subject: Re: Need help: XHCI interrupter's pending bit not set
PostPosted: Fri Aug 26, 2022 11:27 am 
Offline
Member
Member
User avatar

Joined: Fri Jun 11, 2021 6:02 am
Posts: 96
Location: Belgium
You don't need to check the interrupter management register. You just need to check if the cycle bit is on (or off, see manual to find out when it needs to be on or off) of the TRB at current dequeue pointer/index.

Nitpick: note the -er in interrupter.

_________________
My OS is Norost B (website, Github, sourcehut)
My filesystem is NRFS (Github, sourcehut)


Top
 Profile  
 
 Post subject: Re: Need help: XHCI interrupter's pending bit not set
PostPosted: Fri Aug 26, 2022 7:10 pm 
Offline
Member
Member
User avatar

Joined: Fri Jun 11, 2021 6:02 am
Posts: 96
Location: Belgium
I didn't read your question properly, sorry for that (my fault for trying to answer a question in a haste).

I assume you're using MSI or MSI-X. In that case the IP is cleared automatically.

Intel xHCI manual, page 291 wrote:
If PCI Message Signaled Interrupts (MSI or MSI-X) are enabled, then the
assertion of the Interrupt Pending (IP) flag in Figure 4-22 generates a PCI Dword
write. The IP flag is automatically cleared by the completion of the PCI write.


So, from my understanding, how the IP flag works is:

  • If IMODC == 0, then IP = 1
  • If IP == 1, then generate interrupt and clear it immediately

So when you receive the first interrupt, the bit gets cleared.
When the second interrupt is generated (i.e. IP is set to 1) it stays at 1 because it can't generate an interrupt due to EHB not being cleared.

Also, this is why I think it's important to emphasize the -er in interrupter, as it is something that generates an interrupt. It is not something that represents an (active) interrupt.

_________________
My OS is Norost B (website, Github, sourcehut)
My filesystem is NRFS (Github, sourcehut)


Top
 Profile  
 
 Post subject: Re: Need help: XHCI interrupter's pending bit not set
PostPosted: Mon Aug 29, 2022 11:14 pm 
Offline

Joined: Thu Aug 25, 2022 7:28 am
Posts: 12
Demindiro wrote:
I didn't read your question properly, sorry for that (my fault for trying to answer a question in a haste).

I assume you're using MSI or MSI-X. In that case the IP is cleared automatically.

Intel xHCI manual, page 291 wrote:
If PCI Message Signaled Interrupts (MSI or MSI-X) are enabled, then the
assertion of the Interrupt Pending (IP) flag in Figure 4-22 generates a PCI Dword
write. The IP flag is automatically cleared by the completion of the PCI write.


So, from my understanding, how the IP flag works is:

  • If IMODC == 0, then IP = 1
  • If IP == 1, then generate interrupt and clear it immediately

So when you receive the first interrupt, the bit gets cleared.
When the second interrupt is generated (i.e. IP is set to 1) it stays at 1 because it can't generate an interrupt due to EHB not being cleared.

Also, this is why I think it's important to emphasize the -er in interrupter, as it is something that generates an interrupt. It is not something that represents an (active) interrupt.


Thanks for your reply! The problem has solved. Thank u!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group