All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Rood <benjaminjrood@gmail.com>
To: linux-scsi@vger.kernel.org, xjtuwjp@gmail.com,
	James.Bottomley@HansenPartnership.com
Cc: Benjamin Rood <brood@attotech.com>
Subject: [PATCH 8/8] pm80xx: avoid a panic if MSI(X) interrupts are disabled
Date: Fri, 30 Oct 2015 10:53:31 -0400	[thread overview]
Message-ID: <1446216811-2248-9-git-send-email-brood@attotech.com> (raw)
In-Reply-To: <1446216811-2248-1-git-send-email-brood@attotech.com>

If MSI(X) interrupts are disabled via the kernel command line
(pci=nomsi), the pm8001 driver will kernel panic because it does not
detect that MSI interrupts are disabled and will soldier on and attempt to
configure MSI interrupts anyways.  This leads to a kernel panic, most
likely because a required data structure is not available down the
line.  Using the pci_msi_enabled() function in order to detect if MSI
interrupts are enabled before configuring them resolves this issue and
avoids a kernel panic when the module is loaded.  Additionally, the
irq_vector structure must be initialized when legacy interrupts are
being used otherwise legacy interrupts will simply not function and
result in another panic.

Signed-off-by: Benjamin Rood <brood@attotech.com>
---
 drivers/scsi/pm8001/pm8001_init.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index ab99984..bdc624f 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -482,7 +482,8 @@ static struct pm8001_hba_info *pm8001_pci_alloc(struct pci_dev *pdev,
 
 #ifdef PM8001_USE_TASKLET
 	/* Tasklet for non msi-x interrupt handler */
-	if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001))
+	if ((!pdev->msix_cap || !pci_msi_enabled())
+	    || (pm8001_ha->chip_id == chip_8001))
 		tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
 			(unsigned long)&(pm8001_ha->irq_vector[0]));
 	else
@@ -951,7 +952,7 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
 	pdev = pm8001_ha->pdev;
 
 #ifdef PM8001_USE_MSIX
-	if (pdev->msix_cap)
+	if (pdev->msix_cap && pci_msi_enabled())
 		return pm8001_setup_msix(pm8001_ha);
 	else {
 		PM8001_INIT_DBG(pm8001_ha,
@@ -962,6 +963,8 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
 
 intx:
 	/* initialize the INT-X interrupt */
+	pm8001_ha->irq_vector[0].irq_id = 0;
+	pm8001_ha->irq_vector[0].drv_inst = pm8001_ha;
 	rc = request_irq(pdev->irq, pm8001_interrupt_handler_intx, IRQF_SHARED,
 		DRV_NAME, SHOST_TO_SAS_HA(pm8001_ha->shost));
 	return rc;
@@ -1112,7 +1115,8 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
 #endif
 #ifdef PM8001_USE_TASKLET
 	/* For non-msix and msix interrupts */
-	if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001))
+	if ((!pdev->msix_cap || !pci_msi_enabled()) ||
+	    (pm8001_ha->chip_id == chip_8001))
 		tasklet_kill(&pm8001_ha->tasklet[0]);
 	else
 		for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
@@ -1161,7 +1165,8 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state)
 #endif
 #ifdef PM8001_USE_TASKLET
 	/* For non-msix and msix interrupts */
-	if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001))
+	if ((!pdev->msix_cap || !pci_msi_enabled()) ||
+	    (pm8001_ha->chip_id == chip_8001))
 		tasklet_kill(&pm8001_ha->tasklet[0]);
 	else
 		for (j = 0; j < PM8001_MAX_MSIX_VEC; j++)
@@ -1231,7 +1236,8 @@ static int pm8001_pci_resume(struct pci_dev *pdev)
 		goto err_out_disable;
 #ifdef PM8001_USE_TASKLET
 	/*  Tasklet for non msi-x interrupt handler */
-	if ((!pdev->msix_cap) || (pm8001_ha->chip_id == chip_8001))
+	if ((!pdev->msix_cap || !pci_msi_enabled()) ||
+	    (pm8001_ha->chip_id == chip_8001))
 		tasklet_init(&pm8001_ha->tasklet[0], pm8001_tasklet,
 			(unsigned long)&(pm8001_ha->irq_vector[0]));
 	else
-- 
2.4.3


  parent reply	other threads:[~2015-10-30 14:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 14:53 [PATCH 0/8] pm80xx: Add ATTO 12Gb HBA support and fix various issues Benjamin Rood
2015-10-30 14:53 ` [PATCH 1/8] pm80xx: configure PHY settings based on subsystem vendor ID Benjamin Rood
2015-11-02  7:51   ` Hannes Reinecke
2015-11-02  8:00   ` Jack Wang
2015-10-30 14:53 ` [PATCH 2/8] pm80xx: add support for PMC Sierra 8070 and PMC Sierra 8072 SAS controllers Benjamin Rood
2015-11-02  7:51   ` Hannes Reinecke
2015-11-02  8:01   ` Jack Wang
2015-10-30 14:53 ` [PATCH 3/8] pm80xx: add ATTO PCI IDs to pm8001_pci_table Benjamin Rood
2015-11-02  7:52   ` Hannes Reinecke
2015-11-02  8:02   ` Jack Wang
2015-10-30 14:53 ` [PATCH 4/8] pm80xx: add support for ATTO devices during SAS address initiailization Benjamin Rood
2015-11-02  7:53   ` Hannes Reinecke
2015-11-02  8:06     ` Jack Wang
2015-11-02 20:39       ` [PATCH v2 4/9] " Benjamin Rood
2015-10-30 14:53 ` [PATCH 5/8] pm80xx: set PHY profiles for ATTO 12Gb SAS controllers Benjamin Rood
2015-11-02  7:57   ` Hannes Reinecke
2015-11-02  8:08   ` Jack Wang
2015-10-30 14:53 ` [PATCH 6/8] pm80xx: do not examine registers for iButton feature if ATTO adapter Benjamin Rood
2015-11-02  7:58   ` Hannes Reinecke
2015-11-02  8:08   ` Jack Wang
2015-10-30 14:53 ` [PATCH 7/8] pm80xx: wait a minimum of 500ms before issuing commands to SPCv Benjamin Rood
2015-11-02  8:00   ` Hannes Reinecke
2015-11-02  8:12   ` Jack Wang
2015-11-02 20:42     ` [PATCH v2 7/9] " Benjamin Rood
2015-10-30 14:53 ` Benjamin Rood [this message]
2015-11-02  8:01   ` [PATCH 8/8] pm80xx: avoid a panic if MSI(X) interrupts are disabled Hannes Reinecke
2015-11-02  8:12   ` Jack Wang
2015-11-03  4:44 ` [PATCH 0/8] pm80xx: Add ATTO 12Gb HBA support and fix various issues Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446216811-2248-9-git-send-email-brood@attotech.com \
    --to=benjaminjrood@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brood@attotech.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=xjtuwjp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.