Skip to content

Commit fb3b067

Browse files
committed
Merge tag 'mailbox-v5.17' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox updates from Jassi Brar: - qcom: misc updates to qcom-ipcc driver - mpfs: change compatible string - pcc: - fix handling of subtypes - avoid uninitialized variable - mtk: - add missing of_node_put - enable control_by_sw - silent probe-defer prints - fix gce_num for mt8192 - zynq: add missing of_node_put - imx: check for NULL instead of IS_ERR - appple: switch to generic compatibles - hi3660: convert comments to kernel-doc notation * tag 'mailbox-v5.17' of git://git.linaro.org/landing-teams/working/fujitsu/integration: dt-bindings: mailbox: Add more protocol and client ID mailbox: qcom-ipcc: Support interrupt wake up from suspend mailbox: qcom-ipcc: Support more IPCC instance mailbox: qcom-ipcc: Dynamic alloc for channel arrangement mailbox: change mailbox-mpfs compatible string mailbox: pcc: Handle all PCC subtypes correctly in pcc_mbox_irq mailbox: pcc: Avoid using the uninitialized variable 'dev' mailbox: mtk: add missing of_node_put before return mailbox: zynq: add missing of_node_put before return mailbox: imx: Fix an IS_ERR() vs NULL bug mailbox: hi3660: convert struct comments to kernel-doc notation mailbox: add control_by_sw for mt8195 mailbox: mtk-cmdq: Silent EPROBE_DEFER errors for clks mailbox: fix gce_num of mt8192 driver data mailbox: apple: Bind to generic compatibles dt-bindings: mailbox: apple,mailbox: Add generic and t6000 compatibles
2 parents 747c19e + 869b6ca commit fb3b067

File tree

10 files changed

+116
-51
lines changed

10 files changed

+116
-51
lines changed

Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ properties:
2727
for example for the display controller, the system management
2828
controller and the NVMe coprocessor.
2929
items:
30-
- const: apple,t8103-asc-mailbox
30+
- enum:
31+
- apple,t8103-asc-mailbox
32+
- apple,t6000-asc-mailbox
33+
- const: apple,asc-mailbox-v4
3134

3235
- description:
3336
M3 mailboxes are an older variant with a slightly different MMIO
3437
interface still found on the M1. It is used for the Thunderbolt
3538
co-processors.
3639
items:
37-
- const: apple,t8103-m3-mailbox
40+
- enum:
41+
- apple,t8103-m3-mailbox
42+
- apple,t6000-m3-mailbox
43+
- const: apple,m3-mailbox-v2
3844

3945
reg:
4046
maxItems: 1
@@ -71,7 +77,7 @@ additionalProperties: false
7177
examples:
7278
- |
7379
mailbox@77408000 {
74-
compatible = "apple,t8103-asc-mailbox";
80+
compatible = "apple,t8103-asc-mailbox", "apple,asc-mailbox-v4";
7581
reg = <0x77408000 0x4000>;
7682
interrupts = <1 583 4>, <1 584 4>, <1 585 4>, <1 586 4>;
7783
interrupt-names = "send-empty", "send-not-empty",

drivers/mailbox/apple-mailbox.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ static const struct apple_mbox_hw apple_mbox_m3_hw = {
364364
};
365365

366366
static const struct of_device_id apple_mbox_of_match[] = {
367-
{ .compatible = "apple,t8103-asc-mailbox", .data = &apple_mbox_asc_hw },
368-
{ .compatible = "apple,t8103-m3-mailbox", .data = &apple_mbox_m3_hw },
367+
{ .compatible = "apple,asc-mailbox-v4", .data = &apple_mbox_asc_hw },
368+
{ .compatible = "apple,m3-mailbox-v2", .data = &apple_mbox_m3_hw },
369369
{}
370370
};
371371
MODULE_DEVICE_TABLE(of, apple_mbox_of_match);

drivers/mailbox/hi3660-mailbox.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,29 @@
4444
#define MBOX_MSG_LEN 8
4545

4646
/**
47-
* Hi3660 mailbox channel information
47+
* struct hi3660_chan_info - Hi3660 mailbox channel information
48+
* @dst_irq: Interrupt vector for remote processor
49+
* @ack_irq: Interrupt vector for local processor
4850
*
4951
* A channel can be used for TX or RX, it can trigger remote
5052
* processor interrupt to notify remote processor and can receive
51-
* interrupt if has incoming message.
52-
*
53-
* @dst_irq: Interrupt vector for remote processor
54-
* @ack_irq: Interrupt vector for local processor
53+
* interrupt if it has an incoming message.
5554
*/
5655
struct hi3660_chan_info {
5756
unsigned int dst_irq;
5857
unsigned int ack_irq;
5958
};
6059

6160
/**
62-
* Hi3660 mailbox controller data
63-
*
64-
* Mailbox controller includes 32 channels and can allocate
65-
* channel for message transferring.
66-
*
61+
* struct hi3660_mbox - Hi3660 mailbox controller data
6762
* @dev: Device to which it is attached
6863
* @base: Base address of the register mapping region
6964
* @chan: Representation of channels in mailbox controller
7065
* @mchan: Representation of channel info
7166
* @controller: Representation of a communication channel controller
67+
*
68+
* Mailbox controller includes 32 channels and can allocate
69+
* channel for message transferring.
7270
*/
7371
struct hi3660_mbox {
7472
struct device *dev;

drivers/mailbox/imx-mailbox.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ static int imx_mu_probe(struct platform_device *pdev)
563563
size = sizeof(struct imx_sc_rpc_msg_max);
564564

565565
priv->msg = devm_kzalloc(dev, size, GFP_KERNEL);
566-
if (IS_ERR(priv->msg))
567-
return PTR_ERR(priv->msg);
566+
if (!priv->msg)
567+
return -ENOMEM;
568568

569569
priv->clk = devm_clk_get(dev, NULL);
570570
if (IS_ERR(priv->clk)) {

drivers/mailbox/mailbox-mpfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int mpfs_mbox_probe(struct platform_device *pdev)
232232
}
233233

234234
static const struct of_device_id mpfs_mbox_of_match[] = {
235-
{.compatible = "microchip,polarfire-soc-mailbox", },
235+
{.compatible = "microchip,mpfs-mailbox", },
236236
{},
237237
};
238238
MODULE_DEVICE_TABLE(of, mpfs_mbox_of_match);

drivers/mailbox/mtk-cmdq-mailbox.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,17 +573,20 @@ static int cmdq_probe(struct platform_device *pdev)
573573
cmdq->clocks[alias_id].id = clk_names[alias_id];
574574
cmdq->clocks[alias_id].clk = of_clk_get(node, 0);
575575
if (IS_ERR(cmdq->clocks[alias_id].clk)) {
576-
dev_err(dev, "failed to get gce clk: %d\n", alias_id);
577-
return PTR_ERR(cmdq->clocks[alias_id].clk);
576+
of_node_put(node);
577+
return dev_err_probe(dev,
578+
PTR_ERR(cmdq->clocks[alias_id].clk),
579+
"failed to get gce clk: %d\n",
580+
alias_id);
578581
}
579582
}
580583
}
581584
} else {
582585
cmdq->clocks[alias_id].id = clk_name;
583586
cmdq->clocks[alias_id].clk = devm_clk_get(&pdev->dev, clk_name);
584587
if (IS_ERR(cmdq->clocks[alias_id].clk)) {
585-
dev_err(dev, "failed to get gce clk\n");
586-
return PTR_ERR(cmdq->clocks[alias_id].clk);
588+
return dev_err_probe(dev, PTR_ERR(cmdq->clocks[alias_id].clk),
589+
"failed to get gce clk\n");
587590
}
588591
}
589592

@@ -658,13 +661,13 @@ static const struct gce_plat gce_plat_v5 = {
658661
.thread_nr = 24,
659662
.shift = 3,
660663
.control_by_sw = true,
661-
.gce_num = 2
664+
.gce_num = 1
662665
};
663666

664667
static const struct gce_plat gce_plat_v6 = {
665668
.thread_nr = 24,
666669
.shift = 3,
667-
.control_by_sw = false,
670+
.control_by_sw = true,
668671
.gce_num = 2
669672
};
670673

drivers/mailbox/pcc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,11 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
241241
if (ret)
242242
return IRQ_NONE;
243243

244-
val &= pchan->cmd_complete.status_mask;
245-
if (!val)
246-
return IRQ_NONE;
244+
if (val) { /* Ensure GAS exists and value is non-zero */
245+
val &= pchan->cmd_complete.status_mask;
246+
if (!val)
247+
return IRQ_NONE;
248+
}
247249

248250
ret = pcc_chan_reg_read(&pchan->error, &val);
249251
if (ret)
@@ -289,7 +291,7 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
289291
pchan = chan_info + subspace_id;
290292
chan = pchan->chan.mchan;
291293
if (IS_ERR(chan) || chan->cl) {
292-
dev_err(dev, "Channel not found for idx: %d\n", subspace_id);
294+
pr_err("Channel not found for idx: %d\n", subspace_id);
293295
return ERR_PTR(-EBUSY);
294296
}
295297
dev = chan->mbox->dev;

drivers/mailbox/qcom-ipcc.c

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#include <dt-bindings/mailbox/qcom-ipcc.h>
1515

16-
#define IPCC_MBOX_MAX_CHAN 48
17-
1816
/* IPCC Register offsets */
1917
#define IPCC_REG_SEND_ID 0x0c
2018
#define IPCC_REG_RECV_ID 0x10
@@ -52,9 +50,10 @@ struct qcom_ipcc {
5250
struct device *dev;
5351
void __iomem *base;
5452
struct irq_domain *irq_domain;
55-
struct mbox_chan chan[IPCC_MBOX_MAX_CHAN];
56-
struct qcom_ipcc_chan_info mchan[IPCC_MBOX_MAX_CHAN];
53+
struct mbox_chan *chans;
54+
struct qcom_ipcc_chan_info *mchan;
5755
struct mbox_controller mbox;
56+
int num_chans;
5857
int irq;
5958
};
6059

@@ -166,41 +165,87 @@ static struct mbox_chan *qcom_ipcc_mbox_xlate(struct mbox_controller *mbox,
166165
struct qcom_ipcc *ipcc = to_qcom_ipcc(mbox);
167166
struct qcom_ipcc_chan_info *mchan;
168167
struct mbox_chan *chan;
169-
unsigned int i;
168+
struct device *dev;
169+
int chan_id;
170+
171+
dev = ipcc->dev;
170172

171173
if (ph->args_count != 2)
172174
return ERR_PTR(-EINVAL);
173175

174-
for (i = 0; i < IPCC_MBOX_MAX_CHAN; i++) {
175-
chan = &ipcc->chan[i];
176-
if (!chan->con_priv) {
177-
mchan = &ipcc->mchan[i];
178-
mchan->client_id = ph->args[0];
179-
mchan->signal_id = ph->args[1];
180-
chan->con_priv = mchan;
181-
break;
182-
}
176+
for (chan_id = 0; chan_id < mbox->num_chans; chan_id++) {
177+
chan = &ipcc->chans[chan_id];
178+
mchan = chan->con_priv;
183179

184-
chan = NULL;
180+
if (!mchan)
181+
break;
182+
else if (mchan->client_id == ph->args[0] &&
183+
mchan->signal_id == ph->args[1])
184+
return ERR_PTR(-EBUSY);
185185
}
186186

187-
return chan ?: ERR_PTR(-EBUSY);
187+
if (chan_id >= mbox->num_chans)
188+
return ERR_PTR(-EBUSY);
189+
190+
mchan = devm_kzalloc(dev, sizeof(*mchan), GFP_KERNEL);
191+
if (!mchan)
192+
return ERR_PTR(-ENOMEM);
193+
194+
mchan->client_id = ph->args[0];
195+
mchan->signal_id = ph->args[1];
196+
chan->con_priv = mchan;
197+
198+
return chan;
188199
}
189200

190201
static const struct mbox_chan_ops ipcc_mbox_chan_ops = {
191202
.send_data = qcom_ipcc_mbox_send_data,
192203
.shutdown = qcom_ipcc_mbox_shutdown,
193204
};
194205

195-
static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc)
206+
static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc,
207+
struct device_node *controller_dn)
196208
{
209+
struct of_phandle_args curr_ph;
210+
struct device_node *client_dn;
197211
struct mbox_controller *mbox;
198212
struct device *dev = ipcc->dev;
213+
int i, j, ret;
214+
215+
/*
216+
* Find out the number of clients interested in this mailbox
217+
* and create channels accordingly.
218+
*/
219+
ipcc->num_chans = 0;
220+
for_each_node_with_property(client_dn, "mboxes") {
221+
if (!of_device_is_available(client_dn))
222+
continue;
223+
i = of_count_phandle_with_args(client_dn,
224+
"mboxes", "#mbox-cells");
225+
for (j = 0; j < i; j++) {
226+
ret = of_parse_phandle_with_args(client_dn, "mboxes",
227+
"#mbox-cells", j, &curr_ph);
228+
of_node_put(curr_ph.np);
229+
if (!ret && curr_ph.np == controller_dn) {
230+
ipcc->num_chans++;
231+
break;
232+
}
233+
}
234+
}
235+
236+
/* If no clients are found, skip registering as a mbox controller */
237+
if (!ipcc->num_chans)
238+
return 0;
239+
240+
ipcc->chans = devm_kcalloc(dev, ipcc->num_chans,
241+
sizeof(struct mbox_chan), GFP_KERNEL);
242+
if (!ipcc->chans)
243+
return -ENOMEM;
199244

200245
mbox = &ipcc->mbox;
201246
mbox->dev = dev;
202-
mbox->num_chans = IPCC_MBOX_MAX_CHAN;
203-
mbox->chans = ipcc->chan;
247+
mbox->num_chans = ipcc->num_chans;
248+
mbox->chans = ipcc->chans;
204249
mbox->ops = &ipcc_mbox_chan_ops;
205250
mbox->of_xlate = qcom_ipcc_mbox_xlate;
206251
mbox->txdone_irq = false;
@@ -212,6 +257,8 @@ static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc)
212257
static int qcom_ipcc_probe(struct platform_device *pdev)
213258
{
214259
struct qcom_ipcc *ipcc;
260+
static int id;
261+
char *name;
215262
int ret;
216263

217264
ipcc = devm_kzalloc(&pdev->dev, sizeof(*ipcc), GFP_KERNEL);
@@ -228,27 +275,33 @@ static int qcom_ipcc_probe(struct platform_device *pdev)
228275
if (ipcc->irq < 0)
229276
return ipcc->irq;
230277

278+
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "ipcc_%d", id++);
279+
if (!name)
280+
return -ENOMEM;
281+
231282
ipcc->irq_domain = irq_domain_add_tree(pdev->dev.of_node,
232283
&qcom_ipcc_irq_ops, ipcc);
233284
if (!ipcc->irq_domain)
234285
return -ENOMEM;
235286

236-
ret = qcom_ipcc_setup_mbox(ipcc);
287+
ret = qcom_ipcc_setup_mbox(ipcc, pdev->dev.of_node);
237288
if (ret)
238289
goto err_mbox;
239290

240291
ret = devm_request_irq(&pdev->dev, ipcc->irq, qcom_ipcc_irq_fn,
241-
IRQF_TRIGGER_HIGH, "ipcc", ipcc);
292+
IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND, name, ipcc);
242293
if (ret < 0) {
243294
dev_err(&pdev->dev, "Failed to register the irq: %d\n", ret);
244-
goto err_mbox;
295+
goto err_req_irq;
245296
}
246297

247-
enable_irq_wake(ipcc->irq);
248298
platform_set_drvdata(pdev, ipcc);
249299

250300
return 0;
251301

302+
err_req_irq:
303+
if (ipcc->num_chans)
304+
mbox_controller_unregister(&ipcc->mbox);
252305
err_mbox:
253306
irq_domain_remove(ipcc->irq_domain);
254307

drivers/mailbox/zynqmp-ipi-mailbox.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
655655
mbox->pdata = pdata;
656656
ret = zynqmp_ipi_mbox_probe(mbox, nc);
657657
if (ret) {
658+
of_node_put(nc);
658659
dev_err(dev, "failed to probe subdev.\n");
659660
ret = -EINVAL;
660661
goto free_mbox_dev;

include/dt-bindings/mailbox/qcom-ipcc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
/* Signal IDs for MPROC protocol */
1010
#define IPCC_MPROC_SIGNAL_GLINK_QMP 0
11+
#define IPCC_MPROC_SIGNAL_TZ 1
1112
#define IPCC_MPROC_SIGNAL_SMP2P 2
1213
#define IPCC_MPROC_SIGNAL_PING 3
1314

@@ -29,6 +30,7 @@
2930
#define IPCC_CLIENT_PCIE1 14
3031
#define IPCC_CLIENT_PCIE2 15
3132
#define IPCC_CLIENT_SPSS 16
33+
#define IPCC_CLIENT_TME 23
3234
#define IPCC_CLIENT_WPSS 24
3335

3436
#endif

0 commit comments

Comments
 (0)