Issue
I have an adaptec 6805e RAID controller and I'm looking to compile the linux driver for ubuntu 20.04 (kernel=v5.4) but there have been a vast number of changes between kernel ~4x => 5x and I'm not a kernel developer.
OS:
Ubuntu LTS 20.04
Kernel:
v5.4
Adaptec 6805e:
https://storage.microsemi.com/en-us/support/raid/sas_raid/sas-6805e/
Any obvious major hurdles, or advice is appreciated, but right now the issue I'm having is trying to find a replacement for the 'pci_set_dma_max_seg_size' function. I have found the 'dma_set_max_seg_size' but that function accepts a generic device structure (struct device), whereas the adaptec code is using the (struct pci_dev) structure that seems to be specific for PCI devices.
aacraid-1.2.1-52011/linit.c:3992:10: error: implicit declaration of function ‘pci_set_dma_max_seg_size’; did you mean ‘dma_set_max_seg_size’? [-Werror=implicit-function-declaration]
3992 | error = pci_set_dma_max_seg_size(pdev,
Like I said any help is appreciated and if this seems like the wrong way to resolve this problem I'm open to ideas -- I'd like to be able to utilize the benefits of more recent linux developments with a slightly older adaptec chipset.
Thanks
Reference materials: https://elixir.bootlin.com/linux/v5.4.128/source/include/linux
Solution
I believe since Linux v4.x you fell victim to (or benefitted from, depending on your perspective) an effort to overhaul the DMA unmapping support. That patchset, and particularly the specific patch linked to here, show what PCI driver maintainers who were obliged to accommodate this rework were expected to do:
[3/3] PCI: remove pci_set_dma_max_seg_size
Fortunately for you, they gave specific examples of how existing drivers got patched and it's not bad. It should be pretty straightforward for you to figure out at least roughly the Linux version this change corresponds to around the 2018-19 date of the patch's acceptance upstream, code a new stanza in the Adaptec driver source to update it accordingly (e.g.
#if ((LINUX_VERSION_CODE > KERNEL_VERSION(5,1,0))
<patch Adaptec's code to use dma_set_max_seg_size() here>
#else
compile the driver and be on your way. Note that the README does not explicitly mention support for the Adaptec 6805e RAID controller yet, so if you manage to make it work and post your patch you should at least add a comment to the effect that you believe this supports the controller now.
Answered By - Frank Hoeflich Answer Checked By - Terry (WPSolving Volunteer)