Skip to content

Replace pci_enable_msix() with pci_alloc_irq_vectors() - #5

Open
andreas-rollbuehler wants to merge 2 commits into
henning-schild-work:jailhousefrom
andreas-rollbuehler:replace-pci-enable-msix
Open

Replace pci_enable_msix() with pci_alloc_irq_vectors()#5
andreas-rollbuehler wants to merge 2 commits into
henning-schild-work:jailhousefrom
andreas-rollbuehler:replace-pci-enable-msix

Conversation

@andreas-rollbuehler

Copy link
Copy Markdown

Since kernel version 4.8. pci_enable_msix() isn't available any more.
Therefore it is replaced with pci_alloc_irq_vectors() if used
kernel version is >= 4.8

Signed-off-by: Andreas Rollbühler andreas.rollbuehler@siemens.com

@henning-schild henning-schild left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i found a few minor style problems and it seems the free is missing on one path.

#include <linux/uio_driver.h>
#include <linux/io.h>

#include <linux/version.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add this right under the other includes, some people like to order them somehow but i do not care

Comment thread kernel_module/uio/uio_ivshmem.c Outdated
#else
err = pci_alloc_irq_vectors(ivs_info->dev, 1, ivs_info->nvectors,
PCI_IRQ_MSIX);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation of the second line is wrong

Comment thread kernel_module/uio/uio_ivshmem.c Outdated
ivs_info->msix_entries[i].entry = i;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip the empty line

Comment thread kernel_module/uio/uio_ivshmem.c Outdated
} else {
ivs_info->nvectors = err;
}
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with a bit of restructuring both the error handling and the assignment of "nvectors = err" can be reused across the two cases.

Comment thread kernel_module/uio/uio_ivshmem.c Outdated
"%s-config", name);

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip empty line

goto error;
}
#endif
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only real change is the first argument for request_irq, right? If you factor that out all the rest can be reused in both cases instead of copying it.

Did the return value of request_irq change? Why the change from if (err) to if (err < 0)?

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,8,0)
pci_free_irq_vectors(ivs_info->dev);
#endif
return err;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something similar will also have to go into ivshmem_pci_remove. I think that should be called when you unbind the device from the driver or when you rmmod the module.

This patch doesn't change any functionality. It just refactors some code to make
the changes in the subsequent patch easier to read.

Signed-off-by: Andreas Rollbühler <andreas.rollbuehler@siemens.com>
Since kernel version 4.8. pci_enable_msix() isn't available any more.
Therefore it is replaced with pci_alloc_irq_vectors() if the used
kernel version is >= 4.8

Signed-off-by: Andreas Rollbühler <andreas.rollbuehler@siemens.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants