From patchwork Wed Oct 14 15:57:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 7396971 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6CA7FBEEA4 for ; Wed, 14 Oct 2015 16:36:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E8C620946 for ; Wed, 14 Oct 2015 16:36:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 079D820928 for ; Wed, 14 Oct 2015 16:36:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbbJNQgY (ORCPT ); Wed, 14 Oct 2015 12:36:24 -0400 Received: from mx0a-0016ce01.pphosted.com ([67.231.148.157]:2755 "EHLO mx0a-0016ce01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751875AbbJNQgX (ORCPT ); Wed, 14 Oct 2015 12:36:23 -0400 Received: from pps.filterd (m0045602.ppops.net [127.0.0.1]) by mx0a-0016ce01.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id t9EGS9wk023430; Wed, 14 Oct 2015 09:36:00 -0700 Received: from avcashub1.qlogic.com (avcashub2.qlogic.com [198.70.193.116]) by mx0a-0016ce01.pphosted.com with ESMTP id 1xhtgh80je-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 14 Oct 2015 09:36:00 -0700 Received: from dut6217.mv.qlogic.com (172.29.56.217) by qlc.com (10.1.4.191) with Microsoft SMTP Server id 14.3.235.1; Wed, 14 Oct 2015 09:35:59 -0700 Received: by dut6217.mv.qlogic.com (Postfix, from userid 0) id 89CD2522042; Wed, 14 Oct 2015 11:57:41 -0400 (EDT) From: Himanshu Madhani To: , CC: , , , Subject: [PATCH 2/2] qla2xxx: fix rwlock recursion Date: Wed, 14 Oct 2015 11:57:41 -0400 Message-ID: <1444838261-20990-3-git-send-email-himanshu.madhani@qlogic.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1444838261-20990-1-git-send-email-himanshu.madhani@qlogic.com> References: <1444838261-20990-1-git-send-email-himanshu.madhani@qlogic.com> MIME-Version: 1.0 disclaimer: bypass X-Proofpoint-Virus-Version: vendor=nai engine=5700 definitions=7954 signatures=670649 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1011 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1507310000 definitions=main-1510140199 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes rwlock recursion introduced for ISP82XX by commit 8dfa4b5a ("qla2xxx: Fix sparse annotations") Original patch fixes other sparse warnings which did not cause any regression. So instead of reverting complete patch, this patch will revert only part which caused recursion. stack track has following signature kernel:BUG: rwlock recursion on CPU#2, insmod/39333, ffff8803e998cb28 kernel: ffffffff8181d7de ffff88040f2af8a8 ffffffff810a8047 ffff8803e998cb28 kernel: ffff8803e998cb40 ffff88040f2af8c8 ffffffff810a833a 0000000000000086 kernel: Call Trace: kernel: [] dump_stack+0x48/0x64 kernel: [] rwlock_bug+0x67/0x70 kernel: [] do_raw_write_lock+0x8a/0xa0 kernel: [] _raw_write_lock_irqsave+0x63/0x80 kernel: [] ? qla82xx_rd_32+0xe8/0x140 [qla2xxx] kernel: [] qla82xx_rd_32+0xe8/0x140 [qla2xxx] kernel: [] qla82xx_crb_win_lock+0x25/0x60 [qla2xxx] kernel: [] qla82xx_wr_32+0xf6/0x150 [qla2xxx] kernel: [] ? qla82xx_disable_intrs+0x34/0x80 [qla2xxx] kernel: [] qla82xx_disable_intrs+0x50/0x80 [qla2xxx] kernel: [] qla82xx_reset_chip+0x1a/0x20 [qla2xxx] kernel: [] qla2x00_initialize_adapter+0x132/0x420 [qla2xxx] kernel: [] ? qla82xx_rd_32+0xe8/0x140 [qla2xxx] kernel: [] qla82xx_rd_32+0xe8/0x140 [qla2xxx] kernel: [] qla82xx_crb_win_lock+0x25/0x60 [qla2xxx] kernel: [] qla82xx_wr_32+0xf6/0x150 [qla2xxx] kernel: [] ? qla82xx_disable_intrs+0x34/0x80 [qla2xxx] kernel: [] qla82xx_disable_intrs+0x50/0x80 [qla2xxx] kernel: [] qla82xx_reset_chip+0x1a/0x20 [qla2xxx] kernel: [] qla2x00_initialize_adapter+0x132/0x420 [qla2xxx] kernel: [] qla2x00_probe_one+0xefe/0x2130 [qla2xxx] kernel: [] ? __pm_runtime_resume+0x6c/0x90 kernel: [] local_pci_probe+0x4c/0xa0 kernel: [] pci_call_probe+0x83/0xa0 kernel: [] pci_device_probe+0x7f/0xb0 kernel: [] really_probe+0x133/0x390 kernel: [] driver_probe_device+0x59/0xd0 kernel: [] __driver_attach+0xa1/0xb0 kernel: [] ? driver_probe_device+0xd0/0xd0 kernel: [] bus_for_each_dev+0x8d/0xb0 kernel: [] driver_attach+0x1e/0x20 kernel: [] bus_add_driver+0x1d2/0x290 kernel: [] driver_register+0x60/0xe0 kernel: [] __pci_register_driver+0x64/0x70 kernel: [] qla2x00_module_init+0x1cb/0x21b [qla2xxx] kernel: [] ? 0xffffffffa04bc000 kernel: [] do_one_initcall+0xad/0x1c0 kernel: [] do_init_module+0x69/0x210 kernel: [] load_module+0x5cc/0x750 kernel: [] ? mod_sysfs_teardown+0x140/0x140 kernel: [] ? copy_user_enhanced_fast_string+0x5/0x10 kernel: [] ? module_sect_show+0x30/0x30 kernel: [] ? copy_module_from_user+0x8d/0xf0 kernel: [] SyS_init_module+0x92/0xc0 kernel: [] entry_SYSCALL_64_fastpath+0x12/0x6f Signed-off-by: Himanshu Madhani Signed-off-by: Giridhar Malavali --- drivers/scsi/qla2xxx/qla_nx.c | 58 ++++++++++++++++++++-------------------- 1 files changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index eb0cc54..96f9b39 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c @@ -347,31 +347,33 @@ char *qdev_state(uint32_t dev_state) } /* - * In: 'off_in' is offset from CRB space in 128M pci map - * Out: 'off_out' is 2M pci map addr + * In: 'off' is offset from CRB space in 128M pci map + * Out: 'off' is 2M pci map addr * side effect: lock crb window */ static void -qla82xx_pci_set_crbwindow_2M(struct qla_hw_data *ha, ulong off_in, - void __iomem **off_out) +qla82xx_pci_set_crbwindow_2M(struct qla_hw_data *ha, ulong *off) { u32 win_read; scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); - ha->crb_win = CRB_HI(off_in); - writel(ha->crb_win, CRB_WINDOW_2M + ha->nx_pcibase); + ha->crb_win = CRB_HI(*off); + writel(ha->crb_win, + (void __iomem *)(CRB_WINDOW_2M + ha->nx_pcibase)); /* Read back value to make sure write has gone through before trying * to use it. */ - win_read = RD_REG_DWORD(CRB_WINDOW_2M + ha->nx_pcibase); + win_read = RD_REG_DWORD((void __iomem *) + (CRB_WINDOW_2M + ha->nx_pcibase)); if (win_read != ha->crb_win) { ql_dbg(ql_dbg_p3p, vha, 0xb000, "%s: Written crbwin (0x%x) " "!= Read crbwin (0x%x), off=0x%lx.\n", - __func__, ha->crb_win, win_read, off_in); + __func__, ha->crb_win, win_read, *off); } - *off_out = (off_in & MASK(16)) + CRB_INDIRECT_2M + ha->nx_pcibase; + *off = (*off & MASK(16)) + CRB_INDIRECT_2M + + (unsigned long)ha->nx_pcibase; } static inline unsigned long @@ -416,30 +418,30 @@ qla82xx_pci_set_crbwindow(struct qla_hw_data *ha, u64 off) } static int -qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong off_in, - void __iomem **off_out) +qla82xx_pci_get_crb_addr_2M(struct qla_hw_data *ha, ulong *off) { struct crb_128M_2M_sub_block_map *m; - if (off_in >= QLA82XX_CRB_MAX) + if (*off >= QLA82XX_CRB_MAX) return -1; - if (off_in >= QLA82XX_PCI_CAMQM && off_in < QLA82XX_PCI_CAMQM_2M_END) { - *off_out = (off_in - QLA82XX_PCI_CAMQM) + - QLA82XX_PCI_CAMQM_2M_BASE + ha->nx_pcibase; + if (*off >= QLA82XX_PCI_CAMQM && (*off < QLA82XX_PCI_CAMQM_2M_END)) { + *off = (*off - QLA82XX_PCI_CAMQM) + + QLA82XX_PCI_CAMQM_2M_BASE + (unsigned long)ha->nx_pcibase; return 0; } - if (off_in < QLA82XX_PCI_CRBSPACE) + if (*off < QLA82XX_PCI_CRBSPACE) return -1; - *off_out = (void __iomem *)(off_in - QLA82XX_PCI_CRBSPACE); + *off -= QLA82XX_PCI_CRBSPACE; /* Try direct map */ - m = &crb_128M_2M_map[CRB_BLK(off_in)].sub_block[CRB_SUBBLK(off_in)]; + m = &crb_128M_2M_map[CRB_BLK(*off)].sub_block[CRB_SUBBLK(*off)]; - if (m->valid && (m->start_128M <= off_in) && (m->end_128M > off_in)) { - *off_out = off_in + m->start_2M - m->start_128M + ha->nx_pcibase; + if (m->valid && (m->start_128M <= *off) && (m->end_128M > *off)) { + *off = *off + m->start_2M - m->start_128M + + (unsigned long) ha->nx_pcibase; return 0; } /* Not in direct map, use crb window */ @@ -465,13 +467,12 @@ static int qla82xx_crb_win_lock(struct qla_hw_data *ha) } int -qla82xx_wr_32(struct qla_hw_data *ha, ulong off_in, u32 data) +qla82xx_wr_32(struct qla_hw_data *ha, ulong off, u32 data) { - void __iomem *off; unsigned long flags = 0; int rv; - rv = qla82xx_pci_get_crb_addr_2M(ha, off_in, &off); + rv = qla82xx_pci_get_crb_addr_2M(ha, &off); BUG_ON(rv == -1); @@ -480,7 +481,7 @@ qla82xx_wr_32(struct qla_hw_data *ha, ulong off_in, u32 data) write_lock_irqsave(&ha->hw_lock, flags); #endif qla82xx_crb_win_lock(ha); - qla82xx_pci_set_crbwindow_2M(ha, off_in, &off); + qla82xx_pci_set_crbwindow_2M(ha, &off); } writel(data, (void __iomem *)off); @@ -495,14 +496,13 @@ qla82xx_wr_32(struct qla_hw_data *ha, ulong off_in, u32 data) } int -qla82xx_rd_32(struct qla_hw_data *ha, ulong off_in) +qla82xx_rd_32(struct qla_hw_data *ha, ulong off) { - void __iomem *off; unsigned long flags = 0; int rv; u32 data; - rv = qla82xx_pci_get_crb_addr_2M(ha, off_in, &off); + rv = qla82xx_pci_get_crb_addr_2M(ha, &off); BUG_ON(rv == -1); @@ -511,9 +511,9 @@ qla82xx_rd_32(struct qla_hw_data *ha, ulong off_in) write_lock_irqsave(&ha->hw_lock, flags); #endif qla82xx_crb_win_lock(ha); - qla82xx_pci_set_crbwindow_2M(ha, off_in, &off); + qla82xx_pci_set_crbwindow_2M(ha, &off); } - data = RD_REG_DWORD(off); + data = RD_REG_DWORD((void __iomem *)off); if (rv == 1) { qla82xx_rd_32(ha, QLA82XX_PCIE_REG(PCIE_SEM7_UNLOCK));