diff --git a/patches/vmebridge.diff b/patches/vmebridge.diff deleted file mode 100644 index 55488ab50b2a11e1a330e5a46ac7c05f3cf3fd91..0000000000000000000000000000000000000000 --- a/patches/vmebridge.diff +++ /dev/null @@ -1,300 +0,0 @@ -diff --git a/vmebridge-ng/driver/Kbuild b/vmebridge-ng/driver/Kbuild -index d66acd8e..64092538 100644 ---- a/vmebridge-ng/driver/Kbuild -+++ b/vmebridge-ng/driver/Kbuild -@@ -1,4 +1,4 @@ --ccflags-y += -g -Wall -Werror -I$(src) -+ccflags-y += -g -Wall -Werror -Wno-error=vla -I$(src) - ccflags-y += -DGIT_VERSION=\"$(GIT_VERSION)\" - - obj-m = vmebus.o -diff --git a/vmebridge-ng/driver/bridges/pldz002/pldz002.h b/vmebridge-ng/driver/bridges/pldz002/pldz002.h -index d1715292..273761b9 100644 ---- a/vmebridge-ng/driver/bridges/pldz002/pldz002.h -+++ b/vmebridge-ng/driver/bridges/pldz002/pldz002.h -@@ -8,7 +8,6 @@ - #define _PLDZ002_H - - #include <linux/version.h> --#include <asm-generic/iomap.h> - - #include "vmebus.h" - #include "vme_bridge.h" -diff --git a/vmebridge-ng/driver/bridges/pldz002/pldz002_irq.c b/vmebridge-ng/driver/bridges/pldz002/pldz002_irq.c -index 34a14b8d..99f9dc5d 100644 ---- a/vmebridge-ng/driver/bridges/pldz002/pldz002_irq.c -+++ b/vmebridge-ng/driver/bridges/pldz002/pldz002_irq.c -@@ -17,6 +17,7 @@ - #include "pldz002.h" - #include "vme_irq.h" - #include "vme_bridge.h" -+#include "vme_compat.h" - - static struct interrupt_stats int_stats[] = { - {.name = "SPURIOUS"}, -diff --git a/vmebridge-ng/driver/vme_bridge.c b/vmebridge-ng/driver/vme_bridge.c -index 4f11778f..7166f7c8 100644 ---- a/vmebridge-ng/driver/vme_bridge.c -+++ b/vmebridge-ng/driver/vme_bridge.c -@@ -516,10 +516,12 @@ out_err: - * If .match fails for a particular device, the device is removed. - */ - -+#if KERNEL_VERSION(3, 15, 0) > LINUX_VERSION_CODE - static void remove_callback(struct device *dev) - { - vme_unregister_device(to_vme_dev(dev)); - } -+#endif - - static ssize_t remove_store(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -@@ -529,12 +531,16 @@ static ssize_t remove_store(struct device *dev, struct device_attribute *attr, - i = kstrtoint(buf, 0, &rm); - if (i < 0) - return -EINVAL; -+#if KERNEL_VERSION(3, 15, 0) > LINUX_VERSION_CODE - /* An attribute cannot be unregistered by one of its own methods, - * so we have to use this roundabout approach. - */ - if (rm) - ret = device_schedule_callback(dev, remove_callback); -- -+#else -+ if (rm) -+ ret = device_remove_file_self(dev, attr); -+#endif - return ret ? ret : count; - } - static DEVICE_ATTR_WO(remove); -@@ -1185,9 +1191,14 @@ static void vme_initialize_device(struct vme_dev *vme_dev) - * It tells if a device belong to a driver that generated the - * device itself - */ -+ -+#if KERNEL_VERSION(5, 3, 0) > LINUX_VERSION_CODE - static int __vme_unregister_find_device(struct device *dev, void *data) -+#else -+static int __vme_unregister_find_device(struct device *dev, const void *data) -+#endif - { -- struct vme_driver *vme_driver = data; -+ struct vme_driver *vme_driver = (struct vme_driver *)data; - - return (dev->platform_data == vme_driver); - } -@@ -1205,7 +1216,8 @@ void vme_unregister_driver(struct vme_driver *vme_driver) - * until we remove them all - */ - dev = driver_find_device(&vme_driver->driver, NULL, -- vme_driver, __vme_unregister_find_device); -+ vme_driver, -+ __vme_unregister_find_device); - if (!dev) - break; - device_unregister(dev); -diff --git a/vmebridge-ng/driver/vme_bus.c b/vmebridge-ng/driver/vme_bus.c -index 499d7b75..da6dc4c9 100644 ---- a/vmebridge-ng/driver/vme_bus.c -+++ b/vmebridge-ng/driver/vme_bus.c -@@ -531,7 +531,6 @@ static void vme_bus_scan_all(struct bus_type *bus) - } - } - } -- - static ssize_t rescan_store(struct bus_type *bus, - const char *buf, size_t count) - { -@@ -544,7 +543,11 @@ static ssize_t rescan_store(struct bus_type *bus, - vme_bus_scan_all(bus); - return count; - } -+#if KERNEL_VERSION(4, 20, 0) <= LINUX_VERSION_CODE - BUS_ATTR_WO(rescan); -+#else -+BUS_ATTR(rescan, 0200, NULL, rescan_store); -+#endif - - static ssize_t bridge_type_show(struct bus_type *bus, char *buf) - { -@@ -562,18 +565,18 @@ static struct attribute *vme_bus_attr_list_dma[] = { - &bus_attr_backoff_time_pci.attr, - &bus_attr_block_size_vme.attr, - &bus_attr_block_size_pci.attr, -- &bus_attr_bridge_type, -+ &bus_attr_bridge_type.attr, - NULL, - }; - - static const struct attribute_group vme_dev_group_basic_dma = { - .name = "dma", -- .attrs = vme_dev_attr_list_basic_dma, -+ .attrs = vme_bus_attr_list_dma, - }; - - - static const struct attribute_group *vme_bus_attrs_groups[] = { -- &vme_bus_attrs_group, -+ &vme_dev_group_basic_dma, - NULL, - }; - #else -diff --git a/vmebridge-ng/driver/vme_compat.h b/vmebridge-ng/driver/vme_compat.h -index 41bc8337..1b1ad82a 100644 ---- a/vmebridge-ng/driver/vme_compat.h -+++ b/vmebridge-ng/driver/vme_compat.h -@@ -80,6 +80,10 @@ extern long get_user_pages_l(unsigned long start, unsigned long nr_pages, - extern int insert_resource_l(struct resource *parent, struct resource *new); - #endif - -+#if KERNEL_VERSION(3,13,0) <= LINUX_VERSION_CODE -+#define DMA_SUCCESS DMA_COMPLETE -+#endif -+ - #if KERNEL_VERSION(3, 10, 0) > LINUX_VERSION_CODE - enum dmaengine_tx_result { - DMA_TRANS_NOERROR = 0, /* SUCCESS */ -diff --git a/vmebridge-ng/driver/vme_debug.c b/vmebridge-ng/driver/vme_debug.c -index 126ee1f3..67f971e2 100644 ---- a/vmebridge-ng/driver/vme_debug.c -+++ b/vmebridge-ng/driver/vme_debug.c -@@ -7,6 +7,7 @@ - #include <linux/debugfs.h> - #include <linux/irq.h> - #include <linux/irqdomain.h> -+#include <linux/uaccess.h> - - #include "vme_irq.h" - #include "vme_bridge.h" -diff --git a/vmebridge-ng/driver/vme_dmaengine.c b/vmebridge-ng/driver/vme_dmaengine.c -index 4852ccc4..b2ba991d 100644 ---- a/vmebridge-ng/driver/vme_dmaengine.c -+++ b/vmebridge-ng/driver/vme_dmaengine.c -@@ -36,6 +36,7 @@ - #include <linux/delay.h> - #include <linux/sched.h> - #include <linux/semaphore.h> -+#include <linux/version.h> - - #include "vmebus.h" - #include "vme_bridge.h" -@@ -141,7 +142,7 @@ enum vme_dmaengine_mode { - VME_DMAENGINE_MODE_DIRECT, - }; - --static void vme_dma_terminate_all(struct dma_chan *dchan) -+static int vme_dma_terminate_all(struct dma_chan *dchan) - { - struct vme_dma_chan *vdchan = to_vme_dma_chan(dchan); - struct vme_bridge_dma_mgr *dma_mgr = -@@ -178,8 +179,29 @@ static void vme_dma_terminate_all(struct dma_chan *dchan) - vdchan->tx_desc_current = NULL; - out: - spin_unlock_irqrestore(&vdchan->lock, flags); -+ -+ return 0; -+} -+ -+static int vme_dma_start(struct dma_chan *dchan) -+{ -+ struct vme_dma_chan *vdchan = to_vme_dma_chan(dchan); -+ struct vme_bridge_dma_mgr *dma_mgr = -+ to_vme_bridge_dma_mgr(vdchan->dchan.device); -+ -+ dma_mgr->ops->dma_set_ctrl(vdchan, VME_DMA_START); -+ return 0; - } - -+static int vme_dma_pause(struct dma_chan *dchan) -+{ -+ struct vme_dma_chan *vdchan = to_vme_dma_chan(dchan); -+ struct vme_bridge_dma_mgr *dma_mgr = -+ to_vme_bridge_dma_mgr(vdchan->dchan.device); -+ -+ dma_mgr->ops->dma_set_ctrl(vdchan, VME_DMA_PAUSE); -+ return 0; -+} - - /** - * Allocate resources for the given channel. This function must keep the -@@ -329,13 +351,11 @@ static void vme_dmaengine_issue_pending(struct dma_chan *dchan) - * It allows drivers to send commands to the engine. - * For the time being we only support the TERMINATE command - */ -+#if KERNEL_VERSION(4, 0, 0) > LINUX_VERSION_CODE - static int vme_dmaengine_device_control(struct dma_chan *dchan, - enum dma_ctrl_cmd cmd, - unsigned long arg) - { -- struct vme_dma_chan *vdchan = to_vme_dma_chan(dchan); -- struct vme_bridge_dma_mgr *dma_mgr = -- to_vme_bridge_dma_mgr(vdchan->dchan.device); - int ret = 0; - - switch (cmd) { -@@ -347,11 +367,11 @@ static int vme_dmaengine_device_control(struct dma_chan *dchan, - * Pause works only with linked-list mode. This engine will - * perform *only* linked-list transfers. So, pause always work - */ -- ret = dma_mgr->ops->dma_set_ctrl(vdchan, VME_DMA_PAUSE); -+ vme_dma_pause(dchan); - udelay(10); - break; - case DMA_RESUME: -- ret = dma_mgr->ops->dma_set_ctrl(vdchan, VME_DMA_START); -+ vme_dma_start(dchan); - break; - default: - ret = -ENXIO; -@@ -360,7 +380,7 @@ static int vme_dmaengine_device_control(struct dma_chan *dchan, - - return ret; - } -- -+#endif - - /** - * The DMA transfer is complete, remove it from the list and try to run -@@ -561,8 +581,25 @@ int vme_dmaengine_init(struct vme_bridge_device *vbridge) - vme_dmaengine_free_chan_resources; - dma_mgr->dma.device_prep_slave_sg = - vme_dmaengine_prep_slave_sg; -+#if KERNEL_VERSION(4, 0, 0) > LINUX_VERSION_CODE - dma_mgr->dma.device_control = - vme_dmaengine_device_control; -+#else -+ dma_mgr->dma.src_addr_widths = -+ DMA_SLAVE_BUSWIDTH_4_BYTES; -+ dma_mgr->dma.dst_addr_widths = -+ DMA_SLAVE_BUSWIDTH_4_BYTES; -+ dma_mgr->dma.directions = -+ 1 << DMA_DEV_TO_MEM | -+ 1 << DMA_MEM_TO_DEV; -+ dma_mgr->dma.residue_granularity = 0; -+ dma_mgr->dma.device_terminate_all = -+ vme_dma_terminate_all; -+ dma_mgr->dma.device_pause = -+ vme_dma_pause; -+ dma_mgr->dma.device_resume = -+ vme_dma_start; -+#endif - dma_mgr->dma.device_tx_status = - dma_cookie_status; - dma_mgr->dma.device_issue_pending = -diff --git a/vmebridge-ng/driver/vme_irq.c b/vmebridge-ng/driver/vme_irq.c -index 01b5cf9d..73227494 100644 ---- a/vmebridge-ng/driver/vme_irq.c -+++ b/vmebridge-ng/driver/vme_irq.c -@@ -338,9 +338,9 @@ static int vme_irq_domain_create(struct vme_bridge_device *vbridge) - irq_mgr->msi_enabled = 1; /* used to disable msi */ - pr_debug(PFX "Enabling MSI capability.\n"); - } -- err = request_irq(vbridge->pdev->irq, -- irq_mgr->ops->interrupt_handler, 0, -- vbridge->pdev->dev.driver->name, vbridge); -+ err = request_threaded_irq(vbridge->pdev->irq, NULL, -+ irq_mgr->ops->interrupt_handler, IRQF_ONESHOT, -+ vbridge->pdev->dev.driver->name, vbridge); - if (err) - goto out; - diff --git a/scripts/vmebridge_build.sh b/scripts/vmebridge_build.sh index 2f5bae563f834b905ebcd36ab1141a43ff67653e..3b3f083bcdc413eea134b0a07df87798ff74c614 100644 --- a/scripts/vmebridge_build.sh +++ b/scripts/vmebridge_build.sh @@ -8,10 +8,9 @@ cd $BUILD_DIR rm -rf ${PROJECT} mkdir -p $PROJECT -[ -d coht ] || git clone https://gitlab.cern.ch/cohtdrivers/coht.git +[ -d coht ] || git clone https://gitlab.cern.ch/dlamprid/coht.git cd coht -#TODO: release! -git checkout -f develop +git checkout -f feature/vmebridge-ng/modernise [ $SKIP_PATCH ] || [ -e $PATCH_DIR/$PROJECT.diff ] && patch -p1 < $PATCH_DIR/$PROJECT.diff cp -r vmebridge-ng/{driver,include,lib,vmeutils} ../${PROJECT}/ cd ../$PROJECT/driver