Skip to content

Commit aa034b2

Browse files
committed
drivers: pci: Fix endpoint MSI setup
rt_pci_ep_set_msi() checked the set_msix callback before calling set_msi. That rejects endpoint controllers that implement MSI without MSI-X, and can call through a NULL set_msi pointer when only MSI-X is provided. The same helper converts a requested MSI vector count into the log2 field passed to the controller. Stop after the first value large enough for the request so smaller requests are not widened by later loop iterations. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
1 parent 5882e6a commit aa034b2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

components/drivers/pci/endpoint/endpoint.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ rt_err_t rt_pci_ep_set_msi(struct rt_pci_ep *ep, rt_uint8_t func_no,
182182

183183
if (ep && ep->ops && func_no < ep->max_functions)
184184
{
185-
if (ep->ops->set_msix)
185+
if (ep->ops->set_msi)
186186
{
187187
err = -RT_EINVAL;
188188

@@ -193,6 +193,7 @@ rt_err_t rt_pci_ep_set_msi(struct rt_pci_ep *ep, rt_uint8_t func_no,
193193
rt_mutex_take(&ep->lock, RT_WAITING_FOREVER);
194194
err = ep->ops->set_msi(ep, func_no, log2);
195195
rt_mutex_release(&ep->lock);
196+
break;
196197
}
197198
}
198199
}

0 commit comments

Comments
 (0)