* [PATCH] accel/qaic: Handle DBC deactivation if the owner went away
@ 2025-12-23 15:31 Youssef Samir
2025-12-24 5:43 ` kernel test robot
2025-12-24 10:11 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Youssef Samir @ 2025-12-23 15:31 UTC (permalink / raw)
To: jeff.hugo, carl.vanderlip, troy.hanson, zachary.mckevitt
Cc: ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm, dri-devel
When a DBC is released, the device sends a QAIC_TRANS_DEACTIVATE_FROM_DEV
transaction to the host over the QAIC_CONTROL MHI channel. QAIC handles
this by calling decode_deactivate() to release the resources allocated for
that DBC. Since that handling is done in the qaic_manage_ioctl() context,
if the user goes away before receiving and handling the deactivation, the
host will be out-of-sync with the DBCs available for use, and the DBC
resources will not be freed unless the device is removed. If another user
loads and requests to activate a network, then the device assigns the same
DBC to that network, QAIC will "indefinitely" wait for dbc->in_use = false,
leading the user process to hang.
As a solution to this, handle QAIC_TRANS_DEACTIVATE_FROM_DEV transactions
that are received after the user has gone away.
Fixes: 129776ac2e38 ("accel/qaic: Add control path")
Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com>
---
drivers/accel/qaic/qaic_control.c | 46 +++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/drivers/accel/qaic/qaic_control.c b/drivers/accel/qaic/qaic_control.c
index 428d8f65bff3..16bdae028935 100644
--- a/drivers/accel/qaic/qaic_control.c
+++ b/drivers/accel/qaic/qaic_control.c
@@ -913,7 +913,7 @@ static int decode_deactivate(struct qaic_device *qdev, void *trans, u32 *msg_len
*/
return -ENODEV;
- if (status) {
+ if (usr && status) {
/*
* Releasing resources failed on the device side, which puts
* us in a bind since they may still be in use, so enable the
@@ -1108,6 +1108,9 @@ static void *msg_xfer(struct qaic_device *qdev, struct wrapper_list *wrappers, u
mutex_lock(&qdev->cntl_mutex);
if (!list_empty(&elem.list))
list_del(&elem.list);
+ /* resp_worker() processed the response but the wait was interrupted */
+ else if (list_empty(&elem.list) && ret == -ERESTARTSYS)
+ ret = 0;
if (!ret && !elem.buf)
ret = -ETIMEDOUT;
else if (ret > 0 && !elem.buf)
@@ -1418,7 +1421,46 @@ static void resp_worker(struct work_struct *work)
}
mutex_unlock(&qdev->cntl_mutex);
- if (!found)
+ if (!found) {
+ /*
+ * The user might have gone away at this point without waiting
+ * for QAIC_TRANS_DEACTIVATE_FROM_DEV transaction coming from
+ * the device. If this is not handled correctly, the host will
+ * not know that the DBC[n] has been freed on the device.
+ * Due to this failure in synchronization between the device and
+ * the host, if another user requests to activate a network, and
+ * the device assigns DBC[n] again, save_dbc_buf() will hang,
+ * waiting for dbc[n]->in_use to be set to false, which will not
+ * happen unless the qaic_dev_reset_clean_local_state() gets
+ * called by resetting the device (or re-inserting the module).
+ *
+ * As a solution, we look for QAIC_TRANS_DEACTIVATE_FROM_DEV
+ * transactions in the message before disposing of it, then
+ * handle releasing the DBC resources.
+ *
+ * Since the user has gone away, if the device could not
+ * deactivate the network (status != 0), there is no way to
+ * enable and reassign the DBC to the user. We can put trust in
+ * the device that it will release all the active DBCs in
+ * response to the QAIC_TRANS_TERMINATE_TO_DEV transaction,
+ * otherwise, the user can issue an soc_reset to the device.
+ */
+ u32 msg_count = le32_to_cpu(msg->hdr.count);
+ u32 msg_len = le32_to_cpu(msg->hdr.len);
+ u32 len = 0;
+ int j;
+
+ for (j = 0; j < msg_count && len < msg_len; ++j) {
+ struct wire_trans_hdr *trans_hdr;
+
+ trans_hdr = (struct wire_trans_hdr *)(msg->data + len);
+ if (le32_to_cpu(trans_hdr->type) == QAIC_TRANS_DEACTIVATE_FROM_DEV) {
+ if (decode_deactivate(qdev, trans_hdr, &len, NULL))
+ len += le32_to_cpu(trans_hdr->len);
+ } else {
+ len += le32_to_cpu(trans_hdr->len);
+ }
+ }
/* request must have timed out, drop packet */
kfree(msg);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] accel/qaic: Handle DBC deactivation if the owner went away
2025-12-23 15:31 [PATCH] accel/qaic: Handle DBC deactivation if the owner went away Youssef Samir
@ 2025-12-24 5:43 ` kernel test robot
2025-12-24 10:11 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-12-24 5:43 UTC (permalink / raw)
To: Youssef Samir, jeff.hugo, carl.vanderlip, troy.hanson,
zachary.mckevitt
Cc: oe-kbuild-all, ogabbay, lizhi.hou, karol.wachowski, linux-arm-msm,
dri-devel
Hi Youssef,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.19-rc2 next-20251219]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Youssef-Samir/accel-qaic-Handle-DBC-deactivation-if-the-owner-went-away/20251223-233305
base: https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link: https://lore.kernel.org/r/20251223153151.2232297-1-youssef.abdulrahman%40oss.qualcomm.com
patch subject: [PATCH] accel/qaic: Handle DBC deactivation if the owner went away
config: xtensa-randconfig-002-20251224 (https://download.01.org/0day-ci/archive/20251224/202512241354.SUxDprgM-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251224/202512241354.SUxDprgM-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512241354.SUxDprgM-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
drivers/accel/qaic/qaic_control.c: In function 'resp_worker':
>> drivers/accel/qaic/qaic_control.c:1470:13: error: invalid storage class for function 'free_wrapper_from_list'
static void free_wrapper_from_list(struct wrapper_list *wrappers, struct wrapper_msg *wrapper)
^~~~~~~~~~~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1602:1: error: expected declaration or statement at end of input
}
^
At top level:
>> drivers/accel/qaic/qaic_control.c:1591:6: warning: 'wake_all_cntl' defined but not used [-Wunused-function]
void wake_all_cntl(struct qaic_device *qdev)
^~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1543:6: warning: 'qaic_release_usr' defined but not used [-Wunused-function]
void qaic_release_usr(struct qaic_device *qdev, struct qaic_user *usr)
^~~~~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1538:6: warning: 'qaic_control_close' defined but not used [-Wunused-function]
void qaic_control_close(struct qaic_device *qdev)
^~~~~~~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1514:5: warning: 'qaic_control_open' defined but not used [-Wunused-function]
int qaic_control_open(struct qaic_device *qdev)
^~~~~~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1491:6: warning: 'qaic_mhi_dl_xfer_cb' defined but not used [-Wunused-function]
void qaic_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
^~~~~~~~~~~~~~~~~~~
>> drivers/accel/qaic/qaic_control.c:1483:6: warning: 'qaic_mhi_ul_xfer_cb' defined but not used [-Wunused-function]
void qaic_mhi_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
^~~~~~~~~~~~~~~~~~~
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=y]
Selected by [y]:
- CAN [=y] && NET [=y]
vim +/free_wrapper_from_list +1470 drivers/accel/qaic/qaic_control.c
129776ac2e3823 Jeff Hugo 2023-03-27 1469
129776ac2e3823 Jeff Hugo 2023-03-27 @1470 static void free_wrapper_from_list(struct wrapper_list *wrappers, struct wrapper_msg *wrapper)
129776ac2e3823 Jeff Hugo 2023-03-27 1471 {
129776ac2e3823 Jeff Hugo 2023-03-27 1472 bool all_done = false;
129776ac2e3823 Jeff Hugo 2023-03-27 1473
129776ac2e3823 Jeff Hugo 2023-03-27 1474 spin_lock(&wrappers->lock);
129776ac2e3823 Jeff Hugo 2023-03-27 1475 kref_put(&wrapper->ref_count, free_wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1476 all_done = list_empty(&wrappers->list);
129776ac2e3823 Jeff Hugo 2023-03-27 1477 spin_unlock(&wrappers->lock);
129776ac2e3823 Jeff Hugo 2023-03-27 1478
129776ac2e3823 Jeff Hugo 2023-03-27 1479 if (all_done)
129776ac2e3823 Jeff Hugo 2023-03-27 1480 kfree(wrappers);
129776ac2e3823 Jeff Hugo 2023-03-27 1481 }
129776ac2e3823 Jeff Hugo 2023-03-27 1482
129776ac2e3823 Jeff Hugo 2023-03-27 @1483 void qaic_mhi_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
129776ac2e3823 Jeff Hugo 2023-03-27 1484 {
129776ac2e3823 Jeff Hugo 2023-03-27 1485 struct wire_msg *msg = mhi_result->buf_addr;
129776ac2e3823 Jeff Hugo 2023-03-27 1486 struct wrapper_msg *wrapper = container_of(msg, struct wrapper_msg, msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1487
129776ac2e3823 Jeff Hugo 2023-03-27 1488 free_wrapper_from_list(wrapper->head, wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1489 }
129776ac2e3823 Jeff Hugo 2023-03-27 1490
129776ac2e3823 Jeff Hugo 2023-03-27 @1491 void qaic_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
129776ac2e3823 Jeff Hugo 2023-03-27 1492 {
129776ac2e3823 Jeff Hugo 2023-03-27 1493 struct qaic_device *qdev = dev_get_drvdata(&mhi_dev->dev);
129776ac2e3823 Jeff Hugo 2023-03-27 1494 struct wire_msg *msg = mhi_result->buf_addr;
129776ac2e3823 Jeff Hugo 2023-03-27 1495 struct resp_work *resp;
129776ac2e3823 Jeff Hugo 2023-03-27 1496
129776ac2e3823 Jeff Hugo 2023-03-27 1497 if (mhi_result->transaction_status || msg->hdr.magic_number != MANAGE_MAGIC_NUMBER) {
129776ac2e3823 Jeff Hugo 2023-03-27 1498 kfree(msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1499 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1500 }
129776ac2e3823 Jeff Hugo 2023-03-27 1501
129776ac2e3823 Jeff Hugo 2023-03-27 1502 resp = kmalloc(sizeof(*resp), GFP_ATOMIC);
129776ac2e3823 Jeff Hugo 2023-03-27 1503 if (!resp) {
129776ac2e3823 Jeff Hugo 2023-03-27 1504 kfree(msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1505 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1506 }
129776ac2e3823 Jeff Hugo 2023-03-27 1507
129776ac2e3823 Jeff Hugo 2023-03-27 1508 INIT_WORK(&resp->work, resp_worker);
129776ac2e3823 Jeff Hugo 2023-03-27 1509 resp->qdev = qdev;
129776ac2e3823 Jeff Hugo 2023-03-27 1510 resp->buf = msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1511 queue_work(qdev->cntl_wq, &resp->work);
129776ac2e3823 Jeff Hugo 2023-03-27 1512 }
129776ac2e3823 Jeff Hugo 2023-03-27 1513
129776ac2e3823 Jeff Hugo 2023-03-27 @1514 int qaic_control_open(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1515 {
129776ac2e3823 Jeff Hugo 2023-03-27 1516 if (!qdev->cntl_ch)
129776ac2e3823 Jeff Hugo 2023-03-27 1517 return -ENODEV;
129776ac2e3823 Jeff Hugo 2023-03-27 1518
129776ac2e3823 Jeff Hugo 2023-03-27 1519 qdev->cntl_lost_buf = false;
129776ac2e3823 Jeff Hugo 2023-03-27 1520 /*
129776ac2e3823 Jeff Hugo 2023-03-27 1521 * By default qaic should assume that device has CRC enabled.
129776ac2e3823 Jeff Hugo 2023-03-27 1522 * Qaic comes to know if device has CRC enabled or disabled during the
129776ac2e3823 Jeff Hugo 2023-03-27 1523 * device status transaction, which is the first transaction performed
129776ac2e3823 Jeff Hugo 2023-03-27 1524 * on control channel.
129776ac2e3823 Jeff Hugo 2023-03-27 1525 *
129776ac2e3823 Jeff Hugo 2023-03-27 1526 * So CRC validation of first device status transaction response is
129776ac2e3823 Jeff Hugo 2023-03-27 1527 * ignored (by calling valid_crc_stub) and is done later during decoding
129776ac2e3823 Jeff Hugo 2023-03-27 1528 * if device has CRC enabled.
129776ac2e3823 Jeff Hugo 2023-03-27 1529 * Now that qaic knows whether device has CRC enabled or not it acts
129776ac2e3823 Jeff Hugo 2023-03-27 1530 * accordingly.
129776ac2e3823 Jeff Hugo 2023-03-27 1531 */
129776ac2e3823 Jeff Hugo 2023-03-27 1532 qdev->gen_crc = gen_crc;
129776ac2e3823 Jeff Hugo 2023-03-27 1533 qdev->valid_crc = valid_crc_stub;
129776ac2e3823 Jeff Hugo 2023-03-27 1534
129776ac2e3823 Jeff Hugo 2023-03-27 1535 return mhi_prepare_for_transfer(qdev->cntl_ch);
129776ac2e3823 Jeff Hugo 2023-03-27 1536 }
129776ac2e3823 Jeff Hugo 2023-03-27 1537
129776ac2e3823 Jeff Hugo 2023-03-27 @1538 void qaic_control_close(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1539 {
129776ac2e3823 Jeff Hugo 2023-03-27 1540 mhi_unprepare_from_transfer(qdev->cntl_ch);
129776ac2e3823 Jeff Hugo 2023-03-27 1541 }
129776ac2e3823 Jeff Hugo 2023-03-27 1542
129776ac2e3823 Jeff Hugo 2023-03-27 @1543 void qaic_release_usr(struct qaic_device *qdev, struct qaic_user *usr)
129776ac2e3823 Jeff Hugo 2023-03-27 1544 {
129776ac2e3823 Jeff Hugo 2023-03-27 1545 struct wire_trans_terminate_to_dev *trans;
129776ac2e3823 Jeff Hugo 2023-03-27 1546 struct wrapper_list *wrappers;
129776ac2e3823 Jeff Hugo 2023-03-27 1547 struct wrapper_msg *wrapper;
129776ac2e3823 Jeff Hugo 2023-03-27 1548 struct wire_msg *msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1549 struct wire_msg *rsp;
129776ac2e3823 Jeff Hugo 2023-03-27 1550
129776ac2e3823 Jeff Hugo 2023-03-27 1551 wrappers = alloc_wrapper_list();
129776ac2e3823 Jeff Hugo 2023-03-27 1552 if (!wrappers)
129776ac2e3823 Jeff Hugo 2023-03-27 1553 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1554
129776ac2e3823 Jeff Hugo 2023-03-27 1555 wrapper = add_wrapper(wrappers, sizeof(*wrapper) + sizeof(*msg) + sizeof(*trans));
129776ac2e3823 Jeff Hugo 2023-03-27 1556 if (!wrapper)
129776ac2e3823 Jeff Hugo 2023-03-27 1557 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1558
129776ac2e3823 Jeff Hugo 2023-03-27 1559 msg = &wrapper->msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1560
129776ac2e3823 Jeff Hugo 2023-03-27 1561 trans = (struct wire_trans_terminate_to_dev *)msg->data;
129776ac2e3823 Jeff Hugo 2023-03-27 1562
129776ac2e3823 Jeff Hugo 2023-03-27 1563 trans->hdr.type = cpu_to_le32(QAIC_TRANS_TERMINATE_TO_DEV);
129776ac2e3823 Jeff Hugo 2023-03-27 1564 trans->hdr.len = cpu_to_le32(sizeof(*trans));
129776ac2e3823 Jeff Hugo 2023-03-27 1565 trans->handle = cpu_to_le32(usr->handle);
129776ac2e3823 Jeff Hugo 2023-03-27 1566
129776ac2e3823 Jeff Hugo 2023-03-27 1567 mutex_lock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 1568 wrapper->len = sizeof(msg->hdr) + sizeof(*trans);
129776ac2e3823 Jeff Hugo 2023-03-27 1569 msg->hdr.magic_number = MANAGE_MAGIC_NUMBER;
129776ac2e3823 Jeff Hugo 2023-03-27 1570 msg->hdr.sequence_number = cpu_to_le32(qdev->next_seq_num++);
129776ac2e3823 Jeff Hugo 2023-03-27 1571 msg->hdr.len = cpu_to_le32(wrapper->len);
129776ac2e3823 Jeff Hugo 2023-03-27 1572 msg->hdr.count = cpu_to_le32(1);
129776ac2e3823 Jeff Hugo 2023-03-27 1573 msg->hdr.handle = cpu_to_le32(usr->handle);
129776ac2e3823 Jeff Hugo 2023-03-27 1574 msg->hdr.padding = cpu_to_le32(0);
129776ac2e3823 Jeff Hugo 2023-03-27 1575 msg->hdr.crc32 = cpu_to_le32(qdev->gen_crc(wrappers));
129776ac2e3823 Jeff Hugo 2023-03-27 1576
129776ac2e3823 Jeff Hugo 2023-03-27 1577 /*
129776ac2e3823 Jeff Hugo 2023-03-27 1578 * msg_xfer releases the mutex
129776ac2e3823 Jeff Hugo 2023-03-27 1579 * We don't care about the return of msg_xfer since we will not do
129776ac2e3823 Jeff Hugo 2023-03-27 1580 * anything different based on what happens.
129776ac2e3823 Jeff Hugo 2023-03-27 1581 * We ignore pending signals since one will be set if the user is
129776ac2e3823 Jeff Hugo 2023-03-27 1582 * killed, and we need give the device a chance to cleanup, otherwise
129776ac2e3823 Jeff Hugo 2023-03-27 1583 * DMA may still be in progress when we return.
129776ac2e3823 Jeff Hugo 2023-03-27 1584 */
129776ac2e3823 Jeff Hugo 2023-03-27 1585 rsp = msg_xfer(qdev, wrappers, qdev->next_seq_num - 1, true);
129776ac2e3823 Jeff Hugo 2023-03-27 1586 if (!IS_ERR(rsp))
129776ac2e3823 Jeff Hugo 2023-03-27 1587 kfree(rsp);
129776ac2e3823 Jeff Hugo 2023-03-27 1588 free_wrapper_from_list(wrappers, wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1589 }
129776ac2e3823 Jeff Hugo 2023-03-27 1590
129776ac2e3823 Jeff Hugo 2023-03-27 @1591 void wake_all_cntl(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1592 {
129776ac2e3823 Jeff Hugo 2023-03-27 1593 struct xfer_queue_elem *elem;
129776ac2e3823 Jeff Hugo 2023-03-27 1594 struct xfer_queue_elem *i;
129776ac2e3823 Jeff Hugo 2023-03-27 1595
129776ac2e3823 Jeff Hugo 2023-03-27 1596 mutex_lock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 1597 list_for_each_entry_safe(elem, i, &qdev->cntl_xfer_list, list) {
129776ac2e3823 Jeff Hugo 2023-03-27 1598 list_del_init(&elem->list);
129776ac2e3823 Jeff Hugo 2023-03-27 1599 complete_all(&elem->xfer_done);
129776ac2e3823 Jeff Hugo 2023-03-27 1600 }
129776ac2e3823 Jeff Hugo 2023-03-27 1601 mutex_unlock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 @1602 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] accel/qaic: Handle DBC deactivation if the owner went away
2025-12-23 15:31 [PATCH] accel/qaic: Handle DBC deactivation if the owner went away Youssef Samir
2025-12-24 5:43 ` kernel test robot
@ 2025-12-24 10:11 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-12-24 10:11 UTC (permalink / raw)
To: Youssef Samir, jeff.hugo, carl.vanderlip, troy.hanson,
zachary.mckevitt
Cc: llvm, oe-kbuild-all, ogabbay, lizhi.hou, karol.wachowski,
linux-arm-msm, dri-devel
Hi Youssef,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.19-rc2 next-20251219]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Youssef-Samir/accel-qaic-Handle-DBC-deactivation-if-the-owner-went-away/20251223-233305
base: https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next
patch link: https://lore.kernel.org/r/20251223153151.2232297-1-youssef.abdulrahman%40oss.qualcomm.com
patch subject: [PATCH] accel/qaic: Handle DBC deactivation if the owner went away
config: i386-randconfig-012-20251224 (https://download.01.org/0day-ci/archive/20251224/202512241701.p3agYhbp-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251224/202512241701.p3agYhbp-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202512241701.p3agYhbp-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/accel/qaic/qaic_control.c:1471:1: error: function definition is not allowed here
1471 | {
| ^
drivers/accel/qaic/qaic_control.c:1484:1: error: function definition is not allowed here
1484 | {
| ^
drivers/accel/qaic/qaic_control.c:1492:1: error: function definition is not allowed here
1492 | {
| ^
drivers/accel/qaic/qaic_control.c:1515:1: error: function definition is not allowed here
1515 | {
| ^
drivers/accel/qaic/qaic_control.c:1539:1: error: function definition is not allowed here
1539 | {
| ^
drivers/accel/qaic/qaic_control.c:1544:1: error: function definition is not allowed here
1544 | {
| ^
drivers/accel/qaic/qaic_control.c:1592:1: error: function definition is not allowed here
1592 | {
| ^
>> drivers/accel/qaic/qaic_control.c:1602:2: error: expected '}'
1602 | }
| ^
drivers/accel/qaic/qaic_control.c:1404:1: note: to match this '{'
1404 | {
| ^
8 errors generated.
vim +1471 drivers/accel/qaic/qaic_control.c
129776ac2e3823 Jeff Hugo 2023-03-27 1469
129776ac2e3823 Jeff Hugo 2023-03-27 1470 static void free_wrapper_from_list(struct wrapper_list *wrappers, struct wrapper_msg *wrapper)
129776ac2e3823 Jeff Hugo 2023-03-27 @1471 {
129776ac2e3823 Jeff Hugo 2023-03-27 1472 bool all_done = false;
129776ac2e3823 Jeff Hugo 2023-03-27 1473
129776ac2e3823 Jeff Hugo 2023-03-27 1474 spin_lock(&wrappers->lock);
129776ac2e3823 Jeff Hugo 2023-03-27 1475 kref_put(&wrapper->ref_count, free_wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1476 all_done = list_empty(&wrappers->list);
129776ac2e3823 Jeff Hugo 2023-03-27 1477 spin_unlock(&wrappers->lock);
129776ac2e3823 Jeff Hugo 2023-03-27 1478
129776ac2e3823 Jeff Hugo 2023-03-27 1479 if (all_done)
129776ac2e3823 Jeff Hugo 2023-03-27 1480 kfree(wrappers);
129776ac2e3823 Jeff Hugo 2023-03-27 1481 }
129776ac2e3823 Jeff Hugo 2023-03-27 1482
129776ac2e3823 Jeff Hugo 2023-03-27 1483 void qaic_mhi_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
129776ac2e3823 Jeff Hugo 2023-03-27 1484 {
129776ac2e3823 Jeff Hugo 2023-03-27 1485 struct wire_msg *msg = mhi_result->buf_addr;
129776ac2e3823 Jeff Hugo 2023-03-27 1486 struct wrapper_msg *wrapper = container_of(msg, struct wrapper_msg, msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1487
129776ac2e3823 Jeff Hugo 2023-03-27 1488 free_wrapper_from_list(wrapper->head, wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1489 }
129776ac2e3823 Jeff Hugo 2023-03-27 1490
129776ac2e3823 Jeff Hugo 2023-03-27 1491 void qaic_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
129776ac2e3823 Jeff Hugo 2023-03-27 1492 {
129776ac2e3823 Jeff Hugo 2023-03-27 1493 struct qaic_device *qdev = dev_get_drvdata(&mhi_dev->dev);
129776ac2e3823 Jeff Hugo 2023-03-27 1494 struct wire_msg *msg = mhi_result->buf_addr;
129776ac2e3823 Jeff Hugo 2023-03-27 1495 struct resp_work *resp;
129776ac2e3823 Jeff Hugo 2023-03-27 1496
129776ac2e3823 Jeff Hugo 2023-03-27 1497 if (mhi_result->transaction_status || msg->hdr.magic_number != MANAGE_MAGIC_NUMBER) {
129776ac2e3823 Jeff Hugo 2023-03-27 1498 kfree(msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1499 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1500 }
129776ac2e3823 Jeff Hugo 2023-03-27 1501
129776ac2e3823 Jeff Hugo 2023-03-27 1502 resp = kmalloc(sizeof(*resp), GFP_ATOMIC);
129776ac2e3823 Jeff Hugo 2023-03-27 1503 if (!resp) {
129776ac2e3823 Jeff Hugo 2023-03-27 1504 kfree(msg);
129776ac2e3823 Jeff Hugo 2023-03-27 1505 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1506 }
129776ac2e3823 Jeff Hugo 2023-03-27 1507
129776ac2e3823 Jeff Hugo 2023-03-27 1508 INIT_WORK(&resp->work, resp_worker);
129776ac2e3823 Jeff Hugo 2023-03-27 1509 resp->qdev = qdev;
129776ac2e3823 Jeff Hugo 2023-03-27 1510 resp->buf = msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1511 queue_work(qdev->cntl_wq, &resp->work);
129776ac2e3823 Jeff Hugo 2023-03-27 1512 }
129776ac2e3823 Jeff Hugo 2023-03-27 1513
129776ac2e3823 Jeff Hugo 2023-03-27 1514 int qaic_control_open(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1515 {
129776ac2e3823 Jeff Hugo 2023-03-27 1516 if (!qdev->cntl_ch)
129776ac2e3823 Jeff Hugo 2023-03-27 1517 return -ENODEV;
129776ac2e3823 Jeff Hugo 2023-03-27 1518
129776ac2e3823 Jeff Hugo 2023-03-27 1519 qdev->cntl_lost_buf = false;
129776ac2e3823 Jeff Hugo 2023-03-27 1520 /*
129776ac2e3823 Jeff Hugo 2023-03-27 1521 * By default qaic should assume that device has CRC enabled.
129776ac2e3823 Jeff Hugo 2023-03-27 1522 * Qaic comes to know if device has CRC enabled or disabled during the
129776ac2e3823 Jeff Hugo 2023-03-27 1523 * device status transaction, which is the first transaction performed
129776ac2e3823 Jeff Hugo 2023-03-27 1524 * on control channel.
129776ac2e3823 Jeff Hugo 2023-03-27 1525 *
129776ac2e3823 Jeff Hugo 2023-03-27 1526 * So CRC validation of first device status transaction response is
129776ac2e3823 Jeff Hugo 2023-03-27 1527 * ignored (by calling valid_crc_stub) and is done later during decoding
129776ac2e3823 Jeff Hugo 2023-03-27 1528 * if device has CRC enabled.
129776ac2e3823 Jeff Hugo 2023-03-27 1529 * Now that qaic knows whether device has CRC enabled or not it acts
129776ac2e3823 Jeff Hugo 2023-03-27 1530 * accordingly.
129776ac2e3823 Jeff Hugo 2023-03-27 1531 */
129776ac2e3823 Jeff Hugo 2023-03-27 1532 qdev->gen_crc = gen_crc;
129776ac2e3823 Jeff Hugo 2023-03-27 1533 qdev->valid_crc = valid_crc_stub;
129776ac2e3823 Jeff Hugo 2023-03-27 1534
129776ac2e3823 Jeff Hugo 2023-03-27 1535 return mhi_prepare_for_transfer(qdev->cntl_ch);
129776ac2e3823 Jeff Hugo 2023-03-27 1536 }
129776ac2e3823 Jeff Hugo 2023-03-27 1537
129776ac2e3823 Jeff Hugo 2023-03-27 1538 void qaic_control_close(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1539 {
129776ac2e3823 Jeff Hugo 2023-03-27 1540 mhi_unprepare_from_transfer(qdev->cntl_ch);
129776ac2e3823 Jeff Hugo 2023-03-27 1541 }
129776ac2e3823 Jeff Hugo 2023-03-27 1542
129776ac2e3823 Jeff Hugo 2023-03-27 1543 void qaic_release_usr(struct qaic_device *qdev, struct qaic_user *usr)
129776ac2e3823 Jeff Hugo 2023-03-27 1544 {
129776ac2e3823 Jeff Hugo 2023-03-27 1545 struct wire_trans_terminate_to_dev *trans;
129776ac2e3823 Jeff Hugo 2023-03-27 1546 struct wrapper_list *wrappers;
129776ac2e3823 Jeff Hugo 2023-03-27 1547 struct wrapper_msg *wrapper;
129776ac2e3823 Jeff Hugo 2023-03-27 1548 struct wire_msg *msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1549 struct wire_msg *rsp;
129776ac2e3823 Jeff Hugo 2023-03-27 1550
129776ac2e3823 Jeff Hugo 2023-03-27 1551 wrappers = alloc_wrapper_list();
129776ac2e3823 Jeff Hugo 2023-03-27 1552 if (!wrappers)
129776ac2e3823 Jeff Hugo 2023-03-27 1553 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1554
129776ac2e3823 Jeff Hugo 2023-03-27 1555 wrapper = add_wrapper(wrappers, sizeof(*wrapper) + sizeof(*msg) + sizeof(*trans));
129776ac2e3823 Jeff Hugo 2023-03-27 1556 if (!wrapper)
129776ac2e3823 Jeff Hugo 2023-03-27 1557 return;
129776ac2e3823 Jeff Hugo 2023-03-27 1558
129776ac2e3823 Jeff Hugo 2023-03-27 1559 msg = &wrapper->msg;
129776ac2e3823 Jeff Hugo 2023-03-27 1560
129776ac2e3823 Jeff Hugo 2023-03-27 1561 trans = (struct wire_trans_terminate_to_dev *)msg->data;
129776ac2e3823 Jeff Hugo 2023-03-27 1562
129776ac2e3823 Jeff Hugo 2023-03-27 1563 trans->hdr.type = cpu_to_le32(QAIC_TRANS_TERMINATE_TO_DEV);
129776ac2e3823 Jeff Hugo 2023-03-27 1564 trans->hdr.len = cpu_to_le32(sizeof(*trans));
129776ac2e3823 Jeff Hugo 2023-03-27 1565 trans->handle = cpu_to_le32(usr->handle);
129776ac2e3823 Jeff Hugo 2023-03-27 1566
129776ac2e3823 Jeff Hugo 2023-03-27 1567 mutex_lock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 1568 wrapper->len = sizeof(msg->hdr) + sizeof(*trans);
129776ac2e3823 Jeff Hugo 2023-03-27 1569 msg->hdr.magic_number = MANAGE_MAGIC_NUMBER;
129776ac2e3823 Jeff Hugo 2023-03-27 1570 msg->hdr.sequence_number = cpu_to_le32(qdev->next_seq_num++);
129776ac2e3823 Jeff Hugo 2023-03-27 1571 msg->hdr.len = cpu_to_le32(wrapper->len);
129776ac2e3823 Jeff Hugo 2023-03-27 1572 msg->hdr.count = cpu_to_le32(1);
129776ac2e3823 Jeff Hugo 2023-03-27 1573 msg->hdr.handle = cpu_to_le32(usr->handle);
129776ac2e3823 Jeff Hugo 2023-03-27 1574 msg->hdr.padding = cpu_to_le32(0);
129776ac2e3823 Jeff Hugo 2023-03-27 1575 msg->hdr.crc32 = cpu_to_le32(qdev->gen_crc(wrappers));
129776ac2e3823 Jeff Hugo 2023-03-27 1576
129776ac2e3823 Jeff Hugo 2023-03-27 1577 /*
129776ac2e3823 Jeff Hugo 2023-03-27 1578 * msg_xfer releases the mutex
129776ac2e3823 Jeff Hugo 2023-03-27 1579 * We don't care about the return of msg_xfer since we will not do
129776ac2e3823 Jeff Hugo 2023-03-27 1580 * anything different based on what happens.
129776ac2e3823 Jeff Hugo 2023-03-27 1581 * We ignore pending signals since one will be set if the user is
129776ac2e3823 Jeff Hugo 2023-03-27 1582 * killed, and we need give the device a chance to cleanup, otherwise
129776ac2e3823 Jeff Hugo 2023-03-27 1583 * DMA may still be in progress when we return.
129776ac2e3823 Jeff Hugo 2023-03-27 1584 */
129776ac2e3823 Jeff Hugo 2023-03-27 1585 rsp = msg_xfer(qdev, wrappers, qdev->next_seq_num - 1, true);
129776ac2e3823 Jeff Hugo 2023-03-27 1586 if (!IS_ERR(rsp))
129776ac2e3823 Jeff Hugo 2023-03-27 1587 kfree(rsp);
129776ac2e3823 Jeff Hugo 2023-03-27 1588 free_wrapper_from_list(wrappers, wrapper);
129776ac2e3823 Jeff Hugo 2023-03-27 1589 }
129776ac2e3823 Jeff Hugo 2023-03-27 1590
129776ac2e3823 Jeff Hugo 2023-03-27 1591 void wake_all_cntl(struct qaic_device *qdev)
129776ac2e3823 Jeff Hugo 2023-03-27 1592 {
129776ac2e3823 Jeff Hugo 2023-03-27 1593 struct xfer_queue_elem *elem;
129776ac2e3823 Jeff Hugo 2023-03-27 1594 struct xfer_queue_elem *i;
129776ac2e3823 Jeff Hugo 2023-03-27 1595
129776ac2e3823 Jeff Hugo 2023-03-27 1596 mutex_lock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 1597 list_for_each_entry_safe(elem, i, &qdev->cntl_xfer_list, list) {
129776ac2e3823 Jeff Hugo 2023-03-27 1598 list_del_init(&elem->list);
129776ac2e3823 Jeff Hugo 2023-03-27 1599 complete_all(&elem->xfer_done);
129776ac2e3823 Jeff Hugo 2023-03-27 1600 }
129776ac2e3823 Jeff Hugo 2023-03-27 1601 mutex_unlock(&qdev->cntl_mutex);
129776ac2e3823 Jeff Hugo 2023-03-27 @1602 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-24 10:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-23 15:31 [PATCH] accel/qaic: Handle DBC deactivation if the owner went away Youssef Samir
2025-12-24 5:43 ` kernel test robot
2025-12-24 10:11 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox