2024-05-16 05:57:52

by Oliver Neukum

[permalink] [raw]
Subject: question regarding ordering in btintel_pcie_send_sync()

Hi,

I was looking at the code. I do not have documentation for the
device, but it looks relatively ordinary. Hence this piece of
code caught my eye:


/* Set the doorbell to notify the device */
btintel_pcie_set_tx_db(data, tfd_index);

Requesting an interrupt. However, are you sure the IO can be processed
and trigger an interrupt only after the PCI write, which this triggers?

/* Wait for the complete interrupt - URBD0 */
ret = wait_event_timeout(data->tx_wait_q, data->tx_wait_done,
msecs_to_jiffies(BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS));

Regards
Oliver


2024-05-16 13:29:19

by K, Kiran

[permalink] [raw]
Subject: RE: question regarding ordering in btintel_pcie_send_sync()

Hi Oliver,


>-----Original Message-----
>From: Oliver Neukum <[email protected]>
>Sent: Thursday, May 16, 2024 11:28 AM
>To: K, Kiran <[email protected]>; Marcel Holtmann <[email protected]>
>Cc: [email protected]
>Subject: question regarding ordering in btintel_pcie_send_sync()
>
>Hi,
>
>I was looking at the code. I do not have documentation for the device, but it
>looks relatively ordinary. Hence this piece of code caught my eye:
>
>
> /* Set the doorbell to notify the device */
> btintel_pcie_set_tx_db(data, tfd_index);
>
>Requesting an interrupt. However, are you sure the IO can be processed and
>trigger an interrupt only after the PCI write, which this triggers?
>
This wait is for reception of packet at the device side. Bluetooth controller can raise the interrupt with different causes. Here driver waits for interrupt BTINTEL_*_CAUSE_0 which indicates that TX has been completed. Device raises BTINTEL_*_CAUSE_1 interrupt when TX packet has been processed and there is some data in RX queue to be read by driver.

> /* Wait for the complete interrupt - URBD0 */
> ret = wait_event_timeout(data->tx_wait_q, data->tx_wait_done,
> msecs_to_jiffies(BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS));
>
> Regards
> Oliver

Thanks,
Kiran