From nobody Mon May 25 05:54:12 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D781314A95 for ; Mon, 18 May 2026 09:39:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097193; cv=none; b=aSp8Bj7BLCRVNgGZMXvK+tmxwMB04hPZls2itS0oDibPmo9KfnFxxm0k1raEhWfUXZ2nt5caFwgrlQdgS7AaLvlIMIdOT9F+xP+mDU7IZ2rsYZ90peGmCIEcqPYq2T0ZkYGKck0RjZk2cDOsNJwr/l11cwY4zEgjTSIdNTVyn8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779097193; c=relaxed/simple; bh=d9VWM5r7b8HFxhB2mnvl/vovRf4IFGuHWik9LcA6YJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XuC3Wx00sqV9TiVSItFqGb8JoH5645HeWqTy7/jiBIWsUzigOQT6t5pI/7ZJWUmzYVLxbHZxyigHE0LuWKBM3JL4LanYEL6y92EMv0rIG01jrIxiYjcnMuhBx5avmly/m2XUZiTjJPH+3v9RcM39mM5BcQf2bzKRZ4SagD3KWZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Qwc2RtEh; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qwc2RtEh" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-449cdc12a8aso272169f8f.2 for ; Mon, 18 May 2026 02:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779097190; x=1779701990; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GxdjSCoSHRAw2soZ2duKpNm8mf0V8MJVumP3dJOuQ34=; b=Qwc2RtEhdfmsh7cyrBmYfW1JasgYpxL6cC4kSHtJDLefnivlvwF3I1JTYcngj+1s05 kOcRcK9Bfbq/qq0eZQYlXZEe2jyMmKnRS59jpXimmcDsrOaER/aKQdLcXO5azq42jK5O Fwq0VR8ZJkPLiq9libJJ6mxpgx0ekfKA4AQGrGLHblwsJIO6+1rZhUpZsnAhg6KHBiky mLN8Y5fS7rtK+jG1p2SGghZOlWHVsaxurfYorYNU9gst9vgqGfsMaoHYtwHIywwz0xGP B1/+BNnPx+y/rEt5e4PgJjqWboSuWMFm9wKapcz397pDJK/5tgS27Fo0XW5Vnlm9QYIE AYXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779097190; x=1779701990; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=GxdjSCoSHRAw2soZ2duKpNm8mf0V8MJVumP3dJOuQ34=; b=lDksCFKUIuCWyCQMORwVROLSYf9tn3yil2Ml3wwVaRaEc1KIpyR9gzfG2N6mO6NjIv Vqcj8fmm1yB77hAjoy2qLRZLaMkj6cZopqJd7pYE3bijNhhxpyUWieqqTaA9B5Q0gpl0 5bpJRR8FghI5yyppi9xiPIyXQcKV+56NuqWqZpwePCORDzXbDfTg7M+/cVEarktUUgva nCgvSwZQNsTPJm2jiZnYhWH9j8kklGSemw32mVK2k1Sja2qQ9j5Rd0loePRQ2gdnHc08 AaIEYkVZe9IEzYVnCjRQ82jQR+l/K2hLqc664SneJSO77m6YOqFH2sG4Nwgkci2bJWzf n1Pw== X-Forwarded-Encrypted: i=1; AFNElJ8LZJazKrmrDWQbRIUWVg0gk0a9+duF1Mie0y3sGrwQcfdS0jWO/s9X9rJwK6nOawMe0CW3oaakEBBabqw=@vger.kernel.org X-Gm-Message-State: AOJu0YzYKo1GmRRrTErAbjAhuvtz6Ub5gGlPGpV2OI5e3vWwpGp+AkYz PhY1Y0N8C9uOylXgfkWNB4+4NaxgllQggCAqxKgWCQFDayNKi1F3e8nG X-Gm-Gg: Acq92OHGKBMywdJ7ohCn5Yg9PKxxysVa4mCWzG9Y7hJMMVZVAxCBrv2qKWGg/C1LaHk LRAzYGIePqThxnfGEGJ7GVpgvbHzXV4WIoIRc7sJPMW2ewwQ7C3dGYG5v7m1+VehUm3Lxwc+/Lh mQPSdLtH8ifEIJnoeWByylOcNnflR/KFtoeNwWJ4A4KSqvQW+0fTzRN9a4BtDNNkmQ6yowcsbZl c0q+xTHs+4tlb3zWWNk5jN2JgRs8cZO1AJMtulfeGE0EpX5tvQ/4BsL1GscHRKeOqYOMztBnORz h3/KvBFxLaF6JFmz5NFn+piHZH0PsjN7FSKt+7ze/9aEJb8WxhsHW7zSmkAeeD5BhUa6bQJQhDk TOIvOjHAi0SxtzmymrihhhoEsZASYnjsK3K83Lih27HN9HSF/wkQ6rH4PgzMH7EGtkUG4ZqfQFD MC+dWg1zlZBsT/PxRKhW7VYytcGOaKQDOP+PnNQOfdUXY0 X-Received: by 2002:a05:600c:3594:b0:490:502:8422 with SMTP id 5b1f17b1804b1-4900d55ec74mr24159285e9.6.1779097189418; Mon, 18 May 2026 02:39:49 -0700 (PDT) Received: from localhost.localdomain ([82.215.118.79]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fe4862209sm245408615e9.0.2026.05.18.02.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 02:39:48 -0700 (PDT) From: Stepan Ionichev To: Frank.Li@nxp.com Cc: peng.fan@oss.nxp.com, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, shawnguo@kernel.org, gregkh@linuxfoundation.org, hcazarim@yahoo.com, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sozdayvek@gmail.com Subject: [PATCH v2] firmware: imx: scu-irq: drop wakeup_src sysfs file, log via dev_dbg() Date: Mon, 18 May 2026 14:39:33 +0500 Message-Id: <20260518093934.1910-1-sozdayvek@gmail.com> X-Mailer: git-send-email 2.33.0.windows.2 In-Reply-To: <20260515175002.34853-1-sozdayvek@gmail.com> References: <20260515175002.34853-1-sozdayvek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" wakeup_source_show() walks all IMX_SC_IRQ_NUM_GROUP groups and rewrites buf from offset 0 each iteration, so userspace reading /sys/firmware/scu_wakeup_source/wakeup_src only ever sees the last group reported, and the trailing strlen(buf) reports only that line length. sprintf() is also unbounded against the sysfs PAGE_SIZE buffer. The attribute is not documented under Documentation/ABI/ and a code search across GitHub and Debian found no out-of-tree consumers. Peng Fan (NXP) confirmed it is safe to drop. Remove the attribute, the supporting kobject and the per-group valid/wakeup_src state used only to feed it. Log the same wakeup information via dev_dbg() from imx_scu_irq_work_handler() so it can be enabled dynamically when needed. Fixes: c081197a33a2 ("firmware: imx: scu-irq: support identifying SCU wakeu= p source from sysfs") Suggested-by: Greg Kroah-Hartman Link: https://lore.kernel.org/all/2026051656-corral-edgy-290c@gregkh/ Signed-off-by: Stepan Ionichev --- v2: - Drop the sysfs file entirely instead of patching it (Greg) - Log wakeup info via dev_dbg() in the IRQ work handler (Greg) - Peng Fan (NXP) confirmed no out-of-tree consumers v1: https://lore.kernel.org/all/20260515175002.34853-1-sozdayvek@gmail.com/ drivers/firmware/imx/imx-scu-irq.c | 84 ++++++------------------------ 1 file changed, 16 insertions(+), 68 deletions(-) diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-= scu-irq.c index a68d38f89..5969460ba 100644 --- a/drivers/firmware/imx/imx-scu-irq.c +++ b/drivers/firmware/imx/imx-scu-irq.c @@ -9,11 +9,9 @@ #include #include #include -#include #include #include #include -#include =20 #define IMX_SC_IRQ_FUNC_ENABLE 1 #define IMX_SC_IRQ_FUNC_STATUS 2 @@ -43,19 +41,8 @@ struct imx_sc_msg_irq_enable { u8 enable; } __packed; =20 -struct scu_wakeup { - u32 mask; - u32 wakeup_src; - bool valid; -}; - -/* Sysfs functions */ -static struct kobject *wakeup_obj; -static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attrib= ute *attr, char *buf); -static struct kobj_attribute wakeup_source_attr =3D - __ATTR(wakeup_src, 0660, wakeup_source_show, NULL); - -static struct scu_wakeup scu_irq_wakeup[IMX_SC_IRQ_NUM_GROUP]; +static u32 scu_irq_wakeup_mask[IMX_SC_IRQ_NUM_GROUP]; +static struct device *imx_sc_irq_dev; =20 static struct imx_sc_ipc *imx_sc_irq_ipc_handle; static struct work_struct imx_sc_irq_work; @@ -88,11 +75,6 @@ static void imx_scu_irq_work_handler(struct work_struct = *work) u8 i; =20 for (i =3D 0; i < IMX_SC_IRQ_NUM_GROUP; i++) { - if (scu_irq_wakeup[i].mask) { - scu_irq_wakeup[i].valid =3D false; - scu_irq_wakeup[i].wakeup_src =3D 0; - } - ret =3D imx_scu_irq_get_status(i, &irq_status); if (ret) { pr_err("get irq group %d status failed, ret %d\n", @@ -102,12 +84,15 @@ static void imx_scu_irq_work_handler(struct work_struc= t *work) =20 if (!irq_status) continue; - if (scu_irq_wakeup[i].mask & irq_status) { - scu_irq_wakeup[i].valid =3D true; - scu_irq_wakeup[i].wakeup_src =3D irq_status & scu_irq_wakeup[i].mask; - } else { - scu_irq_wakeup[i].wakeup_src =3D irq_status; - } + + if (scu_irq_wakeup_mask[i] & irq_status) + dev_dbg(imx_sc_irq_dev, + "Wakeup source group =3D %d, irq =3D 0x%x\n", + i, irq_status & scu_irq_wakeup_mask[i]); + else + dev_dbg(imx_sc_irq_dev, + "Spurious SCU wakeup, group =3D %d, irq =3D 0x%x\n", + i, irq_status); =20 pm_system_wakeup(); imx_scu_irq_notifier_call_chain(irq_status, &i); @@ -164,9 +149,9 @@ int imx_scu_irq_group_enable(u8 group, u32 mask, u8 ena= ble) group, mask, ret); =20 if (enable) - scu_irq_wakeup[group].mask |=3D mask; + scu_irq_wakeup_mask[group] |=3D mask; else - scu_irq_wakeup[group].mask &=3D ~mask; + scu_irq_wakeup_mask[group] &=3D ~mask; =20 return ret; } @@ -177,25 +162,6 @@ static void imx_scu_irq_callback(struct mbox_client *c= , void *msg) schedule_work(&imx_sc_irq_work); } =20 -static ssize_t wakeup_source_show(struct kobject *kobj, struct kobj_attrib= ute *attr, char *buf) -{ - int i; - - for (i =3D 0; i < IMX_SC_IRQ_NUM_GROUP; i++) { - if (!scu_irq_wakeup[i].wakeup_src) - continue; - - if (scu_irq_wakeup[i].valid) - sprintf(buf, "Wakeup source group =3D %d, irq =3D 0x%x\n", - i, scu_irq_wakeup[i].wakeup_src); - else - sprintf(buf, "Spurious SCU wakeup, group =3D %d, irq =3D 0x%x\n", - i, scu_irq_wakeup[i].wakeup_src); - } - - return strlen(buf); -} - int imx_scu_enable_general_irq_channel(struct device *dev) { struct of_phandle_args spec; @@ -233,29 +199,11 @@ int imx_scu_enable_general_irq_channel(struct device = *dev) if (IS_ERR(ch)) { ret =3D PTR_ERR(ch); dev_err(dev, "failed to request mbox chan gip3, ret %d\n", ret); - goto free_cl; - } - - /* Create directory under /sysfs/firmware */ - wakeup_obj =3D kobject_create_and_add("scu_wakeup_source", firmware_kobj); - if (!wakeup_obj) { - ret =3D -ENOMEM; - goto free_ch; + devm_kfree(dev, cl); + return ret; } =20 - ret =3D sysfs_create_file(wakeup_obj, &wakeup_source_attr.attr); - if (ret) { - dev_err(dev, "Cannot create wakeup source src file......\n"); - kobject_put(wakeup_obj); - goto free_ch; - } + imx_sc_irq_dev =3D dev; =20 return 0; - -free_ch: - mbox_free_channel(ch); -free_cl: - devm_kfree(dev, cl); - - return ret; } --=20 2.43.0