Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp974510imu; Fri, 7 Dec 2018 11:57:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vl/Mn+V6iOsxRTO/8kGAQZLE9s9LLhLUWJxs7QFBbCRtdUPFIgzppofKdRiU99XwKSk6sY X-Received: by 2002:a62:931a:: with SMTP id b26mr3697228pfe.65.1544212665953; Fri, 07 Dec 2018 11:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544212665; cv=none; d=google.com; s=arc-20160816; b=UJCzeszJtxIz7w4eIgYnNgB2PhwvXOaARt8ZtSpHJs4pNkgEMMAb1YpHF3g4rZzVp5 y163AtSkS0gpPo8mzzpDlsBrNNHGIK/0Mrlokgv8aqXzoM3TDD2IRuc4E9m9kL21Rvig Xpltn1BLneLz01uN/74PZouizbkyWMJzD+cfkhYrYVM/srByP3tDRgWcprBW1tKGSvq+ mTcFZ0EeZxhve0u5RrSKlXdo+Usq5DNsDOKEUmA4CV4cUCdTKmQ9V/+ci7MbT5IkHhsI KWO6M43OWV1c6ifSjSr9UMTi2F2GLj2n3LkThZqmzr+45v1j0u+bkDgECsa0ETFg9SnR qAnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=HV0ad/tgre+nQE1kpbpFmKwpw7ygKBPnSSglbtGnX7Q=; b=uGEeC/KNhw0Cjvv0OSwnMDp56hfLr1xtw1jBHAR6QoETxOmpj6J43cRbMZ1FRT03xH GPjqFNcfJftIHhkvrUAVlAl5HrRO0VNHSrq//2mCBwh09TetudTm6guXCA6C2qE2h7ju de7Rlyi//KEAMtjN2jhtpDGvmMHH7xNCo2MGx/B+w50/kFcLuxBneIEkpxsb20/QWoXS dYNXbXOuyW74FasMNO5W9cPuWPfeOC+OX2ZkreMckUIjVkGuTTpodt478sRTvHMJElRc +2LwqfO0uBJnclGqfBscg5P1TigjQ9souKr854tUbf80sNegtChoS+cQei+cFNGdUOm9 vvlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gROOvirD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si3628378pgj.73.2018.12.07.11.57.29; Fri, 07 Dec 2018 11:57:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gROOvirD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726210AbeLGT4x (ORCPT + 99 others); Fri, 7 Dec 2018 14:56:53 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38554 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726047AbeLGT4x (ORCPT ); Fri, 7 Dec 2018 14:56:53 -0500 Received: by mail-pl1-f196.google.com with SMTP id e5so2290351plb.5; Fri, 07 Dec 2018 11:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=HV0ad/tgre+nQE1kpbpFmKwpw7ygKBPnSSglbtGnX7Q=; b=gROOvirD1iZcrkD8A5kMTq10pDO4gNhlIA7Qrgx2npb0l41LbJ87UsMVOA2mlBg5gS D7mIyuA9KnqpkM0ziPpB+NaXmwwr+baDu3ytkmwXRmT2uuPMbloUEBv7nFftHseRjEc8 nInmesZwVu4h4v1jPOQ8wc5cj+GAYa5IGp081lxYMrBlannvlNZxowPUT37XDmNzibvj frIsJb2GMb1ZqecCO3vgPaucGbJlnHN5fxxQH7gTtCmAWQAt9kiqCXOdDGs9RWgMJyKz XdPpnL9US94g1bXpY2ReIP98BsgMFhV8pCUwN4uLhwX06Fue+CcUooWdLBDIqaLsXgCW 4xWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HV0ad/tgre+nQE1kpbpFmKwpw7ygKBPnSSglbtGnX7Q=; b=DbfI6JpNpdoZrsEOlMDn2zh8YAcvzJU+W4AA775ltIDuqCRR6SQ6IEkhAgrcvt6iIX kAwbCT3FX2CNo3HzzpfP2fF/xE5W16ISDLXcdMA4jXpEFJhbU3fWsewEUA+wZv1D+8j6 l2dDqNh+uOjf70zmL6O2qLhM5kz+yx7eV85SmaMe5pZ5FNAHSkmNX+QwzDagRxkjuFFH uQQVnaSsVuHy2g9lJ3zwIQzJUF9e3CWA6TqP8yd1Fv6vDKNYrmba7K84CsqII+jkvARG J9GcAEaqEHrAqqzjjvo5nR4xAyCAbBIn/5c5c07O2pOwNDwTNc3higucyR0kPbVElC5n 6Iww== X-Gm-Message-State: AA+aEWZXkbZLVHZs/jNilXELEtBB7ZLqLrcSCZPqfF0+VTQrv1cN4qoq Qb0eIDDqm68G//J7FziD3rU= X-Received: by 2002:a17:902:112c:: with SMTP id d41mr3270364pla.144.1544212612139; Fri, 07 Dec 2018 11:56:52 -0800 (PST) Received: from dev-aglagolev.dev.purestorage.com ([192.30.188.252]) by smtp.googlemail.com with ESMTPSA id i123sm6687358pfg.164.2018.12.07.11.56.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Dec 2018 11:56:51 -0800 (PST) From: Anatoliy Glagolev To: aglagolev@purestorage.com, qla2xxx-upstream@qlogic.com, jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Anatoliy Glagolev Subject: [PATCH] scsi: qla2xxx: disabling pci error handler early Date: Fri, 7 Dec 2018 12:56:42 -0700 Message-Id: <1544212602-28085-1-git-send-email-glagolig@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org qla2x00_disable_board_on_pci_error and pcie error handlers may run in parallel. Specifically, I observed qla2xxx_pci_slot_reset running at around the same moment as qla2x00_disable_board_on_pci_error. If scsi_qla_host_t or qla_hw_data structs are removed before an error handler completes, the handler crashes. This patch disables pcie error handling early in qla2x00_disable_board_on_pci_error and in other paths that remove those structs. Signed-off-by: Anatoliy Glagolev --- drivers/scsi/qla2xxx/qla_os.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index e881fce..b8f277a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2775,9 +2775,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) return ret; } - /* This may fail but that's ok */ - pci_enable_pcie_error_reporting(pdev); - ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); if (!ha) { ql_log_pci(ql_log_fatal, pdev, 0x0009, @@ -3039,6 +3036,9 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) goto probe_hw_failed; } + /* This may fail but that's ok */ + pci_enable_pcie_error_reporting(pdev); + pci_set_drvdata(pdev, base_vha); set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); @@ -3400,6 +3400,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) kthread_stop(t); } + pci_disable_pcie_error_reporting(); + qla2x00_free_device(base_vha); scsi_host_put(base_vha->host); /* @@ -3625,6 +3627,8 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) } qla2x00_wait_for_hba_ready(base_vha); + pci_disable_pcie_error_reporting(pdev); + qla2x00_wait_for_sess_deletion(base_vha); /* @@ -3698,8 +3702,6 @@ static void qla2x00_iocb_work_fn(struct work_struct *work) pci_release_selected_regions(ha->pdev, ha->bars); kfree(ha); - pci_disable_pcie_error_reporting(pdev); - pci_disable_device(pdev); } @@ -5826,6 +5828,8 @@ void qla2x00_relogin(struct scsi_qla_host *vha) return; } + pci_disable_pcie_error_reporting(pdev); + qla2x00_wait_for_sess_deletion(base_vha); set_bit(UNLOADING, &base_vha->dpc_flags); @@ -5866,7 +5870,6 @@ void qla2x00_relogin(struct scsi_qla_host *vha) qla2x00_unmap_iobases(ha); pci_release_selected_regions(ha->pdev, ha->bars); - pci_disable_pcie_error_reporting(pdev); pci_disable_device(pdev); /* -- 1.9.1