From patchwork Thu Feb 29 00:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 13576162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31A5FC5478C for ; Thu, 29 Feb 2024 00:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Z2M3fU105KLaGDN4ytXRfIDZLCvq0sTFTYkd2e9wpZ4=; b=LeJ CnQjR7y/GSdrruSoSk11RuHoDyRxHccBfMVgH16g6mJPa5K9Fq+wQJcwHt+115HAKPxkTmJiVcNF7 QCPfonB+BPERVTcWtyF0vmpodLzgp3+HBEBwTkbtEtRzoh0zWSDoqyGEyTpaaHnrZrBHzmvbwFhlA Ry+ekHJBhJVa4eDISoO0gxLONX+KVXzKoAEHLlpIbnzE51CLUniI5OpjAr4R0pq1Ghs9UWiCIdlB9 b94Tjts71JbatKqnWSGewg3lp4A0y+wmHKdnJviOB6SHP9JSdTC0AfMvImUEio3okcaWtfs4xsvKr FBhMwXHLzK3387TIdNbUdaYVzP7fyZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfUZv-0000000BSaV-0s0N; Thu, 29 Feb 2024 00:47:15 +0000 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfUZs-0000000BSZu-3bIG for linux-arm-kernel@lists.infradead.org; Thu, 29 Feb 2024 00:47:14 +0000 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a3e85a76fa8so49528666b.1 for ; Wed, 28 Feb 2024 16:47:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20230601.gappssmtp.com; s=20230601; t=1709167630; x=1709772430; darn=lists.infradead.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=eObertsJakPpi13M9q57oeVvcenpnPh+pTJAq0BssCY=; b=yRvKzW/Lawnmw5ydrRftqRmYqwwbt3OsW+qRtgIY2UiKtEMPcdwSClzMdaNlnenbbU b0GjxkqvhALjH14JoW4unruRNLqAAZRaskvJtHLpkSo9CEgL5KW4BY03V1oA/WQGacNa 5Lgwr3Ii5LvMFovDrdsnaEjRBA2e5KFiqwRBNuw5b8ZvgOmp2rEL6K1lcujetyNcAx5c d+X9vLfp7KzCi529ratOqKKvTP1KwO5QQbBkegywbXjAsixPojeYASTZyO7wEkJiBt7W 2Ov6NKRnbSZGht3PfrQX6FKs3gdyGC8gXZBvMSDXxQMFWP/wkdYWzoWxS+6SWTNIILur typQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709167630; x=1709772430; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=eObertsJakPpi13M9q57oeVvcenpnPh+pTJAq0BssCY=; b=IYR1j12iugj9yX7I/WCnfN99y/Axy1AAOCBYiHrHX06UCPx9M/a5WiWk9GygJMvwvX QCVfaAi6XAun9rOaLZluiOKJsIkrzLAGxMmgEzA9mLlgKyq5rtXde6RTdu/qVk6Q/lOV S1PlN387gQ1b+QY3VanTzNfvzsTyqD0xVenqRd3GqadPJPdxH1x1XAekoEFC+ROjsBGj wFNBh1ebNc86Iovtq1+bfXfV/M88969Ln2giburElUFB4mDR7Yixn31Gx1jvyGC36LR7 s4HeZlmqs5LweCdlI7EoXj3qFQqEtbc78ZeIpG4KCk8j3VwBBgWva5qaZ6Y1M1yNrGAO tjnw== X-Forwarded-Encrypted: i=1; AJvYcCUTK+4s1m0PQScZL3sCe595UGK0q9m79clFaXPNiLybaagdIjmA2NWmK2QlYk7S2t9ryjqS/q27ofImFiP6xNDUEKvCxGWS92hPdTM0zLqvquzPcLE= X-Gm-Message-State: AOJu0YyQwNcSYc3PgZPN3UBTx9NCI3yyltGRTYcqHRLuTcg5+bQzFUQJ pdwZvLvf3PXCUTvubbEnu8rVzwVis5H+WyqrAC+5Jqsw/fbYGFdnbccFzAe5O5YGR8ktuXhyFNE G52RspW1VfkcXrEoZ/xAv3QUQ0meL6f0i/mKLt2+tzCmK6bcs+Eg= X-Google-Smtp-Source: AGHT+IHKCqfPq48qiYDzf2tAiPSexhtl+EPdKvyt7gADI6g62Gv1JEhXHOgRLKUAKImlFKM4Dck8XEay1QLsGfeGZXc= X-Received: by 2002:a17:906:a40e:b0:a44:4317:d65c with SMTP id l14-20020a170906a40e00b00a444317d65cmr59979ejz.44.1709167629942; Wed, 28 Feb 2024 16:47:09 -0800 (PST) MIME-Version: 1.0 From: Tim Harvey Date: Wed, 28 Feb 2024 16:46:58 -0800 Message-ID: Subject: TPM error path on probe To: linux-integrity@vger.kernel.org, Peter Huewe , Jarkko Sakkinen , Lino Sanfilippo , Linux ARM Mailing List X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240228_164713_128633_75EDF6B1 X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Greetings, Commit 481c2d14627d ("tpm,tpm_tis: Disable interrupts after 1000 unhandled IRQs") introduced a kernel warning for boards that do not have a TPM loaded but have one defined in the device-tree (ie a subloaded board assembly): [ 2.434431] WARNING: CPU: 3 PID: 55 at kernel/workqueue.c:3397 __flush_work.isra.0+0x2ac/0x2d8 [ 2.443069] Modules linked in: [ 2.446133] CPU: 3 PID: 55 Comm: kworker/u8:3 Not tainted 6.6.8-00021-g232153790aa6-dirty #434 [ 2.454758] Hardware name: Gateworks Venice GW73xx-2x i.MX8MP Development Kit (DT) [ 2.462337] Workqueue: events_unbound async_run_entry_fn [ 2.467669] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.474647] pc : __flush_work.isra.0+0x2ac/0x2d8 [ 2.479278] lr : flush_work+0x10/0x1c [ 2.482950] sp : ffff80008270ba40 [ 2.486271] x29: ffff80008270ba40 x28: 00000000ffffffff x27: 00000000ffffffff [ 2.493425] x26: ffff000000293000 x25: ffff80008218aff8 x24: ffff800080a1c6a8 [ 2.500578] x23: 00000000ffffffff x22: ffff80008213ca18 x21: 0000000000000001 [ 2.507731] x20: ffff000000e142c0 x19: ffff000000e14280 x18: 0000000000000000 [ 2.514884] x17: 0000000000000000 x16: 000000000000001c x15: 0000000000000000 [ 2.522038] x14: ffff00003fd94100 x13: 0000000000000002 x12: 0000000000000000 [ 2.529191] x11: 0000000000000400 x10: 0000000000000910 x9 : 00000000ffffffff [ 2.536346] x8 : 0000000000000cc1 x7 : ffff8000804c76d8 x6 : 00000000090ee8ad [ 2.543500] x5 : ffff00000026c380 x4 : 0000000000000000 x3 : 0000000000000000 [ 2.550655] x2 : 0000000000000000 x1 : ffff00000026c380 x0 : 0000000000000000 [ 2.557806] Call trace: [ 2.560261] __flush_work.isra.0+0x2ac/0x2d8 [ 2.564544] flush_work+0x10/0x1c [ 2.567869] tpm_tis_remove+0x8c/0xc4 [ 2.571545] tpm_tis_core_init+0x194/0x7b8 [ 2.575656] tpm_tis_spi_probe+0xa4/0xd4 [ 2.579593] tpm_tis_spi_driver_probe+0x34/0x64 [ 2.584136] spi_probe+0x84/0xe4 [ 2.587377] really_probe+0x148/0x2c0 [ 2.591052] __driver_probe_device+0x78/0x12c [ 2.595417] driver_probe_device+0xd8/0x15c [ 2.599609] __device_attach_driver+0xb8/0x134 [ 2.604064] bus_for_each_drv+0x84/0xe0 [ 2.607913] __device_attach_async_helper+0xac/0xd0 [ 2.612808] async_run_entry_fn+0x34/0xe0 [ 2.616832] process_one_work+0x138/0x260 [ 2.620851] worker_thread+0x32c/0x438 [ 2.624609] kthread+0x118/0x11c [ 2.627844] ret_from_fork+0x10/0x20 [ 2.631428] ---[ end trace 0000000000000000 ]--- The issue is caused by tpm_tis_remove() calling flush_work() on the work queue that has not yet been initialized. I can move the INIT_WORK call added in this commit into the probe to fix this: I'm not sure if a hard coded 0xffffffff check is best here. Best regards, Tim diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index d5ea22196b5b..e62294b3a437 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1133,6 +1133,8 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, dev_set_drvdata(&chip->dev, priv); + INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func); + rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor); if (rc < 0) return rc; @@ -1159,8 +1161,6 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, } } - INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func); - if (chip->ops->clk_enable != NULL) chip->ops->clk_enable(chip, true); However I wonder if we should simply have error checking for an invalid vendor of 0xffffffff. Is there any reason to not return an -ENODEV if vendor == 0xffffffff? diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index d5ea22196b5b..1bb1b3e1b2d0 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1136,6 +1136,8 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, rc = tpm_tis_read32(priv, TPM_DID_VID(0), &vendor); if (rc < 0) return rc; + if (rc == 0xffffffff) + return -ENODEV; priv->manufacturer_id = vendor;