Skip to contentSkip to conversation

scsi: arcmsr: Add driver module parameter msi_enable

PATCH Superseded Ching Huang 2 participants 4 messages Nov 23, 2017 – Nov 24, 2017 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 scsi: arcmsr: Add driver module parameter msi_enable

From: Ching Huang <[email protected]>

Add module parameter msi_enable to has a chance to disable msi interrupt if it does not work properly.

---

drivers/scsi/arcmsr/arcmsr_hba.c +10 -2
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -75,6 +75,10 @@ MODULE_DESCRIPTION("Areca ARC11xx/12xx/1
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 
+static int msi_enable = 1;
+module_param(msi_enable, int, S_IRUGO);
+MODULE_PARM_DESC(msi_enable, " Enable MSI interrupt(0 ~ 1), msi_enable=1(enable), =0(disable)");
+
 static int host_can_queue = ARCMSR_DEFAULT_OUTSTANDING_CMD;
 module_param(host_can_queue, int, S_IRUGO);
 MODULE_PARM_DESC(host_can_queue, " adapter queue depth(32 ~ 1024), default is 128");
@@ -831,11 +835,15 @@ arcmsr_request_irq(struct pci_dev *pdev,
 		pr_info("arcmsr%d: msi-x enabled\n", acb->host->host_no);
 		flags = 0;
 	} else {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1,
-				PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+		if (msi_enable == 1)
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
+		else
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY);
 		if (nvec < 1)
 			return FAILED;
 
+		if (msi_enable == 1)
+			pr_info("arcmsr%d: msi enabled\n", acb->host->host_no);
 		flags = IRQF_SHARED;
 	}
 
#1 lore raw
Quoted 11 lines · Ching Huang

From: Ching Huang <[email protected]>

Add module parameter msi_enable to has a chance to disable msi interrupt if it does not work properly.

---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 79

Quoted 5 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
@@ -75,6 +75,10 @@ MODULE_DESCRIPTION("Areca ARC11xx/12xx/1
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 
+static int msi_enable = 1;
+module_param(msi_enable, int, S_IRUGO);
                                 ^^^^^^^

checkpatch.pl will complain that this should be 0444

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 80

Quoted 1 line
drivers/scsi/arcmsr/arcmsr_hba.c +1 -0
+MODULE_PARM_DESC(msi_enable, " Enable MSI interrupt(0 ~ 1), msi_enable=1(enable), =0(disable)");
                                 ^

Remove the extra space

Quoted 6 lines
drivers/scsi/arcmsr/arcmsr_hba.c +1 -0
+
 static int host_can_queue = ARCMSR_DEFAULT_OUTSTANDING_CMD;
 module_param(host_can_queue, int, S_IRUGO);
 MODULE_PARM_DESC(host_can_queue, " adapter queue depth(32 ~ 1024), default is 128");
@@ -831,11 +835,15 @@ arcmsr_request_irq(struct pci_dev *pdev,
 		pr_info("arcmsr%d: msi-x enabled\n", acb->host->host_no);

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 843

Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4 -2
 		flags = 0;
 	} else {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1,
-				PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+		if (msi_enable == 1)
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
+		else
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY);
 		if (nvec < 1)
 			return FAILED;

I feel like we should try PCI_IRQ_MSI then if it fails we could fall back to PCI_IRQ_LEGACY. Originally, it worked like this and now it just fails unless you toggle the module param. It's a regression.

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 845

Quoted 3 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+		if (msi_enable == 1)
+			pr_info("arcmsr%d: msi enabled\n", acb->host->host_no);

This printk could be improved. Use dev_info(&pdev->dev, for a start. I know that the other prints don't use this, but we could use it one time then slowly add more users until more are using dev_info() than pr_info() and then someone will decide to clean up the old users.

regards,
dan carpenter

#3 lore raw
In reply to Ching Huang
Quoted 65 lines · Ching Huang

Hello Dan,

Quoted 15 lines · Dan Carpenter
Quoted 14 lines · Ching Huang

From: Ching Huang <[email protected]>

Add module parameter msi_enable to has a chance to disable msi interrupt if it does not work properly.

---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c

drivers/scsi/arcmsr/arcmsr_hba.c +0 -0
@@ -75,6 +75,10 @@ MODULE_DESCRIPTION("Areca ARC11xx/12xx/1
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 
Quoted 4 lines

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 79

Quoted 2 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+static int msi_enable = 1;
+module_param(msi_enable, int, S_IRUGO);
                                 ^^^^^^^

checkpatch.pl will complain that this should be 0444

S_IRUGO value is 00444, defined in <linux/stat.h> -> <uapi/linux/stat.h>.
A. It will be not a issue.

Quoted 4 lines

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 80

Quoted 2 lines
drivers/scsi/arcmsr/arcmsr_hba.c +1 -0
+MODULE_PARM_DESC(msi_enable, " Enable MSI interrupt(0 ~ 1), msi_enable=1(enable), =0(disable)");
                                 ^

Remove the extra space

OK

Quoted 13 lines
Quoted 13 lines
drivers/scsi/arcmsr/arcmsr_hba.c +3 -2
+
 static int host_can_queue = ARCMSR_DEFAULT_OUTSTANDING_CMD;
 module_param(host_can_queue, int, S_IRUGO);
 MODULE_PARM_DESC(host_can_queue, " adapter queue depth(32 ~ 1024), default is 128");
@@ -831,11 +835,15 @@ arcmsr_request_irq(struct pci_dev *pdev,
 		pr_info("arcmsr%d: msi-x enabled\n", acb->host->host_no);
 		flags = 0;
 	} else {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1,
-				PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+		if (msi_enable == 1)
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
Quoted 8 lines

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 843

Quoted 4 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+		else
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY);
 		if (nvec < 1)
 			return FAILED;

I feel like we should try PCI_IRQ_MSI then if it fails we could fall back to PCI_IRQ_LEGACY. Originally, it worked like this and now it just fails unless you toggle the module param. It's a regression.

update as below
---

		unsigned int irq_flag;
		irq_flag = PCI_IRQ_LEGACY;
		if (msi_enable == 1)
			irq_flag |= PCI_IRQ_MSI;
		nvec = pci_alloc_irq_vectors(pdev, 1, 1, irq_flag);
Quoted 8 lines

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 845

Quoted 3 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+		if (msi_enable == 1)
+			pr_info("arcmsr%d: msi enabled\n", acb->host->host_no);

This printk could be improved. Use dev_info(&pdev->dev, for a start. I know that the other prints don't use this, but we could use it one time then slowly add more users until more are using dev_info() than pr_info() and then someone will decide to clean up the old users.

Quoted 10 lines

update as below
---

		if (msi_enable == 1)
			dev_info(&pdev->dev, "msi enabled\n");
Quoted 4 lines

regards,
dan carpenter

Dan,.

This new patch apply to mkp/scsi.git 4.16/scsi-queue
---

drivers/scsi/arcmsr/arcmsr_hba.c +13 -3
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -75,6 +75,10 @@ MODULE_DESCRIPTION("Areca ARC11xx/12xx/1
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 
+static int msi_enable = 1;
+module_param(msi_enable, int, S_IRUGO);
+MODULE_PARM_DESC(msi_enable, "Enable MSI interrupt(0 ~ 1), msi_enable=1(enable), =0(disable)");
+
 static int host_can_queue = ARCMSR_DEFAULT_OUTSTANDING_CMD;
 module_param(host_can_queue, int, S_IRUGO);
 MODULE_PARM_DESC(host_can_queue, " adapter queue depth(32 ~ 1024), default is 128");
@@ -831,11 +835,17 @@ arcmsr_request_irq(struct pci_dev *pdev,
 		pr_info("arcmsr%d: msi-x enabled\n", acb->host->host_no);
 		flags = 0;
 	} else {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1,
-				PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+		if (msi_enable == 1) {
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
+			if (nvec == 1) {
+				dev_info(&pdev->dev, "msi enabled\n");
+				goto msi_int1;
+			}
+		}
+		nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY);
 		if (nvec < 1)
 			return FAILED;
-
+msi_int1:
 		flags = IRQF_SHARED;
 	}
 
#2 lore raw
In reply to Dan Carpenter

Hello Dan,

Quoted 15 lines · Dan Carpenter
Quoted 14 lines · Ching Huang

From: Ching Huang <[email protected]>

Add module parameter msi_enable to has a chance to disable msi interrupt if it does not work properly.

---

diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c

drivers/scsi/arcmsr/arcmsr_hba.c +0 -0
@@ -75,6 +75,10 @@ MODULE_DESCRIPTION("Areca ARC11xx/12xx/1
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_VERSION(ARCMSR_DRIVER_VERSION);
 
Quoted 4 lines

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 79

Quoted 2 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+static int msi_enable = 1;
+module_param(msi_enable, int, S_IRUGO);
                                 ^^^^^^^

checkpatch.pl will complain that this should be 0444

S_IRUGO value is 00444, defined in <linux/stat.h> -> <uapi/linux/stat.h>.
A. It will be not a issue.

Quoted 4 lines

drivers/scsi/arcmsr/arcmsr_hba.c MODULE_DESCRIPTION("Areca ARC11xx/12xx/1 · line 80

Quoted 2 lines
drivers/scsi/arcmsr/arcmsr_hba.c +1 -0
+MODULE_PARM_DESC(msi_enable, " Enable MSI interrupt(0 ~ 1), msi_enable=1(enable), =0(disable)");
                                 ^

Remove the extra space

OK

Quoted 13 lines
Quoted 13 lines
drivers/scsi/arcmsr/arcmsr_hba.c +3 -2
+
 static int host_can_queue = ARCMSR_DEFAULT_OUTSTANDING_CMD;
 module_param(host_can_queue, int, S_IRUGO);
 MODULE_PARM_DESC(host_can_queue, " adapter queue depth(32 ~ 1024), default is 128");
@@ -831,11 +835,15 @@ arcmsr_request_irq(struct pci_dev *pdev,
 		pr_info("arcmsr%d: msi-x enabled\n", acb->host->host_no);
 		flags = 0;
 	} else {
-		nvec = pci_alloc_irq_vectors(pdev, 1, 1,
-				PCI_IRQ_MSI | PCI_IRQ_LEGACY);
+		if (msi_enable == 1)
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
Quoted 8 lines

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 843

Quoted 4 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+		else
+			nvec = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_LEGACY);
 		if (nvec < 1)
 			return FAILED;

I feel like we should try PCI_IRQ_MSI then if it fails we could fall back to PCI_IRQ_LEGACY. Originally, it worked like this and now it just fails unless you toggle the module param. It's a regression.

update as below
---

		unsigned int irq_flag;
		irq_flag = PCI_IRQ_LEGACY;
		if (msi_enable == 1)
			irq_flag |= PCI_IRQ_MSI;
		nvec = pci_alloc_irq_vectors(pdev, 1, 1, irq_flag);
Quoted 8 lines

drivers/scsi/arcmsr/arcmsr_hba.c arcmsr_request_irq(struct pci_dev *pdev, · line 845

Quoted 3 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -0
+		if (msi_enable == 1)
+			pr_info("arcmsr%d: msi enabled\n", acb->host->host_no);

This printk could be improved. Use dev_info(&pdev->dev, for a start. I know that the other prints don't use this, but we could use it one time then slowly add more users until more are using dev_info() than pr_info() and then someone will decide to clean up the old users.

update as below
---

		if (msi_enable == 1)
			dev_info(&pdev->dev, "msi enabled\n");
Quoted 4 lines

regards,
dan carpenter