2023-01-09 22:52:55

by Bjorn Andersson

[permalink] [raw]
Subject: [PATCH 0/6] rpmsg: glink: Misc improvements

This series refactors glink_native to move IRQ and mailbox handling to SMEM and
RPM driver, in preparation for more work. It then introduces the logic to fail
glink transactions and pending intent requests in the event of the edge being
torn down.

Bjorn Andersson (6):
rpmsg: glink: Extract tx kick operation
rpmsg: glink: smem: Wrap driver context
rpmsg: glink: rpm: Wrap driver context
rpmsg: glink: Move irq and mbox handling to transports
rpmsg: glink: Fail qcom_glink_tx() once remove has been initiated
rpmsg: glink: Cancel pending intent requests at removal

drivers/remoteproc/qcom_common.h | 3 +-
drivers/rpmsg/qcom_glink_native.c | 93 ++++++++++-----------
drivers/rpmsg/qcom_glink_native.h | 3 +-
drivers/rpmsg/qcom_glink_rpm.c | 94 ++++++++++++++++-----
drivers/rpmsg/qcom_glink_smem.c | 132 +++++++++++++++++++++++-------
include/linux/rpmsg/qcom_glink.h | 12 +--
6 files changed, 228 insertions(+), 109 deletions(-)

--
2.37.3


2023-01-09 22:53:16

by Bjorn Andersson

[permalink] [raw]
Subject: [PATCH 3/6] rpmsg: glink: rpm: Wrap driver context

As with the SMEM driver update, wrap the RPM context in a struct to
facilitate the upcoming changes of moving IRQ and mailbox registration
to the driver.

Signed-off-by: Bjorn Andersson <[email protected]>
---
drivers/rpmsg/qcom_glink_rpm.c | 44 ++++++++++++++++++++--------------
1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c
index f64f45d1a735..6443843df6ca 100644
--- a/drivers/rpmsg/qcom_glink_rpm.c
+++ b/drivers/rpmsg/qcom_glink_rpm.c
@@ -53,6 +53,13 @@ struct glink_rpm_pipe {
void __iomem *fifo;
};

+struct glink_rpm {
+ struct qcom_glink *glink;
+
+ struct glink_rpm_pipe rx_pipe;
+ struct glink_rpm_pipe tx_pipe;
+};
+
static size_t glink_rpm_rx_avail(struct qcom_glink_pipe *glink_pipe)
{
struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe);
@@ -257,8 +264,7 @@ static int glink_rpm_parse_toc(struct device *dev,
static int glink_rpm_probe(struct platform_device *pdev)
{
struct qcom_glink *glink;
- struct glink_rpm_pipe *rx_pipe;
- struct glink_rpm_pipe *tx_pipe;
+ struct glink_rpm *rpm;
struct device_node *np;
void __iomem *msg_ram;
size_t msg_ram_size;
@@ -266,9 +272,8 @@ static int glink_rpm_probe(struct platform_device *pdev)
struct resource r;
int ret;

- rx_pipe = devm_kzalloc(&pdev->dev, sizeof(*rx_pipe), GFP_KERNEL);
- tx_pipe = devm_kzalloc(&pdev->dev, sizeof(*tx_pipe), GFP_KERNEL);
- if (!rx_pipe || !tx_pipe)
+ rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL);
+ if (!rpm)
return -ENOMEM;

np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", 0);
@@ -283,36 +288,39 @@ static int glink_rpm_probe(struct platform_device *pdev)
return -ENOMEM;

ret = glink_rpm_parse_toc(dev, msg_ram, msg_ram_size,
- rx_pipe, tx_pipe);
+ &rpm->rx_pipe, &rpm->tx_pipe);
if (ret)
return ret;

/* Pipe specific accessors */
- rx_pipe->native.avail = glink_rpm_rx_avail;
- rx_pipe->native.peak = glink_rpm_rx_peak;
- rx_pipe->native.advance = glink_rpm_rx_advance;
- tx_pipe->native.avail = glink_rpm_tx_avail;
- tx_pipe->native.write = glink_rpm_tx_write;
+ rpm->rx_pipe.native.avail = glink_rpm_rx_avail;
+ rpm->rx_pipe.native.peak = glink_rpm_rx_peak;
+ rpm->rx_pipe.native.advance = glink_rpm_rx_advance;
+ rpm->tx_pipe.native.avail = glink_rpm_tx_avail;
+ rpm->tx_pipe.native.write = glink_rpm_tx_write;

- writel(0, tx_pipe->head);
- writel(0, rx_pipe->tail);
+ writel(0, rpm->tx_pipe.head);
+ writel(0, rpm->rx_pipe.tail);

- glink = qcom_glink_native_probe(&pdev->dev,
+ glink = qcom_glink_native_probe(dev,
0,
- &rx_pipe->native,
- &tx_pipe->native,
+ &rpm->rx_pipe.native,
+ &rpm->tx_pipe.native,
true);
if (IS_ERR(glink))
return PTR_ERR(glink);

- platform_set_drvdata(pdev, glink);
+ rpm->glink = glink;
+
+ platform_set_drvdata(pdev, rpm);

return 0;
}

static int glink_rpm_remove(struct platform_device *pdev)
{
- struct qcom_glink *glink = platform_get_drvdata(pdev);
+ struct glink_rpm *rpm = platform_get_drvdata(pdev);
+ struct qcom_glink *glink = rpm->glink;

qcom_glink_native_remove(glink);

--
2.37.3

2023-01-09 22:54:21

by Bjorn Andersson

[permalink] [raw]
Subject: [PATCH 1/6] rpmsg: glink: Extract tx kick operation

Refactor out the tx kick operations to its own function, in preparation
for pushing the details to the individual transports.

Signed-off-by: Bjorn Andersson <[email protected]>
---
drivers/rpmsg/qcom_glink_native.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 115c0a1eddb1..5fd8b70271b7 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -303,6 +303,12 @@ static void qcom_glink_tx_write(struct qcom_glink *glink,
glink->tx_pipe->write(glink->tx_pipe, hdr, hlen, data, dlen);
}

+static void qcom_glink_tx_kick(struct qcom_glink *glink)
+{
+ mbox_send_message(glink->mbox_chan, NULL);
+ mbox_client_txdone(glink->mbox_chan, 0);
+}
+
static void qcom_glink_send_read_notify(struct qcom_glink *glink)
{
struct glink_msg msg;
@@ -313,8 +319,7 @@ static void qcom_glink_send_read_notify(struct qcom_glink *glink)

qcom_glink_tx_write(glink, &msg, sizeof(msg), NULL, 0);

- mbox_send_message(glink->mbox_chan, NULL);
- mbox_client_txdone(glink->mbox_chan, 0);
+ qcom_glink_tx_kick(glink);
}

static int qcom_glink_tx(struct qcom_glink *glink,
@@ -355,9 +360,7 @@ static int qcom_glink_tx(struct qcom_glink *glink,
}

qcom_glink_tx_write(glink, hdr, hlen, data, dlen);
-
- mbox_send_message(glink->mbox_chan, NULL);
- mbox_client_txdone(glink->mbox_chan, 0);
+ qcom_glink_tx_kick(glink);

out:
spin_unlock_irqrestore(&glink->tx_lock, flags);
@@ -1046,9 +1049,7 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data)
break;
case RPM_CMD_READ_NOTIF:
qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
-
- mbox_send_message(glink->mbox_chan, NULL);
- mbox_client_txdone(glink->mbox_chan, 0);
+ qcom_glink_tx_kick(glink);
break;
case RPM_CMD_INTENT:
qcom_glink_handle_intent(glink, param1, param2, avail);
--
2.37.3

2023-01-25 06:36:10

by Chris Lew

[permalink] [raw]
Subject: Re: [PATCH 1/6] rpmsg: glink: Extract tx kick operation



On 1/9/2023 2:39 PM, Bjorn Andersson wrote:
> Refactor out the tx kick operations to its own function, in preparation
> for pushing the details to the individual transports.
>
> Signed-off-by: Bjorn Andersson <[email protected]>
> ---

Reviewed-by: Chris Lew <[email protected]>

> drivers/rpmsg/qcom_glink_native.c | 17 +++++++++--------
> 1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index 115c0a1eddb1..5fd8b70271b7 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -303,6 +303,12 @@ static void qcom_glink_tx_write(struct qcom_glink *glink,
> glink->tx_pipe->write(glink->tx_pipe, hdr, hlen, data, dlen);
> }
>
> +static void qcom_glink_tx_kick(struct qcom_glink *glink)
> +{
> + mbox_send_message(glink->mbox_chan, NULL);
> + mbox_client_txdone(glink->mbox_chan, 0);
> +}
> +
> static void qcom_glink_send_read_notify(struct qcom_glink *glink)
> {
> struct glink_msg msg;
> @@ -313,8 +319,7 @@ static void qcom_glink_send_read_notify(struct qcom_glink *glink)
>
> qcom_glink_tx_write(glink, &msg, sizeof(msg), NULL, 0);
>
> - mbox_send_message(glink->mbox_chan, NULL);
> - mbox_client_txdone(glink->mbox_chan, 0);
> + qcom_glink_tx_kick(glink);
> }
>
> static int qcom_glink_tx(struct qcom_glink *glink,
> @@ -355,9 +360,7 @@ static int qcom_glink_tx(struct qcom_glink *glink,
> }
>
> qcom_glink_tx_write(glink, hdr, hlen, data, dlen);
> -
> - mbox_send_message(glink->mbox_chan, NULL);
> - mbox_client_txdone(glink->mbox_chan, 0);
> + qcom_glink_tx_kick(glink);
>
> out:
> spin_unlock_irqrestore(&glink->tx_lock, flags);
> @@ -1046,9 +1049,7 @@ static irqreturn_t qcom_glink_native_intr(int irq, void *data)
> break;
> case RPM_CMD_READ_NOTIF:
> qcom_glink_rx_advance(glink, ALIGN(sizeof(msg), 8));
> -
> - mbox_send_message(glink->mbox_chan, NULL);
> - mbox_client_txdone(glink->mbox_chan, 0);
> + qcom_glink_tx_kick(glink);
> break;
> case RPM_CMD_INTENT:
> qcom_glink_handle_intent(glink, param1, param2, avail);

2023-01-25 07:11:09

by Chris Lew

[permalink] [raw]
Subject: Re: [PATCH 3/6] rpmsg: glink: rpm: Wrap driver context



On 1/9/2023 2:39 PM, Bjorn Andersson wrote:
> As with the SMEM driver update, wrap the RPM context in a struct to
> facilitate the upcoming changes of moving IRQ and mailbox registration
> to the driver.
>
> Signed-off-by: Bjorn Andersson <[email protected]>
> ---

Reviewed-by: Chris Lew <[email protected]>

> drivers/rpmsg/qcom_glink_rpm.c | 44 ++++++++++++++++++++--------------
> 1 file changed, 26 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c
> index f64f45d1a735..6443843df6ca 100644
> --- a/drivers/rpmsg/qcom_glink_rpm.c
> +++ b/drivers/rpmsg/qcom_glink_rpm.c
> @@ -53,6 +53,13 @@ struct glink_rpm_pipe {
> void __iomem *fifo;
> };
>
> +struct glink_rpm {
> + struct qcom_glink *glink;
> +
> + struct glink_rpm_pipe rx_pipe;
> + struct glink_rpm_pipe tx_pipe;
> +};
> +
> static size_t glink_rpm_rx_avail(struct qcom_glink_pipe *glink_pipe)
> {
> struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe);
> @@ -257,8 +264,7 @@ static int glink_rpm_parse_toc(struct device *dev,
> static int glink_rpm_probe(struct platform_device *pdev)
> {
> struct qcom_glink *glink;
> - struct glink_rpm_pipe *rx_pipe;
> - struct glink_rpm_pipe *tx_pipe;
> + struct glink_rpm *rpm;
> struct device_node *np;
> void __iomem *msg_ram;
> size_t msg_ram_size;
> @@ -266,9 +272,8 @@ static int glink_rpm_probe(struct platform_device *pdev)
> struct resource r;
> int ret;
>
> - rx_pipe = devm_kzalloc(&pdev->dev, sizeof(*rx_pipe), GFP_KERNEL);
> - tx_pipe = devm_kzalloc(&pdev->dev, sizeof(*tx_pipe), GFP_KERNEL);
> - if (!rx_pipe || !tx_pipe)
> + rpm = devm_kzalloc(&pdev->dev, sizeof(*rpm), GFP_KERNEL);
> + if (!rpm)
> return -ENOMEM;
>
> np = of_parse_phandle(dev->of_node, "qcom,rpm-msg-ram", 0);
> @@ -283,36 +288,39 @@ static int glink_rpm_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> ret = glink_rpm_parse_toc(dev, msg_ram, msg_ram_size,
> - rx_pipe, tx_pipe);
> + &rpm->rx_pipe, &rpm->tx_pipe);
> if (ret)
> return ret;
>
> /* Pipe specific accessors */
> - rx_pipe->native.avail = glink_rpm_rx_avail;
> - rx_pipe->native.peak = glink_rpm_rx_peak;
> - rx_pipe->native.advance = glink_rpm_rx_advance;
> - tx_pipe->native.avail = glink_rpm_tx_avail;
> - tx_pipe->native.write = glink_rpm_tx_write;
> + rpm->rx_pipe.native.avail = glink_rpm_rx_avail;
> + rpm->rx_pipe.native.peak = glink_rpm_rx_peak;
> + rpm->rx_pipe.native.advance = glink_rpm_rx_advance;
> + rpm->tx_pipe.native.avail = glink_rpm_tx_avail;
> + rpm->tx_pipe.native.write = glink_rpm_tx_write;
>
> - writel(0, tx_pipe->head);
> - writel(0, rx_pipe->tail);
> + writel(0, rpm->tx_pipe.head);
> + writel(0, rpm->rx_pipe.tail);
>
> - glink = qcom_glink_native_probe(&pdev->dev,
> + glink = qcom_glink_native_probe(dev,
> 0,
> - &rx_pipe->native,
> - &tx_pipe->native,
> + &rpm->rx_pipe.native,
> + &rpm->tx_pipe.native,
> true);
> if (IS_ERR(glink))
> return PTR_ERR(glink);
>
> - platform_set_drvdata(pdev, glink);
> + rpm->glink = glink;
> +
> + platform_set_drvdata(pdev, rpm);
>
> return 0;
> }
>
> static int glink_rpm_remove(struct platform_device *pdev)
> {
> - struct qcom_glink *glink = platform_get_drvdata(pdev);
> + struct glink_rpm *rpm = platform_get_drvdata(pdev);
> + struct qcom_glink *glink = rpm->glink;
>
> qcom_glink_native_remove(glink);
>