Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Umang Jain and committed by
Greg Kroah-Hartman
6d0ef321 39fbff9d

+19 -14
+11 -8
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
··· 129 129 unsigned int scatterlist_mapped; 130 130 }; 131 131 132 - static void __iomem *g_regs; 133 - 134 132 static int 135 133 vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handle, void *data, 136 134 unsigned int size, enum vchiq_bulk_dir dir); ··· 137 139 vchiq_doorbell_irq(int irq, void *dev_id) 138 140 { 139 141 struct vchiq_state *state = dev_id; 142 + struct vchiq_drv_mgmt *mgmt; 140 143 irqreturn_t ret = IRQ_NONE; 141 144 unsigned int status; 142 145 146 + mgmt = dev_get_drvdata(state->dev); 147 + 143 148 /* Read (and clear) the doorbell */ 144 - status = readl(g_regs + BELL0); 149 + status = readl(mgmt->regs + BELL0); 145 150 146 151 if (status & ARM_DS_ACTIVE) { /* Was the doorbell rung? */ 147 152 remote_event_pollall(state); ··· 557 556 if (err) 558 557 return err; 559 558 560 - g_regs = devm_platform_ioremap_resource(pdev, 0); 561 - if (IS_ERR(g_regs)) 562 - return PTR_ERR(g_regs); 559 + drv_mgmt->regs = devm_platform_ioremap_resource(pdev, 0); 560 + if (IS_ERR(drv_mgmt->regs)) 561 + return PTR_ERR(drv_mgmt->regs); 563 562 564 563 irq = platform_get_irq(pdev, 0); 565 564 if (irq <= 0) ··· 642 641 } 643 642 644 643 void 645 - remote_event_signal(struct remote_event *event) 644 + remote_event_signal(struct vchiq_state *state, struct remote_event *event) 646 645 { 646 + struct vchiq_drv_mgmt *mgmt = dev_get_drvdata(state->dev); 647 + 647 648 /* 648 649 * Ensure that all writes to shared data structures have completed 649 650 * before signalling the peer. ··· 657 654 dsb(sy); /* data barrier operation */ 658 655 659 656 if (event->armed) 660 - writel(0, g_regs + BELL2); /* trigger vc interrupt */ 657 + writel(0, mgmt->regs + BELL2); /* trigger vc interrupt */ 661 658 } 662 659 663 660 int
+2
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
··· 50 50 char *fragments_base; 51 51 char *free_fragments; 52 52 unsigned int fragments_size; 53 + 54 + void __iomem *regs; 53 55 }; 54 56 55 57 struct user_service {
+5 -5
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
··· 691 691 /* But first, flush through the last slot. */ 692 692 state->local_tx_pos = tx_pos; 693 693 local->tx_pos = tx_pos; 694 - remote_event_signal(&state->remote->trigger); 694 + remote_event_signal(state, &state->remote->trigger); 695 695 696 696 if (!is_blocking || 697 697 (wait_for_completion_interruptible(&state->slot_available_event))) ··· 1124 1124 if (!(flags & QMFLAGS_NO_MUTEX_UNLOCK)) 1125 1125 mutex_unlock(&state->slot_mutex); 1126 1126 1127 - remote_event_signal(&state->remote->trigger); 1127 + remote_event_signal(state, &state->remote->trigger); 1128 1128 1129 1129 return 0; 1130 1130 } ··· 1202 1202 &svc_fourcc, VCHIQ_MSG_SRCPORT(msgid), 1203 1203 VCHIQ_MSG_DSTPORT(msgid), size); 1204 1204 1205 - remote_event_signal(&state->remote->sync_trigger); 1205 + remote_event_signal(state, &state->remote->sync_trigger); 1206 1206 1207 1207 if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_PAUSE) 1208 1208 mutex_unlock(&state->sync_mutex); ··· 1260 1260 * A write barrier is necessary, but remote_event_signal 1261 1261 * contains one. 1262 1262 */ 1263 - remote_event_signal(&state->remote->recycle); 1263 + remote_event_signal(state, &state->remote->recycle); 1264 1264 } 1265 1265 1266 1266 mutex_unlock(&state->recycle_mutex); ··· 3240 3240 release_message_sync(struct vchiq_state *state, struct vchiq_header *header) 3241 3241 { 3242 3242 header->msgid = VCHIQ_MSGID_PADDING; 3243 - remote_event_signal(&state->remote->sync_release); 3243 + remote_event_signal(state, &state->remote->sync_release); 3244 3244 } 3245 3245 3246 3246 int
+1 -1
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h
··· 516 516 517 517 void vchiq_complete_bulk(struct vchiq_instance *instance, struct vchiq_bulk *bulk); 518 518 519 - void remote_event_signal(struct remote_event *event); 519 + void remote_event_signal(struct vchiq_state *state, struct remote_event *event); 520 520 521 521 void vchiq_dump_platform_state(struct seq_file *f); 522 522