Skip to content

Commit 1c1094e

Browse files
committed
Merge tag 'mailbox-v6.4' of git://git.linaro.org/landing-teams/working/fujitsu/integration
Pull mailbox updates from Jassi Brar: - mailbox api: allow direct registration to a channel and convert omap and pcc to use mbox_bind_client - omap and hi6220 : use of_property_read_bool - test: fix double-free and use spinlock header - rockchip and bcm-pdc: drop of_match_ptr - mpfs: change config symbol - mediatek gce: support MT6795 - qcom apcs: consolidate of_device_id and support IPQ9574 * tag 'mailbox-v6.4' of git://git.linaro.org/landing-teams/working/fujitsu/integration: dt-bindings: mailbox: qcom: add compatible for IPQ9574 SoC mailbox: qcom-apcs-ipc: do not grow the of_device_id dt-bindings: mailbox: qcom,apcs-kpss-global: use fallbacks for few variants dt-bindings: mailbox: mediatek,gce-mailbox: Add support for MT6795 mailbox: mpfs: convert SOC_MICROCHIP_POLARFIRE to ARCH_MICROCHIP_POLARFIRE mailbox: bcm-pdc: drop of_match_ptr for ID table mailbox: rockchip: drop of_match_ptr for ID table mailbox: mailbox-test: Fix potential double-free in mbox_test_message_write() mailbox: mailbox-test: Explicitly include header for spinlock support mailbox: Use of_property_read_bool() for boolean properties mailbox: pcc: Use mbox_bind_client mailbox: omap: Use mbox_bind_client mailbox: Allow direct registration to a channel
2 parents 03e5cb7 + d396133 commit 1c1094e

File tree

13 files changed

+288
-122
lines changed

13 files changed

+288
-122
lines changed

Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ description:
1616

1717
properties:
1818
compatible:
19-
enum:
20-
- mediatek,mt6779-gce
21-
- mediatek,mt8173-gce
22-
- mediatek,mt8183-gce
23-
- mediatek,mt8186-gce
24-
- mediatek,mt8188-gce
25-
- mediatek,mt8192-gce
26-
- mediatek,mt8195-gce
19+
oneOf:
20+
- enum:
21+
- mediatek,mt6779-gce
22+
- mediatek,mt8173-gce
23+
- mediatek,mt8183-gce
24+
- mediatek,mt8186-gce
25+
- mediatek,mt8188-gce
26+
- mediatek,mt8192-gce
27+
- mediatek,mt8195-gce
28+
- items:
29+
- const: mediatek,mt6795-gce
30+
- const: mediatek,mt8173-gce
2731

2832
"#mbox-cells":
2933
const: 2

Documentation/devicetree/bindings/mailbox/qcom,apcs-kpss-global.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,15 @@ properties:
1919
- items:
2020
- enum:
2121
- qcom,ipq5332-apcs-apps-global
22+
- qcom,ipq8074-apcs-apps-global
23+
- qcom,ipq9574-apcs-apps-global
2224
- const: qcom,ipq6018-apcs-apps-global
2325
- items:
2426
- enum:
25-
- qcom,ipq6018-apcs-apps-global
26-
- qcom,ipq8074-apcs-apps-global
27-
- qcom,msm8996-apcs-hmss-global
28-
- qcom,msm8998-apcs-hmss-global
29-
- qcom,qcm2290-apcs-hmss-global
3027
- qcom,sc7180-apss-shared
3128
- qcom,sc8180x-apss-shared
32-
- qcom,sdm660-apcs-hmss-global
33-
- qcom,sdm845-apss-shared
34-
- qcom,sm4250-apcs-hmss-global
35-
- qcom,sm6125-apcs-hmss-global
36-
- qcom,sm6115-apcs-hmss-global
3729
- qcom,sm8150-apss-shared
30+
- const: qcom,sdm845-apss-shared
3831
- items:
3932
- enum:
4033
- qcom,msm8916-apcs-kpss-global
@@ -45,6 +38,18 @@ properties:
4538
- qcom,qcs404-apcs-apps-global
4639
- qcom,sdx55-apcs-gcc
4740
- const: syscon
41+
- enum:
42+
- qcom,ipq6018-apcs-apps-global
43+
- qcom,ipq8074-apcs-apps-global
44+
- qcom,msm8996-apcs-hmss-global
45+
- qcom,msm8998-apcs-hmss-global
46+
- qcom,qcm2290-apcs-hmss-global
47+
- qcom,sdm660-apcs-hmss-global
48+
- qcom,sdm845-apss-shared
49+
- qcom,sm4250-apcs-hmss-global
50+
- qcom,sm6115-apcs-hmss-global
51+
- qcom,sm6125-apcs-hmss-global
52+
4853
reg:
4954
maxItems: 1
5055

@@ -88,6 +93,7 @@ allOf:
8893
items:
8994
- const: pll
9095
- const: aux
96+
9197
- if:
9298
properties:
9399
compatible:
@@ -112,7 +118,6 @@ allOf:
112118
contains:
113119
enum:
114120
- qcom,ipq6018-apcs-apps-global
115-
- qcom,ipq8074-apcs-apps-global
116121
then:
117122
properties:
118123
clocks:
@@ -134,14 +139,11 @@ allOf:
134139
- qcom,msm8996-apcs-hmss-global
135140
- qcom,msm8998-apcs-hmss-global
136141
- qcom,qcm2290-apcs-hmss-global
137-
- qcom,sc7180-apss-shared
138-
- qcom,sc8180x-apss-shared
139142
- qcom,sdm660-apcs-hmss-global
140143
- qcom,sdm845-apss-shared
141144
- qcom,sm4250-apcs-hmss-global
142145
- qcom,sm6115-apcs-hmss-global
143146
- qcom,sm6125-apcs-hmss-global
144-
- qcom,sm8150-apss-shared
145147
then:
146148
properties:
147149
clocks: false
@@ -153,7 +155,6 @@ allOf:
153155
contains:
154156
enum:
155157
- qcom,ipq6018-apcs-apps-global
156-
- qcom,ipq8074-apcs-apps-global
157158
then:
158159
properties:
159160
'#clock-cells':

drivers/mailbox/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ config MAILBOX_TEST
176176
config POLARFIRE_SOC_MAILBOX
177177
tristate "PolarFire SoC (MPFS) Mailbox"
178178
depends on HAS_IOMEM
179-
depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST
179+
depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST
180180
help
181181
This driver adds support for the PolarFire SoC (MPFS) mailbox controller.
182182

drivers/mailbox/bcm-pdc-mailbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ static struct platform_driver pdc_mbox_driver = {
16351635
.remove = pdc_remove,
16361636
.driver = {
16371637
.name = "brcm-iproc-pdc-mbox",
1638-
.of_match_table = of_match_ptr(pdc_mbox_of_match),
1638+
.of_match_table = pdc_mbox_of_match,
16391639
},
16401640
};
16411641
module_platform_driver(pdc_mbox_driver);

drivers/mailbox/hi6220-mailbox.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,7 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
325325
writel(~0x0, ACK_INT_CLR_REG(mbox->ipc));
326326

327327
/* use interrupt for tx's ack */
328-
if (of_find_property(node, "hi6220,mbox-tx-noirq", NULL))
329-
mbox->tx_irq_mode = false;
330-
else
331-
mbox->tx_irq_mode = true;
328+
mbox->tx_irq_mode = !of_property_read_bool(node, "hi6220,mbox-tx-noirq");
332329

333330
if (mbox->tx_irq_mode)
334331
mbox->controller.txdone_irq = true;

drivers/mailbox/mailbox-test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
#include <linux/kernel.h>
1313
#include <linux/mailbox_client.h>
1414
#include <linux/module.h>
15+
#include <linux/mutex.h>
1516
#include <linux/of.h>
1617
#include <linux/platform_device.h>
1718
#include <linux/poll.h>
1819
#include <linux/slab.h>
20+
#include <linux/spinlock.h>
1921
#include <linux/uaccess.h>
2022
#include <linux/sched/signal.h>
2123

@@ -38,6 +40,7 @@ struct mbox_test_device {
3840
char *signal;
3941
char *message;
4042
spinlock_t lock;
43+
struct mutex mutex;
4144
wait_queue_head_t waitq;
4245
struct fasync_struct *async_queue;
4346
struct dentry *root_debugfs_dir;
@@ -110,6 +113,8 @@ static ssize_t mbox_test_message_write(struct file *filp,
110113
return -EINVAL;
111114
}
112115

116+
mutex_lock(&tdev->mutex);
117+
113118
tdev->message = kzalloc(MBOX_MAX_MSG_LEN, GFP_KERNEL);
114119
if (!tdev->message)
115120
return -ENOMEM;
@@ -144,6 +149,8 @@ static ssize_t mbox_test_message_write(struct file *filp,
144149
kfree(tdev->message);
145150
tdev->signal = NULL;
146151

152+
mutex_unlock(&tdev->mutex);
153+
147154
return ret < 0 ? ret : count;
148155
}
149156

@@ -392,6 +399,7 @@ static int mbox_test_probe(struct platform_device *pdev)
392399
platform_set_drvdata(pdev, tdev);
393400

394401
spin_lock_init(&tdev->lock);
402+
mutex_init(&tdev->mutex);
395403

396404
if (tdev->rx_channel) {
397405
tdev->rx_buffer = devm_kzalloc(&pdev->dev,

drivers/mailbox/mailbox.c

Lines changed: 68 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,71 @@ int mbox_flush(struct mbox_chan *chan, unsigned long timeout)
317317
}
318318
EXPORT_SYMBOL_GPL(mbox_flush);
319319

320+
static int __mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl)
321+
{
322+
struct device *dev = cl->dev;
323+
unsigned long flags;
324+
int ret;
325+
326+
if (chan->cl || !try_module_get(chan->mbox->dev->driver->owner)) {
327+
dev_dbg(dev, "%s: mailbox not free\n", __func__);
328+
return -EBUSY;
329+
}
330+
331+
spin_lock_irqsave(&chan->lock, flags);
332+
chan->msg_free = 0;
333+
chan->msg_count = 0;
334+
chan->active_req = NULL;
335+
chan->cl = cl;
336+
init_completion(&chan->tx_complete);
337+
338+
if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone)
339+
chan->txdone_method = TXDONE_BY_ACK;
340+
341+
spin_unlock_irqrestore(&chan->lock, flags);
342+
343+
if (chan->mbox->ops->startup) {
344+
ret = chan->mbox->ops->startup(chan);
345+
346+
if (ret) {
347+
dev_err(dev, "Unable to startup the chan (%d)\n", ret);
348+
mbox_free_channel(chan);
349+
return ret;
350+
}
351+
}
352+
353+
return 0;
354+
}
355+
356+
/**
357+
* mbox_bind_client - Request a mailbox channel.
358+
* @chan: The mailbox channel to bind the client to.
359+
* @cl: Identity of the client requesting the channel.
360+
*
361+
* The Client specifies its requirements and capabilities while asking for
362+
* a mailbox channel. It can't be called from atomic context.
363+
* The channel is exclusively allocated and can't be used by another
364+
* client before the owner calls mbox_free_channel.
365+
* After assignment, any packet received on this channel will be
366+
* handed over to the client via the 'rx_callback'.
367+
* The framework holds reference to the client, so the mbox_client
368+
* structure shouldn't be modified until the mbox_free_channel returns.
369+
*
370+
* Return: 0 if the channel was assigned to the client successfully.
371+
* <0 for request failure.
372+
*/
373+
int mbox_bind_client(struct mbox_chan *chan, struct mbox_client *cl)
374+
{
375+
int ret;
376+
377+
mutex_lock(&con_mutex);
378+
ret = __mbox_bind_client(chan, cl);
379+
mutex_unlock(&con_mutex);
380+
381+
return ret;
382+
}
383+
EXPORT_SYMBOL_GPL(mbox_bind_client);
384+
320385
/**
321386
* mbox_request_channel - Request a mailbox channel.
322387
* @cl: Identity of the client requesting the channel.
@@ -340,7 +405,6 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
340405
struct mbox_controller *mbox;
341406
struct of_phandle_args spec;
342407
struct mbox_chan *chan;
343-
unsigned long flags;
344408
int ret;
345409

346410
if (!dev || !dev->of_node) {
@@ -372,33 +436,9 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
372436
return chan;
373437
}
374438

375-
if (chan->cl || !try_module_get(mbox->dev->driver->owner)) {
376-
dev_dbg(dev, "%s: mailbox not free\n", __func__);
377-
mutex_unlock(&con_mutex);
378-
return ERR_PTR(-EBUSY);
379-
}
380-
381-
spin_lock_irqsave(&chan->lock, flags);
382-
chan->msg_free = 0;
383-
chan->msg_count = 0;
384-
chan->active_req = NULL;
385-
chan->cl = cl;
386-
init_completion(&chan->tx_complete);
387-
388-
if (chan->txdone_method == TXDONE_BY_POLL && cl->knows_txdone)
389-
chan->txdone_method = TXDONE_BY_ACK;
390-
391-
spin_unlock_irqrestore(&chan->lock, flags);
392-
393-
if (chan->mbox->ops->startup) {
394-
ret = chan->mbox->ops->startup(chan);
395-
396-
if (ret) {
397-
dev_err(dev, "Unable to startup the chan (%d)\n", ret);
398-
mbox_free_channel(chan);
399-
chan = ERR_PTR(ret);
400-
}
401-
}
439+
ret = __mbox_bind_client(chan, cl);
440+
if (ret)
441+
chan = ERR_PTR(ret);
402442

403443
mutex_unlock(&con_mutex);
404444
return chan;

drivers/mailbox/omap-mailbox.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,6 @@ struct mbox_chan *omap_mbox_request_channel(struct mbox_client *cl,
417417
struct device *dev = cl->dev;
418418
struct omap_mbox *mbox = NULL;
419419
struct omap_mbox_device *mdev;
420-
struct mbox_chan *chan;
421-
unsigned long flags;
422420
int ret;
423421

424422
if (!dev)
@@ -441,23 +439,11 @@ struct mbox_chan *omap_mbox_request_channel(struct mbox_client *cl,
441439
if (!mbox || !mbox->chan)
442440
return ERR_PTR(-ENOENT);
443441

444-
chan = mbox->chan;
445-
spin_lock_irqsave(&chan->lock, flags);
446-
chan->msg_free = 0;
447-
chan->msg_count = 0;
448-
chan->active_req = NULL;
449-
chan->cl = cl;
450-
init_completion(&chan->tx_complete);
451-
spin_unlock_irqrestore(&chan->lock, flags);
452-
453-
ret = chan->mbox->ops->startup(chan);
454-
if (ret) {
455-
pr_err("Unable to startup the chan (%d)\n", ret);
456-
mbox_free_channel(chan);
457-
chan = ERR_PTR(ret);
458-
}
442+
ret = mbox_bind_client(mbox->chan, cl);
443+
if (ret)
444+
return ERR_PTR(ret);
459445

460-
return chan;
446+
return mbox->chan;
461447
}
462448
EXPORT_SYMBOL(omap_mbox_request_channel);
463449

@@ -763,8 +749,7 @@ static int omap_mbox_probe(struct platform_device *pdev)
763749

764750
finfo->name = child->name;
765751

766-
if (of_find_property(child, "ti,mbox-send-noirq", NULL))
767-
finfo->send_no_irq = true;
752+
finfo->send_no_irq = of_property_read_bool(child, "ti,mbox-send-noirq");
768753

769754
if (finfo->tx_id >= num_fifos || finfo->rx_id >= num_fifos ||
770755
finfo->tx_usr >= num_users || finfo->rx_usr >= num_users)

0 commit comments

Comments
 (0)