Created
December 23, 2018 07:06
-
-
Save jsutlovic/8c0c5d855708382ed248370df8033c37 to your computer and use it in GitHub Desktop.
Full RocketRaid 26xx v1.5 Driver Patch for 4.x kernels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/inc/linux/Makefile.def b/inc/linux/Makefile.def | |
index f6f5087..862fa63 100755 | |
--- a/inc/linux/Makefile.def | |
+++ b/inc/linux/Makefile.def | |
@@ -74,18 +74,27 @@ ifndef KERNELDIR | |
KERNELDIR := /lib/modules/$(shell uname -r)/build | |
endif | |
-MAJOR := $(shell expr `grep LINUX_VERSION_CODE $(KERNELDIR)/include/linux/version.h | cut -d\ -f3` / 65536 % 65536) | |
-MINOR := $(shell expr `grep LINUX_VERSION_CODE $(KERNELDIR)/include/linux/version.h | cut -d\ -f3` / 256 % 256) | |
+VERSION_H := $(shell sh -c " \ | |
+if test -f $(KERNELDIR)/include/linux/version.h; then \ | |
+ echo $(KERNELDIR)/include/linux/version.h; \ | |
+elif test -f $(KERNELDIR)/include/generated/uapi/linux/version.h; then \ | |
+ echo $(KERNELDIR)/include/generated/uapi/linux/version.h; \ | |
+fi") | |
+ | |
+MAJOR := $(shell expr `grep LINUX_VERSION_CODE $(VERSION_H) | cut -d\ -f3` / 65536 % 65536) | |
+MINOR := $(shell expr `grep LINUX_VERSION_CODE $(VERSION_H) | cut -d\ -f3` / 256 % 256) | |
KERNEL_VER := $(MAJOR).$(MINOR) | |
ifeq ($(KERNEL_VER),) | |
$(error Cannot find kernel version. Check $(KERNELDIR)/include/linux/version.h.) | |
endif | |
+ifneq ($(MAJOR), 4) | |
ifneq ($(MAJOR), 3) | |
ifneq ($(KERNEL_VER), 2.6) | |
ifneq ($(KERNEL_VER), 2.4) | |
-$(error Only kernel 2.4/2.6/3.x is supported but you use $(KERNEL_VER)) | |
+$(error Only kernel 2.4/2.6/3.x/4.x is supported but you use $(KERNEL_VER)) | |
+endif | |
endif | |
endif | |
endif | |
@@ -153,8 +162,8 @@ CFLAGS := $(C_OPTS) $(C_DEFINES) $(C_INCLUDES) | |
# export variables used by the scripts. | |
export HPT_ROOT TARGETNAME TARGETMODS TARGETOBJS KERNELDIR C_DEFINE KERNEL_VER | |
-#patchkernel: | |
-# @sh $(HPT_ROOT)/osm/linux/patch.sh | |
+patchkernel: | |
+ @sh $(HPT_ROOT)/osm/linux/patch.sh | |
install: $(TARGET) | |
@sh $(HPT_ROOT)/osm/linux/install.sh | |
diff --git a/osm/linux/hptinfo.c b/osm/linux/hptinfo.c | |
index 29909b6..2c38c3e 100644 | |
--- a/osm/linux/hptinfo.c | |
+++ b/osm/linux/hptinfo.c | |
@@ -8,6 +8,7 @@ | |
#include "osm_linux.h" | |
#include "hptintf.h" | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
typedef struct _hpt_GET_INFO { | |
char *buffer; | |
int buflength; | |
@@ -52,6 +53,10 @@ static int hpt_copy_info(HPT_GET_INFO *pinfo, char *fmt, ...) | |
hpt_copy_mem_info(pinfo, buf, len); | |
return len; | |
} | |
+#else // >= KERNEL_VERSION(3,10,0) | |
+typedef struct seq_file HPT_GET_INFO; | |
+#define hpt_copy_info seq_printf | |
+#endif | |
#define HPT_DO_IOCTL(code, inbuf, insize, outbuf, outsize) ({\ | |
IOCTL_ARG arg;\ | |
@@ -181,7 +186,7 @@ static void hpt_dump_devinfo(HPT_GET_INFO *pinfo, DEVICEID id, int indent) | |
devinfo.u.device.ControllerId+1, | |
devinfo.u.device.PathId+1, | |
devinfo.u.device.TargetId+1, | |
- devinfo.u.device.IdentifyData.ModelNumber | |
+ (char*)devinfo.u.device.IdentifyData.ModelNumber | |
); | |
else { | |
memcpy(sn, devinfo.u.device.IdentifyData.SerialNumber, | |
@@ -193,7 +198,7 @@ static void hpt_dump_devinfo(HPT_GET_INFO *pinfo, DEVICEID id, int indent) | |
(devinfo.u.device.Flags & DEVICE_FLAG_IN_ENCLOSURE) ? "E" : "", | |
devinfo.u.device.PathId+1, | |
devinfo.u.device.TargetId+1, | |
- devinfo.u.device.IdentifyData.ModelNumber, sn, | |
+ (char*)devinfo.u.device.IdentifyData.ModelNumber, sn, | |
(int)(devinfo.Capacity*512/1000000), | |
(devinfo.u.device.Flags & DEVICE_FLAG_DISABLED)? "Disabled" : "Normal", | |
devinfo.u.device.ReadAheadEnabled? "[RA]":"", | |
@@ -234,15 +239,25 @@ static void hpt_dump_devinfo(HPT_GET_INFO *pinfo, DEVICEID id, int indent) | |
} | |
#define MAX_PHYSICAL_DEVICE 128 | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
int hpt_proc_get_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length) | |
+#else | |
+int hpt_proc_show_info(struct seq_file *m, struct Scsi_Host *host) | |
+#endif | |
{ | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
HPT_GET_INFO info; | |
+#else | |
+#define info (*m) | |
+#define buffillen count ? 0 : 0 | |
+#endif | |
int i, j, count; | |
CONTROLLER_INFO_V2 conInfo2; | |
DEVICEID *ids; | |
int devs; | |
PVBUS_EXT vbus_ext = get_vbus_ext(host); | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
info.buffer = buffer; | |
info.buflength = length; | |
info.bufoffset = offset; | |
@@ -250,6 +265,7 @@ int hpt_proc_get_info(struct Scsi_Host *host, char *buffer, char **start, off_t | |
info.buffillen = 0; | |
if (start) *start = buffer; | |
+#endif | |
hpt_copy_info(&info, "%s %s\n\n", driver_name_long, driver_ver); | |
diff --git a/osm/linux/install.sh b/osm/linux/install.sh | |
index 4dff2e9..0e57788 100644 | |
--- a/osm/linux/install.sh | |
+++ b/osm/linux/install.sh | |
@@ -10,7 +10,7 @@ case ${KERNEL_VER} in | |
OBJ=o | |
MODVER=`modinfo -f%{kernel_version} ${PWD}/${TARGETNAME}.${OBJ}` | |
;; | |
- 2.6 | 3.* ) | |
+ 2.6 | 3.* | 4.* ) | |
OBJ=ko | |
MODVER=`modinfo -F vermagic ${PWD}/${TARGETNAME}.${OBJ} | cut -d' ' -f1` | |
;; | |
diff --git a/osm/linux/os_linux.c b/osm/linux/os_linux.c | |
index 8f3fd0a..4c8c54a 100644 | |
--- a/osm/linux/os_linux.c | |
+++ b/osm/linux/os_linux.c | |
@@ -203,7 +203,11 @@ void *os_kmap_sgptr(PSG psg) | |
if (page) | |
return (PageHighMem(page)? | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) | |
+ (char *)kmap_atomic(page) : | |
+#else | |
(char *)kmap_atomic(page, HPT_KMAP_TYPE) : | |
+#endif | |
(char *)page_address(page)) | |
+ (psg->addr.bus & 0xffffffff); | |
else | |
@@ -213,7 +217,11 @@ void *os_kmap_sgptr(PSG psg) | |
void os_kunmap_sgptr(void *ptr) | |
{ | |
if ((HPT_UPTR)ptr >= (HPT_UPTR)high_memory) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) | |
+ kunmap_atomic(ptr); | |
+#else | |
kunmap_atomic(ptr, HPT_KMAP_TYPE); | |
+#endif | |
} | |
#else | |
void *os_kmap_sgptr(PSG psg) { return psg->addr._logical; } | |
@@ -356,17 +364,25 @@ void refresh_sd_flags(PVBUS_EXT vbus_ext) | |
blkdev_get(bdev, FMODE_READ, 0 __BDEV_RAW) | |
#endif | |
==0) { | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0) | |
+ if (bdev->bd_disk && ((disk_to_dev(bdev->bd_disk)->parent)==&SDptr->sdev_gendev)) { | |
+#else | |
if (bdev->bd_disk && bdev->bd_disk->driverfs_dev==&SDptr->sdev_gendev) { | |
+#endif | |
if (vbus_ext->sd_flags[id] & SD_FLAG_REVALIDATE) { | |
if (bdev->bd_disk->fops->revalidate_disk) | |
bdev->bd_disk->fops->revalidate_disk(bdev->bd_disk); | |
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) | |
+ inode_lock(bdev->bd_inode); | |
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) | |
mutex_lock(&bdev->bd_inode->i_mutex); | |
#else | |
down(&bdev->bd_inode->i_sem); | |
#endif | |
i_size_write(bdev->bd_inode, (loff_t)get_capacity(bdev->bd_disk)<<9); | |
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,7,0) | |
+ inode_unlock(bdev->bd_inode); | |
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) | |
mutex_unlock(&bdev->bd_inode->i_mutex); | |
#else | |
up(&bdev->bd_inode->i_sem); | |
diff --git a/osm/linux/osm_linux.c b/osm/linux/osm_linux.c | |
index a62cc6a..be13284 100644 | |
--- a/osm/linux/osm_linux.c | |
+++ b/osm/linux/osm_linux.c | |
@@ -449,7 +449,11 @@ static int scsicmd_buf_get(Scsi_Cmnd *cmd, void **pbuf) | |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) | |
struct scatterlist *sg; | |
sg = scsi_sglist(cmd); | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) | |
+ *pbuf = kmap_atomic(HPT_SG_PAGE(sg)) + sg->offset; | |
+#else | |
*pbuf = kmap_atomic(HPT_SG_PAGE(sg), HPT_KMAP_TYPE) + sg->offset; | |
+#endif | |
buflen = sg->length; | |
#else | |
@@ -479,7 +483,11 @@ static inline void scsicmd_buf_put(struct scsi_cmnd *cmd, void *buf) | |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) | |
struct scatterlist *sg; | |
sg = scsi_sglist(cmd); | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) | |
+ kunmap_atomic((char *)buf - sg->offset); | |
+#else | |
kunmap_atomic((char *)buf - sg->offset, HPT_KMAP_TYPE); | |
+#endif | |
#else | |
if (cmd->use_sg) { | |
@@ -1799,6 +1807,7 @@ invalid: | |
return -EINVAL; | |
} | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
static int hpt_proc_info26(struct Scsi_Host *host, char *buffer, char **start, | |
off_t offset, int length, int inout) | |
{ | |
@@ -1808,6 +1817,7 @@ static int hpt_proc_info26(struct Scsi_Host *host, char *buffer, char **start, | |
else | |
return hpt_proc_get_info(host, buffer, start, offset, length); | |
} | |
+#endif | |
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) | |
static int hpt_proc_info24(char *buffer,char **start, off_t offset, | |
@@ -2108,7 +2118,12 @@ static Scsi_Host_Template driver_template = { | |
#endif | |
#else /* 2.6.x */ | |
proc_name: driver_name, | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
proc_info: hpt_proc_info26, | |
+#else | |
+ show_info: hpt_proc_show_info, | |
+ write_info: hpt_proc_set_info, | |
+#endif | |
max_sectors: 128, | |
#endif | |
this_id: -1 | |
diff --git a/osm/linux/osm_linux.h b/osm/linux/osm_linux.h | |
index 5edd242..ed9c553 100644 | |
--- a/osm/linux/osm_linux.h | |
+++ b/osm/linux/osm_linux.h | |
@@ -175,7 +175,9 @@ typedef void irqreturn_t; | |
#define scsi_set_max_cmd_len(host, len) host->max_cmd_len = len | |
#endif | |
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) | |
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) | |
+#define HPT_FIND_PCI_DEVICE pci_get_device | |
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) | |
#define HPT_KMAP_TYPE KM_BIO_SRC_IRQ | |
#define HPT_FIND_PCI_DEVICE pci_get_device | |
#else | |
@@ -297,6 +299,9 @@ VBUS_EXT, *PVBUS_EXT; | |
void refresh_sd_flags(PVBUS_EXT vbus_ext); | |
void hpt_do_ioctl(IOCTL_ARG *ioctl_args); | |
void hpt_stop_tasks(PVBUS_EXT vbus_ext); | |
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) | |
int hpt_proc_get_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length); | |
- | |
+#else | |
+int hpt_proc_show_info(struct seq_file *m, struct Scsi_Host *host); | |
+#endif | |
#endif | |
diff --git a/osm/linux/patch.sh b/osm/linux/patch.sh | |
index f009eda..0b14f53 100644 | |
--- a/osm/linux/patch.sh | |
+++ b/osm/linux/patch.sh | |
@@ -143,7 +143,7 @@ CONFIG_SCSI_${UTARGETNAME}=y | |
fi | |
fi | |
;; | |
- 2.6 ) | |
+ 2.6 | 3.* | 4.* ) | |
cd ${HPT_ROOT}/lib/linux/free-${ARCH}-regparm0 | |
ld -r -o ${ARCH}-${TARGETNAME}.obj ${TARGETMODS} | |
mv ${ARCH}-${TARGETNAME}.obj $KERNELDIR/drivers/scsi/${TARGETNAME}/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment