From: Thierry Reding <thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Jon Hunter <jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Timo Alho <talho-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Peter De Schrijver
<pdeschrijver-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Sivaram Nair <sivaramn-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
Joseph Lo <josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3 05/12] firmware: tegra: Add BPMP support
Date: Mon, 22 Aug 2016 14:54:58 +0200 [thread overview]
Message-ID: <20160822125458.GC17367@ulmo.ba.sec> (raw)
In-Reply-To: <94227d94-1d60-fda7-731b-26656633d585-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 6048 bytes --]
On Mon, Aug 22, 2016 at 10:26:50AM +0100, Jon Hunter wrote:
>
> On 19/08/16 18:32, Thierry Reding wrote:
> > From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> >
> > The Boot and Power Management Processor (BPMP) is a co-processor found
> > on Tegra SoCs. It is designed to handle the early stages of the boot
> > process and offload power management tasks (such as clocks, resets,
> > powergates, ...) as well as system control services.
> >
> > Compared to the ARM SCPI, the services provided by BPMP are message-
> > based rather than method-based. The BPMP firmware driver provides the
> > services to transmit data to and receive data from the BPMP. Users can
> > also register an MRQ, for which a service routine will be run when a
> > corresponding event is received from the firmware.
>
> MRQ?
I think that means "Message ReQuest", which is sort of like an IRQ but
the user will receive a message (with potentially payload) instead. Do
you want me to spell that out in the commit message, or what would you
suggest?
> > diff --git a/drivers/firmware/tegra/Makefile b/drivers/firmware/tegra/Makefile
> > index 92e2153e8173..e34a2f79e1ad 100644
> > --- a/drivers/firmware/tegra/Makefile
> > +++ b/drivers/firmware/tegra/Makefile
> > @@ -1 +1,2 @@
> > +obj-$(CONFIG_TEGRA_BPMP) += bpmp.o
> > obj-$(CONFIG_TEGRA_IVC) += ivc.o
> > diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c
> > new file mode 100644
> > index 000000000000..a09043b1be05
> > --- /dev/null
> > +++ b/drivers/firmware/tegra/bpmp.c
> > @@ -0,0 +1,880 @@
> > +/*
> > + * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> > + *
> > + * This program is free software; you can redistribute it and/or modify it
> > + * under the terms and conditions of the GNU General Public License,
> > + * version 2, as published by the Free Software Foundation.
> > + *
> > + * This program is distributed in the hope it will be useful, but WITHOUT
> > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> > + * more details.
> > + */
> > +
> > +#define DEBUG
>
> I don't think we want DEBUG by default, right?
Yes, that's left-over from debugging.
> > +static int tegra_bpmp_ping(struct tegra_bpmp *bpmp)
> > +{
> > + struct mrq_ping_response response;
> > + struct mrq_ping_request request;
> > + struct tegra_bpmp_message msg;
> > + ktime_t start, delta;
> > + unsigned long flags;
> > + int err;
> > +
> > + memset(&request, 0, sizeof(request));
> > + request.challenge = 1;
> > +
> > + memset(&response, 0, sizeof(response));
> > +
> > + memset(&msg, 0, sizeof(msg));
> > + msg.mrq = MRQ_PING;
> > + msg.tx.data = &request;
> > + msg.tx.size = sizeof(request);
> > + msg.rx.data = &response;
> > + msg.rx.size = sizeof(response);
> > +
> > + start = ktime_get();
> > +
> > + local_irq_save(flags);
> > + err = tegra_bpmp_transfer_atomic(bpmp, &msg);
> > + local_irq_restore(flags);
> > +
> > + delta = ktime_sub(ktime_get(), start);
> > +
> > + if (!err)
> > + dev_info(bpmp->dev,
> > + "ping ok: challenge: %u, response: %u, time: %lld\n",
> > + request.challenge, response.reply,
> > + ktime_to_us(delta));
>
> Should this be a dev_dbg? I guess this only happens on probe.
I suppose you could use this anywhere else, too, just to check that the
BPMP is still responding. But yes, I think making this DEBUG level will
be enough.
>
> > + return err;
> > +}
>
> [snip]
>
> > +static int tegra_bpmp_probe(struct platform_device *pdev)
> > +{
> > + struct tegra_bpmp_channel *channel;
> > + struct tegra_bpmp *bpmp;
> > + struct device_node *np;
> > + struct resource res;
> > + unsigned int i;
> > + char tag[32];
> > + size_t size;
> > + int err;
> > +
> > + bpmp = devm_kzalloc(&pdev->dev, sizeof(*bpmp), GFP_KERNEL);
> > + if (!bpmp)
> > + return -ENOMEM;
> > +
> > + bpmp->soc = of_device_get_match_data(&pdev->dev);
> > + bpmp->dev = &pdev->dev;
> > +
> > + np = of_parse_phandle(pdev->dev.of_node, "shmem", 0);
> > + if (!np)
> > + return -ENOENT;
> > +
> > + of_address_to_resource(np, 0, &res);
> > + of_node_put(np);
> > +
> > + bpmp->tx_base = devm_ioremap_resource(&pdev->dev, &res);
> > + if (IS_ERR(bpmp->tx_base))
> > + return PTR_ERR(bpmp->tx_base);
> > +
> > + np = of_parse_phandle(pdev->dev.of_node, "shmem", 1);
> > + if (!np)
> > + return -ENOENT;
> > +
> > + of_address_to_resource(np, 0, &res);
> > + of_node_put(np);
> > +
> > + bpmp->rx_base = devm_ioremap_resource(&pdev->dev, &res);
> > + if (IS_ERR(bpmp->rx_base))
> > + return PTR_ERR(bpmp->rx_base);
> > +
> > + bpmp->num_channels = bpmp->soc->channels.cpu_tx.count +
> > + bpmp->soc->channels.thread.count +
> > + bpmp->soc->channels.cpu_rx.count;
> > +
> > + bpmp->channels = devm_kcalloc(&pdev->dev, bpmp->num_channels,
> > + sizeof(*channel), GFP_KERNEL);
> > + if (!bpmp->channels)
> > + return -ENOMEM;
> > +
> > + /* mbox registration */
> > + bpmp->mbox.client.dev = &pdev->dev;
> > + bpmp->mbox.client.rx_callback = tegra_bpmp_handle_rx;
> > + bpmp->mbox.client.tx_block = false;
> > + bpmp->mbox.client.knows_txdone = false;
> > +
> > + bpmp->mbox.channel = mbox_request_channel(&bpmp->mbox.client, 0);
> > + if (IS_ERR(bpmp->mbox.channel)) {
> > + err = PTR_ERR(bpmp->mbox.channel);
> > + dev_err(&pdev->dev, "failed to get HSP mailbox: %d\n", err);
> > + return err;
> > + }
> > +
> > + /* message channel initialization */
> > + for (i = 0; i < bpmp->num_channels; i++) {
> > + struct tegra_bpmp_channel *channel = &bpmp->channels[i];
> > +
> > + err = tegra_bpmp_channel_init(channel, bpmp, i);
> > + if (err)
> > + return err;
> > + }
>
> We should make sure we free the mbox if we fail after requesting it.
Yes, will do.
Thanks,
Thierry
>
> Cheers
> Jon
>
> --
> nvpublic
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-08-22 12:54 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 17:32 [PATCH v3 00/12] Initial Tegra186 support Thierry Reding
[not found] ` <20160819173233.13260-1-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-19 17:32 ` [PATCH v3 01/12] dt-bindings: mailbox: Add Tegra HSP binding Thierry Reding
2016-08-19 17:32 ` [PATCH v3 02/12] mailbox: Add Tegra HSP driver Thierry Reding
2016-08-22 13:43 ` Arnd Bergmann
2016-08-22 14:17 ` Thierry Reding
[not found] ` <20160822141728.GF17367-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-08-22 16:42 ` Stephen Warren
[not found] ` <20160819173233.13260-3-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 16:53 ` Stephen Warren
2016-08-23 0:06 ` Sivaram Nair
2016-08-23 0:12 ` Sivaram Nair
2016-08-19 17:32 ` [PATCH v3 03/12] dt-bindings: firmware: Add bindings for Tegra BPMP Thierry Reding
2016-08-19 17:32 ` [PATCH v3 04/12] firmware: tegra: Add IVC library Thierry Reding
[not found] ` <20160819173233.13260-5-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 10:46 ` Jon Hunter
[not found] ` <90222c3a-7c69-6fa3-d161-4ed0c5759f34-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-08-22 12:40 ` Thierry Reding
2016-08-22 18:49 ` Stephen Warren
2016-08-24 15:13 ` Jon Hunter
2016-08-19 17:32 ` [PATCH v3 05/12] firmware: tegra: Add BPMP support Thierry Reding
[not found] ` <20160819173233.13260-6-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 9:26 ` Jon Hunter
[not found] ` <94227d94-1d60-fda7-731b-26656633d585-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-08-22 12:54 ` Thierry Reding [this message]
[not found] ` <20160822125458.GC17367-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-08-22 14:24 ` Jon Hunter
[not found] ` <6bb4d32f-4f13-285e-430e-672f375a9a46-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-08-22 15:00 ` Thierry Reding
2016-08-22 18:51 ` Stephen Warren
2016-08-22 13:34 ` Arnd Bergmann
2016-08-22 14:02 ` Thierry Reding
[not found] ` <20160822140211.GE17367-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-08-22 14:42 ` Arnd Bergmann
2016-08-22 15:32 ` Thierry Reding
[not found] ` <20160822153258.GB21012-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-08-22 15:43 ` Arnd Bergmann
2016-08-22 18:56 ` Stephen Warren
2016-08-23 14:58 ` Arnd Bergmann
2016-08-23 23:26 ` Sivaram Nair
2016-08-22 22:23 ` Stephen Warren
2016-08-19 17:32 ` [PATCH v3 06/12] soc/tegra: Add Tegra186 support Thierry Reding
[not found] ` <20160819173233.13260-7-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 19:01 ` Stephen Warren
2016-08-23 13:44 ` Jon Hunter
2016-08-19 17:32 ` [PATCH v3 07/12] arm64: defconfig: Enable Tegra186 SoC Thierry Reding
[not found] ` <20160819173233.13260-8-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 19:01 ` Stephen Warren
2016-08-19 17:32 ` [PATCH v3 08/12] arm64: dts: tegra: Add Tegra186 support Thierry Reding
[not found] ` <20160819173233.13260-9-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 17:11 ` Stephen Warren
2016-08-22 19:07 ` Stephen Warren
2016-08-19 17:32 ` [PATCH v3 09/12] arm64: dts: tegra: Add NVIDIA P3310 main board support Thierry Reding
[not found] ` <20160819173233.13260-10-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 19:08 ` Stephen Warren
2016-08-23 17:35 ` Jon Hunter
2016-08-19 17:32 ` [PATCH v3 10/12] arm64: dts: tegra: Add NVIDIA P2771 " Thierry Reding
[not found] ` <20160819173233.13260-11-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 19:11 ` Stephen Warren
2016-08-19 17:32 ` [PATCH v3 11/12] clk: tegra: Add BPMP clock driver Thierry Reding
[not found] ` <20160819173233.13260-12-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 10:11 ` Jon Hunter
[not found] ` <0d7080bc-9e82-75dd-7169-0a5b7429801e-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-08-22 13:28 ` Thierry Reding
[not found] ` <20160822132833.GD17367-EkSeR96xj6Pcmrwk2tT4+A@public.gmane.org>
2016-08-23 13:49 ` Jon Hunter
2016-08-22 19:47 ` Stephen Warren
2016-08-19 17:32 ` [PATCH v3 12/12] reset: Add Tegra BPMP reset driver Thierry Reding
[not found] ` <20160819173233.13260-13-thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-22 19:56 ` Stephen Warren
2016-11-26 13:39 ` [PATCH v3 00/12] Initial Tegra186 support Pavel Machek
[not found] ` <20161126133927.GE20568-5NIqAleC692hcjWhqY66xCZi+YwRKgec@public.gmane.org>
2016-11-28 7:33 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160822125458.GC17367@ulmo.ba.sec \
--to=thierry.reding-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=josephl-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pdeschrijver-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=sivaramn-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
--cc=talho-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).