From 70d6e847cda8acf818e7ca5f795e029071f0ca00 Mon Sep 17 00:00:00 2001
From: Kishon Vijay Abraham I <kishon@ti.com>
Date: Mon, 7 Feb 2022 13:18:53 +0530
Subject: [PATCH] net: ethernet: ti: icss_iep: Add missing spin_lock_init()

Add missing spin_lock_init() for irq_lock member of struct icss_iep.

This fixes the following dump:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
CPU: 1 PID: 1032 Comm: sh Not tainted 5.10.65-08510-g85c8939a4059 #205
Hardware name: Texas Instruments AM642 EVM (DT)
Call trace:
 dump_backtrace+0x0/0x1d0
 show_stack+0x18/0x28
 dump_stack+0xec/0x154
 register_lock_class+0x4e8/0x508
 __lock_acquire+0x7c/0x1d60
 lock_acquire+0x154/0x410
 _raw_spin_lock_irqsave+0x70/0x144
 icss_iep_ptp_enable+0x194/0x300 [icss_iep]
 pps_enable_store+0xc0/0xe0
 dev_attr_store+0x18/0x30
 sysfs_kf_write+0x4c/0x78
 kernfs_fop_write_iter+0x120/0x1b8
 new_sync_write+0xe8/0x188
 vfs_write+0x2ac/0x450
 ksys_write+0x6c/0xf8
 __arm64_sys_write+0x1c/0x28
 el0_svc_common.constprop.0+0x7c/0x1f0
 do_el0_svc+0x24/0x90
 el0_svc+0x20/0x30
 el0_sync_handler+0xb0/0xb8
 el0_sync+0x180/0x1c0
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:947
in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1032, name: sh
INFO: lockdep is turned off.
irq event stamp: 65068
hardirqs last  enabled at (65067): [<ffff800010cbefa0>] _raw_spin_unlock_irqrestore+0x80/0x98
hardirqs last disabled at (65068): [<ffff800010cbf660>] _raw_spin_lock_irqsave+0xb0/0x144
softirqs last  enabled at (64770): [<ffff80001001062c>] efi_header_end+0x62c/0x6b0
softirqs last disabled at (64761): [<ffff80001005993c>] irq_exit+0x1c4/0x1d8
Preemption disabled at:
[<ffff8000094f1674>] icss_iep_ptp_enable+0x194/0x300 [icss_iep]
CPU: 1 PID: 1032 Comm: sh Not tainted 5.10.65-08510-g85c8939a4059 #205
Hardware name: Texas Instruments AM642 EVM (DT)
Call trace:
 dump_backtrace+0x0/0x1d0
 show_stack+0x18/0x28
 dump_stack+0xec/0x154
 ___might_sleep+0x194/0x240
 __might_sleep+0x50/0x88
 __mutex_lock+0x5c/0x900
 mutex_lock_nested+0x34/0x50
 regmap_lock_mutex+0x14/0x20
 regmap_write+0x3c/0x78
 icss_iep_perout_enable_hw+0x68/0x210 [icss_iep]
 icss_iep_ptp_enable+0x2ac/0x300 [icss_iep]
 pps_enable_store+0xc0/0xe0
 dev_attr_store+0x18/0x30
 sysfs_kf_write+0x4c/0x78
 kernfs_fop_write_iter+0x120/0x1b8
 new_sync_write+0xe8/0x188
 vfs_write+0x2ac/0x450
 ksys_write+0x6c/0xf8
 __arm64_sys_write+0x1c/0x28
 el0_svc_common.constprop.0+0x7c/0x1f0
 do_el0_svc+0x24/0x90
 el0_svc+0x20/0x30
 el0_sync_handler+0xb0/0xb8
 el0_sync+0x180/0x1c0

Fixes: 5d58df8eb0bb ("net: ethernet: ti: icss_iep: fix pps irq race vs pps disable")
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
---
 drivers/net/ethernet/ti/icss_iep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/icss_iep.c b/drivers/net/ethernet/ti/icss_iep.c
index 481dc366a7c2..48a2f76bcc1a 100644
--- a/drivers/net/ethernet/ti/icss_iep.c
+++ b/drivers/net/ethernet/ti/icss_iep.c
@@ -956,6 +956,7 @@ static int icss_iep_probe(struct platform_device *pdev)
 
 	iep->ptp_info = icss_iep_ptp_info;
 	mutex_init(&iep->ptp_clk_mutex);
+	spin_lock_init(&iep->irq_lock);
 	dev_set_drvdata(dev, iep);
 	icss_iep_disable(iep);
 
