Re: [PATCH 2/3] hisi_sas: fix the inconsistent lock issue reported by CONFIG_PROVE_LOCKING

2016-06-05 Thread zhangfei



On 05/31/2016 08:38 PM, John Garry wrote:

It is not necessary to surround call to
notify_port_event(, PORTE_BROADCAST_RCVD) by spin_lock_irqsave(),
so remove.
This was causing a warn, as below:

 =
 [ INFO: inconsistent lock state ]
 4.4.8+ #12 Not tainted
 -
 inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
 kworker/u64:1/168 [HC0[0]:SC0[0]:HE1:SE1] takes:
  (&(_hba->lock)->rlock){?.}, at: [] 
alloc_dev_quirk_v2_hw+0x48/0xec
 {IN-HARDIRQ-W} state was registered at:
   [] mark_lock+0x19c/0x6a0
   [] __lock_acquire+0xa2c/0x1d00
   [] lock_acquire+0x58/0x7c
   [] _raw_spin_lock_irqsave+0x54/0x6c
   [] int_chnl_int_v2_hw+0x1c4/0x248
   [] handle_irq_event_percpu+0x9c/0x144
   [] handle_irq_event+0x44/0x74
   [] handle_fasteoi_irq+0xb4/0x188
   [] generic_handle_irq+0x24/0x38
   [] __handle_domain_irq+0x60/0xac
   [] gic_handle_irq+0xcc/0x168
   [] el1_irq+0x6c/0xe0
   [] default_idle_call+0x1c/0x34
   [] cpu_startup_entry+0x1d4/0x228
   [] rest_init+0x150/0x160
   [] start_kernel+0x3a4/0x3b8
   [<008bb000>] 0x8bb000
 irq event stamp: 32661
 hardirqs last  enabled at (32661): [] 
__mutex_unlock_slowpath+0x108/0x18c
 hardirqs last disabled at (32660): [] 
__mutex_unlock_slowpath+0x44/0x18c
 softirqs last  enabled at (25114): [] 
__do_softirq+0x210/0x27c
 softirqs last disabled at (25095): [] irq_exit+0x9c/0xe8

 other info that might help us debug this:
  Possible unsafe locking scenario:

CPU0

   lock(&(_hba->lock)->rlock);
   
 lock(&(_hba->lock)->rlock);

  *** DEADLOCK ***

 2 locks held by kworker/u64:1/168:
  #0:  ("%s"shost->work_q_name){.+}, at: [] 
process_one_work+0x134/0x3cc
  #1:  ((>work)#2){+.+.+.}, at: [] 
process_one_work+0x134/0x3cc

 stack backtrace:
 CPU: 4 PID: 168 Comm: kworker/u64:1 Not tainted 4.4.8+ #12
 Hardware name: Huawei Technologies Co., Ltd. D03/D03, BIOS 1.12 01/01/1900
 Workqueue: scsi_wq_1 sas_discover_domain
 Call trace:
 [] dump_backtrace+0x0/0x114
 [] show_stack+0x14/0x1c
 [] dump_stack+0xb4/0xf0
 [] print_usage_bug+0x210/0x2b4
 [] mark_lock+0x5fc/0x6a0
 [] __lock_acquire+0x800/0x1d00
 [] lock_acquire+0x58/0x7c
 [] _raw_spin_lock+0x44/0x58
 [] alloc_dev_quirk_v2_hw+0x48/0xec
 [] hisi_sas_dev_found+0x48/0x1b8
 [] sas_notify_lldd_dev_found+0x34/0xe0
 [] sas_discover_root_expander+0x58/0x128
 [] sas_discover_domain+0x4bc/0x564
 [] process_one_work+0x1a0/0x3cc
 [] worker_thread+0x138/0x438
 [] kthread+0xdc/0xf0
 [] ret_from_fork+0x10/0x40

Signed-off-by: Wei Xu 
Signed-off-by: John Garry 


Reviewed-by: Zhangfei Gao 


Re: [PATCH 2/3] hisi_sas: fix the inconsistent lock issue reported by CONFIG_PROVE_LOCKING

2016-06-05 Thread zhangfei



On 05/31/2016 08:38 PM, John Garry wrote:

It is not necessary to surround call to
notify_port_event(, PORTE_BROADCAST_RCVD) by spin_lock_irqsave(),
so remove.
This was causing a warn, as below:

 =
 [ INFO: inconsistent lock state ]
 4.4.8+ #12 Not tainted
 -
 inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
 kworker/u64:1/168 [HC0[0]:SC0[0]:HE1:SE1] takes:
  (&(_hba->lock)->rlock){?.}, at: [] 
alloc_dev_quirk_v2_hw+0x48/0xec
 {IN-HARDIRQ-W} state was registered at:
   [] mark_lock+0x19c/0x6a0
   [] __lock_acquire+0xa2c/0x1d00
   [] lock_acquire+0x58/0x7c
   [] _raw_spin_lock_irqsave+0x54/0x6c
   [] int_chnl_int_v2_hw+0x1c4/0x248
   [] handle_irq_event_percpu+0x9c/0x144
   [] handle_irq_event+0x44/0x74
   [] handle_fasteoi_irq+0xb4/0x188
   [] generic_handle_irq+0x24/0x38
   [] __handle_domain_irq+0x60/0xac
   [] gic_handle_irq+0xcc/0x168
   [] el1_irq+0x6c/0xe0
   [] default_idle_call+0x1c/0x34
   [] cpu_startup_entry+0x1d4/0x228
   [] rest_init+0x150/0x160
   [] start_kernel+0x3a4/0x3b8
   [<008bb000>] 0x8bb000
 irq event stamp: 32661
 hardirqs last  enabled at (32661): [] 
__mutex_unlock_slowpath+0x108/0x18c
 hardirqs last disabled at (32660): [] 
__mutex_unlock_slowpath+0x44/0x18c
 softirqs last  enabled at (25114): [] 
__do_softirq+0x210/0x27c
 softirqs last disabled at (25095): [] irq_exit+0x9c/0xe8

 other info that might help us debug this:
  Possible unsafe locking scenario:

CPU0

   lock(&(_hba->lock)->rlock);
   
 lock(&(_hba->lock)->rlock);

  *** DEADLOCK ***

 2 locks held by kworker/u64:1/168:
  #0:  ("%s"shost->work_q_name){.+}, at: [] 
process_one_work+0x134/0x3cc
  #1:  ((>work)#2){+.+.+.}, at: [] 
process_one_work+0x134/0x3cc

 stack backtrace:
 CPU: 4 PID: 168 Comm: kworker/u64:1 Not tainted 4.4.8+ #12
 Hardware name: Huawei Technologies Co., Ltd. D03/D03, BIOS 1.12 01/01/1900
 Workqueue: scsi_wq_1 sas_discover_domain
 Call trace:
 [] dump_backtrace+0x0/0x114
 [] show_stack+0x14/0x1c
 [] dump_stack+0xb4/0xf0
 [] print_usage_bug+0x210/0x2b4
 [] mark_lock+0x5fc/0x6a0
 [] __lock_acquire+0x800/0x1d00
 [] lock_acquire+0x58/0x7c
 [] _raw_spin_lock+0x44/0x58
 [] alloc_dev_quirk_v2_hw+0x48/0xec
 [] hisi_sas_dev_found+0x48/0x1b8
 [] sas_notify_lldd_dev_found+0x34/0xe0
 [] sas_discover_root_expander+0x58/0x128
 [] sas_discover_domain+0x4bc/0x564
 [] process_one_work+0x1a0/0x3cc
 [] worker_thread+0x138/0x438
 [] kthread+0xdc/0xf0
 [] ret_from_fork+0x10/0x40

Signed-off-by: Wei Xu 
Signed-off-by: John Garry 


Reviewed-by: Zhangfei Gao 


[PATCH 2/3] hisi_sas: fix the inconsistent lock issue reported by CONFIG_PROVE_LOCKING

2016-05-31 Thread John Garry
It is not necessary to surround call to
notify_port_event(, PORTE_BROADCAST_RCVD) by spin_lock_irqsave(),
so remove.
This was causing a warn, as below:

=
[ INFO: inconsistent lock state ]
4.4.8+ #12 Not tainted
-
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
kworker/u64:1/168 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (&(_hba->lock)->rlock){?.}, at: [] 
alloc_dev_quirk_v2_hw+0x48/0xec
{IN-HARDIRQ-W} state was registered at:
  [] mark_lock+0x19c/0x6a0
  [] __lock_acquire+0xa2c/0x1d00
  [] lock_acquire+0x58/0x7c
  [] _raw_spin_lock_irqsave+0x54/0x6c
  [] int_chnl_int_v2_hw+0x1c4/0x248
  [] handle_irq_event_percpu+0x9c/0x144
  [] handle_irq_event+0x44/0x74
  [] handle_fasteoi_irq+0xb4/0x188
  [] generic_handle_irq+0x24/0x38
  [] __handle_domain_irq+0x60/0xac
  [] gic_handle_irq+0xcc/0x168
  [] el1_irq+0x6c/0xe0
  [] default_idle_call+0x1c/0x34
  [] cpu_startup_entry+0x1d4/0x228
  [] rest_init+0x150/0x160
  [] start_kernel+0x3a4/0x3b8
  [<008bb000>] 0x8bb000
irq event stamp: 32661
hardirqs last  enabled at (32661): [] 
__mutex_unlock_slowpath+0x108/0x18c
hardirqs last disabled at (32660): [] 
__mutex_unlock_slowpath+0x44/0x18c
softirqs last  enabled at (25114): [] 
__do_softirq+0x210/0x27c
softirqs last disabled at (25095): [] irq_exit+0x9c/0xe8

other info that might help us debug this:
 Possible unsafe locking scenario:

   CPU0
   
  lock(&(_hba->lock)->rlock);
  
lock(&(_hba->lock)->rlock);

 *** DEADLOCK ***

2 locks held by kworker/u64:1/168:
 #0:  ("%s"shost->work_q_name){.+}, at: [] 
process_one_work+0x134/0x3cc
 #1:  ((>work)#2){+.+.+.}, at: [] 
process_one_work+0x134/0x3cc

stack backtrace:
CPU: 4 PID: 168 Comm: kworker/u64:1 Not tainted 4.4.8+ #12
Hardware name: Huawei Technologies Co., Ltd. D03/D03, BIOS 1.12 01/01/1900
Workqueue: scsi_wq_1 sas_discover_domain
Call trace:
[] dump_backtrace+0x0/0x114
[] show_stack+0x14/0x1c
[] dump_stack+0xb4/0xf0
[] print_usage_bug+0x210/0x2b4
[] mark_lock+0x5fc/0x6a0
[] __lock_acquire+0x800/0x1d00
[] lock_acquire+0x58/0x7c
[] _raw_spin_lock+0x44/0x58
[] alloc_dev_quirk_v2_hw+0x48/0xec
[] hisi_sas_dev_found+0x48/0x1b8
[] sas_notify_lldd_dev_found+0x34/0xe0
[] sas_discover_root_expander+0x58/0x128
[] sas_discover_domain+0x4bc/0x564
[] process_one_work+0x1a0/0x3cc
[] worker_thread+0x138/0x438
[] kthread+0xdc/0xf0
[] ret_from_fork+0x10/0x40

Signed-off-by: Wei Xu 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index e933cdc..c8c0b45 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1909,14 +1909,9 @@ static void phy_bcast_v2_hw(int phy_no, struct hisi_hba 
*hisi_hba)
struct hisi_sas_phy *phy = _hba->phy[phy_no];
struct asd_sas_phy *sas_phy = >sas_phy;
struct sas_ha_struct *sas_ha = _hba->sha;
-   unsigned long flags;
 
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
-
-   spin_lock_irqsave(_hba->lock, flags);
sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
-   spin_unlock_irqrestore(_hba->lock, flags);
-
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
 CHL_INT0_SL_RX_BCST_ACK_MSK);
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);
-- 
1.9.1



[PATCH 2/3] hisi_sas: fix the inconsistent lock issue reported by CONFIG_PROVE_LOCKING

2016-05-31 Thread John Garry
It is not necessary to surround call to
notify_port_event(, PORTE_BROADCAST_RCVD) by spin_lock_irqsave(),
so remove.
This was causing a warn, as below:

=
[ INFO: inconsistent lock state ]
4.4.8+ #12 Not tainted
-
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
kworker/u64:1/168 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (&(_hba->lock)->rlock){?.}, at: [] 
alloc_dev_quirk_v2_hw+0x48/0xec
{IN-HARDIRQ-W} state was registered at:
  [] mark_lock+0x19c/0x6a0
  [] __lock_acquire+0xa2c/0x1d00
  [] lock_acquire+0x58/0x7c
  [] _raw_spin_lock_irqsave+0x54/0x6c
  [] int_chnl_int_v2_hw+0x1c4/0x248
  [] handle_irq_event_percpu+0x9c/0x144
  [] handle_irq_event+0x44/0x74
  [] handle_fasteoi_irq+0xb4/0x188
  [] generic_handle_irq+0x24/0x38
  [] __handle_domain_irq+0x60/0xac
  [] gic_handle_irq+0xcc/0x168
  [] el1_irq+0x6c/0xe0
  [] default_idle_call+0x1c/0x34
  [] cpu_startup_entry+0x1d4/0x228
  [] rest_init+0x150/0x160
  [] start_kernel+0x3a4/0x3b8
  [<008bb000>] 0x8bb000
irq event stamp: 32661
hardirqs last  enabled at (32661): [] 
__mutex_unlock_slowpath+0x108/0x18c
hardirqs last disabled at (32660): [] 
__mutex_unlock_slowpath+0x44/0x18c
softirqs last  enabled at (25114): [] 
__do_softirq+0x210/0x27c
softirqs last disabled at (25095): [] irq_exit+0x9c/0xe8

other info that might help us debug this:
 Possible unsafe locking scenario:

   CPU0
   
  lock(&(_hba->lock)->rlock);
  
lock(&(_hba->lock)->rlock);

 *** DEADLOCK ***

2 locks held by kworker/u64:1/168:
 #0:  ("%s"shost->work_q_name){.+}, at: [] 
process_one_work+0x134/0x3cc
 #1:  ((>work)#2){+.+.+.}, at: [] 
process_one_work+0x134/0x3cc

stack backtrace:
CPU: 4 PID: 168 Comm: kworker/u64:1 Not tainted 4.4.8+ #12
Hardware name: Huawei Technologies Co., Ltd. D03/D03, BIOS 1.12 01/01/1900
Workqueue: scsi_wq_1 sas_discover_domain
Call trace:
[] dump_backtrace+0x0/0x114
[] show_stack+0x14/0x1c
[] dump_stack+0xb4/0xf0
[] print_usage_bug+0x210/0x2b4
[] mark_lock+0x5fc/0x6a0
[] __lock_acquire+0x800/0x1d00
[] lock_acquire+0x58/0x7c
[] _raw_spin_lock+0x44/0x58
[] alloc_dev_quirk_v2_hw+0x48/0xec
[] hisi_sas_dev_found+0x48/0x1b8
[] sas_notify_lldd_dev_found+0x34/0xe0
[] sas_discover_root_expander+0x58/0x128
[] sas_discover_domain+0x4bc/0x564
[] process_one_work+0x1a0/0x3cc
[] worker_thread+0x138/0x438
[] kthread+0xdc/0xf0
[] ret_from_fork+0x10/0x40

Signed-off-by: Wei Xu 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index e933cdc..c8c0b45 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1909,14 +1909,9 @@ static void phy_bcast_v2_hw(int phy_no, struct hisi_hba 
*hisi_hba)
struct hisi_sas_phy *phy = _hba->phy[phy_no];
struct asd_sas_phy *sas_phy = >sas_phy;
struct sas_ha_struct *sas_ha = _hba->sha;
-   unsigned long flags;
 
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 1);
-
-   spin_lock_irqsave(_hba->lock, flags);
sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD);
-   spin_unlock_irqrestore(_hba->lock, flags);
-
hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0,
 CHL_INT0_SL_RX_BCST_ACK_MSK);
hisi_sas_phy_write32(hisi_hba, phy_no, SL_RX_BCAST_CHK_MSK, 0);
-- 
1.9.1