aboutsummaryrefslogtreecommitdiff
path: root/kernel/rpmsg/ethosu_rpmsg_inference.c
diff options
context:
space:
mode:
authorMikael Olsson <mikael.olsson@arm.com>2024-02-12 09:56:56 +0100
committerMikael Olsson <mikael.olsson@arm.com>2024-02-12 13:28:26 +0100
commit16be28550f0906e2bfff20b94dd373f59b4a2ccf (patch)
tree72ac8fa23cccacc5db2f4e08e31659eaed60ad51 /kernel/rpmsg/ethosu_rpmsg_inference.c
parentd4ad9e55cb8e17a4a42b3a94c64e6bc48529b26e (diff)
downloadethos-u-linux-driver-stack-16be28550f0906e2bfff20b94dd373f59b4a2ccf.tar.gz
Rename macros and types to namespace their usage
Macros and types have been renamed accordingly to namespace them by their usage in the new kernel driver source tree structure. This is done in a separate commit from the restructuring to avoid Git from seeing some of the moved files as new ones because they have been both moved and modified at the same time and thus losing the connection in the history. Change-Id: Icd4d8e8c76779479b5b46a55bf1d4f78a629c281 Signed-off-by: Mikael Olsson <mikael.olsson@arm.com>
Diffstat (limited to 'kernel/rpmsg/ethosu_rpmsg_inference.c')
-rw-r--r--kernel/rpmsg/ethosu_rpmsg_inference.c152
1 files changed, 77 insertions, 75 deletions
diff --git a/kernel/rpmsg/ethosu_rpmsg_inference.c b/kernel/rpmsg/ethosu_rpmsg_inference.c
index b721fb7..b6288ef 100644
--- a/kernel/rpmsg/ethosu_rpmsg_inference.c
+++ b/kernel/rpmsg/ethosu_rpmsg_inference.c
@@ -38,22 +38,22 @@
* Variables
****************************************************************************/
-static int ethosu_inference_release(struct inode *inode,
- struct file *file);
+static int ethosu_rpmsg_inference_release(struct inode *inode,
+ struct file *file);
-static __poll_t ethosu_inference_poll(struct file *file,
- poll_table *wait);
+static __poll_t ethosu_rpmsg_inference_poll(struct file *file,
+ poll_table *wait);
-static long ethosu_inference_ioctl(struct file *file,
- unsigned int cmd,
- unsigned long arg);
+static long ethosu_rpmsg_inference_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long arg);
-static const struct file_operations ethosu_inference_fops = {
- .release = &ethosu_inference_release,
- .poll = &ethosu_inference_poll,
- .unlocked_ioctl = &ethosu_inference_ioctl,
+static const struct file_operations ethosu_rpmsg_inference_fops = {
+ .release = &ethosu_rpmsg_inference_release,
+ .poll = &ethosu_rpmsg_inference_poll,
+ .unlocked_ioctl = &ethosu_rpmsg_inference_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = &ethosu_inference_ioctl,
+ .compat_ioctl = &ethosu_rpmsg_inference_ioctl,
#endif
};
@@ -88,19 +88,19 @@ static const char *status_to_string(const enum ethosu_uapi_status status)
}
}
-static int ethosu_inference_send(struct ethosu_inference *inf)
+static int ethosu_rpmsg_inference_send(struct ethosu_rpmsg_inference *inf)
{
struct device *dev = inf->dev;
int ret;
inf->status = ETHOSU_UAPI_STATUS_ERROR;
- ret = ethosu_mailbox_inference(inf->mailbox, &inf->msg,
- inf->ifm_count, inf->ifm,
- inf->ofm_count, inf->ofm,
- inf->net, inf->pmu_event_config,
- ETHOSU_PMU_EVENT_MAX,
- inf->pmu_cycle_counter_enable);
+ ret = ethosu_rpmsg_mailbox_inference(inf->mailbox, &inf->msg,
+ inf->ifm_count, inf->ifm,
+ inf->ofm_count, inf->ofm,
+ inf->net, inf->pmu_event_config,
+ ETHOSU_PMU_EVENT_MAX,
+ inf->pmu_cycle_counter_enable);
if (ret) {
dev_warn(dev,
"Failed to send inference request. inf=0x%pK, ret=%d",
@@ -111,14 +111,14 @@ static int ethosu_inference_send(struct ethosu_inference *inf)
inf->status = ETHOSU_UAPI_STATUS_RUNNING;
- ethosu_inference_get(inf);
+ ethosu_rpmsg_inference_get(inf);
return 0;
}
-static void ethosu_inference_fail(struct ethosu_mailbox_msg *msg)
+static void ethosu_rpmsg_inference_fail(struct ethosu_rpmsg_mailbox_msg *msg)
{
- struct ethosu_inference *inf =
+ struct ethosu_rpmsg_inference *inf =
container_of(msg, typeof(*inf), msg);
int ret;
@@ -126,7 +126,7 @@ static void ethosu_inference_fail(struct ethosu_mailbox_msg *msg)
return;
/* Decrement reference count if inference was pending reponse */
- ret = ethosu_inference_put(inf);
+ ret = ethosu_rpmsg_inference_put(inf);
if (ret)
return;
@@ -139,22 +139,22 @@ static void ethosu_inference_fail(struct ethosu_mailbox_msg *msg)
wake_up_interruptible(&inf->waitq);
}
-static bool ethosu_inference_verify(struct file *file)
+static bool ethosu_rpmsg_inference_verify(struct file *file)
{
- return file->f_op == &ethosu_inference_fops;
+ return file->f_op == &ethosu_rpmsg_inference_fops;
}
-static void ethosu_inference_kref_destroy(struct kref *kref)
+static void ethosu_rpmsg_inference_kref_destroy(struct kref *kref)
{
- struct ethosu_inference *inf =
- container_of(kref, struct ethosu_inference, kref);
+ struct ethosu_rpmsg_inference *inf =
+ container_of(kref, struct ethosu_rpmsg_inference, kref);
struct device *dev = inf->dev;
dev_dbg(dev,
"Inference destroy. inf=0x%pK, status=%d, ifm_count=%u, ofm_count=%u",
inf, inf->status, inf->ifm_count, inf->ofm_count);
- ethosu_mailbox_deregister(inf->mailbox, &inf->msg);
+ ethosu_rpmsg_mailbox_deregister(inf->mailbox, &inf->msg);
while (inf->ifm_count-- > 0)
ethosu_buffer_put(inf->ifm[inf->ifm_count]);
@@ -162,15 +162,15 @@ static void ethosu_inference_kref_destroy(struct kref *kref)
while (inf->ofm_count-- > 0)
ethosu_buffer_put(inf->ofm[inf->ofm_count]);
- ethosu_network_put(inf->net);
+ ethosu_rpmsg_network_put(inf->net);
memset(inf, 0, sizeof(*inf));
devm_kfree(dev, inf);
}
-static int ethosu_inference_release(struct inode *inode,
- struct file *file)
+static int ethosu_rpmsg_inference_release(struct inode *inode,
+ struct file *file)
{
- struct ethosu_inference *inf = file->private_data;
+ struct ethosu_rpmsg_inference *inf = file->private_data;
struct device *dev = inf->dev;
dev_dbg(dev,
@@ -178,16 +178,16 @@ static int ethosu_inference_release(struct inode *inode,
file, inf);
device_lock(dev);
- ethosu_inference_put(inf);
+ ethosu_rpmsg_inference_put(inf);
device_unlock(dev);
return 0;
}
-static __poll_t ethosu_inference_poll(struct file *file,
- poll_table *wait)
+static __poll_t ethosu_rpmsg_inference_poll(struct file *file,
+ poll_table *wait)
{
- struct ethosu_inference *inf = file->private_data;
+ struct ethosu_rpmsg_inference *inf = file->private_data;
__poll_t ret = 0;
poll_wait(file, &inf->waitq, wait);
@@ -198,11 +198,11 @@ static __poll_t ethosu_inference_poll(struct file *file,
return ret;
}
-static long ethosu_inference_ioctl(struct file *file,
- unsigned int cmd,
- unsigned long arg)
+static long ethosu_rpmsg_inference_ioctl(struct file *file,
+ unsigned int cmd,
+ unsigned long arg)
{
- struct ethosu_inference *inf = file->private_data;
+ struct ethosu_rpmsg_inference *inf = file->private_data;
struct device *dev = inf->dev;
void __user *udata = (void __user *)arg;
int ret;
@@ -243,8 +243,9 @@ static long ethosu_inference_ioctl(struct file *file,
"Inference ioctl: Cancel Inference. Handle=%p\n",
inf);
- ret = ethosu_cancel_inference_request(dev, inf->mailbox, inf,
- &uapi);
+ ret = ethosu_rpmsg_cancel_inference_request(dev, inf->mailbox,
+ inf,
+ &uapi);
if (ret)
break;
@@ -265,12 +266,12 @@ static long ethosu_inference_ioctl(struct file *file,
return ret;
}
-int ethosu_inference_create(struct device *dev,
- struct ethosu_mailbox *mailbox,
- struct ethosu_network *net,
- struct ethosu_uapi_inference_create *uapi)
+int ethosu_rpmsg_inference_create(struct device *dev,
+ struct ethosu_rpmsg_mailbox *mailbox,
+ struct ethosu_rpmsg_network *net,
+ struct ethosu_uapi_inference_create *uapi)
{
- struct ethosu_inference *inf;
+ struct ethosu_rpmsg_inference *inf;
uint32_t i;
int fd;
int ret = -ENOMEM;
@@ -295,10 +296,10 @@ int ethosu_inference_create(struct device *dev,
inf->status = ETHOSU_UAPI_STATUS_ERROR;
kref_init(&inf->kref);
init_waitqueue_head(&inf->waitq);
- inf->msg.fail = ethosu_inference_fail;
+ inf->msg.fail = ethosu_rpmsg_inference_fail;
/* Add inference to pending list */
- ret = ethosu_mailbox_register(mailbox, &inf->msg);
+ ret = ethosu_rpmsg_mailbox_register(mailbox, &inf->msg);
if (ret < 0)
goto kfree;
@@ -341,15 +342,16 @@ int ethosu_inference_create(struct device *dev,
inf->pmu_cycle_counter_count = 0;
/* Increment network reference count */
- ethosu_network_get(net);
+ ethosu_rpmsg_network_get(net);
/* Send inference request to Arm Ethos-U subsystem */
- ret = ethosu_inference_send(inf);
+ ret = ethosu_rpmsg_inference_send(inf);
if (ret)
goto put_net;
/* Create file descriptor */
- ret = fd = anon_inode_getfd("ethosu-inference", &ethosu_inference_fops,
+ ret = fd = anon_inode_getfd("ethosu-inference",
+ &ethosu_rpmsg_inference_fops,
inf, O_RDWR | O_CLOEXEC);
if (ret < 0)
goto put_net;
@@ -365,7 +367,7 @@ int ethosu_inference_create(struct device *dev,
return fd;
put_net:
- ethosu_network_put(inf->net);
+ ethosu_rpmsg_network_put(inf->net);
put_ofm:
while (inf->ofm_count-- > 0)
@@ -375,7 +377,7 @@ put_ifm:
while (inf->ifm_count-- > 0)
ethosu_buffer_put(inf->ifm[inf->ifm_count]);
- ethosu_mailbox_deregister(mailbox, &inf->msg);
+ ethosu_rpmsg_mailbox_deregister(mailbox, &inf->msg);
kfree:
memset(inf, 0, sizeof(*inf));
@@ -384,49 +386,49 @@ kfree:
return ret;
}
-struct ethosu_inference *ethosu_inference_get_from_fd(int fd)
+struct ethosu_rpmsg_inference *ethosu_rpmsg_inference_get_from_fd(int fd)
{
- struct ethosu_inference *inf;
+ struct ethosu_rpmsg_inference *inf;
struct file *file;
file = fget(fd);
if (!file)
return ERR_PTR(-EINVAL);
- if (!ethosu_inference_verify(file)) {
+ if (!ethosu_rpmsg_inference_verify(file)) {
fput(file);
return ERR_PTR(-EINVAL);
}
inf = file->private_data;
- ethosu_inference_get(inf);
+ ethosu_rpmsg_inference_get(inf);
fput(file);
return inf;
}
-void ethosu_inference_get(struct ethosu_inference *inf)
+void ethosu_rpmsg_inference_get(struct ethosu_rpmsg_inference *inf)
{
kref_get(&inf->kref);
}
-int ethosu_inference_put(struct ethosu_inference *inf)
+int ethosu_rpmsg_inference_put(struct ethosu_rpmsg_inference *inf)
{
- return kref_put(&inf->kref, &ethosu_inference_kref_destroy);
+ return kref_put(&inf->kref, &ethosu_rpmsg_inference_kref_destroy);
}
-void ethosu_inference_rsp(struct ethosu_mailbox *mailbox,
- int msg_id,
- struct ethosu_core_msg_inference_rsp *rsp)
+void ethosu_rpmsg_inference_rsp(struct ethosu_rpmsg_mailbox *mailbox,
+ int msg_id,
+ struct ethosu_rpmsg_inference_rsp *rsp)
{
struct device *dev = mailbox->dev;
- struct ethosu_mailbox_msg *msg;
- struct ethosu_inference *inf;
+ struct ethosu_rpmsg_mailbox_msg *msg;
+ struct ethosu_rpmsg_inference *inf;
int i;
- msg = ethosu_mailbox_find(mailbox, msg_id,
- ETHOSU_CORE_MSG_INFERENCE_REQ);
+ msg = ethosu_rpmsg_mailbox_find(mailbox, msg_id,
+ ETHOSU_RPMSG_INFERENCE_REQ);
if (IS_ERR(msg)) {
dev_warn(dev,
"Id for inference msg not found. Id=0x%x: %ld\n",
@@ -447,18 +449,18 @@ void ethosu_inference_rsp(struct ethosu_mailbox *mailbox,
goto done;
}
- if (rsp->status == ETHOSU_CORE_STATUS_OK &&
- inf->ofm_count <= ETHOSU_CORE_BUFFER_MAX)
+ if (rsp->status == ETHOSU_RPMSG_STATUS_OK &&
+ inf->ofm_count <= ETHOSU_RPMSG_BUFFER_MAX)
inf->status = ETHOSU_UAPI_STATUS_OK;
- else if (rsp->status == ETHOSU_CORE_STATUS_REJECTED)
+ else if (rsp->status == ETHOSU_RPMSG_STATUS_REJECTED)
inf->status = ETHOSU_UAPI_STATUS_REJECTED;
- else if (rsp->status == ETHOSU_CORE_STATUS_ABORTED)
+ else if (rsp->status == ETHOSU_RPMSG_STATUS_ABORTED)
inf->status = ETHOSU_UAPI_STATUS_ABORTED;
else
inf->status = ETHOSU_UAPI_STATUS_ERROR;
if (inf->status == ETHOSU_UAPI_STATUS_OK) {
- for (i = 0; i < ETHOSU_CORE_PMU_MAX; i++) {
+ for (i = 0; i < ETHOSU_RPMSG_PMU_MAX; i++) {
inf->pmu_event_config[i] = rsp->pmu_event_config[i];
inf->pmu_event_count[i] = rsp->pmu_event_count[i];
}
@@ -482,5 +484,5 @@ void ethosu_inference_rsp(struct ethosu_mailbox *mailbox,
done:
inf->done = true;
wake_up_interruptible(&inf->waitq);
- ethosu_inference_put(inf);
+ ethosu_rpmsg_inference_put(inf);
}