Deniz-Eren / dev-can-linux

Porting of Linux CAN-bus drivers to QNX
GNU General Public License v2.0
4 stars 1 forks source link

Legacy MSI without Per Vector Masking (PVM) support #26

Closed Deniz-Eren closed 1 month ago

Deniz-Eren commented 8 months ago

Initial experimental implementation of for Legacy PCI 0x05 (MSI) capability without the support for Per Vector Masking (PVM)

Deniz-Eren commented 8 months ago

Created foundry27 post122418

Deniz-Eren commented 8 months ago

Initial experimental implementation for Legacy PCI 0x05 (MSI) capability; for those devices that do not have support for Per Vector Masking (PVM) has been merged to main branch.

Re-opening ticket to keep track of feedback from QNX regarding the topic foundry27 post122418, and pending hardware validation testing.

Deniz-Eren commented 6 months ago

Real hardware testing with legacy PCI 0x05 (MSI) capability has been successful.

Driver verbose output when started:

dev-can-linux -vvvvv
dev-can-linux v1.2.1
Harmonized with Linux Kernel version 66
dev-can-linux comes with ABSOLUTELY NO WARRANTY; for details use option `-w'.
This is free software, and you are welcome to redistribute it
under certain conditions; option `-c' for details.
driver start (version: 1.2.1)
Auto detected device (13fe:00d7) successfully: (driver "adv_pci")
initializing device 13fe:00d7
pci_enable_device: 13fe:00d7
read ssvid: 13fe
read ssid: 00d7
read cs: 0, slot: 0, func: 0, devfn: 0
read capability[2]: 0x10
capability 0x10 (PCIe) already enabled
PCIe version: 1
read capability[1]: 0x05
nirq: 8
capability 0x05 (MSI) Per Vector Masking (PVM) not supported
capability 0x05 (MSI) enabled
read ba[0] MEM { addr: df302000, size: 800 }
io threshold: 0; I/O[0:0], MEM[df302000:df302800]
read ba[1] MEM { addr: df301000, size: 80 }
io threshold: 0; I/O[0:0], MEM[df301000:df302800]
read ba[2] MEM { addr: df300000, size: 80 }
io threshold: 0; I/O[0:0], MEM[df300000:df302800]
read irq[0]: 266
read irq[1]: 267
read irq[2]: 268
read irq[3]: 269
read irq[4]: 270
read irq[5]: 271
read irq[6]: 272
read irq[7]: 273
pci_alloc_irq_vectors
pci_set_master
setup_timer (1a4779cdc0)
pci_resource_start; bar: 0, addr: df302000
ioremap; offset: df302000, size: 400
ioremap [df302000] mapping to [49eb05c000] successful
reg_base=49eb05c000 irq=266
netif_carrier_off
register_netdev: adv_pci-can0
setting BTR0=0x01 BTR1=0x1c
  clock: 8000000Hz
  bitrate: 250000bits/second
  sample_point: 875 (1/10 of percent)
  tq: 250ns (TQ)
  prop_seg: 6
  phase_seg1: 7TQ
  phase_seg2: 2TQ
  sjw: 1TQ
  brp: 2
netif_carrier_on
request_irq; irq: 266, name: adv_pci-can0
attached Legacy-MSI IRQ 266
attached Legacy-MSI IRQ 267
attached Legacy-MSI IRQ 268
attached Legacy-MSI IRQ 269
attached Legacy-MSI IRQ 270
attached Legacy-MSI IRQ 271
attached Legacy-MSI IRQ 272
attached Legacy-MSI IRQ 273
netif_start_queue
resmgr_attach -> 0
resmgr_attach -> 1
setup_timer (1a477b22b0)
pci_resource_start; bar: 0, addr: df302000
ioremap; offset: df302400, size: 400
ioremap [df302400] mapping to [49eb05d400] successful
reg_base=49eb05d400 irq=266
netif_carrier_off
register_netdev: adv_pci-can1
setting BTR0=0x01 BTR1=0x1c
  clock: 8000000Hz
  bitrate: 250000bits/second
  sample_point: 875 (1/10 of percent)
  tq: 250ns (TQ)
  prop_seg: 6
  phase_seg1: 7TQ
  phase_seg2: 2TQ
  sjw: 1TQ
  brp: 2
netif_carrier_on
request_irq; irq: 266, name: adv_pci-can1
netif_start_queue
resmgr_attach -> 2
resmgr_attach -> 3

Driver verbose output when shutdown:

Shutdown IRQ loop
Shutdown program
Shutting down adv_pci
Removing card
Removing device adv_pci-can0
unregister_netdev: adv_pci-can0
netif_stop_queue
free_irq; irq: 266
cancel_delayed_work_sync (1a4779cdc0)
timer_loop shutdown
netif_tx exit: adv_pci-can0
pci_iounmap; addr: 49eb05c000
pci_iounmap; addr: 49eb05c000, size: 400
Removing device adv_pci-can1
unregister_netdev: adv_pci-can1
netif_stop_queue
free_irq; irq: 266
cancel_delayed_work_sync (1a477b22b0)
timer_loop shutdown
netif_tx exit: adv_pci-can1
pci_iounmap; addr: 49eb05d400
pci_iounmap; addr: 49eb05d400, size: 400
pci_free_irq_vectors
pci_disable_device
disabling MSI capability
disabling PCIe capability
disabling PCIe capability not allowed
Deniz-Eren commented 6 months ago

PCI MSI capability is now verified and enabled by default in version v1.2.1.

Only open item for this ticket is to validate the implementation for masking and unmasking the various capabilities with QNX.

Deniz-Eren commented 6 months ago

QNX support requested to validation current implementation. Case number 00204178

Deniz-Eren commented 2 months ago

Recommendations from QNX support:

1) Old devices that only support regular IRQs. Use InterruptMask() and InterruptUnmask(), and take care of shared interrupt lines if present.

2) Legacy PCI devices that have PCI capability 0x05 (MSI) but do not have support for Per Vector Masking (PVM). It is recommended to mask and unmask on the PCI device side, if available. InterruptMask() and InterruptUnmask() can be used, but please note the following.

3) PCI devices with MSI capability with PVM support Use cap_msi_mask_irq_entry() and cap_msi_unmask_irq_entry().

4) PCI devices with MSI-X capability Use cap_msix_mask_irq_entry() and cap_msix_unmask_irq_entry().

Deniz-Eren commented 1 month ago

Test v1.3.4 with real hardware with device 13fe:00d7

#dev-can-linux -Ex -vvvvv

dev-can-linux v1.3.4
Harmonized with Linux Kernel version 69
dev-can-linux comes with ABSOLUTELY NO WARRANTY; for details use option `-w'.
This is free software, and you are welcome to redistribute it
under certain conditions; option `-c' for details.
warning: release versions allow at max -vv option.
driver start (version: 1.3.4)
Auto detected device (13fe:00d7) successfully: (driver "adv_pci")
initializing device 13fe:00d7
read ssvid: 13fe
read ssid: 00d7
read cs: 0, slot: 0, func: 0, devfn: 0
read capability[2]: 0x10
capability 0x10 (PCIe) already enabled
PCIe version: 1
read capability[1]: 0x05
nirq: 8
capability 0x05 (MSI) Per Vector Masking (PVM) not supported
capability 0x05 (MSI) enabled
read ba[0] MEM { addr: df302000, size: 800 }
read ba[1] MEM { addr: df301000, size: 80 }
read ba[2] MEM { addr: df300000, size: 80 }
read irq[0]: 266
read irq[1]: 267
read irq[2]: 268
read irq[3]: 269
read irq[4]: 270
read irq[5]: 271
read irq[6]: 272
read irq[7]: 273
ioremap [df302000] mapping to [1ac8a6a000] successful
reg_base=1ac8a6a000 irq=266
setting BTR0=0x01 BTR1=0x1c
ioremap [df302400] mapping to [1ac8a6b400] successful
reg_base=1ac8a6b400 irq=266
setting BTR0=0x01 BTR1=0x1c