pangzhen1xiaomi opened a new pull request, #22165:
URL: https://github.com/apache/nuttx/pull/22165

   ## Summary
   
   * Why: on a multi-core part where each core runs its own NuttX image
     (AMP, `CONFIG_SMP` off), a driver brought up by a core other than CPU0
     must route its interrupt to that core. `up_affinity_irq()` does this, but
     `include/nuttx/arch.h` only declares it under `CONFIG_SMP`, although the
     interrupt controller drivers that implement it (armv7-a/armv7-r GICv2,
     armv8-r GICv3, arm64 GICv2/GICv3, tricore, intel64) build it in every
     mode. The CTU CAN FD PCI driver never routes its interrupt, so on such a
     core CAN does not start: the interrupt keeps going to CPU0.
   * What:
     1. `arch.h: declare up_affinity_irq() outside of SMP mode` - declare it
        under `#ifndef CONFIG_ARCH_NOINTC`, like `up_enable_irq()` and
        `up_disable_irq()`.
     2. `drivers/can/ctucanfd: fix CAN startup on core1` - after attaching the
        interrupt, route it to the CPU that initializes the device.
   
     The second commit needs the first one to build without `CONFIG_SMP`, so
     they are submitted together.
   * Related: N/A
   
   ## Impact
   
   * Is new feature added? Is existing feature changed? YES:
     `up_affinity_irq()` is now declared in non-SMP builds, and the CTU CAN FD
     driver routes its interrupt to the initializing CPU.
   * Impact on user (will user need to adapt to change)? NO.
   * Impact on build (will build process change)? NO.
   * Impact on hardware (will arch(s) / board(s) / driver(s) change)? YES,
     `drivers/can/ctucanfd_pci.c` only. In SMP builds the interrupt is now bound
     to the CPU that probes the card instead of the controller default.
     `CAN_CTUCANFD` depends on `PCI`, which in-tree is only used by arm, arm64
     and x86_64; all of them implement `up_affinity_irq()`.
   * Impact on documentation (is update required / provided)? NO.
   * Impact on security (any sort of implications)? NO.
   * Impact on compatibility (backward/forward/interoperability)? NO. Arches
     without an implementation only get a declaration they do not call.
   * Anything else to consider or add? NO.
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host(s): Ubuntu 22.04.5 LTS, x86_64, host gcc 13.4.0,
     aarch64-none-elf-gcc 13.4.0, x86_64-none-elf-gcc 13.4.0.
   * Target(s): qemu-armv8a:netnsh and qemu-intel64:nsh_pci (non-SMP),
     qemu-armv8a:netnsh + `CONFIG_SMP` and qemu-intel64:nsh_pci_smp (SMP), all
     with `CONFIG_CAN` and `CONFIG_CAN_CTUCANFD`; sim:nsh and sim:smp for
     regression.
   
   Build only: I have no AMP setup to run the second commit on, and on
   qemu-armv8a the driver already faults in `ctucanfd_probe()` on master
   (data abort in `putreg32()` while accessing the card), so I could not
   exercise it at run time there.
   
   Testing logs before change, with only the ctucanfd commit applied on master:
   
   ```
   qemu-armv8a:netnsh (non-SMP):
     can/ctucanfd_pci.c:1686:3: error: implicit declaration of function 
'up_affinity_irq' [-Werror=implicit-function-declaration]
   qemu-intel64:nsh_pci (non-SMP):
     can/ctucanfd_pci.c:1686:3: warning: implicit declaration of function 
'up_affinity_irq' [-Wimplicit-function-declaration]
   SMP configurations: build OK
   ```
   
   Testing logs after change (both commits):
   
   ```
   qemu-armv8a:netnsh            build OK, 0 warnings
   qemu-armv8a:netnsh + SMP      build OK, 0 warnings
   qemu-intel64:nsh_pci          build OK, 0 warnings
   qemu-intel64:nsh_pci_smp      build OK, 0 warnings
   ```
   
   Regression:
   
   ```
   checkpatch: rc=0
   [sim:nsh] make build: rc=0
   [sim:nsh] ostest: Exiting with status 0
   [sim:smp] make build: rc=0
   [sim:smp] ostest: Exiting with status 0
   [sim:nsh] cmake build: rc=0
   ```
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit 
title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to