Re: [PATCH]: be2iscsi: Fix MSIX interrupt names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/20/2011 04:17 PM, Rolf Eike Beer wrote:
> 
> This could be simpler if you would use devres and devm_kzalloc() and 
> devm_request_irq(). You simply need to return with error then and the driver 
> core would free everything you already allocated.
> 
> Eike

Thanks for the suggestion Eike.

I've never used devres before.  This seems to work -- please review as [v3].

Thanks,

P.

---8<----

The be2iscsi driver uses a single static array in a function for the
irq action->name field.

This results in /proc/interrupts output like

156:  0          0          0          0          0          0          0 
0          0          0          0          0          0          0          0 
        0          0          0          0          0          0          0    
	     0          0       PCI-MSI-X 
	     Wï9ï_ÞJïïïïïïtïïkfbYïï~}ïïïï(pïïï%ïïï'loCmïïïïïïïn`!ïvïï%ï4ïïïïb\"Pïïïïï/"ïtïïï(bïïIïïÔïï1/"ïïRmïu~ïïïïïïï

			                                                                
			     ï8rï)ïNï>\aj*ïï+ïÐïïÛïwBäïBlïï

In the line above, everything up to PCI-MSI-X is correct.  The pointer for
action->name is garbage and scribbles the output on the screen.

This patch fixes the problem and eliminates the need for memory cleanup by
using devres.

156:          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0          0       PCI-MSI-X  beiscsi_msix_0017


Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 94b9a07..16a83ee 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -874,40 +874,44 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 	struct pci_dev *pcidev = phba->pcidev;
 	struct hwi_controller *phwi_ctrlr;
 	struct hwi_context_memory *phwi_context;
-	int ret, msix_vec, i, j;
-	char desc[32];
+	int ret, msix_vec, i;
 
 	phwi_ctrlr = phba->phwi_ctrlr;
 	phwi_context = phwi_ctrlr->phwi_ctxt;
 
 	if (phba->msix_enabled) {
 		for (i = 0; i < phba->num_cpus; i++) {
-			sprintf(desc, "beiscsi_msix_%04x", i);
+			phba->msi_name[i] = devm_kzalloc(&pcidev->dev, 20,
+							 GFP_KERNEL);
+			if (!phba->msi_name[i])
+				return -ENOMEM;
+			sprintf(phba->msi_name[i], "beiscsi_msix_%04x", i);
 			msix_vec = phba->msix_entries[i].vector;
-			ret = request_irq(msix_vec, be_isr_msix, 0, desc,
-					  &phwi_context->be_eq[i]);
+			ret = devm_request_irq(&pcidev->dev,
+					       msix_vec, be_isr_msix, 0,
+					       phba->msi_name[i],
+					       &phwi_context->be_eq[i]);
 			if (ret) {
 				shost_printk(KERN_ERR, phba->shost,
 					     "beiscsi_init_irqs-Failed to"
 					     "register msix for i = %d\n", i);
-				if (!i)
-					return ret;
-				goto free_msix_irqs;
+				return ret;
 			}
 		}
 		msix_vec = phba->msix_entries[i].vector;
-		ret = request_irq(msix_vec, be_isr_mcc, 0, "beiscsi_msix_mcc",
-				  &phwi_context->be_eq[i]);
+		ret = devm_request_irq(&pcidev->dev,
+				       msix_vec, be_isr_mcc, 0,
+				       "beiscsi_msix_mcc",
+				       &phwi_context->be_eq[i]);
 		if (ret) {
 			shost_printk(KERN_ERR, phba->shost, "beiscsi_init_irqs-"
 				     "Failed to register beiscsi_msix_mcc\n");
-			i++;
-			goto free_msix_irqs;
+			return ret;
 		}
 
 	} else {
-		ret = request_irq(pcidev->irq, be_isr, IRQF_SHARED,
-				  "beiscsi", phba);
+		ret = devm_request_irq(&pcidev->dev, pcidev->irq, be_isr,
+				       IRQF_SHARED, "beiscsi", phba);
 		if (ret) {
 			shost_printk(KERN_ERR, phba->shost, "beiscsi_init_irqs-"
 				     "Failed to register irq\\n");
@@ -915,10 +919,6 @@ static int beiscsi_init_irqs(struct beiscsi_hba *phba)
 		}
 	}
 	return 0;
-free_msix_irqs:
-	for (j = i - 1; j == 0; j++)
-		free_irq(msix_vec, &phwi_context->be_eq[j]);
-	return ret;
 }
 
 static void hwi_ring_cq_db(struct beiscsi_hba *phba,
@@ -4122,11 +4122,12 @@ static void beiscsi_remove(struct pci_dev *pcidev)
 	if (phba->msix_enabled) {
 		for (i = 0; i <= phba->num_cpus; i++) {
 			msix_vec = phba->msix_entries[i].vector;
-			free_irq(msix_vec, &phwi_context->be_eq[i]);
+			devm_free_irq(&pcidev->dev, msix_vec,
+				      &phwi_context->be_eq[i]);
 		}
 	} else
 		if (phba->pcidev->irq)
-			free_irq(phba->pcidev->irq, phba);
+			devm_free_irq(&pcidev->dev, phba->pcidev->irq, phba);
 	pci_disable_msix(phba->pcidev);
 	destroy_workqueue(phba->wq);
 	if (blk_iopoll_enabled)
diff --git a/drivers/scsi/be2iscsi/be_main.h b/drivers/scsi/be2iscsi/be_main.h
index 081c171..1c03174 100644
--- a/drivers/scsi/be2iscsi/be_main.h
+++ b/drivers/scsi/be2iscsi/be_main.h
@@ -287,6 +287,7 @@ struct beiscsi_hba {
 	unsigned int num_cpus;
 	unsigned int nxt_cqid;
 	struct msix_entry msix_entries[MAX_CPUS + 1];
+	char *msi_name[MAX_CPUS + 1];
 	bool msix_enabled;
 	struct be_mem_descriptor *init_mem;
 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux