Skip to content

Commit 6d0ef32

Browse files
Umang Jaingregkh
authored andcommitted
staging: vc04_services: Move global memory mapped pointer
g_regs stores the remapped memory pointer for the vchiq platform. It can be moved to struct vchiq_drv_mgmt instead of being global. Adjust the affected functions accordingly. Pass vchiq_state pointer wherever necessary to access struct vchiq_drv_mgmt. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Link: https://lore.kernel.org/r/20240412075743.60712-8-umang.jain@ideasonboard.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 39fbff9 commit 6d0ef32

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ struct vchiq_pagelist_info {
129129
unsigned int scatterlist_mapped;
130130
};
131131

132-
static void __iomem *g_regs;
133-
134132
static int
135133
vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *data,
136134
unsigned int size, enum vchiq_bulk_dir dir);
@@ -139,11 +137,14 @@ static irqreturn_t
139137
vchiq_doorbell_irq(int irq, void *dev_id)
140138
{
141139
struct vchiq_state *state = dev_id;
140+
struct vchiq_drv_mgmt *mgmt;
142141
irqreturn_t ret = IRQ_NONE;
143142
unsigned int status;
144143

144+
mgmt = dev_get_drvdata(state->dev);
145+
145146
/* Read (and clear) the doorbell */
146-
status = readl(g_regs + BELL0);
147+
status = readl(mgmt->regs + BELL0);
147148

148149
if (status & ARM_DS_ACTIVE) { /* Was the doorbell rung? */
149150
remote_event_pollall(state);
@@ -556,9 +557,9 @@ static int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state
556557
if (err)
557558
return err;
558559

559-
g_regs = devm_platform_ioremap_resource(pdev, 0);
560-
if (IS_ERR(g_regs))
561-
return PTR_ERR(g_regs);
560+
drv_mgmt->regs = devm_platform_ioremap_resource(pdev, 0);
561+
if (IS_ERR(drv_mgmt->regs))
562+
return PTR_ERR(drv_mgmt->regs);
562563

563564
irq = platform_get_irq(pdev, 0);
564565
if (irq <= 0)
@@ -641,8 +642,10 @@ static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *
641642
}
642643

643644
void
644-
remote_event_signal(struct remote_event *event)
645+
remote_event_signal(struct vchiq_state *state, struct remote_event *event)
645646
{
647+
struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(state->dev);
648+
646649
/*
647650
* Ensure that all writes to shared data structures have completed
648651
* before signalling the peer.
@@ -654,7 +657,7 @@ remote_event_signal(struct remote_event *event)
654657
dsb(sy); /* data barrier operation */
655658

656659
if (event->armed)
657-
writel(0, g_regs + BELL2); /* trigger vc interrupt */
660+
writel(0, mgmt->regs + BELL2); /* trigger vc interrupt */
658661
}
659662

660663
int

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ struct vchiq_drv_mgmt {
5050
char *fragments_base;
5151
char *free_fragments;
5252
unsigned int fragments_size;
53+
54+
void __iomem *regs;
5355
};
5456

5557
struct user_service {

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking)
691691
/* But first, flush through the last slot. */
692692
state->local_tx_pos = tx_pos;
693693
local->tx_pos = tx_pos;
694-
remote_event_signal(&state->remote->trigger);
694+
remote_event_signal(state, &state->remote->trigger);
695695

696696
if (!is_blocking ||
697697
(wait_for_completion_interruptible(&state->slot_available_event)))
@@ -1124,7 +1124,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service,
11241124
if (!(flags & QMFLAGS_NO_MUTEX_UNLOCK))
11251125
mutex_unlock(&state->slot_mutex);
11261126

1127-
remote_event_signal(&state->remote->trigger);
1127+
remote_event_signal(state, &state->remote->trigger);
11281128

11291129
return 0;
11301130
}
@@ -1202,7 +1202,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
12021202
&svc_fourcc, VCHIQ_MSG_SRCPORT(msgid),
12031203
VCHIQ_MSG_DSTPORT(msgid), size);
12041204

1205-
remote_event_signal(&state->remote->sync_trigger);
1205+
remote_event_signal(state, &state->remote->sync_trigger);
12061206

12071207
if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_PAUSE)
12081208
mutex_unlock(&state->sync_mutex);
@@ -1260,7 +1260,7 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info,
12601260
* A write barrier is necessary, but remote_event_signal
12611261
* contains one.
12621262
*/
1263-
remote_event_signal(&state->remote->recycle);
1263+
remote_event_signal(state, &state->remote->recycle);
12641264
}
12651265

12661266
mutex_unlock(&state->recycle_mutex);
@@ -3240,7 +3240,7 @@ static void
32403240
release_message_sync(struct vchiq_state *state, struct vchiq_header *header)
32413241
{
32423242
header->msgid = VCHIQ_MSGID_PADDING;
3243-
remote_event_signal(&state->remote->sync_release);
3243+
remote_event_signal(state, &state->remote->sync_release);
32443244
}
32453245

32463246
int

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ int vchiq_prepare_bulk_data(struct vchiq_instance *instance, struct vchiq_bulk *
516516

517517
void vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bulk);
518518

519-
void remote_event_signal(struct remote_event *event);
519+
void remote_event_signal(struct vchiq_state *state, struct remote_event *event);
520520

521521
void vchiq_dump_platform_state(struct seq_file *f);
522522

0 commit comments

Comments
 (0)