Accept, connect, recv and send replies indexed gastrSockets[] with the
socket ID from the firmware, and winc1500_close() lacked an upper bound.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
Fix three issues in the nPM10xx charger driver:
- Use correct mask to report CHARGER_HEALTH_SAFETY_TIMER_EXPIRE;
- Do not change ISETDOUBLE in runtime to avoid silently doubling/halving
the currents set for the other two NTC regions;
- Add a missing _ in the vbat-low-microvolt Devicetree property retrieval.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
For the STM32 HSEM, do not clear interrupts before enabling them so that
potential pending interrupts can be triggered.
Fixes#117403
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Some regulator drivers for the Nordic nPM PMICs did not previously call
regulator_common_data_init in their initializers. This patch fixes that.
Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
The IRQs are already enabled later in the init process,
enabling them too early (eg before the timer is setup) causes crashes,
and this is not supposed to happen here anyway.
Signed-off-by: Camille BAUD <mail@massdriver.space>
When a TX underflow stops the SSIE mid-block, the idle event restarts
the stream with the next queued block, which overwrote tx_stream without
freeing the block that was playing. A drop completing in the idle
callback did not free it either. Each event lost one block of the
caller's slab, and once all were lost the output stopped for good.
Free the in-flight block in both places.
Tested on an EK-RA8P1 by holding off interrupts for 3 ms every 5 s while
playing: the stream now recovers from every underflow, where it used to
stop after as many as the slab has blocks.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
nrf_wifi_wpa_supp_signal_poll() receives an uninitialized struct
wpa_signal_info from wpa_supplicant_signal_poll() and fills in only part
of it. current_tx_rate is set from the get_station event, which is
requested only when the cached RSSI is older than
CONFIG_NRF70_RSSI_STALE_TIMEOUT_MS. On the fresh-RSSI path it keeps
whatever was on the stack, so SIGNAL_POLL reports a random LINKSPEED and
`wifi status` prints values such as 537121.8 Mbps. current_noise is never
set at all.
Zero the struct on entry and mark the noise as invalid, as documented for
the current_noise field.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Assisted-by: Claude:claude-opus-5
The pin is held low across reset to force the primary I2C address, but a
board that does not route it can still drive the controller by probing
for the address the panel straps. Make the property optional, and gate
INPUT_GT911_INTERRUPT on a devicetree node providing the pin so that such
a board is left with polling. Have it select GPIO too, instead of
mentioning the requirement in the help text.
Tested on a Waveshare ESP32-P4-WIFI6-Touch-LCD-4.3, whose GT911 interrupt
line is not routed.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
STM32U0, U3, U5, and C5 power.c all selected the Stop wake-up clock
with `#if{def} STM32_SYSCLK_SRC_xxx` without including the header
they're defined in (stm32_clock_control.h), so the tests were silently
false, causing the part to wake up on the fallback clock (HSI16, or
HSIDIV3 on C5) even when SYSCLK is MSI, MSIS or HSIS.
Similarly, clock_stm32_ll_common.h guarded its declarations with
STM32_*_ENABLED macros, while also missing the same header.
Include the header so the conditions preprocess correctly.
Signed-off-by: Eden Frosst <eden.frosst@rbr-global.com>
i2s_siwx91x_queue_get() copied the item into *mem_block even when
sys_ringq_get() found the queue empty, so the TX DMA callback stored an
uninitialized pointer in stream->mem_block, which
i2s_siwx91x_stream_disable() then freed. The TX queue runs empty on
every underrun and at the end of a drain ("When all TX blocks are
transmitted the state is changed to READY"). Only update the outputs
when an item was read.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
queue_get() copied the item into *mem_block even when sys_ringq_get()
found the queue empty, so the TX DMA callback stored an uninitialized
pointer in stream->mem_block, which tx_stream_disable() then freed. The
TX queue runs empty on every underrun and at the end of a drain ("When
all TX blocks are transmitted the state is changed to READY"). Only
update the outputs when an item was read.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
A device that repeats a packet whose ACK it missed makes the core
acknowledge and drop it, then halt the channel with DTGERR. An interrupt
IN channel left that unhandled and stopped polling, which stalled the
status endpoint of a hub. Take the toggle the core now expects and poll
again at the next interval. Seen with a GL850G hub on an ESP32-P4.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
The filter configuration sets the injected external trigger to
DFSDM_FILTER_EXT_TRIG_TIM8_TRGO, which the HAL does not define on
STM32L451/L452/L462, as these parts have no TIM8, so the driver fails
to build for them. The injected trigger is never external, so the HAL
ignores this value; use DFSDM_FILTER_EXT_TRIG_TIM1_TRGO, which every
DFSDM part defines.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: YunHung Hua <oliverhua.us@gmail.com>
Shutting down the high-speed controller cleared the ICU event link of
the full-speed interrupt, which that controller does not have. Its
vector is FSP_INVALID_VECTOR, which is negative, so the write landed 33
words before the IELSR table, and the high-speed event stayed linked.
Clear the link of the interrupt that was set up.
Tested on an EK-RA8P1 with an application that initializes, enables,
disables and shuts down the host stack: after the shutdown, IELSR for
the USBHS interrupt reads 0 instead of the USBHS event.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
UHCI hands received bytes to the DMA only when a packet ends, on
length or after an idle period. rx_disable() stopped the DMA
right away, so bytes still held by UHCI were lost.
Make rx_disable() asynchronous: mask the RX FIFO interrupt, lower
the UART idle threshold and enable the idle EOF, then finish the
stop from a dedicated work item a few character times later. The
EOF moves the pending bytes into the buffer and sets the count
from the descriptor. While the stop is pending, the DMA
completion and the timeout work leave the buffer to the stop
work, and a pending stop is cancelled when the DMA runs out of
buffers first.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Bytes received while async RX was off stay in the RX FIFO and are
delivered at the start of the next buffer. Reset the RX FIFO in
rx_enable() before the RX interrupts are armed again.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
UART_TX_DONE was raised from the DMA completion, while the tail of
the buffer was still in the TX FIFO. A caller acting on TX_DONE,
for example by disabling RX or suspending the device, cut the
transfer short.
Arm the UART TX_DONE interrupt when the DMA completes and report
the event from the ISR once the transmitter is idle. Release the
TX state before the callback so a chained uart_tx() is accepted,
and reject a new transfer while the FIFO drains. On abort, flush
the TX FIFO and drop the drain PM lock along with the TX state,
and clear the state when a transfer fails to start.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
An EOF leaves the channel running, and stopping it does not
discard the descriptors it has already prefetched or the events
it latched, so the next transfer inherited them and delivered
stale or truncated data.
Clear the channel where it is handed a new descriptor list, going
through the stop barrier so the reset takes the abort path an axi
channel needs. Doing it before the interrupts are enabled keeps a
callback from seeing a half-reset channel.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
On a soc with a write-back data cache the controller and the cpu
disagree about an rx buffer twice over.
Before the transfer the cpu still owns the buffer and the
controller may fill only part of it, so write the cached copy out
and drop it: memory then holds the cpu data and no stale line can
later be written over what the controller delivers.
After the transfer the cached copy is stale and must be dropped,
but the buffer rarely starts or ends on a cache line, so its two
edge lines are shared with data the cpu owns and keeps writing
while the transfer runs. Writing those lines back first would put
a stale copy of the buffer on top of the received data, and
dropping them whole would discard the cpu's writes. Save the
shared bytes, invalidate whole lines, and restore them.
Do this before every rx callback and not only on the end-of-frame
one: a consumer reading the buffer from a block callback would
otherwise see stale bytes.
Round to the widest line the build uses rather than to
CONFIG_DCACHE_LINE_SIZE, which holds the devicetree value and can
be narrower than the line the cache is programmed with: esp32s3
picks its data cache line at startup and esp32p4 keeps a second
level, and a range operation covers those whole.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The controller writes the transferred length and the owner bit
back into the descriptor, so the cached copy the CPU reads is
stale once a transfer ends: on esp32p4 the length came back as
zero while the data had already landed in the buffer.
Where the SoC maps internal RAM through a non-cacheable alias,
read those fields through it, which leaves the CPU-owned fields
sharing the cache line untouched. Only esp32p4 has such an
alias, so elsewhere keep invalidating the descriptor.
Bound the alias to the internal RAM range rather than testing
esp_ptr_internal(), which also accepts regions that have no
alias.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Async UART API calls such as uart_tx_abort() are allowed from
the event callback, which runs in the GDMA interrupt, and they
read the channel state through dma_get_status(). Put get_status
in IRAM next to that interrupt handler and drop the logging on
its error paths.
While here, compare the status pointer against NULL explicitly.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The rx status reads the transferred length from the prefetched
descriptor register, but the AHB instance on esp32p4 reports zero
there once the transfer has ended, so total_copied stayed zero
even though the data had been written to memory.
Read the successful-EOF descriptor register instead when the
prefetched one is unset. It still points at the last descriptor
the controller wrote back on every supported instance. That
register is a latch and keeps its value across a rearm, so take
it only while the descriptor it names is no longer owned by the
controller, or a new transfer would report the previous one's
byte count.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Pair the ARC range operations' arch_irq_lock() with arch_irq_unlock()
to avoid decrementing an outer SMP global lock. Use local IRQ locking
for the all-cache operations too; shared SLC locking is unchanged.
Pair irq_lock() with irq_unlock() in the ESP32 USB serial callback to
balance its SMP global lock state.
Signed-off-by: Jinming Zhao <jinmzhao@qti.qualcomm.com>
The mailbox shared buffer was mapped with K_MEM_CACHE_NONE, which the
arm64 MMU code turns into Device-nGnRnE memory. Any unaligned access to
Device memory raises an alignment fault, regardless of SCTLR.A.
rpi_fw_transfer_list() memcpy()s each tag payload to shm + 0x14, which
is only 4-byte aligned. With CONFIG_SIZE_OPTIMIZATIONS picolibc's
memcpy() copies byte by byte and this goes unnoticed. With
CONFIG_SPEED_OPTIMIZATIONS the optimized AArch64 memcpy() uses 64-bit
stores and the first transfer faults during boot:
ESR 0x96000061 (alignment fault), FAR 0x3f800014, ELR in memcpy
On ARM and ARM64, map the buffer as K_MEM_ARM_NORMAL_NC instead. It
stays uncached, so the VideoCore still sees coherent data, and
unaligned accesses are permitted.
Tested with samples/synchronization on qemu_cortex_a72 with
CONFIG_SPEED_OPTIMIZATIONS=y.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
The STM32 UDC endpoint dequeue path currently flushes the endpoint and
cancels queued requests without explicitly aborting an active transfer.
Use the STM32 HAL endpoint abort operation before flushing and cancelling
the endpoint queue so that an in-progress transfer is stopped before the
queued requests are released.
Signed-off-by: Ahmed Ashraf NourEldeen <a.programmer55559@gmail.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/video`
- `drivers/wifi`
Assisted-by: Claude:claude-sonnet-5-5 codespell
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
i2c_sf32lb_controller_send_dma() returns an uninitialized value for a
zero-length write that does not send the address. Return 0 as the
receive path does.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
As it has been done for STM32MP2X (Copro setup), the STM32MP15
make Zephyr run on Cortex-M4 coprocessor next to Cortex-A7 that
controls timer kernel clocks.
In this condition, the STM32MP15 can also benefit from the
fallback newly done in the driver if only one single clock is
described in the device tree timer node.
Signed-off-by: Erwan SZYMANSKI <erwan.szymanski@st.com>
After the reset command the ADXL355 does not respond until it has
reloaded its NVM: reads return 0xFF and writes are ignored. The probe
programmed the device right away with read-modify-writes, which then
started from 0xFF. Depending on timing, one of them landed with the
reserved bits set, for example FILTER = 0x0F (a reserved ODR), and the
device output zero on all axes.
Poll STATUS every 1 ms after the reset until NVM_BUSY is clear, for at
most 100 ms. A STATUS read of 0xFF has NVM_BUSY set, so this also waits
out the time in which the device does not respond.
Fixes#120747
Signed-off-by: Sibo Van Gool <sibo.vangool@hotmail.com>
Since the previous update removed the QSPI ex_op enumeration,
this commit reverts that update to fix the QSPI build failure
when ex_op is enabled
Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
set_alarm() returned -EINVAL when an absolute alarm was set at or
before the current time, but the counter API documents -ETIME for
"Absolute alarm was set too late". The in-tree consumer rtc_counter.c
sets COUNTER_ALARM_CFG_ABSOLUTE | COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE
and only takes its immediate-expiry path on -ETIME, so with -EINVAL
the alarm was neither armed as an immediate expiry nor reported as
late, and rtc_alarm_set_time() failed instead of firing.
The late check also used "ticks < current". The alarm fires when the
counter increments to equal the match value, so an absolute target
equal to the current count never matches; use "ticks <= current" so
it is reported late.
The check was applied to relative alarms too. A relative request
whose ticks + current wraps past 2^32 always yields ticks < current
and was wrongly rejected. A relative alarm cannot be late by
definition, so the check now only applies to absolute alarms.
This mirrors the identical fix in counter_mcux_rtc, verified on
frdm_mcxw72; the RT10xx hardware for this driver was not available,
so this change is by code inspection against the shared pattern.
Assisted-by: Vero Coder:claude-sonnet
Signed-off-by: Holt Sun <holt.sun@nxp.com>
set_alarm() returned -EINVAL when an absolute alarm was set at or
before the current time, but the counter API documents -ETIME for
"Absolute alarm was set too late". The in-tree consumer rtc_counter.c
sets COUNTER_ALARM_CFG_ABSOLUTE | COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE
and only takes its immediate-expiry path on -ETIME, so with -EINVAL
the alarm was neither armed as an immediate expiry nor reported as
late, and rtc_alarm_set_time() failed instead of firing.
The late check also used "ticks < current". The RTC alarm fires when
the seconds counter increments to equal the match value, so an
absolute target equal to the current count never matches; use
"ticks <= current" so it is reported late.
The check was applied to relative alarms too. A relative request
whose ticks + current wraps past 2^32 always yields ticks < current
and was wrongly rejected. A relative alarm cannot be late by
definition, so the check now only applies to absolute alarms.
This mirrors the identical fix in counter_mcux_rtc, verified on
frdm_mcxw72; the LPC55S6x hardware for this driver was not available,
so this change is by code inspection against the shared pattern.
Assisted-by: Vero Coder:claude-sonnet
Signed-off-by: Holt Sun <holt.sun@nxp.com>
set_alarm() returned -EINVAL when an absolute alarm was set at or
before the current time, but the counter API documents -ETIME for
"Absolute alarm was set too late". The in-tree consumer rtc_counter.c
sets COUNTER_ALARM_CFG_ABSOLUTE | COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE
and only takes its immediate-expiry path on -ETIME, so with -EINVAL
the alarm was neither armed as an immediate expiry nor reported as
late, and rtc_alarm_set_time() failed instead of firing.
The late check also used "ticks < current", but the Kinetis RTC
raises TAF when TSR increments to equal TAR, so arming TAR equal to
the current TSR never matches until the 32-bit wrap; that alarm was
silently accepted and then lost. Use "ticks <= current" so an
absolute target at or before now is reported late.
Finally, the check was applied to relative alarms too. A relative
request whose ticks + current wraps past 2^32 always yields
ticks < current and was wrongly rejected. A relative alarm cannot be
late by definition, so the check now only applies to absolute alarms.
Reproduced on frdm_mcxw72 (nxp,rtc): before the fix a past absolute
alarm returned -EINVAL and an alarm equal to the current tick was
silently armed; after the fix both return -ETIME while a valid future
alarm still succeeds.
Assisted-by: Vero Coder:claude-sonnet
Signed-off-by: Holt Sun <holt.sun@nxp.com>
The PM_DEVICE_ACTION_TURN_ON handler assigns the clock divider through
data->clock, which does not exist with PERI_CLOCK_V2, so every
PM_DEVICE build fails on kit_t2g_c2d6m_lite. Skip it there as
ifx_cat1_uart_init() does: ifx_cat1_uart_configure() assigns the
divider through the clock control driver.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The driver thread logs every new transfer at info level. With the
console on CDC-ACM, each log line queues an IN transfer, which logs
again, so the console floods endlessly and the CPU is kept busy. This
is per-transfer tracing: log it at debug level, as the other UDC
drivers do.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The driver read the "name" cell of its mclk specifier, which only a
clock controller multiplexing several clocks carries. A fixed clock or a
PWM output has no cell at all and failed to build, so pass no subsystem
when the specifier has none.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
With more BSSes in range than the scan cache holds, the weakest entries
are evicted, so an AP of the requested network weaker than its
neighbours was dropped and the connection failed with "AP not found".
Pass the SSID the supplicant scans for down to the cache and never evict
entries of that network. Advertise two scan SSIDs so that each scan the
supplicant issues carries it next to the wildcard.
A hidden AP only reveals its SSID in probe responses, so probe for the
target SSID directly and fill in the SSID of an entry first seen through
its empty beacon.
Signed-off-by: William Markezana <william.markezana@gmail.com>
The firmware clears the MFP flag of the connect request while matching
beacons, so it adds the AP station without its MFP capability and sends
robust management frames to it unprotected. The AP drops the
deauthentication sent on disconnect and keeps the association, and the
next connection to it times out after SAE (status 11). Set the
capability once the SAE connection is up.
Signed-off-by: William Markezana <william.markezana@gmail.com>
The generic firmware key API derives the cipher from the key length and
stores a group key in slot vif * 4 + key_idx. The IGTK (key_idx 4) thus
went in as a CCMP key over the pairwise key of station 0 whenever the
link used interface 1, as the first connection after boot always does:
the link came up but no unicast frame decrypted and DHCP never completed.
Install it with bl_wifi_set_igtk_internal() instead.
Signed-off-by: William Markezana <william.markezana@gmail.com>
The firmware caches only a handful of BSSes seen while scanning, and
drops every frame from a BSS it cannot cache. A scan leaves that cache
full and a join scan does not clear it, so joining an AP the scan did
not happen to cache failed with status 14, typically on the first
connect after a scan. Clear the cache once a scan completes.
Add scanu_cached_scanresult_clear() to the BL60x no-blobs link stubs,
along with the sm_env the driver already referenced, whose absence
broke CONFIG_BUILD_ONLY_NO_BLOBS builds on BL60x.
Signed-off-by: William Markezana <william.markezana@gmail.com>
The endpoint state was only cleared at controller init, so a device
attached after another was removed inherited its data toggles and its
first transfers were dropped as duplicates. Clear it on a bus reset,
which returns every endpoint to DATA0.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5
The idle level is written to a shadow register and reaches the pad
only when that register is committed. The commit used to happen when
transmission started, after the receiver was already running, so the
level change was captured as one extra symbol or hid the first one.
Stop the channel at the end of configure. That commits the registers
without starting a frame, so the pad is already idle when a capture
begins. Chips that write the idle level straight into the active
register are unchanged.
Assisted-by: Grok:4.7
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
The driver polls the PHY PLL lock and the lane stop state with
k_busy_wait(), but only got <zephyr/kernel.h> through the logging
header. With CONFIG_LOG=n the declaration is missing and the
build fails, since commit 03b5cf71a6 ("drivers: mipi_dsi: add
the esp32p4 mipi-dsi host"). Include the kernel header directly.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The driver implements register_event_cb() for vsync and frame
done, but its capabilities left supported_events at zero, so
display_register_event_cb() refused every registration with
-ENOSYS since commit 2b71bd5f70 ("drivers: display: add the
esp32p4 dsi scanout controller"). Report both events and drop
the driver's own event mask check, which the wrapper already
performs against supported_events.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Fix typos from "on succes" to "on success" in video control
function documentation comments.
Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: Jacky Mpoka <jackympoka22@gmail.com>
channel_priority was ignored. Program it into the GDMA channel priority
registers, and reject values above what the hardware supports.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The STM32 OTG (dwc2) UDC allocated each IN endpoint's TxFIFO with
HAL_PCDEx_SetTxFiFo() on ep_enable and released it on ep_disable.
HAL_PCDEx_SetTxFiFo() does not take an offset: it derives the FIFO's start
address from the sum of the RxFIFO, the EP0 TxFIFO and every lower-indexed
TxFIFO read from the live core registers, i.e. it always packs FIFOs
contiguously in ascending index order. That is only correct when IN
endpoints are enabled once, in ascending index order, and never disabled
and re-enabled -- which the USB stack does not guarantee.
A UAC2 full-duplex device is a concrete counter-example. It has two audio
streaming interfaces the host enables independently via SET_INTERFACE as
the playback and capture streams start, stop and recover (an ALSA underrun
re-selects the alternate setting): a playback OUT interface carrying an
explicit-feedback IN endpoint and a capture IN interface. When the capture
IN endpoint (higher index) is enabled while the feedback IN endpoint (lower
index) is still disabled, HAL_PCDEx_SetTxFiFo() computes the capture FIFO's
offset with the feedback FIFO depth still zero and places capture at the
offset the feedback FIFO will later occupy. Enabling the feedback endpoint
then places its FIFO on top of the capture FIFO. The overlapping TxFIFOs
corrupt the OTG core: every IN endpoint (including an unrelated CDC-ACM
management interface) wedges with no recovery short of a power cycle. The
FIFO RAM is not exhausted (~928/1280 B used); the failure is purely a
layout overlap.
Track the FIFO RAM with a per-instance bitmap (one bit per 32-bit word,
sys_bitarray) and program each IN endpoint's DIEPTXF start address and
depth
explicitly. A TxFIFO is allocated from the bitmap on enable and released on
disable, and its explicit offset means it never moves or overlaps another
endpoint's FIFO regardless of the order in which endpoints are enabled and
disabled. Unlike a scheme that freezes reservations to avoid the overlap,
releasing on disable lets the RAM be reused, so reconfiguring endpoints
with
different sizes cannot spuriously fail to fit.
The bitmap is sized from the device's ram-size and reserves the RxFIFO and
EP0 TxFIFO region up front; there is no new Kconfig and no dynamic
allocation. Only the OTG path is changed; the st,stm32-usb (PMA) path is
untouched.
Verified on an STM32U575 (OTG-FS) UAC2 full-duplex composite device
(playback iso-OUT + explicit-feedback iso-IN + capture iso-IN, plus
CDC-ACM): no core wedge over a stress run with the capture and playback
streams starting, stopping and recovering out of order, CDC-ACM stays
alive throughout, and a UAC2 loopback round-trips with correlation 1.0 and
0 dropouts (SNR 65 dB). Before the change the same setup wedged all IN
endpoints within seconds of the first ALSA underrun.
Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Peter Buchegger <peter.buchegger7@gmail.com>
arm_gic_irq_enable() only sets GICD_IROUTER implicitly, to whichever core
happens to call it (and only when built with CONFIG_ARMV8_A_NS or
CONFIG_GIC_SINGLE_SECURITY_STATE) - there was no way to route an SPI to
an arbitrary core, analogous to k_thread_cpu_pin() for threads.
Add arm_gic_irq_set_affinity(irq, mpidr), which writes GICD_IROUTER for
an SPI/extended-SPI to target any core's MPIDR affinity value, callable
at any time from any core. Un-gate the existing arm_gic_write_irouter()
helper it wraps (previously compiled only under the same
CONFIG_ARMV8_A_NS/CONFIG_GIC_SINGLE_SECURITY_STATE condition as its one
caller) so the new API works unconditionally; arm_gic_irq_enable()'s own
implicit self-affinity behavior is unchanged.
Callers obtain the target MPIDR from existing mechanisms - a specific
CPU's devicetree node (DT_REG_ADDR(DT_NODELABEL(cpuX))) or, for the core
the caller is currently pinned to, MPIDR_TO_CORE(GET_MPIDR()) - so no new
arch MPIDR lookup helper is required.
Signed-off-by: Appana Durga Kedareswara rao <appana.durga.kedareswara.rao@amd.com>
In full-duplex mode (I2S_DIR_BOTH), multiple issues affected error
handling, DMA quiescence, buffer ownership, and recovery:
1. When a DMA fault or queue underrun occurred on TX, rx_callback did
not check for error state after enqueuing its completed block, which
could lead to allocating new slab blocks and restarting DMA.
2. In the RX chunking and error exits, dma_reload() and dma_start()
failures jumped to rx_disable without updating state to
I2S_STATE_ERROR.
3. On restart_dma() failures in rx_callback and tx_compl_transfer,
unstarted blocks were dropped on legacy SoCs without being returned
to the memory slab.
4. i2s_esp32_trigger() checked validity before acquiring irq_lock(),
creating a race window where concurrent trigger callers could pass
validation and interfere with active DMA streams.
5. I2S_TRIGGER_PREPARE stopped only the requested direction (dir) rather
than ensuring the full active operation (active_dir) was quiesced,
and ignored stop failures while writing READY unconditionally.
Address these issues:
- Update rx_callback to check dev_data->state == I2S_STATE_ERROR after
queueing the in-flight block, halting RX cleanly without dropping data
or leaking subsequent buffers.
- Update rx_chunking reload/start failure paths to set I2S_STATE_ERROR.
- Release unstarted buffers to their memory slab on restart_dma()
failures in rx_callback and tx_compl_transfer before disabling the
stream.
- Update rx_stop_transfer() and tx_stop_transfer() to capture dma_stop()
status, clear dma_pending, and return in-flight mem_blocks to their
memory slab on GDMA.
- Serialize trigger validation and execution under irq_lock() in
i2s_esp32_trigger(), ensuring atomicity.
- In I2S_TRIGGER_PREPARE, quiesce dev_data->active_dir, keep the device
in I2S_STATE_ERROR on stop failures, purge the requested stream queue,
and commit READY last.
- Preserve READY state on failed START commands.
Fixes#117644
Assisted-by: Gemini:gemini-3.8-flash
Signed-off-by: harshit kudhial <harshitkudhial@gmail.com>