Skip to content

Commit 9f3bbbb

Browse files
sudeep-hollaJassi Brar
authored andcommitted
mailbox: pcc: Initialize SHMEM before binding the channel with the client
The PCC channel's shared memory region must be set up before the mailbox controller binds the channel with the client, as the binding process may trigger client operations like startup() that may rely on SHMEM being initialized. Reorder the setup sequence to ensure the shared memory is ready before binding. Initialize and map the PCC shared memory (SHMEM) prior to calling mbox_bind_client() so that clients never observe an uninitialized or NULL SHMEM during bind-time callbacks or early use in startup(). This makes the PCC mailbox channel bring-up order consistent and eliminates a race between SHMEM setup and client binding. This will be needed in channel startup to clear/acknowledge any pending interrupts before enabling them. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: lihuisong@huawei.com Tested-by: Adam Young <admiyo@os.amperecomputing.com> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
1 parent 9c753f7 commit 9f3bbbb

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

drivers/mailbox/pcc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,20 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
377377
return ERR_PTR(-EBUSY);
378378
}
379379

380-
rc = mbox_bind_client(chan, cl);
381-
if (rc)
382-
return ERR_PTR(rc);
383-
384380
pcc_mchan = &pchan->chan;
385381
pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr,
386382
pcc_mchan->shmem_size);
387-
if (pcc_mchan->shmem)
388-
return pcc_mchan;
383+
if (!pcc_mchan->shmem)
384+
return ERR_PTR(-ENXIO);
389385

390-
mbox_free_channel(chan);
391-
return ERR_PTR(-ENXIO);
386+
rc = mbox_bind_client(chan, cl);
387+
if (rc) {
388+
iounmap(pcc_mchan->shmem);
389+
pcc_mchan->shmem = NULL;
390+
return ERR_PTR(rc);
391+
}
392+
393+
return pcc_mchan;
392394
}
393395
EXPORT_SYMBOL_GPL(pcc_mbox_request_channel);
394396

0 commit comments

Comments
 (0)