iMX6: MSI-X not working in Linux PCIe device driver - linux-device-driver

I'm trying to get MSI-X working on an iMX6 (Freescale/NXP/Qualcomm) CPU in Linux v4.1 for a PCIe character device driver. Whenever I call either pci_enable_msix() or pci_enable_msix_range() or pci_enable_msix_exact() I get an EINVAL value returned. I do have the CONFIG_PCI_MSI option selected in the kernel configuration and I am also able to get single MSI working with pci_enable_msi(), but I cannot get multiple MSI working either.
I have tested my driver code on an Intel i7 running kernel v3 with the same PCIe hardware attached and I was able to get MSI-X working without any problems so I know my code is correctly written and the hardware is correctly functioning.
When running on the iMX6 I can use lspci -v to view that the hardware has MSI-X capabilities and see the number of IRQs it allows. I can even get the same correct number in my driver when calling pci_msix_vec_count().Questions
Are there any other kernel configuration flags I need to set?
Is there anything specific to the iMX6 CPU I need to consider?
Does anyone have any experience with the iMX6 and either MSI-X or
multiple MSI?

Related

HOW TO ENABLE BOOT IN BIOS LEGACY MODE ON SIMICS PUBLIC PREVIEW 6.0.43

I'm trying to enable boot in bios legacy mode with no success.
Just as test case I'm using an old Ubuntu server image (bionic-server-cloudimg-i386.img).
This what I did:
Under %simics%/simics-qsp-cpu-6.0.1/targets/qsp-x86 I modified qsp-client-core.simics file as below:
# In order to run this, the QSP-x86 (2096), QSP-CPU (8112) and
# QSP-Clear-Linux (4094) packages should be installed.
decl {
! Script that runs the Quick Start Platform (QSP) with a client processor core.
params from "%simics%/targets/qsp-x86/qsp-clear-linux.simics"
default cpu_comp_class = "x86-coffee-lake"
default num_cores = 4
default enable_efi = FALSE
}
$disk0_image="/home/peppe/Scrivania/bionic.craff"
#$disk0_image="/opt/simics/simics-qsp-clear-linux-6.0.9/targets/qsp-x86/images/cl-b28910-v2.craff"
run-command-file "%simics%/targets/qsp-x86/qsp-clear-linux.simics"
When I run this file, the boot gets stuck with "Start PXE over IPv4" message (i.e. Simics doesn't find the UEFI partition and try to boot from network).
If I run the same file with cl-b28910-v2.craff image all works fine.
Note when it comes to bionic image I tried both with the raw format and with the craff format.
Also note the same bionic image boots as expected in QEMU.
My question: is the param enable_efi = FALSE enough to force Simics to boot in legacy mode?
If no what else do I have to do ?
The QSP really only supports booting from UEFI, and only a UEFI binary is shipping with the platform. All modern operating systems boot from UEFI anyway, so this should not be a big deal.
Indeed QSP model is not shipped with legacy BIOS image, but this does not prevent you from creating such and enable it on QSP model yourself. In particular, microvm or regular bios.bin (SeaBIOS?) from QEMU might work with some changes (removing QEMU specifics).

How to find out who loads specific Linux kernel module?

I built a certain driver as module (m) for Linux, the spi-imx by NXP. Nontheless, Linux probes this driver when booting. I'm struggling to find out what process/other module/driver requests this spi-imx driver. A depmod does not show any dependencies between the spi-imx an other modules (except for the spidev as submodule).
After some research, I found out that Linux automatically (?) calls modprobe when it detects a new device. So does Linux actually call modprobe because the ecSPI'S status in the device tree as "okay"? If so, how can I prevent this? I would like to dynamically load the spi-imx from a user space application via modprobe. The story behind it: a coprocessor uses this SPI line in parallel to the Linux boot process. This interferes of course and interrupts the coprocessor's use of the SPI line. When the coprocessor has finished its transfer via SPI (a boot mechanism as well), it should hand over the SPI line to Linux.
I'm very thankful for any kind of tips, links, hints and comments on this.
Thanks a lot for the answers. As you guys mentioned, I also found out that Linux itself probes the device if present ("okay").
One possible solution is to complete cut off the modprobe call via an entry like "install spi-imx /bin/false" in the *.conf file. But that makes it impossible to load the driver via modprobe, for Linux and for user space.
"blacklist spi-imx" inside a *.conf located at /etc/modprobe.d/ is the way to prevent Linux from probing the driver when booting. After that, a modprobe from user space can successfully load the driver afterwards.
Thanks again & best regards

Is there a library for MSR605X that works with Raspberry Pi?

I have been trying to locate a working library for the MSR605X magnetic card reader/writer. At time of writing, I have tried five separate libraries. Only two of these were explicitly for the 605X the other three were for the older 605. All the libraries I have tried either did nothing at all or errored before completing a command (can't figure out the errors either).
I am running Raspberry Pi OS 32 bit on a Raspberry Pi 3 B+ the MSR605X communicates via a USB connection.
So far the library that seems to be most complete is: https://pypi.org/project/msrx/
However, I can not get this library to read or write (either nothing happens or I get a Serial exception "cannot reconfig port).
Any help or links to documentation for this reader is welcome.
EDIT: Adding the commands ran with the above library
msrx -D /dev/input/event4 read
msrx -D /dev/input/jso0 read
The -D is to specify the device path (default is /dev/ttyUSB0 which doesn't exist on my system). I obtained the above two paths by searching for USB serial devices then matching the search result to the device ID which I obtained from lsusb.
Running these commands results in a serial exception (could not reconfig port) which I assume means that I have the wrong device path. I have also checked for any tty* device paths that are changed when I plug in the reader. I consistently get a permission denied error whenever trying to run the above commands with a tty* device path (I am root on this system).
msrx author here — MSR605 requires an external 9V power injected into its cable (via the barrel jack port), otherwise it won't power up properly.

Debugging Linux LKM: how to force probe()

When you insert LKM with insmod it does not seem to execute defined probe() function. What do I need to do to trigger it?
Background: trying to create driver for MAX14830 for old kernel (2.6.39). Cannot use one available (max310x.c) because of old kernel, no support for regmap etc. In the source tree of old kernel there is max3107 driver (same thing, but for 1 serial port, while 14830 has 4). Both drivers use probe functions for initialization, as the SOC communicates with MAX chip over spi. I want to develop driver as LKM first.
What could be my problem?

Start service in kernel mode (Vista)

I'd like to start service before user mode is loaded (in kernel mode).
The reason is I wanna run several system applications(asm code to write data to BIOS) that are not allowed in user mode (privileges problem).
That's why I got an idea: 1. Write windows service 2. Start and run it in kernel mode
Is it possible?
Are there any other ways to solve the problem?
I don't usually use Vista (use linux instead), that's why I'm asking.
Windows services are user-mode applications. To run in kernel-mode you should write a driver. (So-called "legacy" driver will be enough, see Driver Development Part 1: Introduction to Drivers).