All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: alsa-devel@alsa-project.org, broonie@kernel.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	hdegoede@redhat.com, amadeuszx.slawinski@linux.intel.com
Subject: [PATCH v2 04/16] ASoC: Intel: avs: Introduce avs_log_buffer_status_locked()
Date: Fri,  2 Dec 2022 16:28:29 +0100	[thread overview]
Message-ID: <20221202152841.672536-5-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20221202152841.672536-1-cezary.rojewski@intel.com>

Simplify locking of firmware log gathering by providing single location
for such purpose.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/apl.c |  5 +----
 sound/soc/intel/avs/avs.h | 12 ++++++++++++
 sound/soc/intel/avs/ipc.c |  2 +-
 sound/soc/intel/avs/skl.c |  7 +------
 4 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/sound/soc/intel/avs/apl.c b/sound/soc/intel/avs/apl.c
index 7c8ce98eda9d..821d5a9ad25f 100644
--- a/sound/soc/intel/avs/apl.c
+++ b/sound/soc/intel/avs/apl.c
@@ -50,7 +50,6 @@ static int apl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32
 static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
 {
 	struct apl_log_buffer_layout layout;
-	unsigned long flags;
 	void __iomem *addr, *buf;
 
 	addr = avs_log_buffer_addr(adev, msg->log.core);
@@ -59,7 +58,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg
 
 	memcpy_fromio(&layout, addr, sizeof(layout));
 
-	spin_lock_irqsave(&adev->dbg.trace_lock, flags);
 	if (!kfifo_initialized(&adev->dbg.trace_fifo))
 		/* consume the logs regardless of consumer presence */
 		goto update_read_ptr;
@@ -78,7 +76,6 @@ static int apl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg
 	wake_up(&adev->dbg.trace_waitq);
 
 update_read_ptr:
-	spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
 	writel(layout.write_ptr, addr);
 	return 0;
 }
@@ -140,7 +137,7 @@ static int apl_coredump(struct avs_dev *adev, union avs_notify_msg *msg)
 		 * gathered before dumping stack
 		 */
 		lbs_msg.log.core = msg->ext.coredump.core_id;
-		avs_dsp_op(adev, log_buffer_status, &lbs_msg);
+		avs_log_buffer_status_locked(adev, &lbs_msg);
 	}
 
 	pos = dump + AVS_FW_REGS_SIZE;
diff --git a/sound/soc/intel/avs/avs.h b/sound/soc/intel/avs/avs.h
index 8d05b27608fe..1c89af6240d2 100644
--- a/sound/soc/intel/avs/avs.h
+++ b/sound/soc/intel/avs/avs.h
@@ -344,6 +344,18 @@ unsigned int __kfifo_fromio_locked(struct kfifo *fifo, const void __iomem *src,
 			 (avs_sram_addr(adev, AVS_DEBUG_WINDOW) + __offset); \
 })
 
+static inline int avs_log_buffer_status_locked(struct avs_dev *adev, union avs_notify_msg *msg)
+{
+	unsigned long flags;
+	int ret;
+
+	spin_lock_irqsave(&adev->dbg.trace_lock, flags);
+	ret = avs_dsp_op(adev, log_buffer_status, msg);
+	spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
+
+	return ret;
+}
+
 struct apl_log_buffer_layout {
 	u32 read_ptr;
 	u32 write_ptr;
diff --git a/sound/soc/intel/avs/ipc.c b/sound/soc/intel/avs/ipc.c
index af8a260093f4..bdf013c3dd12 100644
--- a/sound/soc/intel/avs/ipc.c
+++ b/sound/soc/intel/avs/ipc.c
@@ -266,7 +266,7 @@ static void avs_dsp_process_notification(struct avs_dev *adev, u64 header)
 		break;
 
 	case AVS_NOTIFY_LOG_BUFFER_STATUS:
-		avs_dsp_op(adev, log_buffer_status, &msg);
+		avs_log_buffer_status_locked(adev, &msg);
 		break;
 
 	case AVS_NOTIFY_EXCEPTION_CAUGHT:
diff --git a/sound/soc/intel/avs/skl.c b/sound/soc/intel/avs/skl.c
index dc98b5cf900f..ff690e99d960 100644
--- a/sound/soc/intel/avs/skl.c
+++ b/sound/soc/intel/avs/skl.c
@@ -55,15 +55,11 @@ int skl_log_buffer_offset(struct avs_dev *adev, u32 core)
 static int
 skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
 {
-	unsigned long flags;
 	void __iomem *buf;
 	u16 size, write, offset;
 
-	spin_lock_irqsave(&adev->dbg.trace_lock, flags);
-	if (!kfifo_initialized(&adev->dbg.trace_fifo)) {
-		spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
+	if (!kfifo_initialized(&adev->dbg.trace_fifo))
 		return 0;
-	}
 
 	size = avs_log_buffer_size(adev) / 2;
 	write = readl(avs_sram_addr(adev, AVS_FW_REGS_WINDOW) + FW_REGS_DBG_LOG_WP(msg->log.core));
@@ -74,7 +70,6 @@ skl_log_buffer_status(struct avs_dev *adev, union avs_notify_msg *msg)
 	buf = avs_log_buffer_addr(adev, msg->log.core) + offset;
 	__kfifo_fromio_locked(&adev->dbg.trace_fifo, buf, size, &adev->dbg.fifo_lock);
 	wake_up(&adev->dbg.trace_waitq);
-	spin_unlock_irqrestore(&adev->dbg.trace_lock, flags);
 
 	return 0;
 }
-- 
2.25.1


  parent reply	other threads:[~2022-12-02 15:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 15:28 [PATCH v2 00/16] ASoC: Intel: avs: Data probing and fw logging Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 01/16] ALSA: hda: Allow for compress stream to hdac_ext_stream assignment Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 02/16] ALSA: hda: Prepare for compress stream support Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 03/16] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2022-12-02 15:28 ` Cezary Rojewski [this message]
2022-12-02 15:28 ` [PATCH v2 05/16] ASoC: Intel: avs: Drop fifo_lock Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 06/16] ASoC: Intel: avs: Introduce debug-context aware helpers Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 07/16] ASoC: Intel: avs: Make enable_logs() dependent on DEBUG_FS Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 08/16] ASoC: Intel: avs: Drop usage of debug members in non-debug code Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 09/16] ASoC: Intel: avs: Add data probing requests Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 10/16] ASoC: Intel: avs: Probe compress operations Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 11/16] ASoC: Intel: avs: Data probing soc-component Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 12/16] ASoC: Intel: avs: Add probe machine board Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 13/16] ASoC: Intel: avs: Probing and firmware tracing over debugfs Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 14/16] ASoC: Intel: avs: Gather remaining logs on strace_release() Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 15/16] ASoC: Intel: avs: Allow for dumping FW_REGS area Cezary Rojewski
2022-12-02 15:28 ` [PATCH v2 16/16] ASoC: Intel: avs: Allow for dumping debug window snapshot Cezary Rojewski
2022-12-05 19:02 ` [PATCH v2 00/16] ASoC: Intel: avs: Data probing and fw logging Mark Brown

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=20221202152841.672536-5-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.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.