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

mailbox: pcc: Always map the shared memory communication address

Currently the shared memory communication address was mapped by the
mailbox client drivers leading to all sorts of inconsistencies.

It also has resulted in the inconsistent attributes used while mapping
the shared memory regions.

In order to remove/eliminate any issues, let us ensures the shared
memory address is always mapped and unmapped when the PCC channels are
requested and release.

We need to map them as the ACPI PCCT associates these shared memory
with each channel subspace and may need use the status or the flags in
the headers of those shared memory communication address regions to
manage the transport/channel.

Note, until all the drivers using PCC start using this mapped shmem,
there might be double mapping of the shared memory address. This
shouldn't have any impact on existing mbox client drivers.

Since there are no users of pcc_chan_ioremap() and also it is mapped
by default, we can stop exporting it and merge the functionality into
pcc_mbox_request_channel().

Acked-by: Huisong Li <lihuisong@huawei.com>
Tested-by: Huisong Li <lihuisong@huawei.com>
Tested-by: Adam Young <admiyo@os.amperecomputing.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>

authored by

Sudeep Holla and committed by
Jassi Brar
fa362ffa 3a675f50

+9 -25
+9 -20
drivers/mailbox/pcc.c
··· 373 373 struct pcc_mbox_chan * 374 374 pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) 375 375 { 376 + struct pcc_mbox_chan *pcc_mchan; 376 377 struct pcc_chan_info *pchan; 377 378 struct mbox_chan *chan; 378 379 int rc; ··· 392 391 if (rc) 393 392 return ERR_PTR(rc); 394 393 395 - return &pchan->chan; 394 + pcc_mchan = &pchan->chan; 395 + pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr, 396 + pcc_mchan->shmem_size); 397 + if (pcc_mchan->shmem) 398 + return pcc_mchan; 399 + 400 + mbox_free_channel(chan); 401 + return ERR_PTR(-ENXIO); 396 402 } 397 403 EXPORT_SYMBOL_GPL(pcc_mbox_request_channel); 398 404 ··· 427 419 mbox_free_channel(chan); 428 420 } 429 421 EXPORT_SYMBOL_GPL(pcc_mbox_free_channel); 430 - 431 - int pcc_mbox_ioremap(struct mbox_chan *chan) 432 - { 433 - struct pcc_chan_info *pchan_info; 434 - struct pcc_mbox_chan *pcc_mbox_chan; 435 - 436 - if (!chan || !chan->cl) 437 - return -1; 438 - pchan_info = chan->con_priv; 439 - pcc_mbox_chan = &pchan_info->chan; 440 - 441 - pcc_mbox_chan->shmem = acpi_os_ioremap(pcc_mbox_chan->shmem_base_addr, 442 - pcc_mbox_chan->shmem_size); 443 - if (!pcc_mbox_chan->shmem) 444 - return -ENXIO; 445 - 446 - return 0; 447 - } 448 - EXPORT_SYMBOL_GPL(pcc_mbox_ioremap); 449 422 450 423 /** 451 424 * pcc_send_data - Called from Mailbox Controller code. Used
-5
include/acpi/pcc.h
··· 37 37 extern struct pcc_mbox_chan * 38 38 pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); 39 39 extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan); 40 - extern int pcc_mbox_ioremap(struct mbox_chan *chan); 41 40 #else 42 41 static inline struct pcc_mbox_chan * 43 42 pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) ··· 44 45 return ERR_PTR(-ENODEV); 45 46 } 46 47 static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { } 47 - static inline int pcc_mbox_ioremap(struct mbox_chan *chan) 48 - { 49 - return 0; 50 - }; 51 48 #endif 52 49 53 50 #endif /* _PCC_H */