Skip to content

Commit 755a13e

Browse files
committed
ipc: remove driver copy
Drivers are now accessible to userspace LL, remove now superfluous copies. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent d255b15 commit 755a13e

2 files changed

Lines changed: 9 additions & 42 deletions

File tree

src/ipc/ipc-common.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -519,43 +519,30 @@ static void ipc_user_thread_fn(void *p1, void *p2, void *p3)
519519
* with kernel privileges.
520520
*
521521
* init_drv = original kernel pointer
522-
* init_drv_data = user-accessible copy
523522
*/
524-
const struct comp_driver *orig_drv =
525-
ipc_user->init_drv;
526-
const struct comp_driver *drv_copy =
527-
(const struct comp_driver *)
528-
ipc_user->init_drv_data;
523+
const struct comp_driver *drv = ipc_user->init_drv;
529524

530525
ipc_user->init_drv = NULL;
531-
if (!orig_drv) {
526+
if (!drv) {
532527
ipc_user->result =
533528
IPC4_MOD_NOT_INITIALIZED;
534529
break;
535530
}
536531

537-
struct comp_dev *dev =
538-
comp_new_ipc4_user(&msg, drv_copy);
532+
struct comp_dev *dev = comp_new_ipc4_user(&msg, drv);
539533

540534
if (!dev) {
541535
ipc_user->result =
542536
IPC4_MOD_NOT_INITIALIZED;
543537
break;
544538
}
545539

546-
/* Restore original kernel driver pointer.
547-
* comp_init() set dev->drv to the copy;
548-
* runtime code expects the canonical
549-
* kernel address.
550-
*/
551-
dev->drv = orig_drv;
552-
553-
ipc_user->result =
554-
ipc4_add_comp_dev(dev);
540+
ipc_user->result = ipc4_add_comp_dev(dev);
555541
if (ipc_user->result != IPC4_SUCCESS)
556542
break;
557543

558544
comp_update_ibs_obs_cpc(dev);
545+
559546
ipc_user->result = 0;
560547
break;
561548
}

src/ipc/ipc4/handler-user.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,43 +1517,23 @@ __cold int ipc4_user_process_module_message(struct ipc4_message_request *ipc4,
15171517
*/
15181518
struct ipc4_module_init_instance mi;
15191519

1520-
BUILD_ASSERT(sizeof(struct comp_driver) + sizeof(struct tr_ctx) <=
1521-
sizeof(((struct ipc_user *)0)->init_drv_data),
1522-
"ipc_user.init_drv_data too small for driver copy");
1523-
15241520
memcpy_s(&mi, sizeof(mi), ipc4, sizeof(*ipc4));
15251521
if (!cpu_is_me(mi.extension.r.core_id)) {
15261522
ret = ipc4_init_module_instance(ipc4);
15271523
} else {
15281524
struct ipc *ipc = ipc_get();
15291525
uint32_t comp_id = IPC4_COMP_ID(mi.primary.r.module_id,
15301526
mi.primary.r.instance_id);
1531-
const struct comp_driver *drv = ipc4_get_comp_drv(
1532-
IPC4_MOD_ID(comp_id));
1527+
const struct comp_driver *drv = ipc4_get_comp_drv(IPC4_MOD_ID(comp_id));
15331528

15341529
if (!drv) {
15351530
ret = IPC4_MOD_NOT_INITIALIZED;
15361531
} else {
15371532
struct ipc_user *pdata = ipc->ipc_user_pdata;
15381533

1539-
/* Copy comp_driver and tr_ctx into
1540-
* user-accessible ipc_user buffer —
1541-
* originals are in kernel .rodata/.data
1542-
* and not readable from user mode.
1543-
*/
1544-
struct comp_driver *drv_copy =
1545-
(struct comp_driver *)pdata->init_drv_data;
1546-
struct tr_ctx *tctx_copy =
1547-
(struct tr_ctx *)(pdata->init_drv_data +
1548-
sizeof(struct comp_driver));
1549-
1550-
memcpy_s(drv_copy, sizeof(*drv_copy),
1551-
drv, sizeof(*drv));
1552-
if (drv->tctx) {
1553-
memcpy_s(tctx_copy, sizeof(*tctx_copy),
1554-
drv->tctx, sizeof(*drv->tctx));
1555-
drv_copy->tctx = tctx_copy;
1556-
}
1534+
ret = llext_manager_map_lib(comp_id);
1535+
if (ret < 0)
1536+
break;
15571537

15581538
pdata->init_drv = drv;
15591539
ret = ipc_user_forward_cmd(ipc4);

0 commit comments

Comments
 (0)