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

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

+116 -51
+9 -3
Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml
··· 27 27 for example for the display controller, the system management 28 28 controller and the NVMe coprocessor. 29 29 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 31 34 32 35 - description: 33 36 M3 mailboxes are an older variant with a slightly different MMIO 34 37 interface still found on the M1. It is used for the Thunderbolt 35 38 co-processors. 36 39 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 38 44 39 45 reg: 40 46 maxItems: 1 ··· 77 71 examples: 78 72 - | 79 73 mailbox@77408000 { 80 - compatible = "apple,t8103-asc-mailbox"; 74 + compatible = "apple,t8103-asc-mailbox", "apple,asc-mailbox-v4"; 81 75 reg = <0x77408000 0x4000>; 82 76 interrupts = <1 583 4>, <1 584 4>, <1 585 4>, <1 586 4>; 83 77 interrupt-names = "send-empty", "send-not-empty",
+2 -2
drivers/mailbox/apple-mailbox.c
··· 364 364 }; 365 365 366 366 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 }, 369 369 {} 370 370 }; 371 371 MODULE_DEVICE_TABLE(of, apple_mbox_of_match);
+8 -10
drivers/mailbox/hi3660-mailbox.c
··· 44 44 #define MBOX_MSG_LEN 8 45 45 46 46 /** 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 48 50 * 49 51 * A channel can be used for TX or RX, it can trigger remote 50 52 * 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. 55 54 */ 56 55 struct hi3660_chan_info { 57 56 unsigned int dst_irq; ··· 58 59 }; 59 60 60 61 /** 61 - * Hi3660 mailbox controller data 62 - * 63 - * Mailbox controller includes 32 channels and can allocate 64 - * channel for message transferring. 65 - * 62 + * struct hi3660_mbox - Hi3660 mailbox controller data 66 63 * @dev: Device to which it is attached 67 64 * @base: Base address of the register mapping region 68 65 * @chan: Representation of channels in mailbox controller 69 66 * @mchan: Representation of channel info 70 67 * @controller: Representation of a communication channel controller 68 + * 69 + * Mailbox controller includes 32 channels and can allocate 70 + * channel for message transferring. 71 71 */ 72 72 struct hi3660_mbox { 73 73 struct device *dev;
+2 -2
drivers/mailbox/imx-mailbox.c
··· 563 563 size = sizeof(struct imx_sc_rpc_msg_max); 564 564 565 565 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; 568 568 569 569 priv->clk = devm_clk_get(dev, NULL); 570 570 if (IS_ERR(priv->clk)) {
+1 -1
drivers/mailbox/mailbox-mpfs.c
··· 232 232 } 233 233 234 234 static const struct of_device_id mpfs_mbox_of_match[] = { 235 - {.compatible = "microchip,polarfire-soc-mailbox", }, 235 + {.compatible = "microchip,mpfs-mailbox", }, 236 236 {}, 237 237 }; 238 238 MODULE_DEVICE_TABLE(of, mpfs_mbox_of_match);
+9 -6
drivers/mailbox/mtk-cmdq-mailbox.c
··· 573 573 cmdq->clocks[alias_id].id = clk_names[alias_id]; 574 574 cmdq->clocks[alias_id].clk = of_clk_get(node, 0); 575 575 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); 578 581 } 579 582 } 580 583 } ··· 585 582 cmdq->clocks[alias_id].id = clk_name; 586 583 cmdq->clocks[alias_id].clk = devm_clk_get(&pdev->dev, clk_name); 587 584 if (IS_ERR(cmdq->clocks[alias_id].clk)) { 588 - dev_err(dev, "failed to get gce clk\n"); 589 - return PTR_ERR(cmdq->clocks[alias_id].clk); 585 + return dev_err_probe(dev, PTR_ERR(cmdq->clocks[alias_id].clk), 586 + "failed to get gce clk\n"); 590 587 } 591 588 } 592 589 ··· 661 658 .thread_nr = 24, 662 659 .shift = 3, 663 660 .control_by_sw = true, 664 - .gce_num = 2 661 + .gce_num = 1 665 662 }; 666 663 667 664 static const struct gce_plat gce_plat_v6 = { 668 665 .thread_nr = 24, 669 666 .shift = 3, 670 - .control_by_sw = false, 667 + .control_by_sw = true, 671 668 .gce_num = 2 672 669 }; 673 670
+6 -4
drivers/mailbox/pcc.c
··· 241 241 if (ret) 242 242 return IRQ_NONE; 243 243 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 + } 247 249 248 250 ret = pcc_chan_reg_read(&pchan->error, &val); 249 251 if (ret) ··· 291 289 pchan = chan_info + subspace_id; 292 290 chan = pchan->chan.mchan; 293 291 if (IS_ERR(chan) || chan->cl) { 294 - dev_err(dev, "Channel not found for idx: %d\n", subspace_id); 292 + pr_err("Channel not found for idx: %d\n", subspace_id); 295 293 return ERR_PTR(-EBUSY); 296 294 } 297 295 dev = chan->mbox->dev;
+76 -23
drivers/mailbox/qcom-ipcc.c
··· 13 13 14 14 #include <dt-bindings/mailbox/qcom-ipcc.h> 15 15 16 - #define IPCC_MBOX_MAX_CHAN 48 17 - 18 16 /* IPCC Register offsets */ 19 17 #define IPCC_REG_SEND_ID 0x0c 20 18 #define IPCC_REG_RECV_ID 0x10 ··· 50 52 struct device *dev; 51 53 void __iomem *base; 52 54 struct irq_domain *irq_domain; 53 - struct mbox_chan chan[IPCC_MBOX_MAX_CHAN]; 54 - struct qcom_ipcc_chan_info mchan[IPCC_MBOX_MAX_CHAN]; 55 + struct mbox_chan *chans; 56 + struct qcom_ipcc_chan_info *mchan; 55 57 struct mbox_controller mbox; 58 + int num_chans; 56 59 int irq; 57 60 }; 58 61 ··· 165 166 struct qcom_ipcc *ipcc = to_qcom_ipcc(mbox); 166 167 struct qcom_ipcc_chan_info *mchan; 167 168 struct mbox_chan *chan; 168 - unsigned int i; 169 + struct device *dev; 170 + int chan_id; 171 + 172 + dev = ipcc->dev; 169 173 170 174 if (ph->args_count != 2) 171 175 return ERR_PTR(-EINVAL); 172 176 173 - for (i = 0; i < IPCC_MBOX_MAX_CHAN; i++) { 174 - chan = &ipcc->chan[i]; 175 - if (!chan->con_priv) { 176 - mchan = &ipcc->mchan[i]; 177 - mchan->client_id = ph->args[0]; 178 - mchan->signal_id = ph->args[1]; 179 - chan->con_priv = mchan; 180 - break; 181 - } 177 + for (chan_id = 0; chan_id < mbox->num_chans; chan_id++) { 178 + chan = &ipcc->chans[chan_id]; 179 + mchan = chan->con_priv; 182 180 183 - chan = NULL; 181 + if (!mchan) 182 + break; 183 + else if (mchan->client_id == ph->args[0] && 184 + mchan->signal_id == ph->args[1]) 185 + return ERR_PTR(-EBUSY); 184 186 } 185 187 186 - return chan ?: ERR_PTR(-EBUSY); 188 + if (chan_id >= mbox->num_chans) 189 + return ERR_PTR(-EBUSY); 190 + 191 + mchan = devm_kzalloc(dev, sizeof(*mchan), GFP_KERNEL); 192 + if (!mchan) 193 + return ERR_PTR(-ENOMEM); 194 + 195 + mchan->client_id = ph->args[0]; 196 + mchan->signal_id = ph->args[1]; 197 + chan->con_priv = mchan; 198 + 199 + return chan; 187 200 } 188 201 189 202 static const struct mbox_chan_ops ipcc_mbox_chan_ops = { ··· 203 192 .shutdown = qcom_ipcc_mbox_shutdown, 204 193 }; 205 194 206 - static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc) 195 + static int qcom_ipcc_setup_mbox(struct qcom_ipcc *ipcc, 196 + struct device_node *controller_dn) 207 197 { 198 + struct of_phandle_args curr_ph; 199 + struct device_node *client_dn; 208 200 struct mbox_controller *mbox; 209 201 struct device *dev = ipcc->dev; 202 + int i, j, ret; 203 + 204 + /* 205 + * Find out the number of clients interested in this mailbox 206 + * and create channels accordingly. 207 + */ 208 + ipcc->num_chans = 0; 209 + for_each_node_with_property(client_dn, "mboxes") { 210 + if (!of_device_is_available(client_dn)) 211 + continue; 212 + i = of_count_phandle_with_args(client_dn, 213 + "mboxes", "#mbox-cells"); 214 + for (j = 0; j < i; j++) { 215 + ret = of_parse_phandle_with_args(client_dn, "mboxes", 216 + "#mbox-cells", j, &curr_ph); 217 + of_node_put(curr_ph.np); 218 + if (!ret && curr_ph.np == controller_dn) { 219 + ipcc->num_chans++; 220 + break; 221 + } 222 + } 223 + } 224 + 225 + /* If no clients are found, skip registering as a mbox controller */ 226 + if (!ipcc->num_chans) 227 + return 0; 228 + 229 + ipcc->chans = devm_kcalloc(dev, ipcc->num_chans, 230 + sizeof(struct mbox_chan), GFP_KERNEL); 231 + if (!ipcc->chans) 232 + return -ENOMEM; 210 233 211 234 mbox = &ipcc->mbox; 212 235 mbox->dev = dev; 213 - mbox->num_chans = IPCC_MBOX_MAX_CHAN; 214 - mbox->chans = ipcc->chan; 236 + mbox->num_chans = ipcc->num_chans; 237 + mbox->chans = ipcc->chans; 215 238 mbox->ops = &ipcc_mbox_chan_ops; 216 239 mbox->of_xlate = qcom_ipcc_mbox_xlate; 217 240 mbox->txdone_irq = false; ··· 257 212 static int qcom_ipcc_probe(struct platform_device *pdev) 258 213 { 259 214 struct qcom_ipcc *ipcc; 215 + static int id; 216 + char *name; 260 217 int ret; 261 218 262 219 ipcc = devm_kzalloc(&pdev->dev, sizeof(*ipcc), GFP_KERNEL); ··· 275 228 if (ipcc->irq < 0) 276 229 return ipcc->irq; 277 230 231 + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "ipcc_%d", id++); 232 + if (!name) 233 + return -ENOMEM; 234 + 278 235 ipcc->irq_domain = irq_domain_add_tree(pdev->dev.of_node, 279 236 &qcom_ipcc_irq_ops, ipcc); 280 237 if (!ipcc->irq_domain) 281 238 return -ENOMEM; 282 239 283 - ret = qcom_ipcc_setup_mbox(ipcc); 240 + ret = qcom_ipcc_setup_mbox(ipcc, pdev->dev.of_node); 284 241 if (ret) 285 242 goto err_mbox; 286 243 287 244 ret = devm_request_irq(&pdev->dev, ipcc->irq, qcom_ipcc_irq_fn, 288 - IRQF_TRIGGER_HIGH, "ipcc", ipcc); 245 + IRQF_TRIGGER_HIGH | IRQF_NO_SUSPEND, name, ipcc); 289 246 if (ret < 0) { 290 247 dev_err(&pdev->dev, "Failed to register the irq: %d\n", ret); 291 - goto err_mbox; 248 + goto err_req_irq; 292 249 } 293 250 294 - enable_irq_wake(ipcc->irq); 295 251 platform_set_drvdata(pdev, ipcc); 296 252 297 253 return 0; 298 254 255 + err_req_irq: 256 + if (ipcc->num_chans) 257 + mbox_controller_unregister(&ipcc->mbox); 299 258 err_mbox: 300 259 irq_domain_remove(ipcc->irq_domain); 301 260
+1
drivers/mailbox/zynqmp-ipi-mailbox.c
··· 655 655 mbox->pdata = pdata; 656 656 ret = zynqmp_ipi_mbox_probe(mbox, nc); 657 657 if (ret) { 658 + of_node_put(nc); 658 659 dev_err(dev, "failed to probe subdev.\n"); 659 660 ret = -EINVAL; 660 661 goto free_mbox_dev;
+2
include/dt-bindings/mailbox/qcom-ipcc.h
··· 8 8 9 9 /* Signal IDs for MPROC protocol */ 10 10 #define IPCC_MPROC_SIGNAL_GLINK_QMP 0 11 + #define IPCC_MPROC_SIGNAL_TZ 1 11 12 #define IPCC_MPROC_SIGNAL_SMP2P 2 12 13 #define IPCC_MPROC_SIGNAL_PING 3 13 14 ··· 30 29 #define IPCC_CLIENT_PCIE1 14 31 30 #define IPCC_CLIENT_PCIE2 15 32 31 #define IPCC_CLIENT_SPSS 16 32 + #define IPCC_CLIENT_TME 23 33 33 #define IPCC_CLIENT_WPSS 24 34 34 35 35 #endif