misc: Constify amba_id table

pcc: cleanup and refactoring of shmem and irq handling
 qcom: add MSM8226 compatible
 fsl,mu: add i.MX94 compatible
 core: misc rejig of header includes
 	  minor const fixes
 mediatek: remove cl in struct cmdq_pkt
 tegra: define dimensioning masks in SoC data
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEE6EwehDt/SOnwFyTyf9lkf8eYP5UFAmfohkwACgkQf9lkf8eY
 P5UzGBAAjQLoHWxsQeaBu3iWKOlp4oCNOiDNZDnRc1h3eOtyk3UTxe58AHMs4egv
 aC76zW7Op3e2JhJ5Rw+G6nfg++l+wdU0x6Wa8hT9W9UCMZGcjYQZ/AUbeKLBTcrC
 oGCoUxA/XCeFMFxVQbZWAs0Zt8t0JBWMxzgv6bChKHMGwdd1j7/9mnor3VJSWWGz
 ESoWNnzp9leABPW/rund7Gv05MGxVv6j2AuQF5S90GE3JBUBck4Wh0qQDAxylf6v
 Z6ap+GZn1c+X26MfXSE5FRe/wefs94050/WrYDCmkHbgYf7kfaxjfD+WKd9mH3JW
 hYvCSwHA8raDI6F8J01Q/BP+0lD7Ixh7Ko3HLCDly30HNPNQnApCMOoGLi0P7BSd
 KZAnlwqvYen+9i3mh217OFwXNEa97Q9GRrBIIMhPleJLnweXR7A1KmMTHj0TaKPV
 FxlnPYunH37MDyipTd9Ml2kXpiTfQtTgS7zfceYoNyn7q74g3wUToxqmoN/cn33v
 6hg7XKOKaIWWmM1I6it2r/F0psnLWgh60RSblsN9lMo48Rq89tU1wLAnhdwEOzoL
 6C/zi8Q6cJ+5wxRROfjkSmEtcKftbKX+e/xzUtNQSqiWojAY9p88VtA1mAY3990T
 xVgHlPxy8bh1GN16DZ9BGO/qTUpfjIwFhuzucpAF2Oj3cDd2Or8=
 =Jii1
 -----END PGP SIGNATURE-----

Merge tag 'mailbox-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox

Pull mailbox updates from Jassi Brar:
 "Core:
   - misc rejig of header includes
   - minor const fixes

  Misc:
   - constify amba_id table

  pcc:
   - cleanup and refactoring of shmem and irq handling

  qcom:
   - add MSM8226 compatible

  fsl,mu:
   - add i.MX94 compatible

  mediatek:
   - remove cl in struct cmdq_pkt

  tegra:
   - define dimensioning masks in SoC data"

* tag 'mailbox-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox: (25 commits)
  mailbox: Remove unneeded semicolon
  mailbox: pcc: Refactor and simplify check_and_ack()
  mailbox: pcc: Always map the shared memory communication address
  mailbox: pcc: Refactor error handling in irq handler into separate function
  mailbox: pcc: Use acpi_os_ioremap() instead of ioremap()
  mailbox: pcc: Return early if no GAS register from pcc_mbox_cmd_complete_check
  mailbox: pcc: Drop unnecessary endianness conversion of pcc_hdr.flags
  mailbox: pcc: Always clear the platform ack interrupt first
  mailbox: pcc: Fix the possible race in updation of chan_in_use flag
  dt-bindings: mailbox: qcom: add compatible for MSM8226 SoC
  dt-bindings: mailbox: fsl,mu: Add i.MX94 compatible
  MAINTAINERS: add mailbox API's tree type and location
  mailbox: remove unused header files
  mailbox: explicitly include <linux/bits.h>
  mailbox: sort headers alphabetically
  mailbox: don't protect of_parse_phandle_with_args with con_mutex
  mailbox: use error ret code of of_parse_phandle_with_args()
  mailbox: arm_mhuv2: Constify amba_id table
  mailbox: arm_mhu_db: Constify amba_id table
  mailbox: arm_mhu: Constify amba_id table
  ...
This commit is contained in:
Linus Torvalds 2025-03-29 18:25:34 -07:00
commit 7f2ff7b626
17 changed files with 149 additions and 111 deletions

View file

@ -54,6 +54,10 @@ properties:
- fsl,imx8qm-mu
- fsl,imx8qxp-mu
- const: fsl,imx6sx-mu
- items:
- enum:
- fsl,imx94-mu
- const: fsl,imx95-mu
reg:
maxItems: 1
@ -142,7 +146,8 @@ allOf:
not:
properties:
compatible:
const: fsl,imx95-mu
contains:
const: fsl,imx95-mu
then:
patternProperties:
"^sram@[a-f0-9]+": false

View file

@ -25,6 +25,7 @@ properties:
- mediatek,mt8188-gce
- mediatek,mt8192-gce
- mediatek,mt8195-gce
- mediatek,mt8196-gce
- items:
- const: mediatek,mt6795-gce
- const: mediatek,mt8173-gce
@ -49,6 +50,9 @@ properties:
items:
- const: gce
iommus:
maxItems: 1
required:
- compatible
- "#mbox-cells"

View file

@ -26,6 +26,7 @@ properties:
- const: qcom,ipq6018-apcs-apps-global
- items:
- enum:
- qcom,msm8226-apcs-kpss-global
- qcom,qcs404-apcs-apps-global
- const: qcom,msm8916-apcs-kpss-global
- const: syscon

View file

@ -14090,6 +14090,7 @@ MAILBOX API
M: Jassi Brar <jassisinghbrar@gmail.com>
L: linux-kernel@vger.kernel.org
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox.git for-next
F: Documentation/devicetree/bindings/mailbox/
F: drivers/mailbox/
F: include/dt-bindings/mailbox/

View file

@ -153,7 +153,7 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)
return 0;
}
static struct amba_id mhu_ids[] = {
static const struct amba_id mhu_ids[] = {
{
.id = 0x1bb098,
.mask = 0xffffff,

View file

@ -328,7 +328,7 @@ static int mhu_db_probe(struct amba_device *adev, const struct amba_id *id)
return 0;
}
static struct amba_id mhu_ids[] = {
static const struct amba_id mhu_ids[] = {
{
.id = 0x1bb098,
.mask = 0xffffff,

View file

@ -1107,7 +1107,7 @@ static void mhuv2_remove(struct amba_device *adev)
writel_relaxed(0x0, &mhu->send->access_request);
}
static struct amba_id mhuv2_ids[] = {
static const struct amba_id mhuv2_ids[] = {
{
/* 2.0 */
.id = 0xbb0d1,

View file

@ -57,7 +57,7 @@ static int exynos_mbox_send_data(struct mbox_chan *chan, void *data)
if (msg->chan_type != EXYNOS_MBOX_CHAN_TYPE_DOORBELL) {
dev_err(dev, "Unsupported channel type [%d]\n", msg->chan_type);
return -EINVAL;
};
}
writel(BIT(msg->chan_id), exynos_mbox->regs + EXYNOS_MBOX_INTGR1);

View file

@ -6,18 +6,15 @@
* Author: Jassi Brar <jassisinghbrar@gmail.com>
*/
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox_controller.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/spinlock.h>
#include "mailbox.h"
@ -413,15 +410,15 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
return ERR_PTR(-ENODEV);
}
mutex_lock(&con_mutex);
if (of_parse_phandle_with_args(dev->of_node, "mboxes",
"#mbox-cells", index, &spec)) {
ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
index, &spec);
if (ret) {
dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
mutex_unlock(&con_mutex);
return ERR_PTR(-ENODEV);
return ERR_PTR(ret);
}
mutex_lock(&con_mutex);
chan = ERR_PTR(-EPROBE_DEFER);
list_for_each_entry(mbox, &mbox_cons, node)
if (mbox->dev->of_node == spec.np) {

View file

@ -3,6 +3,8 @@
#ifndef __MAILBOX_H
#define __MAILBOX_H
#include <linux/bits.h>
#define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */
#define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */
#define TXDONE_BY_ACK BIT(2) /* S/W ACK received by Client ticks the TX */

View file

@ -117,8 +117,6 @@ struct pcc_chan_info {
static struct pcc_chan_info *chan_info;
static int pcc_chan_count;
static int pcc_send_data(struct mbox_chan *chan, void *data);
/*
* PCC can be used with perf critical drivers such as CPPC
* So it makes sense to locally cache the virtual address and
@ -245,13 +243,13 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan)
u64 val;
int ret;
if (!pchan->cmd_complete.gas)
return true;
ret = pcc_chan_reg_read(&pchan->cmd_complete, &val);
if (ret)
return false;
if (!pchan->cmd_complete.gas)
return true;
/*
* Judge if the channel respond the interrupt based on the value of
* command complete.
@ -269,33 +267,43 @@ static bool pcc_mbox_cmd_complete_check(struct pcc_chan_info *pchan)
return !!val;
}
static void check_and_ack(struct pcc_chan_info *pchan, struct mbox_chan *chan)
static int pcc_mbox_error_check_and_clear(struct pcc_chan_info *pchan)
{
struct acpi_pcct_ext_pcc_shared_memory pcc_hdr;
u64 val;
int ret;
ret = pcc_chan_reg_read(&pchan->error, &val);
if (ret)
return ret;
val &= pchan->error.status_mask;
if (val) {
val &= ~pchan->error.status_mask;
pcc_chan_reg_write(&pchan->error, val);
return -EIO;
}
return 0;
}
static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
{
struct acpi_pcct_ext_pcc_shared_memory __iomem *pcc_hdr;
if (pchan->type != ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE)
return;
/* If the memory region has not been mapped, we cannot
* determine if we need to send the message, but we still
* need to set the cmd_update flag before returning.
*/
if (pchan->chan.shmem == NULL) {
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
return;
}
memcpy_fromio(&pcc_hdr, pchan->chan.shmem,
sizeof(struct acpi_pcct_ext_pcc_shared_memory));
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
pcc_hdr = pchan->chan.shmem;
/*
* The PCC slave subspace channel needs to set the command complete bit
* after processing message. If the PCC_ACK_FLAG is set, it should also
* ring the doorbell.
*
* The PCC master subspace channel clears chan_in_use to free channel.
* The PCC slave subspace channel needs to set the command
* complete bit after processing message. If the PCC_ACK_FLAG
* is set, it should also ring the doorbell.
*/
if (le32_to_cpup(&pcc_hdr.flags) & PCC_ACK_FLAG_MASK)
pcc_send_data(chan, NULL);
else
pcc_chan_reg_read_modify_write(&pchan->cmd_update);
if (ioread32(&pcc_hdr->flags) & PCC_CMD_COMPLETION_NOTIFY)
pcc_chan_reg_read_modify_write(&pchan->db);
}
/**
@ -309,10 +317,12 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
{
struct pcc_chan_info *pchan;
struct mbox_chan *chan = p;
u64 val;
int ret;
pchan = chan->con_priv;
if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack))
return IRQ_NONE;
if (pchan->type == ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE &&
!pchan->chan_in_use)
return IRQ_NONE;
@ -320,23 +330,19 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
if (!pcc_mbox_cmd_complete_check(pchan))
return IRQ_NONE;
ret = pcc_chan_reg_read(&pchan->error, &val);
if (ret)
return IRQ_NONE;
val &= pchan->error.status_mask;
if (val) {
val &= ~pchan->error.status_mask;
pcc_chan_reg_write(&pchan->error, val);
return IRQ_NONE;
}
if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack))
if (pcc_mbox_error_check_and_clear(pchan))
return IRQ_NONE;
/*
* Clear this flag after updating interrupt ack register and just
* before mbox_chan_received_data() which might call pcc_send_data()
* where the flag is set again to start new transfer. This is
* required to avoid any possible race in updatation of this flag.
*/
pchan->chan_in_use = false;
mbox_chan_received_data(chan, NULL);
check_and_ack(pchan, chan);
pchan->chan_in_use = false;
pcc_chan_acknowledge(pchan);
return IRQ_HANDLED;
}
@ -356,6 +362,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
struct pcc_mbox_chan *
pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
{
struct pcc_mbox_chan *pcc_mchan;
struct pcc_chan_info *pchan;
struct mbox_chan *chan;
int rc;
@ -374,7 +381,14 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
if (rc)
return ERR_PTR(rc);
return &pchan->chan;
pcc_mchan = &pchan->chan;
pcc_mchan->shmem = acpi_os_ioremap(pcc_mchan->shmem_base_addr,
pcc_mchan->shmem_size);
if (pcc_mchan->shmem)
return pcc_mchan;
mbox_free_channel(chan);
return ERR_PTR(-ENXIO);
}
EXPORT_SYMBOL_GPL(pcc_mbox_request_channel);
@ -403,21 +417,6 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan)
}
EXPORT_SYMBOL_GPL(pcc_mbox_free_channel);
int pcc_mbox_ioremap(struct mbox_chan *chan)
{
struct pcc_chan_info *pchan_info;
struct pcc_mbox_chan *pcc_mbox_chan;
if (!chan || !chan->cl)
return -1;
pchan_info = chan->con_priv;
pcc_mbox_chan = &pchan_info->chan;
pcc_mbox_chan->shmem = ioremap(pcc_mbox_chan->shmem_base_addr,
pcc_mbox_chan->shmem_size);
return 0;
}
EXPORT_SYMBOL_GPL(pcc_mbox_ioremap);
/**
* pcc_send_data - Called from Mailbox Controller code. Used
* here only to ring the channel doorbell. The PCC client

View file

@ -45,18 +45,6 @@ static DEFINE_MUTEX(ipc_m1_lock);
static DECLARE_COMPLETION(ipc_completion);
static ATOMIC_NOTIFIER_HEAD(ipc_notifier);
static inline void set_destination(int source, int mbox)
{
writel_relaxed(CHAN_MASK(source), ipc_base + IPCMxDSET(mbox));
writel_relaxed(CHAN_MASK(source), ipc_base + IPCMxMSET(mbox));
}
static inline void clear_destination(int source, int mbox)
{
writel_relaxed(CHAN_MASK(source), ipc_base + IPCMxDCLEAR(mbox));
writel_relaxed(CHAN_MASK(source), ipc_base + IPCMxMCLEAR(mbox));
}
static void __ipc_send(int mbox, u32 *data)
{
int i;
@ -164,7 +152,7 @@ err:
return ret;
}
static struct amba_id pl320_ids[] = {
static const struct amba_id pl320_ids[] = {
{
.id = 0x00041320,
.mask = 0x000fffff,

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2016-2023, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved.
*/
#include <linux/delay.h>
@ -28,12 +28,6 @@
#define HSP_INT_FULL_MASK 0xff
#define HSP_INT_DIMENSIONING 0x380
#define HSP_nSM_SHIFT 0
#define HSP_nSS_SHIFT 4
#define HSP_nAS_SHIFT 8
#define HSP_nDB_SHIFT 12
#define HSP_nSI_SHIFT 16
#define HSP_nINT_MASK 0xf
#define HSP_DB_TRIGGER 0x0
#define HSP_DB_ENABLE 0x4
@ -97,6 +91,20 @@ struct tegra_hsp_soc {
bool has_per_mb_ie;
bool has_128_bit_mb;
unsigned int reg_stride;
/* Shifts for dimensioning register. */
unsigned int si_shift;
unsigned int db_shift;
unsigned int as_shift;
unsigned int ss_shift;
unsigned int sm_shift;
/* Masks for dimensioning register. */
unsigned int si_mask;
unsigned int db_mask;
unsigned int as_mask;
unsigned int ss_mask;
unsigned int sm_mask;
};
struct tegra_hsp {
@ -747,11 +755,11 @@ static int tegra_hsp_probe(struct platform_device *pdev)
return PTR_ERR(hsp->regs);
value = tegra_hsp_readl(hsp, HSP_INT_DIMENSIONING);
hsp->num_sm = (value >> HSP_nSM_SHIFT) & HSP_nINT_MASK;
hsp->num_ss = (value >> HSP_nSS_SHIFT) & HSP_nINT_MASK;
hsp->num_as = (value >> HSP_nAS_SHIFT) & HSP_nINT_MASK;
hsp->num_db = (value >> HSP_nDB_SHIFT) & HSP_nINT_MASK;
hsp->num_si = (value >> HSP_nSI_SHIFT) & HSP_nINT_MASK;
hsp->num_sm = (value >> hsp->soc->sm_shift) & hsp->soc->sm_mask;
hsp->num_ss = (value >> hsp->soc->ss_shift) & hsp->soc->ss_mask;
hsp->num_as = (value >> hsp->soc->as_shift) & hsp->soc->as_mask;
hsp->num_db = (value >> hsp->soc->db_shift) & hsp->soc->db_mask;
hsp->num_si = (value >> hsp->soc->si_shift) & hsp->soc->si_mask;
err = platform_get_irq_byname_optional(pdev, "doorbell");
if (err >= 0)
@ -915,6 +923,16 @@ static const struct tegra_hsp_soc tegra186_hsp_soc = {
.has_per_mb_ie = false,
.has_128_bit_mb = false,
.reg_stride = 0x100,
.si_shift = 16,
.db_shift = 12,
.as_shift = 8,
.ss_shift = 4,
.sm_shift = 0,
.si_mask = 0xf,
.db_mask = 0xf,
.as_mask = 0xf,
.ss_mask = 0xf,
.sm_mask = 0xf,
};
static const struct tegra_hsp_soc tegra194_hsp_soc = {
@ -922,6 +940,16 @@ static const struct tegra_hsp_soc tegra194_hsp_soc = {
.has_per_mb_ie = true,
.has_128_bit_mb = false,
.reg_stride = 0x100,
.si_shift = 16,
.db_shift = 12,
.as_shift = 8,
.ss_shift = 4,
.sm_shift = 0,
.si_mask = 0xf,
.db_mask = 0xf,
.as_mask = 0xf,
.ss_mask = 0xf,
.sm_mask = 0xf,
};
static const struct tegra_hsp_soc tegra234_hsp_soc = {
@ -929,6 +957,16 @@ static const struct tegra_hsp_soc tegra234_hsp_soc = {
.has_per_mb_ie = false,
.has_128_bit_mb = true,
.reg_stride = 0x100,
.si_shift = 16,
.db_shift = 12,
.as_shift = 8,
.ss_shift = 4,
.sm_shift = 0,
.si_mask = 0xf,
.db_mask = 0xf,
.as_mask = 0xf,
.ss_mask = 0xf,
.sm_mask = 0xf,
};
static const struct tegra_hsp_soc tegra264_hsp_soc = {
@ -936,6 +974,16 @@ static const struct tegra_hsp_soc tegra264_hsp_soc = {
.has_per_mb_ie = false,
.has_128_bit_mb = true,
.reg_stride = 0x1000,
.si_shift = 17,
.db_shift = 12,
.as_shift = 8,
.ss_shift = 4,
.sm_shift = 0,
.si_mask = 0x1f,
.db_mask = 0x1f,
.as_mask = 0xf,
.ss_mask = 0xf,
.sm_mask = 0xf,
};
static const struct of_device_id tegra_hsp_match[] = {

View file

@ -32,13 +32,11 @@ struct pcc_mbox_chan {
#define PCC_CMD_COMPLETION_NOTIFY BIT(0)
#define MAX_PCC_SUBSPACES 256
#define PCC_ACK_FLAG_MASK 0x1
#ifdef CONFIG_PCC
extern struct pcc_mbox_chan *
pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id);
extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan);
extern int pcc_mbox_ioremap(struct mbox_chan *chan);
#else
static inline struct pcc_mbox_chan *
pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
@ -46,10 +44,6 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
return ERR_PTR(-ENODEV);
}
static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { }
static inline int pcc_mbox_ioremap(struct mbox_chan *chan)
{
return 0;
};
#endif
#endif /* _PCC_H */

View file

@ -75,7 +75,6 @@ struct cmdq_pkt {
dma_addr_t pa_base;
size_t cmd_buf_size; /* command occupied size */
size_t buf_size; /* real buffer size */
void *cl;
};
u8 cmdq_get_shift_pa(struct mbox_chan *chan);

View file

@ -7,8 +7,8 @@
#ifndef __MAILBOX_CLIENT_H
#define __MAILBOX_CLIENT_H
#include <linux/of.h>
#include <linux/device.h>
#include <linux/of.h>
struct mbox_chan;

View file

@ -3,11 +3,11 @@
#ifndef __MAILBOX_CONTROLLER_H
#define __MAILBOX_CONTROLLER_H
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/hrtimer.h>
#include <linux/of.h>
#include <linux/types.h>
#include <linux/hrtimer.h>
#include <linux/device.h>
#include <linux/completion.h>
struct mbox_chan;