mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-15 06:27:21 +00:00
[ Upstream commit960ebe97e5] The subroutine __rxe_do_task is not thread safe and it has no way to guarantee that the tasks, which are designed with the assumption that they are non-reentrant, are not reentered. All of its uses are non-performance critical. This patch replaces calls to __rxe_do_task with calls to rxe_sched_task. It also removes irrelevant or unneeded if tests. Instead of calling the task machinery a single call to the tasklet function (rxe_requester, etc.) is sufficient to draing the queues if task execution has been disabled or stopped. Together these changes allow the removal of __rxe_do_task. Link: https://lore.kernel.org/r/20230304174533.11296-7-rpearsonhpe@gmail.com Signed-off-by: Ian Ziemba <ian.ziemba@hpe.com> Signed-off-by: Bob Pearson <rpearsonhpe@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Stable-dep-of:b2b1ddc457("RDMA/rxe: Fix the error "trying to register non-static key in rxe_cleanup_task"") Signed-off-by: Sasha Levin <sashal@kernel.org>
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
|
|
/*
|
|
* Copyright (c) 2016 Mellanox Technologies Ltd. All rights reserved.
|
|
* Copyright (c) 2015 System Fabric Works, Inc. All rights reserved.
|
|
*/
|
|
|
|
#ifndef RXE_TASK_H
|
|
#define RXE_TASK_H
|
|
|
|
enum {
|
|
TASK_STATE_START = 0,
|
|
TASK_STATE_BUSY = 1,
|
|
TASK_STATE_ARMED = 2,
|
|
};
|
|
|
|
/*
|
|
* data structure to describe a 'task' which is a short
|
|
* function that returns 0 as long as it needs to be
|
|
* called again.
|
|
*/
|
|
struct rxe_task {
|
|
struct tasklet_struct tasklet;
|
|
int state;
|
|
spinlock_t lock;
|
|
struct rxe_qp *qp;
|
|
int (*func)(struct rxe_qp *qp);
|
|
int ret;
|
|
bool destroyed;
|
|
};
|
|
|
|
/*
|
|
* init rxe_task structure
|
|
* qp => parameter to pass to func
|
|
* func => function to call until it returns != 0
|
|
*/
|
|
int rxe_init_task(struct rxe_task *task, struct rxe_qp *qp,
|
|
int (*func)(struct rxe_qp *));
|
|
|
|
/* cleanup task */
|
|
void rxe_cleanup_task(struct rxe_task *task);
|
|
|
|
void rxe_run_task(struct rxe_task *task);
|
|
|
|
void rxe_sched_task(struct rxe_task *task);
|
|
|
|
/* keep a task from scheduling */
|
|
void rxe_disable_task(struct rxe_task *task);
|
|
|
|
/* allow task to run */
|
|
void rxe_enable_task(struct rxe_task *task);
|
|
|
|
#endif /* RXE_TASK_H */
|