linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: linux-kernel@vger.kernel.org, patrick.rudolph@9elements.com
Cc: coreboot@coreboot.org,
	Patrick Rudolph <patrick.rudolph@9elements.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Allison Randal <allison@lohutok.net>,
	Alexios Zavras <alexios.zavras@intel.com>,
	Julius Werner <jwerner@chromium.org>,
	Samuel Holland <samuel@sholland.org>
Subject: Re: [PATCH v4 2/2] firmware: google: Expose coreboot tables over sysfs
Date: Thu, 25 Jun 2020 00:10:51 -0700	[thread overview]
Message-ID: <159306905194.62212.10204515187655751787@swboyd.mtv.corp.google.com> (raw)
In-Reply-To: <20200407082923.2001556-3-patrick.rudolph@9elements.com>

Quoting patrick.rudolph@9elements.com (2020-04-07 01:29:07)
> From: Patrick Rudolph <patrick.rudolph@9elements.com>
> 
> Make all coreboot table entries available to userland. This is useful for
> tools that are currently using /dev/mem.
> 
> Besides the tag and size also expose the raw table data itself.
> 
> Update the ABI documentation to explain the new sysfs interface.
> 
> Tools can easily scan for the right coreboot table by reading
> /sys/bus/coreboot/devices/coreboot*/attributes/id
> The binary table data can then be read from
> /sys/bus/coreboot/devices/coreboot*/attributes/data
> 
> Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

Minor nits below:

>  -v2:
>         - Add ABI documentation
>         - Add 0x prefix on hex values
>         - Remove wrong ioremap hint as found by CI
>  -v3:
>         - Use BIN_ATTR_RO
>  -v4:
>         - Updated ABI documentation
> ---
>  Documentation/ABI/stable/sysfs-bus-coreboot | 30 +++++++++++
>  drivers/firmware/google/coreboot_table.c    | 58 +++++++++++++++++++++
>  2 files changed, 88 insertions(+)
> 
> diff --git a/Documentation/ABI/stable/sysfs-bus-coreboot b/Documentation/ABI/stable/sysfs-bus-coreboot
> index 6055906f41f2..328153a1b3f4 100644
> --- a/Documentation/ABI/stable/sysfs-bus-coreboot
> +++ b/Documentation/ABI/stable/sysfs-bus-coreboot
> diff --git a/drivers/firmware/google/coreboot_table.c b/drivers/firmware/google/coreboot_table.c
> index 0205987a4fd4..d0fc3eb93f4f 100644
> --- a/drivers/firmware/google/coreboot_table.c
> +++ b/drivers/firmware/google/coreboot_table.c
> @@ -3,9 +3,11 @@
>   * coreboot_table.c
>   *
>   * Module providing coreboot table access.
> + * Exports coreboot tables as attributes in sysfs.
>   *
>   * Copyright 2017 Google Inc.
>   * Copyright 2017 Samuel Holland <samuel@sholland.org>
> + * Copyright 2019 9elements Agency GmbH
>   */
>  
>  #include <linux/acpi.h>
> @@ -84,6 +86,60 @@ void coreboot_driver_unregister(struct coreboot_driver *driver)
>  }
>  EXPORT_SYMBOL(coreboot_driver_unregister);
>  
> +static ssize_t id_show(struct device *dev,
> +                      struct device_attribute *attr, char *buffer)
> +{
> +       struct coreboot_device *device = CB_DEV(dev);

Wouldn't hurt to throw const in front of these.

> +
> +       return sprintf(buffer, "0x%08x\n", device->entry.tag);
> +}
> +
> +static ssize_t size_show(struct device *dev,
> +                        struct device_attribute *attr, char *buffer)
> +{
> +       struct coreboot_device *device = CB_DEV(dev);

And these. But the function is so short probably doesn't really matter.

> +
> +       return sprintf(buffer, "%u\n", device->entry.size);
> +}
> +
> +static DEVICE_ATTR_RO(id);
> +static DEVICE_ATTR_RO(size);
> +
> +static struct attribute *cb_dev_attrs[] = {
> +       &dev_attr_id.attr,
> +       &dev_attr_size.attr,
> +       NULL
> +};
> +
> +static ssize_t data_read(struct file *filp, struct kobject *kobj,
> +                        struct bin_attribute *bin_attr,
> +                        char *buffer, loff_t offset, size_t count)
> +{
> +       struct device *dev = kobj_to_dev(kobj);
> +       struct coreboot_device *device = CB_DEV(dev);
> +
> +       return memory_read_from_buffer(buffer, count, &offset,
> +                                      &device->entry, device->entry.size);
> +}
> +
> +static BIN_ATTR_RO(data, 0);

Still no way to figure out the actual size? Can we add the bin_attribute
at runtime?

> +
> +static struct bin_attribute *cb_dev_bin_attrs[] = {
> +       &bin_attr_data,
> +       NULL
> +};
> +

      parent reply	other threads:[~2020-06-25  7:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07  8:29 [PATCH v4 0/2] firmware: google: Expose coreboot tables and CBMEM patrick.rudolph
2020-04-07  8:29 ` [PATCH v4 1/2] firmware: google: Expose CBMEM over sysfs patrick.rudolph
2020-04-20  0:07   ` Samuel Holland
2020-06-25  7:05   ` Stephen Boyd
2020-06-25 20:51     ` Julius Werner
2020-06-26  7:27       ` Stephen Boyd
2020-07-01  0:22         ` Julius Werner
2020-04-07  8:29 ` [PATCH v4 2/2] firmware: google: Expose coreboot tables " patrick.rudolph
2020-04-20  0:07   ` Samuel Holland
2020-06-25  7:10   ` Stephen Boyd [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=159306905194.62212.10204515187655751787@swboyd.mtv.corp.google.com \
    --to=swboyd@chromium.org \
    --cc=alexios.zavras@intel.com \
    --cc=allison@lohutok.net \
    --cc=coreboot@coreboot.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jwerner@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patrick.rudolph@9elements.com \
    --cc=samuel@sholland.org \
    --cc=tglx@linutronix.de \
    /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).