Skip to content

Instantly share code, notes, and snippets.

@lethean
Last active March 8, 2016 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lethean/e2e53ca15b1c97cee45a to your computer and use it in GitHub Desktop.
Save lethean/e2e53ca15b1c97cee45a to your computer and use it in GitHub Desktop.
Fix IRQ routing failure of HighPoint RAID driver rr272x_1x in Linux 4.3 and 4.4 versions (http://www.highpoint-tech.com/USA_new/series_rr272x_configuration.htm)
diff --git a/drivers/rr272x/osm/linux/osm_linux.c b/drivers/rr272x/osm/linux/osm_linux.c
index d46ed92..aa5b5f5 100644
--- a/drivers/rr272x/osm/linux/osm_linux.c
+++ b/drivers/rr272x/osm/linux/osm_linux.c
@@ -29,21 +29,6 @@ static int hpt_init_one(HIM *him, struct pci_dev *pcidev)
PVBUS vbus;
PVBUS_EXT vbus_ext;
int order,size;
-
- if (pci_enable_device(pcidev)) {
- os_printk("failed to enable the pci device");
- return -1;
- }
-
- pci_set_master(pcidev);
-
- /* enable 64-bit DMA if possible */
- if (pci_set_dma_mask(pcidev, 0xffffffffffffffffULL)) {
- if (pci_set_dma_mask(pcidev, 0xffffffffUL)) {
- os_printk("failed to set DMA mask\n");
- return -1;
- }
- }
pci_id.vid = pcidev->vendor;
pci_id.did = pcidev->device;
@@ -2611,7 +2596,7 @@ EXPORT_NO_SYMBOLS;
#else
/* scsi_module.c is deprecated in kernel 2.6 */
-static int __init init_this_scsi_driver(void)
+static int init_this_scsi_driver(void)
{
struct scsi_host_template *sht = &driver_template;
struct Scsi_Host *shost;
@@ -2646,7 +2631,7 @@ static int __init init_this_scsi_driver(void)
return error;
}
-static void __exit exit_this_scsi_driver(void)
+static void exit_this_scsi_driver(void)
{
struct scsi_host_template *sht = &driver_template;
struct Scsi_Host *shost, *s;
@@ -2666,8 +2651,72 @@ static void __exit exit_this_scsi_driver(void)
scsi_unregister(shost);
}
-module_init(init_this_scsi_driver);
-module_exit(exit_this_scsi_driver);
+static int linux_pci_probe(struct pci_dev *pcidev,
+ const struct pci_device_id *id)
+{
+ int ret;
+
+ ret = pci_enable_device(pcidev);
+ if (ret) {
+ os_printk("failed to enable the pci device");
+ return ret;
+ }
+
+ pci_set_master(pcidev);
+
+ /* enable 64-bit DMA if possible */
+ ret = pci_set_dma_mask(pcidev, 0xffffffffffffffffULL);
+ if (ret) {
+ ret = pci_set_dma_mask(pcidev, 0xffffffffUL);
+ if (ret) {
+ os_printk("failed to set DMA mask\n");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static void linux_pci_remove(struct pci_dev *pdev)
+{
+ /* nothing to do yet */
+}
+
+static struct pci_device_id linux_pci_id_table[] = {
+ { PCI_DEVICE(0x11ab, 0x9180) },
+ { PCI_DEVICE(0x11ab, 0x9480) },
+ { PCI_DEVICE(0x1b4b, 0x9480) },
+ { PCI_DEVICE(0x1103, 0x2720) },
+ { PCI_DEVICE(0x1103, 0x2721) },
+ { PCI_DEVICE(0x1103, 0x2722) },
+ { PCI_DEVICE(0x1103, 0x2710) },
+ { PCI_DEVICE(0x1103, 0x2711) },
+ { 0, }
+};
+
+MODULE_DEVICE_TABLE(pci, linux_pci_id_table);
+
+static struct pci_driver linux_pci_driver = {
+ .name = driver_name,
+ .id_table = linux_pci_id_table,
+ .probe = linux_pci_probe,
+ .remove = linux_pci_remove,
+};
+
+static int __init linux_pci_driver_init(void)
+{
+ pci_register_driver(&linux_pci_driver);
+ return init_this_scsi_driver();
+}
+
+static void __exit linux_pci_driver_exit(void)
+{
+ exit_this_scsi_driver();
+ pci_unregister_driver(&linux_pci_driver);
+}
+
+module_init(linux_pci_driver_init);
+module_exit(linux_pci_driver_exit);
#endif
@lethean
Copy link
Author

lethean commented Mar 8, 2016

This patch is for Linux 4.3 and 4.4 versions. Note that this patch is not needed any more since Linux 4.5 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment