All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org
Cc: pierre-louis.bossart@linux.intel.com,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	andriy.shevchenko@linux.intel.com, filip.kaczmarski@intel.com,
	harshapriya.n@intel.com, gregkh@linuxfoundation.org,
	marcin.barlik@intel.com, zwisler@google.com, lgirdwood@gmail.com,
	tiwai@suse.com, filip.proborszcz@intel.com, broonie@kernel.org,
	amadeuszx.slawinski@linux.intel.com, michal.wasko@intel.com,
	cujomalainey@chromium.org, krzysztof.hejmowski@intel.com,
	ppapierkowski@habana.ai, vamshi.krishna.gopal@intel.com
Subject: [PATCH v9 09/14] ASoC: Intel: catpt: Simple sysfs attributes
Date: Sat, 26 Sep 2020 10:59:05 +0200	[thread overview]
Message-ID: <20200926085910.21948-10-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20200926085910.21948-1-cezary.rojewski@intel.com>

Add sysfs entries for displaying version of FW currently in use as well
as dumping full FW information including build and log-providers hashes.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

Changes in v9:
- fixed newlines in sysfs as requested by Andy, left tags as no other
  changes done

Changes in v7:
- fixed licence header for fs.c
- renamed fs.c to sysfs.c to better match its purpose
- added documentation within Documentation/ABI/testing for entries
  exposed by catpt
- bin_attribute fw_build replaced by attribute fw_info:
  fw_info contains full FW information and after successful handshake,
  it's always available (stored in driver data) so no need to invoke
  GET_FW_VERSION IPC again, just dump the stored information
- rather than manually creating and removing sysfs files, now makes use
  of dev_groups member of struct device_driver 

Changes in v6:
- functions declaration and usage now part of this patch instead of
  being separated from it

Changes in v2:
- fixed size provided to memcpy() in fw_build_read() as reported by Mark

 .../ABI/testing/sysfs-bus-pci-devices-catpt   | 16 ++++++
 sound/soc/intel/catpt/core.h                  |  2 +
 sound/soc/intel/catpt/device.c                |  1 +
 sound/soc/intel/catpt/sysfs.c                 | 55 +++++++++++++++++++
 4 files changed, 74 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-bus-pci-devices-catpt
 create mode 100644 sound/soc/intel/catpt/sysfs.c

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-catpt b/Documentation/ABI/testing/sysfs-bus-pci-devices-catpt
new file mode 100644
index 000000000000..8a200f4eefbd
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-catpt
@@ -0,0 +1,16 @@
+What:		/sys/devices/pci0000:00/<dev>/fw_version
+Date:		September 2020
+Contact:	Cezary Rojewski <cezary.rojewski@intel.com>
+Description:
+		Version of AudioDSP firmware ASoC catpt driver is
+		communicating with.
+		Format: %d.%d.%d.%d, type:major:minor:build.
+
+What:		/sys/devices/pci0000:00/<dev>/fw_info
+Date:		September 2020
+Contact:	Cezary Rojewski <cezary.rojewski@intel.com>
+Description:
+		Detailed AudioDSP firmware build information including
+		build hash and log-providers hash. This information is
+		obtained during initial handshake with firmware.
+		Format: %s.
diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h
index a29b4c0232cb..88dc3fb6306f 100644
--- a/sound/soc/intel/catpt/core.h
+++ b/sound/soc/intel/catpt/core.h
@@ -15,6 +15,8 @@
 
 struct catpt_dev;
 
+extern const struct attribute_group *catpt_attr_groups[];
+
 void catpt_sram_init(struct resource *sram, u32 start, u32 size);
 void catpt_sram_free(struct resource *sram);
 struct resource *
diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
index 0d2dd919de8d..390ffb203de0 100644
--- a/sound/soc/intel/catpt/device.c
+++ b/sound/soc/intel/catpt/device.c
@@ -342,6 +342,7 @@ static struct platform_driver catpt_acpi_driver = {
 		.name = "intel_catpt",
 		.acpi_match_table = catpt_ids,
 		.pm = &catpt_dev_pm,
+		.dev_groups = catpt_attr_groups,
 	},
 };
 module_platform_driver(catpt_acpi_driver);
diff --git a/sound/soc/intel/catpt/sysfs.c b/sound/soc/intel/catpt/sysfs.c
new file mode 100644
index 000000000000..9579e233a15d
--- /dev/null
+++ b/sound/soc/intel/catpt/sysfs.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright(c) 2020 Intel Corporation. All rights reserved.
+//
+// Author: Cezary Rojewski <cezary.rojewski@intel.com>
+//
+
+#include <linux/pm_runtime.h>
+#include "core.h"
+
+static ssize_t fw_version_show(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	struct catpt_dev *cdev = dev_get_drvdata(dev);
+	struct catpt_fw_version version;
+	int ret;
+
+	pm_runtime_get_sync(cdev->dev);
+
+	ret = catpt_ipc_get_fw_version(cdev, &version);
+
+	pm_runtime_mark_last_busy(cdev->dev);
+	pm_runtime_put_autosuspend(cdev->dev);
+
+	if (ret)
+		return CATPT_IPC_ERROR(ret);
+
+	return sprintf(buf, "%d.%d.%d.%d\n", version.type, version.major,
+		       version.minor, version.build);
+}
+static DEVICE_ATTR_RO(fw_version);
+
+static ssize_t fw_info_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	struct catpt_dev *cdev = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%s\n", cdev->ipc.config.fw_info);
+}
+static DEVICE_ATTR_RO(fw_info);
+
+static struct attribute *catpt_attrs[] = {
+	&dev_attr_fw_version.attr,
+	&dev_attr_fw_info.attr,
+	NULL
+};
+
+static const struct attribute_group catpt_attr_group = {
+	.attrs = catpt_attrs,
+};
+
+const struct attribute_group *catpt_attr_groups[] = {
+	&catpt_attr_group,
+	NULL
+};
-- 
2.17.1


  parent reply	other threads:[~2020-09-26  9:06 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-26  8:58 [PATCH v9 00/14] ASoC: Intel: Catpt - Lynx and Wildcat point Cezary Rojewski
2020-09-26  8:58 ` [PATCH v9 01/14] ASoC: Intel: Add catpt base members Cezary Rojewski
2020-09-26  8:58 ` [PATCH v9 02/14] ASoC: Intel: catpt: Implement IPC protocol Cezary Rojewski
2020-09-28 13:44   ` Andy Shevchenko
2020-09-28 16:52     ` Rojewski, Cezary
2020-09-29  8:46       ` Andy Shevchenko
2020-09-29  9:39         ` Rojewski, Cezary
2020-09-29 10:43           ` Andy Shevchenko
2020-09-26  8:58 ` [PATCH v9 03/14] ASoC: Intel: catpt: Add IPC message handlers Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 04/14] ASoC: Intel: catpt: Define DSP operations Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 05/14] ASoC: Intel: catpt: Firmware loading and context restore Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 06/14] ASoC: Intel: catpt: PCM operations Cezary Rojewski
2020-09-29 11:33   ` Andy Shevchenko
2020-09-29 13:26     ` Rojewski, Cezary
2020-09-29 16:46       ` Andy Shevchenko
2020-09-26  8:59 ` [PATCH v9 07/14] ASoC: Intel: catpt: Device driver lifecycle Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 08/14] ASoC: Intel: catpt: Event tracing Cezary Rojewski
2020-09-26  8:59 ` Cezary Rojewski [this message]
2020-09-28 13:03   ` [PATCH v9 09/14] ASoC: Intel: catpt: Simple sysfs attributes Andy Shevchenko
2020-09-26  8:59 ` [PATCH v9 10/14] ASoC: Intel: haswell: Remove haswell-solution specific code Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 11/14] ASoC: Intel: broadwell: " Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 12/14] ASoC: Intel: bdw-5650: " Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 13/14] ASoC: Intel: bdw-5677: " Cezary Rojewski
2020-09-26  8:59 ` [PATCH v9 14/14] ASoC: Intel: Select catpt and deprecate haswell Cezary Rojewski
2020-09-29 11:49   ` Amadeusz Sławiński
2020-09-29 13:09     ` Rojewski, Cezary
2020-09-29 13:38       ` Rojewski, Cezary

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=20200926085910.21948-10-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cujomalainey@chromium.org \
    --cc=filip.kaczmarski@intel.com \
    --cc=filip.proborszcz@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=harshapriya.n@intel.com \
    --cc=krzysztof.hejmowski@intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=marcin.barlik@intel.com \
    --cc=michal.wasko@intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ppapierkowski@habana.ai \
    --cc=tiwai@suse.com \
    --cc=vamshi.krishna.gopal@intel.com \
    --cc=zwisler@google.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.