From: Michael Ellerman <mpe@ellerman.id.au>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
"linuxppc-dev@ozlabs.org list" <linuxppc-dev@ozlabs.org>
Cc: Anton Blanchard <anton@au1.ibm.com>
Subject: Re: [v2] powerpc/powernv: Expose OPAL firmware symbol map
Date: Fri, 5 Dec 2014 20:40:54 +1100 (AEDT) [thread overview]
Message-ID: <20141205094054.4536E140120@ozlabs.org> (raw)
In-Reply-To: <1417753577.4741.52.camel@kernel.crashing.org>
On Fri, 2014-05-12 at 04:26:17 UTC, Benjamin Herrenschmidt wrote:
> Newer versions of OPAL will provide this, so let's expose it to user
> space so tools like perf can use it to properly decode samples in
> firmware space.
>
> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
> index 06d9076..98f50e8 100644
> --- a/arch/powerpc/platforms/powernv/opal.c
> +++ b/arch/powerpc/platforms/powernv/opal.c
> @@ -61,6 +61,8 @@ static DEFINE_SPINLOCK(opal_notifier_lock);
> static uint64_t last_notified_mask = 0x0ul;
> static atomic_t opal_notifier_hold = ATOMIC_INIT(0);
> static uint32_t opal_heartbeat;
> +static void *opal_symmap;
> +static uint64_t opal_symmap_size;
We shouldn't need these.
The bin_attribute has a size (you set it), you just need to use it in
symbol_map_read().
And the attribute also has a private pointer, which you can use for
opal_symmap.
> @@ -608,6 +610,40 @@ static int opal_sysfs_init(void)
> return 0;
> }
>
> +static ssize_t symbol_map_read(struct file *fp, struct kobject *kobj,
> + struct bin_attribute *bin_attr,
> + char *buf, loff_t off, size_t count)
> +{
> + return memory_read_from_buffer(buf, count, &off,
> + opal_symmap, opal_symmap_size);
So this would be:
return memory_read_from_buffer(buf, count, &off,
bin_attr->private, bin_attr->size);
> +}
> +
> +static BIN_ATTR_RO(symbol_map, 0);
> +
> +static void opal_export_symmap(void)
> +{
> + const __be64 *syms;
> + unsigned int size;
> + struct device_node *fw;
> + int rc;
> +
> + fw = of_find_node_by_path("/ibm,opal/firmware");
> + if (!fw)
> + return;
> + syms = of_get_property(fw, "symbol-map", &size);
> + if (!syms || size != 2 * sizeof(__be64))
> + return;
> +
> + opal_symmap = __va(be64_to_cpu(syms[0]));
> + opal_symmap_size = be64_to_cpu(syms[1]);
I was going to tell you to use of_property_read_u64_index(), but it doesn't
exist - we can add it one day and clean this up then.
> + /* Setup attributes */
> + bin_attr_symbol_map.size = opal_symmap_size;
> + rc = sysfs_create_bin_file(opal_kobj, &bin_attr_symbol_map);
> + if (rc)
> + pr_warn("Error %d creating OPAL symbols file\n", rc);
Can you prefix it please, so:
pr_warn("opal: Error .."
Or add to the very top of the file:
#define pr_fmt(fmt) "opal: " fmt
cheers
prev parent reply other threads:[~2014-12-05 9:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-05 4:26 [PATCH v2] powerpc/powernv: Expose OPAL firmware symbol map Benjamin Herrenschmidt
2014-12-05 9:40 ` Michael Ellerman [this message]
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=20141205094054.4536E140120@ozlabs.org \
--to=mpe@ellerman.id.au \
--cc=anton@au1.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.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).