6.19.6-rc1 review
Subsystems (6)
Sasha Levin
maintainerPATCH 430/844 drm/amd/display: set enable_legacy_fast_update to false for DCN36
In reply to Sasha LevinFrom: YiLing Chen <[email protected]>
[ Upstream commit d0728aee5090853d0b9982757f5fb1b13e2e2b27 ]
[Why/How]
Align the default value of the flag with DCN35/351.
--- drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c +1 -1
@@ -769,7 +769,7 @@ static const struct dc_debug_options debug_defaults_drv = { };static const struct dc_check_config config_defaults = { - .enable_legacy_fast_update = true, + .enable_legacy_fast_update = false, };static const struct dc_panel_config panel_config_defaults = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 431/844 drm/amdgpu: Add HAINAN clock adjustment
In reply to Sasha LevinFrom: decce6 <[email protected]>
[ Upstream commit 49fe2c57bdc0acff9d2551ae337270b6fd8119d9 ]
This patch limits the clock speeds of the AMD Radeon R5 M420 GPU from 850/1000MHz (core/memory) to 800/950 MHz, making it work stably. This patch is for amdgpu.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +5 -0
@@ -3464,6 +3464,11 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, max_sclk =60000 ; max_mclk =80000 ; } +if ((adev->pdev->device ==0x666f ) && + (adev->pdev->revision ==0x00 )) { + max_sclk =80000 ; + max_mclk =95000 ; + } }else if (adev->asic_type ==CHIP_OLAND ) { if ((adev->pdev->revision == 0xC7) || (adev->pdev->revision == 0x80) ||
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 432/844 drm/amd/display: bypass post csc for additional color spaces in dal
In reply to Sasha LevinFrom: Clay King <[email protected]>
[ Upstream commit 7d9ec9dc20ecdb1661f4538cd9112cd3d6a5f15a ]
[Why]
For RGB BT2020 full and limited color spaces, overlay adjustments were applied twice (once by MM and once by DAL). This results in incorrect colours and a noticeable difference between mpo and non-mpo cases.
[How]
Add RGB BT2020 full and limited color spaces to list that bypasses post csc adjustment.
--- .../drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c | 21 ++++++++++++++++--- .../drm/amd/display/dc/dpp/dcn30/dcn30_dpp.h | 4 ++++ .../amd/display/dc/dpp/dcn401/dcn401_dpp.c | 6 +++--- 3 files changed, 25 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.c +18 -3
@@ -376,10 +376,10 @@ void dpp3_cnv_setup ( tbl_entry.color_space = input_color_space; -if (color_space >=COLOR_SPACE_YCBCR601 ) - select =INPUT_CSC_SELECT_ICSC ; -else +if (dpp3_should_bypass_post_csc_for_colorspace (color_space)) select =INPUT_CSC_SELECT_BYPASS ; +else + select =INPUT_CSC_SELECT_ICSC ;dpp3_program_post_csc (dpp_base, color_space, select, &tbl_entry);
@@ -1541,3 +1541,18 @@ bool dpp3_construct(return true; } +bool dpp3_should_bypass_post_csc_for_colorspace (enum dc_color_space dc_color_space) +{ +switch (dc_color_space) { +case COLOR_SPACE_UNKNOWN : +case COLOR_SPACE_SRGB : +case COLOR_SPACE_XR_RGB : +case COLOR_SPACE_SRGB_LIMITED : +case COLOR_SPACE_MSREF_SCRGB : +case COLOR_SPACE_2020_RGB_FULLRANGE : +case COLOR_SPACE_2020_RGB_LIMITEDRANGE : +return true; +default : +return false; + } +}
drivers/gpu/drm/amd/display/dc/dpp/dcn30/dcn30_dpp.h +4 -0
@@ -644,4 +644,8 @@ void dpp3_program_cm_dealpha(void dpp3_cm_get_gamut_remap (struct dpp *dpp_base,struct dpp_grph_csc_adjustment *adjust); + +bool dpp3_should_bypass_post_csc_for_colorspace ( +enum dc_color_space dc_color_space); +#endif /* __DC_HWSS_DCN30_H__ */
drivers/gpu/drm/amd/display/dc/dpp/dcn401/dcn401_dpp.c +3 -3
@@ -206,10 +206,10 @@ void dpp401_dpp_setup( tbl_entry.color_space = input_color_space; -if (color_space >=COLOR_SPACE_YCBCR601 ) - select =INPUT_CSC_SELECT_ICSC ; -else +if (dpp3_should_bypass_post_csc_for_colorspace (color_space)) select =INPUT_CSC_SELECT_BYPASS ; +else + select =INPUT_CSC_SELECT_ICSC ;dpp3_program_post_csc (dpp_base, color_space, select, &tbl_entry);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 433/844 spi: spidev: fix lock inversion between spi_lock and buf_lock
In reply to Sasha LevinFrom: Fabian Godehardt <[email protected]>
[ Upstream commit 40534d19ed2afb880ecf202dab26a8e7a5808d16 ]
The spidev driver previously used two mutexes, spi_lock and buf_lock, but acquired them in different orders depending on the code path:
write()/read(): buf_lock -> spi_lock
ioctl(): spi_lock -> buf_lock
This AB-BA locking pattern triggers lockdep warnings and can cause real deadlocks:
WARNING: possible circular locking dependency detected spidev_ioctl() -> mutex_lock(&spidev->buf_lock) spidev_sync_write() -> mutex_lock(&spidev->spi_lock) *** DEADLOCK ***
The issue is reproducible with a simple userspace program that performs write() and SPI_IOC_WR_MAX_SPEED_HZ ioctl() calls from separate threads on the same spidev file descriptor.
Fix this by simplifying the locking model and removing the lock inversion entirely. spidev_sync() no longer performs any locking, and all callers serialize access using spi_lock.
buf_lock is removed since its functionality is fully covered by spi_lock, eliminating the possibility of lock ordering issues.
This removes the lock inversion and prevents deadlocks without changing userspace ABI or behaviour.
--- drivers/spi/spidev.c | 63 ++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 41 deletions(-)
drivers/spi/spidev.c +22 -41
@@ -74,7 +74,6 @@ struct spidev_data {struct list_head device_entry;/* TX/RX buffers are NULL unless this device is open (users > 0) */ -struct mutex buf_lock;unsigned users;u8 *tx_buffer;u8 *rx_buffer;
@@ -102,24 +101,6 @@ spidev_sync_unlocked(struct spi_device *spi, struct spi_message *message)return status; } -static ssize_t -spidev_sync (struct spidev_data *spidev,struct spi_message *message) -{ -ssize_t status; -struct spi_device *spi; - -mutex_lock (&spidev->spi_lock); - spi = spidev->spi; - -if (spi ==NULL ) - status = -ESHUTDOWN ; -else - status =spidev_sync_unlocked (spi, message); - -mutex_unlock (&spidev->spi_lock); -return status; -} -static inline ssize_t spidev_sync_write (struct spidev_data *spidev,size_t len) {
@@ -132,7 +113,8 @@ spidev_sync_write(struct spidev_data *spidev, size_t len)spi_message_init (&m);spi_message_add_tail (&t, &m); -return spidev_sync (spidev, &m); + +return spidev_sync_unlocked (spidev->spi, &m); } static inline ssize_t
@@ -147,7 +129,8 @@ spidev_sync_read(struct spidev_data *spidev, size_t len)spi_message_init (&m);spi_message_add_tail (&t, &m); -return spidev_sync (spidev, &m); + +return spidev_sync_unlocked (spidev->spi, &m); }/*-------------------------------------------------------------------------*/
@@ -157,7 +140,7 @@ static ssize_t spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { struct spidev_data *spidev; -ssize_t status; +ssize_t status = -ESHUTDOWN ;/* chipselect only toggles at start or end of operation */ if (count > bufsiz)
@@ -165,7 +148,11 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) spidev = filp->private_data; -mutex_lock (&spidev->buf_lock); +mutex_lock (&spidev->spi_lock); + +if (spidev->spi ==NULL ) + goto err_spi_removed; + status =spidev_sync_read (spidev, count);if (status >0 ) {unsigned long missing;
@@ -176,7 +163,9 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)else status = status - missing; } -mutex_unlock (&spidev->buf_lock); + +err_spi_removed: +mutex_unlock (&spidev->spi_lock);return status; }
@@ -187,7 +176,7 @@ spidev_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { struct spidev_data *spidev; -ssize_t status; +ssize_t status = -ESHUTDOWN ;unsigned long missing;/* chipselect only toggles at start or end of operation */
@@ -196,13 +185,19 @@ spidev_write(struct file *filp, const char __user *buf, spidev = filp->private_data; -mutex_lock (&spidev->buf_lock); +mutex_lock (&spidev->spi_lock); + +if (spidev->spi ==NULL ) + goto err_spi_removed; + missing =copy_from_user (spidev->tx_buffer, buf, count);if (missing ==0 ) status =spidev_sync_write (spidev, count);else status = -EFAULT ; -mutex_unlock (&spidev->buf_lock); + +err_spi_removed: +mutex_unlock (&spidev->spi_lock);return status; }
@@ -379,14 +374,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ctlr = spi->controller; -/* use the buffer lock here for triple duty: -* - prevent I/O (from us) so calling spi_setup() is safe; -* - prevent concurrent SPI_IOC_WR_* from morphing -* data fields while SPI_IOC_RD_* reads them; -* - SPI_IOC_MESSAGE needs the buffer locked "normally". -*/ -mutex_lock (&spidev->buf_lock); -switch (cmd) {/* read requests */ case SPI_IOC_RD_MODE :
@@ -510,7 +497,6 @@ spidev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)break ; } -mutex_unlock (&spidev->buf_lock);spi_dev_put (spi);mutex_unlock (&spidev->spi_lock);return retval;
@@ -541,9 +527,6 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,return -ESHUTDOWN ; } -/* SPI_IOC_MESSAGE needs the buffer locked "normally" */ -mutex_lock (&spidev->buf_lock); -/* Check message and copy into scratch area */ ioc =spidev_get_ioc_message (cmd, u_ioc, &n_ioc);if (IS_ERR (ioc)) {
@@ -564,7 +547,6 @@ spidev_compat_ioc_message(struct file *filp, unsigned int cmd,kfree (ioc); done: -mutex_unlock (&spidev->buf_lock);spi_dev_put (spi);mutex_unlock (&spidev->spi_lock);return retval;
@@ -802,7 +784,6 @@ static int spidev_probe(struct spi_device *spi)/* Initialize the driver data */ spidev->spi = spi;mutex_init (&spidev->spi_lock); -mutex_init (&spidev->buf_lock);INIT_LIST_HEAD (&spidev->device_entry);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 434/844 drm/radeon: Add HAINAN clock adjustment
In reply to Sasha LevinFrom: decce6 <[email protected]>
[ Upstream commit 908d318f23d6b5d625bea093c5fc056238cdb7ff ]
This patch limits the clock speeds of the AMD Radeon R5 M420 GPU from 850/1000MHz (core/memory) to 800/950 MHz, making it work stably. This patch is for radeon.
--- drivers/gpu/drm/radeon/si_dpm.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/radeon/si_dpm.c +5 -0
@@ -2925,6 +2925,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, max_sclk =60000 ; max_mclk =80000 ; } +if ((rdev->pdev->device ==0x666f ) && + (rdev->pdev->revision ==0x00 )) { + max_sclk =80000 ; + max_mclk =95000 ; + } }else if (rdev->family ==CHIP_OLAND ) { if ((rdev->pdev->revision == 0xC7) || (rdev->pdev->revision == 0x80) ||
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 435/844 ALSA: usb-audio: Add sanity check for OOB writes at silencing
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit fba2105a157fffcf19825e4eea498346738c9948 ]
At silencing the playback URB packets in the implicit fb mode before the actual playback, we blindly assume that the received packets fit with the buffer size. But when the setup in the capture stream differs from the playback stream (e.g. due to the USB core limitation of max packet size), such an inconsistency may lead to OOB writes to the buffer, resulting in a crash.
For addressing it, add a sanity check of the transfer buffer size at prepare_silent_urb(), and stop the data copy if the received data overflows. Also, report back the transfer error properly from there, too.
Note that this doesn't fix the root cause of the playback error itself, but this merely covers the kernel Oops.
--- sound/usb/endpoint.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
sound/usb/endpoint.c +22 -17
@@ -275,8 +275,8 @@ static inline bool has_tx_length_quirk(struct snd_usb_audio *chip)return chip->quirk_flags &QUIRK_FLAG_TX_LENGTH ; } -static void prepare_silent_urb (struct snd_usb_endpoint *ep, -struct snd_urb_ctx *ctx) +static int prepare_silent_urb (struct snd_usb_endpoint *ep, +struct snd_urb_ctx *ctx) {struct urb *urb = ctx->urb;unsigned int offs =0 ;
@@ -289,28 +289,34 @@ static void prepare_silent_urb(struct snd_usb_endpoint *ep, extra =sizeof (packet_length);for (i =0 ; i < ctx->packets; ++i) { -unsigned int offset; -unsigned int length; -int counts; - - counts =snd_usb_endpoint_next_packet_size (ep, ctx, i,0 ); - length = counts * ep->stride;/* number of silent bytes */ - offset = offs * ep->stride + extra * i; - urb->iso_frame_desc[i].offset = offset; +int length; + + length =snd_usb_endpoint_next_packet_size (ep, ctx, i,0 ); +if (length <0 ) +return length; + length *= ep->stride;/* number of silent bytes */ +if (offs + length + extra > ctx->buffer_size) +break ; + urb->iso_frame_desc[i].offset = offs; urb->iso_frame_desc[i].length = length + extra;if (extra) { packet_length =cpu_to_le32 (length); -memcpy (urb->transfer_buffer + offset, +memcpy (urb->transfer_buffer + offs, &packet_length,sizeof (packet_length)); + offs += extra; } -memset (urb->transfer_buffer + offset + extra, +memset (urb->transfer_buffer + offs, ep->silence_value, length); - offs += counts; + offs += length; } - urb->number_of_packets = ctx->packets; - urb->transfer_buffer_length = offs * ep->stride + ctx->packets * extra; +if (!offs) +return -EPIPE ; + + urb->number_of_packets = i; + urb->transfer_buffer_length = offs; ctx->queued =0 ; +return 0 ; }/*
@@ -332,8 +338,7 @@ static int prepare_outbound_urb(struct snd_usb_endpoint *ep,if (data_subs && ep->prepare_data_urb)return ep->prepare_data_urb (data_subs, urb, in_stream_lock);/* no data provider, so send silence */ -prepare_silent_urb (ep, ctx); -break ; +return prepare_silent_urb (ep, ctx);case SND_USB_ENDPOINT_TYPE_SYNC :if (snd_usb_get_speed (ep->chip->dev) >=USB_SPEED_HIGH ) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 436/844 btrfs: replace BUG() with error handling in __btrfs_balance()
In reply to Sasha LevinFrom: Adarsh Das <[email protected]>
[ Upstream commit be6324a809dbda76d5fdb23720ad9b20e5c1905c ]
We search with offset (u64)-1 which should never match exactly. Previously this was handled with BUG(). Now logs an error and return -EUCLEAN.
--- fs/btrfs/volumes.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/btrfs/volumes.c +8 -2
@@ -4234,8 +4234,14 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)* this shouldn't happen, it means the last relocate * failed */ -if (ret ==0 ) -BUG ();/* FIXME break ? */ +if (unlikely (ret ==0 )) { +btrfs_err (fs_info, +"unexpected exact match of CHUNK_ITEM in chunk tree, offset 0x%llx" , + key.offset); +mutex_unlock (&fs_info->reclaim_bgs_lock); + ret = -EUCLEAN ; + goto error; + } ret =btrfs_previous_item (chunk_root, path,0 ,BTRFS_CHUNK_ITEM_KEY );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 437/844 btrfs: do not ASSERT() when the fs flips RO inside btrfs_repair_io_failure()
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 8ceaad6cd6e7fa5f73b0b2796a2e85d75d37e9f3 ]
[BUG]
There is a bug report that when btrfs hits ENOSPC error in a critical path, btrfs flips RO (this part is expected, although the ENOSPC bug still needs to be addressed).
The problem is after the RO flip, if there is a read repair pending, we can hit the ASSERT() inside btrfs_repair_io_failure() like the following:
BTRFS info (device vdc): relocating block group 30408704 flags metadata|raid1
------------[ cut here ]------------ BTRFS: Transaction aborted (error -28) WARNING: fs/btrfs/extent-tree.c:3235 at __btrfs_free_extent.isra.0+0x453/0xfd0, CPU#1: btrfs/383844 Modules linked in: kvm_intel kvm irqbypass [...] ---[ end trace 0000000000000000 ]--- BTRFS info (device vdc state EA): 2 enospc errors during balance BTRFS info (device vdc state EA): balance: ended with status: -30 BTRFS error (device vdc state EA): parent transid verify failed on logical 30556160 mirror 2 wanted 8 found 6 BTRFS error (device vdc state EA): bdev /dev/nvme0n1 errs: wr 0, rd 0, flush 0, corrupt 10, gen 0 [...] assertion failed: !(fs_info->sb->s_flags & SB_RDONLY) :: 0, in fs/btrfs/bio.c:938 ------------[ cut here ]------------ assertion failed: !(fs_info->sb->s_flags & SB_RDONLY) :: 0, in fs/btrfs/bio.c:938 kernel BUG at fs/btrfs/bio.c:938! Oops: invalid opcode: 0000 [#1] SMP NOPTI CPU: 0 UID: 0 PID: 868 Comm: kworker/u8:13 Tainted: G W N 6.19.0-rc6+ #4788 PREEMPT(full) Tainted: [W]=WARN, [N]=TEST Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.17.0-0-gb52ca86e094d-prebuilt.qemu.org 04/01/2014 Workqueue: btrfs-endio simple_end_io_work RIP: 0010:btrfs_repair_io_failure.cold+0xb2/0x120 RSP: 0000:ffffc90001d2bcf0 EFLAGS: 00010246 RAX: 0000000000000051 RBX: 0000000000001000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffffff8305cf42 RDI: 00000000ffffffff RBP: 0000000000000002 R08: 00000000fffeffff R09: ffffffff837fa988 R10: ffffffff8327a9e0 R11: 6f69747265737361 R12: ffff88813018d310 R13: ffff888168b8a000 R14: ffffc90001d2bd90 R15: ffff88810a169000 FS: 0000000000000000(0000) GS:ffff8885e752c000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 ------------[ cut here ]------------
[CAUSE]
The cause of -ENOSPC error during the test case btrfs/124 is still unknown, although it's known that we still have cases where metadata can be over-committed but can not be fulfilled correctly, thus if we hit such ENOSPC error inside a critical path, we have no choice but abort the current transaction.
This will mark the fs read-only.
The problem is inside the btrfs_repair_io_failure() path that we require the fs not to be mount read-only. This is normally fine, but if we are doing a read-repair meanwhile the fs flips RO due to a critical error, we can enter btrfs_repair_io_failure() with super block set to read-only, thus triggering the above crash.
[FIX]
Just replace the ASSERT() with a proper return if the fs is already read-only.
--- fs/btrfs/bio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/btrfs/bio.c +7 -1
@@ -934,7 +934,6 @@ int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 fileoff,struct bio *bio =NULL ;int ret =0 ; -ASSERT (!(fs_info->sb->s_flags &SB_RDONLY ));BUG_ON (!mirror_num);/* Basic alignment checks. */
@@ -946,6 +945,13 @@ int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 fileoff,ASSERT (step <= length);ASSERT (is_power_of_2 (step)); +/* +* The fs either mounted RO or hit critical errors, no need +* to continue repairing. +*/ +if (unlikely (sb_rdonly (fs_info->sb))) +return 0 ; +if (btrfs_repair_one_zone (fs_info, logical))return 0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 438/844 ASoC: amd: amd_sdw: add machine driver quirk for Lenovo models
In reply to Sasha LevinFrom: Vijendar Mukunda <[email protected]>
[ Upstream commit 3acf517e1ae05ef66561b7a2782690387ce46e21 ]
This patch adds a quirk to include the codec amplifier function for Lenovo models listed in the quirk table.
Note: In these models, the RT722 codec amplifier is excluded, and an external amplifier is used instead.
--- sound/soc/amd/acp/acp-sdw-legacy-mach.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
sound/soc/amd/acp/acp-sdw-legacy-mach.c +16 -0
@@ -95,6 +95,22 @@ static const struct dmi_system_id soc_sdw_quirk_table[] = { }, .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "21YW"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, + { + .callback = soc_sdw_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "21YX"), + }, + .driver_data = (void *)(ASOC_SDW_CODEC_SPKR), + }, {} };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 439/844 ALSA: hda/hdmi: Add quirk for TUXEDO IBS14G6
In reply to Sasha LevinFrom: Aaron Erhardt <[email protected]>
[ Upstream commit d649c58bcad8fb9b749e3837136a201632fa109d ]
Depending on the timing during boot, the BIOS might report wrong pin capabilities, which can lead to HDMI audio being disabled. Therefore, force HDMI audio connection on TUXEDO InfinityBook S 14 Gen6.
--- sound/hda/codecs/hdmi/hdmi.c | 1 + 1 file changed, 1 insertion(+)
sound/hda/codecs/hdmi/hdmi.c +1 -0
@@ -1557,6 +1557,7 @@ static const struct snd_pci_quirk force_connect_list[] = {SND_PCI_QUIRK (0x1043 ,0x86ae ,"ASUS" ,1 ),/* Z170 PRO */ SND_PCI_QUIRK (0x1043 ,0x86c7 ,"ASUS" ,1 ),/* Z170M PLUS */ SND_PCI_QUIRK (0x1462 ,0xec94 ,"MS-7C94" ,1 ), +SND_PCI_QUIRK (0x1558 ,0x14a1 ,"TUXEDO InfinityBook S 14 Gen6" ,1 ),SND_PCI_QUIRK (0x8086 ,0x2060 ,"Intel NUC5CPYB" ,1 ), SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", 1), {}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 440/844 arm64: hugetlbpage: avoid unused-but-set-parameter warning (gcc-16)
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 729a2e8e9ac47099a967567389cc9d73ef4194ca ]
gcc-16 warns about an instance that older compilers did not:
arch/arm64/mm/hugetlbpage.c: In function 'huge_pte_clear':arch/arm64/mm/hugetlbpage.c:369:57: error: parameter 'addr' set but not used [-Werror=unused-but-set-parameter=]
The issue here is that __pte_clear() does not actually use its second argument, but when CONFIG_ARM64_CONTPTE is enabled it still gets updated.
Replace the macro with an inline function to let the compiler see the argument getting passed down.
--- arch/arm64/include/asm/pgtable.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +7 -2
@@ -179,8 +179,6 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))#define pte_none (pte) (!pte_val(pte)) -#define __pte_clear (mm, addr, ptep) \ - __set_pte(ptep, __pte(0))#define pte_page (pte) (pfn_to_page(pte_pfn(pte)))/*
@@ -1320,6 +1318,13 @@ static inline bool pud_user_accessible_page(pud_t pud)/* * Atomic pte/pmd modifications. */ + +static inline void __pte_clear (struct mm_struct *mm, +unsigned long addr,pte_t *ptep) +{ +__set_pte (ptep,__pte (0 )); +} +static inline int __ptep_test_and_clear_young (struct vm_area_struct *vma,unsigned long address,pte_t *ptep)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 441/844 drm/amd/display: Remove conditional for shaper 3DLUT power-on
In reply to Sasha LevinFrom: Alex Hung <[email protected]>
[ Upstream commit 1b38a87b8f8020e8ef4563e7752a64182b5a39b9 ]
[Why]
Shaper programming has high chance to fail on first time after power-on or reboot. This can be verified by running IGT's kms_colorop.
[How]
Always power on the shaper and 3DLUT before programming by removing the debug flag of low power mode.
--- drivers/gpu/drm/amd/display/dc/mpc/dcn32/dcn32_mpc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/mpc/dcn32/dcn32_mpc.c +1 -2
@@ -724,8 +724,7 @@ bool mpc32_program_shaper(return false; } -if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) -mpc32_power_on_shaper_3dlut (mpc, mpcc_id, true); +mpc32_power_on_shaper_3dlut (mpc, mpcc_id, true); current_mode =mpc32_get_shaper_current (mpc, mpcc_id);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 442/844 drm/amdgpu: avoid sdma ring reset in sriov
In reply to Sasha LevinFrom: Victor Zhao <[email protected]>
[ Upstream commit 5cc7bbd9f1b74d9fe2f7ac08d6ba0477e8d2d65f ]
sdma ring reset is not supported in SRIOV. kfd driver does not check reset mask, and could queue sdma ring reset during unmap_queues_cpsch.
Avoid the ring reset for sriov.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c +3 -0
@@ -558,6 +558,9 @@ int amdgpu_sdma_reset_engine(struct amdgpu_device *adev, uint32_t instance_id,struct amdgpu_ring *gfx_ring = &sdma_instance->ring;struct amdgpu_ring *page_ring = &sdma_instance->page; +if (amdgpu_sriov_vf (adev)) +return -EOPNOTSUPP ; +mutex_lock (&sdma_instance->engine_reset_mutex);if (!caller_handles_kernel_queues) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 443/844 rtc: zynqmp: correct frequency value
In reply to Sasha LevinFrom: Tomas Melin <[email protected]>
[ Upstream commit 2724fb4d429cbb724dcb6fa17953040918ebe3a2 ]
Fix calibration value in case a clock reference is provided. The actual calibration value written into register is frequency - 1.
--- drivers/rtc/rtc-zynqmp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/rtc/rtc-zynqmp.c +3 -0
@@ -345,7 +345,10 @@ static int xlnx_rtc_probe(struct platform_device *pdev) &xrtcdev->freq);if (ret) xrtcdev->freq =RTC_CALIB_DEF ; + }else { + xrtcdev->freq--; } + ret =readl (xrtcdev->reg_base +RTC_CALIB_RD );if (!ret)writel (xrtcdev->freq, (xrtcdev->reg_base +RTC_CALIB_WR ));
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 444/844 ntb: ntb_hw_switchtec: Fix array-index-out-of-bounds access
In reply to Sasha LevinFrom: Maciej Grochowski <[email protected]>
[ Upstream commit c8ba7ad2cc1c7b90570aa347b8ebbe279f1eface ]
Number of MW LUTs depends on NTB configuration and can be set to MAX_MWS, This patch protects against invalid index out of bounds access to mw_sizes When invalid access print message to user that configuration is not valid.
--- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +6 -0
@@ -1314,6 +1314,12 @@ static void switchtec_ntb_init_shared(struct switchtec_ntb *sndev)for (i =0 ; i < sndev->nr_lut_mw; i++) {int idx = sndev->nr_direct_mw + i; +if (idx >=MAX_MWS ) { +dev_err (&sndev->stdev->dev, +"Total number of MW cannot be bigger than %d" ,MAX_MWS ); +break ; + } + sndev->self_shared->mw_sizes[idx] =LUT_SIZE ; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 445/844 ntb: ntb_hw_switchtec: Fix shift-out-of-bounds for 0 mw lut
In reply to Sasha LevinFrom: Maciej Grochowski <[email protected]>
[ Upstream commit 186615f8855a0be4ee7d3fcd09a8ecc10e783b08 ]
Number of MW LUTs depends on NTB configuration and can be set to zero, in such scenario rounddown_pow_of_two will cause undefined behaviour and should not be performed.
This patch ensures that rounddown_pow_of_two is called on valid value.
--- drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +4 -2
@@ -1202,7 +1202,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev) sndev->mmio_self_ctrl); sndev->nr_lut_mw =ioread16 (&sndev->mmio_self_ctrl->lut_table_entries); - sndev->nr_lut_mw =rounddown_pow_of_two (sndev->nr_lut_mw); +if (sndev->nr_lut_mw) + sndev->nr_lut_mw =rounddown_pow_of_two (sndev->nr_lut_mw);dev_dbg (&sndev->stdev->dev,"MWs: %d direct, %d lut\n" , sndev->nr_direct_mw, sndev->nr_lut_mw);
@@ -1212,7 +1213,8 @@ static void switchtec_ntb_init_mw(struct switchtec_ntb *sndev) sndev->peer_nr_lut_mw =ioread16 (&sndev->mmio_peer_ctrl->lut_table_entries); - sndev->peer_nr_lut_mw =rounddown_pow_of_two (sndev->peer_nr_lut_mw); +if (sndev->peer_nr_lut_mw) + sndev->peer_nr_lut_mw =rounddown_pow_of_two (sndev->peer_nr_lut_mw);dev_dbg (&sndev->stdev->dev,"Peer MWs: %d direct, %d lut\n" , sndev->peer_nr_direct_mw, sndev->peer_nr_lut_mw);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 446/844 iommu/amd: serialize sequence allocation under concurrent TLB invalidations
In reply to Sasha LevinFrom: Ankit Soni <[email protected]>
[ Upstream commit 9e249c48412828e807afddc21527eb734dc9bd3d ]
With concurrent TLB invalidations, completion wait randomly gets timed out because cmd_sem_val was incremented outside the IOMMU spinlock, allowing CMD_COMPL_WAIT commands to be queued out of sequence and breaking the ordering assumption in wait_on_sem().
Move the cmd_sem_val increment under iommu->lock so completion sequence allocation is serialized with command queuing.
And remove the unnecessary return.
--- drivers/iommu/amd/amd_iommu_types.h | 2 +- drivers/iommu/amd/init.c | 2 +- drivers/iommu/amd/iommu.c | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/iommu/amd/amd_iommu_types.h +1 -1
@@ -706,7 +706,7 @@ struct amd_iommu {u32 flags;volatile u64 *cmd_sem; -atomic64_t cmd_sem_val; +u64 cmd_sem_val;/* * Track physical address to directly use it in build_completion_wait() * and avoid adding any special checks and handling for kdump.
drivers/iommu/amd/init.c +1 -1
@@ -1877,7 +1877,7 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h, iommu->pci_seg = pci_seg;raw_spin_lock_init (&iommu->lock); -atomic64_set (&iommu->cmd_sem_val,0 ); + iommu->cmd_sem_val =0 ;/* Add IOMMU to internal data structures */ list_add_tail (&iommu->list, &amd_iommu_list);
drivers/iommu/amd/iommu.c +12 -6
@@ -1417,6 +1417,12 @@ static int iommu_queue_command(struct amd_iommu *iommu, struct iommu_cmd *cmd)return iommu_queue_command_sync (iommu, cmd, true); } +static u64 get_cmdsem_val (struct amd_iommu *iommu) +{ +lockdep_assert_held (&iommu->lock); +return ++iommu->cmd_sem_val; +} +/* * This function queues a completion wait command into the command * buffer of an IOMMU
@@ -1431,11 +1437,11 @@ static int iommu_completion_wait(struct amd_iommu *iommu)if (!iommu->need_sync)return 0 ; - data =atomic64_inc_return (&iommu->cmd_sem_val); -build_completion_wait (&cmd, iommu, data); -raw_spin_lock_irqsave (&iommu->lock, flags); + data =get_cmdsem_val (iommu); +build_completion_wait (&cmd, iommu, data); + ret =__iommu_queue_command_sync (iommu, &cmd, false);raw_spin_unlock_irqrestore (&iommu->lock, flags);
@@ -3113,10 +3119,11 @@ static void iommu_flush_irt_and_complete(struct amd_iommu *iommu, u16 devid)return ;build_inv_irt (&cmd, devid); - data =atomic64_inc_return (&iommu->cmd_sem_val); -build_completion_wait (&cmd2, iommu, data);raw_spin_lock_irqsave (&iommu->lock, flags); + data =get_cmdsem_val (iommu); +build_completion_wait (&cmd2, iommu, data); + ret =__iommu_queue_command_sync (iommu, &cmd, true);if (ret) goto out_err;
@@ -3130,7 +3137,6 @@ static void iommu_flush_irt_and_complete(struct amd_iommu *iommu, u16 devid) out_err:raw_spin_unlock_irqrestore (&iommu->lock, flags); -return ; }static inline u8 iommu_get_int_tablen (struct iommu_dev_data *dev_data)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 447/844 xfrm6: fix uninitialized saddr in xfrm6_get_saddr()
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit 1799d8abeabc68ec05679292aaf6cba93b343c05 ]
xfrm6_get_saddr() does not check the return value of ipv6_dev_get_saddr(). When ipv6_dev_get_saddr() fails to find a suitable source address (returns -EADDRNOTAVAIL), saddr->in6 is left uninitialized, but xfrm6_get_saddr() still returns 0 (success).
This causes the caller xfrm_tmpl_resolve_one() to use the uninitialized address in xfrm_state_find(), triggering KMSAN warning:
=====================================================
BUG: KMSAN: uninit-value in xfrm_state_find+0x2424/0xa940 xfrm_state_find+0x2424/0xa940 xfrm_resolve_and_create_bundle+0x906/0x5a20 xfrm_lookup_with_ifid+0xcc0/0x3770 xfrm_lookup_route+0x63/0x2b0 ip_route_output_flow+0x1ce/0x270 udp_sendmsg+0x2ce1/0x3400 inet_sendmsg+0x1ef/0x2a0 __sock_sendmsg+0x278/0x3d0 __sys_sendto+0x593/0x720 __x64_sys_sendto+0x130/0x200 x64_sys_call+0x332b/0x3e70 do_syscall_64+0xd3/0xf80 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable tmp.i.i created at:
xfrm_resolve_and_create_bundle+0x3e3/0x5a20 xfrm_lookup_with_ifid+0xcc0/0x3770 =====================================================
Fix by checking the return value of ipv6_dev_get_saddr() and propagating the error.
--- net/ipv6/xfrm6_policy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/ipv6/xfrm6_policy.c +5 -2
@@ -57,6 +57,7 @@ static int xfrm6_get_saddr(xfrm_address_t *saddr,struct dst_entry *dst;struct net_device *dev;struct inet6_dev *idev; +int err; dst =xfrm6_dst_lookup (params);if (IS_ERR (dst))
@@ -68,9 +69,11 @@ static int xfrm6_get_saddr(xfrm_address_t *saddr,return -EHOSTUNREACH ; } dev = idev->dev; -ipv6_dev_get_saddr (dev_net (dev), dev, ¶ms->daddr->in6,0 , - &saddr->in6); + err =ipv6_dev_get_saddr (dev_net (dev), dev, ¶ms->daddr->in6,0 , + &saddr->in6);dst_release (dst); +if (err) +return -EHOSTUNREACH ;return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 448/844 xfrm: skip templates check for packet offload tunnel mode
In reply to Sasha LevinFrom: Leon Romanovsky <[email protected]>
[ Upstream commit 0a4524bc69882a4ddb235bb6b279597721bda197 ]
In packet offload, hardware is responsible to check templates. The result of its operation is forwarded through secpath by relevant drivers. That secpath is actually removed in __xfrm_policy_check2().
In case packet is forwarded, this secpath is reset in RX, but pushed again to TX where policy is rechecked again against dummy secpath in xfrm_policy_ok().
Such situation causes to unexpected XfrmInTmplMismatch increase.
As a solution, simply skip template mismatch check.
--- net/xfrm/xfrm_policy.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
net/xfrm/xfrm_policy.c +9 -2
@@ -3801,8 +3801,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,struct xfrm_tmpl *tp[XFRM_MAX_DEPTH ];struct xfrm_tmpl *stp[XFRM_MAX_DEPTH ];struct xfrm_tmpl **tpp = tp; +int i, k =0 ;int ti =0 ; -int i, k; sp =skb_sec_path (skb);if (!sp)
@@ -3828,6 +3828,12 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, tpp = stp; } +if (pol->xdo.type ==XFRM_DEV_OFFLOAD_PACKET && sp == &dummy) +/* This policy template was already checked by HW +* and secpath was removed in __xfrm_policy_check2. +*/ + goto out; +/* For each tunnel xfrm, find the first matching tmpl. * For each tmpl before that, find corresponding xfrm. * Order is _important_. Later we will implement
@@ -3837,7 +3843,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,* verified to allow them to be skipped in future policy * checks (e.g. nested tunnels). */ -for (i = xfrm_nr-1 , k =0 ; i >=0 ; i--) { +for (i = xfrm_nr -1 ; i >=0 ; i--) { k =xfrm_policy_ok (tpp[i], sp, k, family, if_id);if (k <0 ) {if (k <-1 )
@@ -3853,6 +3859,7 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, goto reject; } +out:xfrm_pols_put (pols, npols); sp->verified_cnt = k;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 449/844 ipmi: ipmb: initialise event handler read bytes
In reply to Sasha LevinFrom: Matt Johnston <[email protected]>
[ Upstream commit 9f235ccecd03c436cb1683eac16b12f119e54aa9 ]
IPMB doesn't use i2c reads, but the handler needs to set a value. Otherwise an i2c read will return an uninitialised value from the bus driver.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_ipmb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/char/ipmi/ipmi_ipmb.c +5 -0
@@ -202,11 +202,16 @@ static int ipmi_ipmb_slave_cb(struct i2c_client *client,break ;case I2C_SLAVE_READ_REQUESTED : + *val =0xff ; +ipmi_ipmb_check_msg_done (iidev); +break ; +case I2C_SLAVE_STOP :ipmi_ipmb_check_msg_done (iidev);break ;case I2C_SLAVE_READ_PROCESSED : + *val =0xff ;break ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 450/844 xfrm: always flush state and policy upon NETDEV_UNREGISTER event
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 4efa91a28576054aae0e6dad9cba8fed8293aef8 ]
syzbot is reporting that "struct xfrm_state" refcount is leaking.
unregister_netdevice: waiting for netdevsim0 to become free. Usage count = 2
ref_tracker: netdev@ffff888052f24618 has 1/1 users at
__netdev_tracker_alloc include/linux/netdevice.h:4400 [inline]
netdev_tracker_alloc include/linux/netdevice.h:4412 [inline]
xfrm_dev_state_add+0x3a5/0x1080 net/xfrm/xfrm_device.c:316
xfrm_state_construct net/xfrm/xfrm_user.c:986 [inline]
xfrm_add_sa+0x34ff/0x5fa0 net/xfrm/xfrm_user.c:1022
xfrm_user_rcv_msg+0x58e/0xc00 net/xfrm/xfrm_user.c:3507
netlink_rcv_skb+0x158/0x420 net/netlink/af_netlink.c:2550
xfrm_netlink_rcv+0x71/0x90 net/xfrm/xfrm_user.c:3529
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x5aa/0x870 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x8c8/0xdd0 net/netlink/af_netlink.c:1894
sock_sendmsg_nosec net/socket.c:727 [inline]
__sock_sendmsg net/socket.c:742 [inline]
____sys_sendmsg+0xa5d/0xc30 net/socket.c:2592
___sys_sendmsg+0x134/0x1d0 net/socket.c:2646
__sys_sendmsg+0x16d/0x220 net/socket.c:2678
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7fThis is because commit d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API") implemented xfrm_dev_unregister() as no-op despite xfrm_dev_state_add() from xfrm_state_construct() acquires a reference to "struct net_device".
I guess that that commit expected that NETDEV_DOWN event is fired before NETDEV_UNREGISTER event fires, and also assumed that xfrm_dev_state_add() is called only if (dev->features & NETIF_F_HW_ESP) != 0.
Sabrina Dubroca identified steps to reproduce the same symptoms as below.
echo 0 > /sys/bus/netdevsim/new_device
dev=$(ls -1 /sys/bus/netdevsim/devices/netdevsim0/net/)
ip xfrm state add src 192.168.13.1 dst 192.168.13.2 proto esp \
spi 0x1000 mode tunnel aead 'rfc4106(gcm(aes))' $key 128 \
offload crypto dev $dev dir out
ethtool -K $dev esp-hw-offload off
echo 0 > /sys/bus/netdevsim/del_deviceLike these steps indicate, the NETIF_F_HW_ESP bit can be cleared after xfrm_dev_state_add() acquired a reference to "struct net_device". Also, xfrm_dev_state_add() does not check for the NETIF_F_HW_ESP bit when acquiring a reference to "struct net_device".
Commit 03891f820c21 ("xfrm: handle NETDEV_UNREGISTER for xfrm device") re-introduced the NETDEV_UNREGISTER event to xfrm_dev_event(), but that commit for unknown reason chose to share xfrm_dev_down() between the NETDEV_DOWN event and the NETDEV_UNREGISTER event.
I guess that that commit missed the behavior in the previous paragraph.
Therefore, we need to re-introduce xfrm_dev_unregister() in order to release the reference to "struct net_device" by unconditionally flushing state and policy.
--- net/xfrm/xfrm_device.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/xfrm/xfrm_device.c +11 -1
@@ -544,6 +544,14 @@ static int xfrm_dev_down(struct net_device *dev)return NOTIFY_DONE ; } +static int xfrm_dev_unregister (struct net_device *dev) +{ +xfrm_dev_state_flush (dev_net (dev), dev, true); +xfrm_dev_policy_flush (dev_net (dev), dev, true); + +return NOTIFY_DONE ; +} +static int xfrm_dev_event (struct notifier_block *this,unsigned long event,void *ptr) {struct net_device *dev =netdev_notifier_info_to_dev (ptr);
@@ -556,8 +564,10 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, voidreturn xfrm_api_check (dev);case NETDEV_DOWN : -case NETDEV_UNREGISTER :return xfrm_dev_down (dev); + +case NETDEV_UNREGISTER : +return xfrm_dev_unregister (dev); }return NOTIFY_DONE ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 451/844 writeback: Fix wakeup and logging timeouts for !DETECT_HUNG_TASK
In reply to Sasha LevinFrom: Huacai Chen <[email protected]>
[ Upstream commit 9eed043d10f17301c1b5141e16bb98a85a8fd07e ]
Recent changes of fs-writeback cause such warnings if DETECT_HUNG_TASK is not enabled:
INFO: The task sync:1342 has been waiting for writeback completion for more than 1 seconds.
The reason is sysctl_hung_task_timeout_secs is 0 when DETECT_HUNG_TASK is not enabled, then it causes the warning message even if the writeback lasts for only one second.
Guard the wakeup and logging with "#ifdef CONFIG_DETECT_HUNG_TASK" can eliminate the warning messages. But on the other hand, it is possible that sysctl_hung_task_timeout_secs be also 0 when DETECT_HUNG_TASK is enabled. So let's just check the value of sysctl_hung_task_timeout_secs to decide whether do wakeup and logging.
--- fs/fs-writeback.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/fs-writeback.c +5 -4
@@ -198,10 +198,11 @@ static void wb_queue_work(struct bdi_writeback *wb,static bool wb_wait_for_completion_cb (struct wb_completion *done) { +unsigned long timeout = sysctl_hung_task_timeout_secs;unsigned long waited_secs = (jiffies - done->wait_start) /HZ ; done->progress_stamp = jiffies; -if (waited_secs > sysctl_hung_task_timeout_secs) +if (timeout && (waited_secs > timeout))pr_info ("INFO: The task %s:%d has been waiting for writeback " "completion for more than %lu seconds." , current->comm, current->pid, waited_secs);
@@ -1944,6 +1945,7 @@ static long writeback_sb_inodes(struct super_block *sb, .range_end = LLONG_MAX, };unsigned long start_time = jiffies; +unsigned long timeout = sysctl_hung_task_timeout_secs;long write_chunk;long total_wrote =0 ;/* count both pages and inodes */ unsigned long dirtied_before = jiffies;
@@ -2030,9 +2032,8 @@ static long writeback_sb_inodes(struct super_block *sb,__writeback_single_inode (inode, &wbc);/* Report progress to inform the hung task detector of the progress. */ -if (work->done && work->done->progress_stamp && - (jiffies - work->done->progress_stamp) >HZ * - sysctl_hung_task_timeout_secs /2 ) +if (work->done && work->done->progress_stamp && timeout && + (jiffies - work->done->progress_stamp) >HZ * timeout /2 )wake_up_all (work->done->waitq);wbc_detach_inode (&wbc);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 452/844 tcp: fix potential race in tcp_v6_syn_recv_sock()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 858d2a4f67ff69e645a43487ef7ea7f28f06deae ]
Code in tcp_v6_syn_recv_sock() after the call to tcp_v4_syn_recv_sock() is done too late.
After tcp_v4_syn_recv_sock(), the child socket is already visible from TCP ehash table and other cpus might use it.
Since newinet->pinet6 is still pointing to the listener ipv6_pinfo bad things can happen as syzbot found.
Move the problematic code in tcp_v6_mapped_child_init() and call this new helper from tcp_v4_syn_recv_sock() before the ehash insertion.
This allows the removal of one tcp_sync_mss(), since tcp_v4_syn_recv_sock() will call it with the correct context.
--- include/net/inet_connection_sock.h | 4 +- include/net/tcp.h | 4 +- net/ipv4/syncookies.c | 2 +- net/ipv4/tcp_fastopen.c | 2 +- net/ipv4/tcp_ipv4.c | 8 ++- net/ipv4/tcp_minisocks.c | 2 +- net/ipv6/tcp_ipv6.c | 98 +++++++++++++----------------- net/mptcp/subflow.c | 6 +- net/smc/af_smc.c | 6 +- 9 files changed, 66 insertions(+), 66 deletions(-)
include/net/inet_connection_sock.h +3 -1
@@ -42,7 +42,9 @@ struct inet_connection_sock_af_ops {struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req); + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk));u16 net_header_len;int (*setsockopt)(struct sock *sk,int level,int optname,sockptr_t optval,unsigned int optlen);
include/net/tcp.h +3 -1
@@ -533,7 +533,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req); + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk));int tcp_v4_do_rcv (struct sock *sk,struct sk_buff *skb);int tcp_v4_connect (struct sock *sk,struct sockaddr_unsized *uaddr,int addr_len);int tcp_connect (struct sock *sk);
net/ipv4/syncookies.c +1 -1
@@ -203,7 +203,7 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,bool own_req; child = icsk->icsk_af_ops->syn_recv_sock (sk, skb, req, dst, -NULL , &own_req); +NULL , &own_req,NULL );if (child) {refcount_set (&req->rsk_refcnt,1 );sock_rps_save_rxhash (child, skb);
net/ipv4/tcp_fastopen.c +1 -1
@@ -247,7 +247,7 @@ static struct sock *tcp_fastopen_create_child(struct sock *sk,bool own_req; child =inet_csk (sk)->icsk_af_ops->syn_recv_sock (sk, skb, req,NULL , -NULL , &own_req); +NULL , &own_req,NULL );if (!child)return NULL ;
net/ipv4/tcp_ipv4.c +7 -1
@@ -1706,7 +1706,9 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct inet_request_sock *ireq;bool found_dup_sk = false;
@@ -1758,6 +1760,10 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, }sk_setup_caps (newsk, dst); +#if IS_ENABLED (CONFIG_IPV6 ) +if (opt_child_init) +opt_child_init (newsk, sk); +#endif tcp_ca_openreq_child (newsk, dst);tcp_sync_mss (newsk,dst_mtu (dst));
net/ipv4/tcp_minisocks.c +1 -1
@@ -909,7 +909,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,* socket is created, wait for troubles. */ child =inet_csk (sk)->icsk_af_ops->syn_recv_sock (sk, skb, req,NULL , - req, &own_req); + req, &own_req,NULL );if (!child) goto listen_overflow;
net/ipv6/tcp_ipv6.c +42 -56
114 lines not on this page · raw message
net/mptcp/subflow.c +4 -2
@@ -810,7 +810,9 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct mptcp_subflow_context *listener = mptcp_subflow_ctx(sk);struct mptcp_subflow_request_sock *subflow_req;
@@ -857,7 +859,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, create_child: child = listener->icsk_af_ops->syn_recv_sock (sk, skb, req, dst, - req_unhash, own_req); + req_unhash, own_req, opt_child_init);if (child && *own_req) {struct mptcp_subflow_context *ctx =mptcp_subflow_ctx (child);
net/smc/af_smc.c +4 -2
@@ -124,7 +124,9 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,struct request_sock *req, struct dst_entry *dst, struct request_sock *req_unhash, - bool *own_req) + bool *own_req, + void (*opt_child_init)(struct sock *newsk, + const struct sock *sk)) { struct smc_sock *smc;struct sock *child;
@@ -142,7 +144,7 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,/* passthrough to original syn recv sock fct */ child = smc->ori_af_ops->syn_recv_sock (sk, skb, req, dst, req_unhash, - own_req); + own_req, opt_child_init);/* child must not inherit smc or its ops */ if (child) {rcu_assign_sk_user_data (child,NULL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 453/844 psp: use sk->sk_hash in psp_write_headers()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit f891007ab1c77436950d10e09eae54507f1865ff ]
udp_flow_src_port() is indirectly using sk->sk_txhash as a base, because __tcp_transmit_skb() uses skb_set_hash_from_sk().
This is problematic because this field can change over the lifetime of a TCP flow, thanks to calls to sk_rethink_txhash().
Problem is that some NIC might (ab)use the PSP UDP source port in their RSS computation, and PSP packets for a given flow could jump from one queue to another.
In order to avoid surprises, it is safer to let Protective Load Balancing (PLB) get its entropy from the IPv6 flowlabel, and change psp_write_headers() to use sk->sk_hash which does not change for the duration of the flow.
We might add a sysctl to select the behavior, if there is a need for it.
--- net/psp/psp_main.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
net/psp/psp_main.c +38 -1
@@ -166,9 +166,46 @@ static void psp_write_headers(struct net *net, struct sk_buff *skb, __be32 spi, {struct udphdr *uh =udp_hdr (skb);struct psphdr *psph = (struct psphdr *)(uh +1 ); +const struct sock *sk = skb->sk; uh->dest =htons (PSP_DEFAULT_UDP_PORT ); - uh->source =udp_flow_src_port (net, skb,0 ,0 , false); + +/* A bit of theory: Selection of the source port. +* +* We need some entropy, so that multiple flows use different +* source ports for better RSS spreading at the receiver. +* +* We also need that all packets belonging to one TCP flow +* use the same source port through their duration, +* so that all these packets land in the same receive queue. +* +* udp_flow_src_port() is using sk_txhash, inherited from +* skb_set_hash_from_sk() call in __tcp_transmit_skb(). +* This field is subject to reshuffling, thanks to +* sk_rethink_txhash() calls in various TCP functions. +* +* Instead, use sk->sk_hash which is constant through +* the whole flow duration. +*/ +if (likely (sk)) { +u32 hash = sk->sk_hash; +int min, max; + +/* These operations are cheap, no need to cache the result +* in another socket field. +*/ +inet_get_local_port_range (net, &min, &max); +/* Since this is being sent on the wire obfuscate hash a bit +* to minimize possibility that any useful information to an +* attacker is leaked. Only upper 16 bits are relevant in the +* computation for 16 bit port value because we use a +* reciprocal divide. +*/ + hash ^= hash <<16 ; + uh->source =htons ((((u64 )hash * (max - min)) >>32 ) + min); + }else { + uh->source =udp_flow_src_port (net, skb,0 ,0 , false); + } uh->check =0 ; uh->len =htons (udp_len);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 454/844 espintcp: Fix race condition in espintcp_close()
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit e1512c1db9e8794d8d130addd2615ec27231d994 ]
This issue was discovered during a code audit.
After cancel_work_sync() is called from espintcp_close(), espintcp_tx_work() can still be scheduled from paths such as the Delayed ACK handler or ksoftirqd.
As a result, the espintcp_tx_work() worker may dereference a freed espintcp ctx or sk.
The following is a simple race scenario:
cpu0 cpu1
espintcp_close()
cancel_work_sync(&ctx->work);
espintcp_write_space()
schedule_work(&ctx->work);To prevent this race condition, cancel_work_sync() is replaced with disable_work_sync().
--- net/xfrm/espintcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/espintcp.c +1 -1
@@ -536,7 +536,7 @@ static void espintcp_close(struct sock *sk, long timeout) sk->sk_prot = &tcp_prot;barrier (); -cancel_work_sync (&ctx->work); +disable_work_sync (&ctx->work);strp_done (&ctx->strp);skb_queue_purge (&ctx->out_queue);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 455/844 net: usb: kaweth: remove TX queue manipulation in kaweth_set_rx_mode
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 64868f5ecadeb359a49bc4485bfa7c497047f13a ]
kaweth_set_rx_mode(), the ndo_set_rx_mode callback, calls netif_stop_queue() and netif_wake_queue(). These are TX queue flow control functions unrelated to RX multicast configuration.
The premature netif_wake_queue() can re-enable TX while tx_urb is still in-flight, leading to a double usb_submit_urb() on the same URB:
kaweth_start_xmit() {
netif_stop_queue();
usb_submit_urb(kaweth->tx_urb);
}kaweth_set_rx_mode() {
netif_stop_queue();
netif_wake_queue(); // wakes TX queue before URB is done
}kaweth_start_xmit() {
netif_stop_queue();
usb_submit_urb(kaweth->tx_urb); // URB submitted while active
}This triggers the WARN in usb_submit_urb():
"URB submitted while active"
This is a similar class of bug fixed in rtl8150 by
- commit 958baf5eaee3 ("net: usb: Remove disruptive netif_wake_queue in rtl8150_set_multicast").
Also kaweth_set_rx_mode() is already functionally broken, the real set_rx_mode action is performed by kaweth_async_set_rx_mode(), which in turn is not a no-op only at ndo_open() time.
--- drivers/net/usb/kaweth.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/usb/kaweth.c +0 -2
@@ -765,7 +765,6 @@ static void kaweth_set_rx_mode(struct net_device *net)netdev_dbg (net,"Setting Rx mode to %d\n" , packet_filter_bitmap); -netif_stop_queue (net);if (net->flags &IFF_PROMISC ) { packet_filter_bitmap |=KAWETH_PACKET_FILTER_PROMISCUOUS ;
@@ -775,7 +774,6 @@ static void kaweth_set_rx_mode(struct net_device *net) } kaweth->packet_filter_bitmap = packet_filter_bitmap; -netif_wake_queue (net); }/****************************************************************
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 456/844 net: usb: lan78xx: scan all MDIO addresses on LAN7801
In reply to Sasha LevinFrom: Martin Pålsson <[email protected]>
[ Upstream commit f1e2f0ce704e4a14e3f367d3b97d3dd2d8e183b7 ]
The LAN7801 is designed exclusively for external PHYs (unlike the LAN7800/LAN7850 which have internal PHYs), but lan78xx_mdio_init() restricts PHY scanning to MDIO addresses 0-7 by setting phy_mask to ~(0xFF). This prevents discovery of external PHYs wired to addresses outside that range.
One such case is the DP83TC814 100BASE-T1 PHY, which is typically configured at MDIO address 10 via PHYAD bootstrap pins and goes undetected with the current mask.
Remove the restrictive phy_mask assignment for the LAN7801 so that the default mask of 0 applies, allowing all 32 MDIO addresses to be scanned during bus registration.
--- drivers/net/usb/lan78xx.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/usb/lan78xx.c +0 -2
@@ -2094,8 +2094,6 @@ static int lan78xx_mdio_init(struct lan78xx_net *dev) dev->mdiobus->phy_mask = ~(1 <<1 );break ;case ID_REV_CHIP_ID_7801_ : -/* scan thru PHYAD[2..0] */ - dev->mdiobus->phy_mask = ~(0xFF );break ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 457/844 proc: Fix pointer error dereference
In reply to Sasha LevinFrom: Ethan Tidmore <[email protected]>
[ Upstream commit f6a495484a27150fb85f943e1a7464da88c2a797 ]
The function try_lookup_noperm() can return an error pointer. Add check for error pointer.
Detected by Smatch:fs/proc/base.c:2148 proc_fill_cache() error:
'child' dereferencing possible ERR_PTR()
--- fs/proc/base.c | 3 +++ 1 file changed, 3 insertions(+)
fs/proc/base.c +3 -0
@@ -2128,6 +2128,9 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,ino_t ino =1 ; child =try_lookup_noperm (&qname, dir); +if (IS_ERR (child)) + goto end_instantiate; +if (!child) {DECLARE_WAIT_QUEUE_HEAD_ONSTACK (wq); child =d_alloc_parallel (dir, &qname, &wq);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 458/844 net: phy: qcom: qca807x: normalize return value of gpio_get
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
[ Upstream commit 2bb995e6155cb4f254574598cbd6fe1dcc99766a ]
The GPIO get callback is expected to return 0 or 1 (or a negative error code). Ensure that the value returned by qca807x_gpio_get() is normalized to the [0, 1] range.
--- drivers/net/phy/qcom/qca807x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/qcom/qca807x.c +1 -1
@@ -375,7 +375,7 @@ static int qca807x_gpio_get(struct gpio_chip *gc, unsigned int offset) reg =QCA807X_MMD7_LED_FORCE_CTRL (offset); val =phy_read_mmd (priv->phy,MDIO_MMD_AN , reg); -return FIELD_GET (QCA807X_GPIO_FORCE_MODE_MASK , val); +return !!FIELD_GET (QCA807X_GPIO_FORCE_MODE_MASK , val); }static int qca807x_gpio_set (struct gpio_chip *gc,unsigned int offset,int value)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 459/844 net: ethernet: xscale: Check for PTP support properly
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
[ Upstream commit 594163ea88a03bdb412063af50fc7177ef3cbeae ]
In ixp4xx_get_ts_info() ixp46x_ptp_find() is called unconditionally despite this feature only existing on ixp46x, leading to the following splat from tcpdump:
root@OpenWrt:~# tcpdump -vv -X -i eth0 (...) Unable to handle kernel NULL pointer dereference at virtual address 00000238 when read (...) Call trace: ptp_clock_index from ixp46x_ptp_find+0x1c/0x38 ixp46x_ptp_find from ixp4xx_get_ts_info+0x4c/0x64 ixp4xx_get_ts_info from __ethtool_get_ts_info+0x90/0x108 __ethtool_get_ts_info from __dev_ethtool+0xa00/0x2648 __dev_ethtool from dev_ethtool+0x160/0x234 dev_ethtool from dev_ioctl+0x2cc/0x460 dev_ioctl from sock_ioctl+0x1ec/0x524 sock_ioctl from sys_ioctl+0x51c/0xa94 sys_ioctl from ret_fast_syscall+0x0/0x44 (...) Segmentation fault
Check for ixp46x in ixp46x_ptp_find() before trying to set up PTP to avoid this.
To avoid altering the returned error code from ixp4xx_hwtstamp_set() which before this patch was -EOPNOTSUPP, we return -EOPNOTSUPP from ixp4xx_hwtstamp_set() if ixp46x_ptp_find() fails no matter the error code. The helper function ixp46x_ptp_find() helper returns -ENODEV.
--- drivers/net/ethernet/xscale/ixp4xx_eth.c | 5 +---- drivers/net/ethernet/xscale/ptp_ixp46x.c | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/xscale/ixp4xx_eth.c +1 -4
@@ -403,15 +403,12 @@ static int ixp4xx_hwtstamp_set(struct net_device *netdev,int ret;int ch; -if (!cpu_is_ixp46x ()) -return -EOPNOTSUPP ; -if (!netif_running (netdev))return -EINVAL ; ret =ixp46x_ptp_find (&port->timesync_regs, &port->phc_index);if (ret) -return ret; +return -EOPNOTSUPP ; ch =PORT2CHANNEL (port); regs = port->timesync_regs;
drivers/net/ethernet/xscale/ptp_ixp46x.c +3 -0
@@ -232,6 +232,9 @@ static struct ixp_clock ixp_clock;int ixp46x_ptp_find (struct ixp46x_ts_regs *__iomem *regs,int *phc_index) { +if (!cpu_is_ixp46x ()) +return -ENODEV ; + *regs = ixp_clock.regs; *phc_index =ptp_clock_index (ixp_clock.ptp_clock);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 460/844 udplite: Fix null-ptr-deref in __udp_enqueue_schedule_skb().
In reply to Sasha LevinFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 470c7ca2b4c3e3a51feeb952b7f97a775b5c49cd ]
syzbot reported null-ptr-deref of udp_sk(sk)->udp_prod_queue. [0]
Since the cited commit, udp_lib_init_sock() can fail, as can udp_init_sock() and udpv6_init_sock().
Let's handle the error in udplite_sk_init() and udplitev6_sk_init().
[0]:
BUG: KASAN: null-ptr-deref in instrument_atomic_read include/linux/instrumented.h:82 [inline] BUG: KASAN: null-ptr-deref in atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline] BUG: KASAN: null-ptr-deref in __udp_enqueue_schedule_skb+0x151/0x1480 net/ipv4/udp.c:1719 Read of size 4 at addr 0000000000000008 by task syz.2.18/2944 CPU: 1 UID: 0 PID: 2944 Comm: syz.2.18 Not tainted syzkaller #0 PREEMPTLAZY Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025 Call Trace: <IRQ> dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120 kasan_report+0xa2/0xe0 mm/kasan/report.c:595 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x264/0x2c0 mm/kasan/generic.c:200 instrument_atomic_read include/linux/instrumented.h:82 [inline] atomic_read include/linux/atomic/atomic-instrumented.h:32 [inline] __udp_enqueue_schedule_skb+0x151/0x1480 net/ipv4/udp.c:1719 __udpv6_queue_rcv_skb net/ipv6/udp.c:795 [inline] udpv6_queue_rcv_one_skb+0xa2e/0x1ad0 net/ipv6/udp.c:906 udp6_unicast_rcv_skb+0x227/0x380 net/ipv6/udp.c:1064 ip6_protocol_deliver_rcu+0xe17/0x1540 net/ipv6/ip6_input.c:438 ip6_input_finish+0x191/0x350 net/ipv6/ip6_input.c:489 NF_HOOK+0x354/0x3f0 include/linux/netfilter.h:318 ip6_input+0x16c/0x2b0 net/ipv6/ip6_input.c:500 NF_HOOK+0x354/0x3f0 include/linux/netfilter.h:318 __netif_receive_skb_one_core net/core/dev.c:6149 [inline] __netif_receive_skb+0xd3/0x370 net/core/dev.c:6262 process_backlog+0x4d6/0x1160 net/core/dev.c:6614 __napi_poll+0xae/0x320 net/core/dev.c:7678 napi_poll net/core/dev.c:7741 [inline] net_rx_action+0x60d/0xdc0 net/core/dev.c:7893 handle_softirqs+0x209/0x8d0 kernel/softirq.c:622 do_softirq+0x52/0x90 kernel/softirq.c:523 </IRQ> <TASK> __local_bh_enable_ip+0xe7/0x120 kernel/softirq.c:450 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:924 [inline] __dev_queue_xmit+0x109c/0x2dc0 net/core/dev.c:4856 __ip6_finish_output net/ipv6/ip6_output.c:-1 [inline] ip6_finish_output+0x158/0x4e0 net/ipv6/ip6_output.c:219 NF_HOOK_COND include/linux/netfilter.h:307 [inline] ip6_output+0x342/0x580 net/ipv6/ip6_output.c:246 ip6_send_skb+0x1d7/0x3c0 net/ipv6/ip6_output.c:1984 udp_v6_send_skb+0x9a5/0x1770 net/ipv6/udp.c:1442 udp_v6_push_pending_frames+0xa2/0x140 net/ipv6/udp.c:1469 udpv6_sendmsg+0xfe0/0x2830 net/ipv6/udp.c:1759 sock_sendmsg_nosec net/socket.c:727 [inline] __sock_sendmsg+0xe5/0x270 net/socket.c:742 __sys_sendto+0x3eb/0x580 net/socket.c:2206 __do_sys_sendto net/socket.c:2213 [inline] __se_sys_sendto net/socket.c:2209 [inline] __x64_sys_sendto+0xde/0x100 net/socket.c:2209 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xd2/0xf20 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f67b4d9c629 Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f67b5c98028 EFLAGS: 00000246 ORIG_RAX: 000000000000002c RAX: ffffffffffffffda RBX: 00007f67b5015fa0 RCX: 00007f67b4d9c629 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007f67b4e32b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000040000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f67b5016038 R14: 00007f67b5015fa0 R15: 00007ffe3cb66dd8 </TASK>
--- net/ipv4/udplite.c | 3 +-- net/ipv6/udplite.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
net/ipv4/udplite.c +1 -2
@@ -20,10 +20,9 @@ EXPORT_SYMBOL(udplite_table);/* Designate sk as UDP-Lite socket */ static int udplite_sk_init (struct sock *sk) { -udp_init_sock (sk);pr_warn_once ("UDP-Lite is deprecated and scheduled to be removed in 2025, " "please contact the netdev mailing list\n" ); -return 0 ; +return udp_init_sock (sk); }static int udplite_rcv (struct sk_buff *skb)
net/ipv6/udplite.c +1 -2
@@ -16,10 +16,9 @@static int udplitev6_sk_init (struct sock *sk) { -udpv6_init_sock (sk);pr_warn_once ("UDP-Lite is deprecated and scheduled to be removed in 2025, " "please contact the netdev mailing list\n" ); -return 0 ; +return udpv6_init_sock (sk); }static int udplitev6_rcv (struct sk_buff *skb)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 461/844 bnxt_en: Fix RSS context delete logic
In reply to Sasha LevinFrom: Pavan Chebbi <[email protected]>
[ Upstream commit e123d9302d223767bd910bfbcfe607bae909f8ac ]
We need to free the corresponding RSS context VNIC in FW everytime an RSS context is deleted in driver. Commit 667ac333dbb7 added a check to delete the VNIC in FW only when netif_running() is true to help delete RSS contexts with interface down.
Having that condition will make the driver leak VNICs in FW whenever close() happens with active RSS contexts. On the subsequent open(), as part of RSS context restoration, we will end up trying to create extra VNICs for which we did not make any reservation. FW can fail this request, thereby making us lose active RSS contexts.
Suppose an RSS context is deleted already and we try to process a delete request again, then the HWRM functions will check for validity of the request and they simply return if the resource is already freed. So, even for delete-when-down cases, netif_running() check is not necessary.
Remove the netif_running() condition check when deleting an RSS context.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +4 -6
@@ -10827,12 +10827,10 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,struct bnxt_ntuple_filter *ntp_fltr;int i; -if (netif_running (bp->dev)) { -bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic); -for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) { -if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID ) -bnxt_hwrm_vnic_ctx_free_one (bp, vnic, i); - } +bnxt_hwrm_vnic_free_one (bp, &rss_ctx->vnic); +for (i =0 ; i <BNXT_MAX_CTX_PER_VNIC ; i++) { +if (vnic->fw_rss_cos_lb_ctx[i] !=INVALID_HW_RING_ID ) +bnxt_hwrm_vnic_ctx_free_one (bp, vnic, i); }if (!all)return ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 462/844 bnxt_en: Fix deleting of Ntuple filters
In reply to Sasha LevinFrom: Pavan Chebbi <[email protected]>
[ Upstream commit c1bbd9900d65ac65b9fce9f129e3369a04871570 ]
Ntuple filters can be deleted when the interface is down. The current code blindly sends the filter delete command to FW. When the interface is down, all the VNICs are deleted in the FW. When the VNIC is freed in the FW, all the associated filters are also freed. We need not send the free command explicitly. Sending such command will generate FW error in the dmesg.
In order to fix this, we can safely return from bnxt_hwrm_cfa_ntuple_filter_free() when BNXT_STATE_OPEN is not true which confirms the VNICs have been deleted.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +3 -0
@@ -6212,6 +6212,9 @@ int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,int rc;set_bit (BNXT_FLTR_FW_DELETED , &fltr->base.state); +if (!test_bit (BNXT_STATE_OPEN , &bp->state)) +return 0 ; + rc =hwrm_req_init (bp, req,HWRM_CFA_NTUPLE_FILTER_FREE );if (rc)return rc;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 463/844 ovpn: tcp - fix packet extraction from stream
In reply to Sasha LevinFrom: Ralf Lici <[email protected]>
[ Upstream commit d4f687fbbce45b5e88438e89b5e26c0c15847992 ]
When processing TCP stream data in ovpn_tcp_recv, we receive large cloned skbs from __strp_rcv that may contain multiple coalesced packets. The current implementation has two bugs:
1. Header offset overflow: Using pskb_pull with large offsets on coalesced skbs causes skb->data - skb->head to exceed the u16 storage of skb->network_header. This causes skb_reset_network_header to fail on the inner decapsulated packet, resulting in packet drops.
2. Unaligned protocol headers: Extracting packets from arbitrary positions within the coalesced TCP stream provides no alignment guarantees for the packet data causing performance penalties on architectures without efficient unaligned access. Additionally, openvpn's 2-byte length prefix on TCP packets causes the subsequent 4-byte opcode and packet ID fields to be inherently misaligned.
Fix both issues by allocating a new skb for each openvpn packet and using skb_copy_bits to extract only the packet content into the new buffer, skipping the 2-byte length prefix. Also, check the length before invoking the function that performs the allocation to avoid creating an invalid skb.
If the packet has to be forwarded to userspace the 2-byte prefix can be pushed to the head safely, without misalignment.
As a side effect, this approach also avoids the expensive linearization that pskb_pull triggers on cloned skbs with page fragments. In testing, this resulted in TCP throughput improvements of up to 74%.
--- drivers/net/ovpn/tcp.c | 53 ++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 17 deletions(-)
drivers/net/ovpn/tcp.c +36 -17
@@ -70,37 +70,56 @@ static void ovpn_tcp_to_userspace(struct ovpn_peer *peer, struct sock *sk, peer->tcp.sk_cb.sk_data_ready (sk); } -static void ovpn_tcp_rcv (struct strparser *strp,struct sk_buff *skb) +static struct sk_buff *ovpn_tcp_skb_packet (const struct ovpn_peer *peer, +struct sk_buff *orig_skb, +const int pkt_len,const int pkt_off) { - struct ovpn_peer *peer = container_of(strp, struct ovpn_peer, tcp.strp); -struct strp_msg *msg =strp_msg (skb); -size_t pkt_len = msg->full_len -2 ; -size_t off = msg->offset +2 ; -u8 opcode; +struct sk_buff *ovpn_skb; +int err; -/* ensure skb->data points to the beginning of the openvpn packet */ -if (!pskb_pull (skb, off)) { -net_warn_ratelimited ("%s: packet too small for peer %u\n" , -netdev_name (peer->ovpn->dev), peer->id); +/* create a new skb with only the content of the current packet */ + ovpn_skb =netdev_alloc_skb (peer->ovpn->dev, pkt_len); +if (unlikely (!ovpn_skb)) goto err; - } -/* strparser does not trim the skb for us, therefore we do it now */ -if (pskb_trim (skb, pkt_len) !=0 ) { -net_warn_ratelimited ("%s: trimming skb failed for peer %u\n" , +skb_copy_header (ovpn_skb, orig_skb); + err =skb_copy_bits (orig_skb, pkt_off,skb_put (ovpn_skb, pkt_len), + pkt_len); +if (unlikely (err)) { +net_warn_ratelimited ("%s: skb_copy_bits failed for peer %u\n" ,netdev_name (peer->ovpn->dev), peer->id); +kfree_skb (ovpn_skb); goto err; } -/* we need the first 4 bytes of data to be accessible +consume_skb (orig_skb); +return ovpn_skb; +err: +kfree_skb (orig_skb); +return NULL ; +} + +static void ovpn_tcp_rcv (struct strparser *strp,struct sk_buff *skb) +{ + struct ovpn_peer *peer = container_of(strp, struct ovpn_peer, tcp.strp); +struct strp_msg *msg =strp_msg (skb); +int pkt_len = msg->full_len -2 ; +u8 opcode; + +/* we need at least 4 bytes of data in the packet * to extract the opcode and the key ID later on */ -if (!pskb_may_pull (skb,OVPN_OPCODE_SIZE )) { +if (unlikely (pkt_len <OVPN_OPCODE_SIZE )) {net_warn_ratelimited ("%s: packet too small to fetch opcode for peer %u\n" ,netdev_name (peer->ovpn->dev), peer->id); goto err; } +/* extract the packet into a new skb */ + skb =ovpn_tcp_skb_packet (peer, skb, pkt_len, msg->offset +2 ); +if (unlikely (!skb)) + goto err; +/* DATA_V2 packets are handled in kernel, the rest goes to user space */ opcode =ovpn_opcode_from_skb (skb,0 );if (unlikely (opcode !=OVPN_DATA_V2 )) {
@@ -113,7 +132,7 @@ static void ovpn_tcp_rcv(struct strparser *strp, struct sk_buff *skb)/* The packet size header must be there when sending the packet * to userspace, therefore we put it back */ -skb_push (skb,2 ); + *(__be16 *)__skb_push (skb,sizeof (u16)) =htons (pkt_len);ovpn_tcp_to_userspace (peer, strp->sk, skb);return ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 464/844 ksmbd: fix signededness bug in smb_direct_prepare_negotiation()
In reply to Sasha LevinFrom: Nicholas Carlini <[email protected]>
[ Upstream commit 6b4f875aac344cdd52a1f34cc70ed2f874a65757 ]
smb_direct_prepare_negotiation() casts an unsigned __u32 value from sp->max_recv_size and req->preferred_send_size to a signed int before computing min_t(int, ...). A maliciously provided preferred_send_size of 0x80000000 will return as smaller than max_recv_size, and then be used to set the maximum allowed alowed receive size for the next message.
By sending a second message with a large value (>1420 bytes) the attacker can then achieve a heap buffer overflow.
This fix replaces min_t(int, ...) with min_t(u32)
--- fs/smb/server/transport_rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/transport_rdma.c +2 -2
@@ -2527,9 +2527,9 @@ static int smb_direct_prepare(struct ksmbd_transport *t) goto put; req = (struct smbdirect_negotiate_req *)recvmsg->packet; - sp->max_recv_size =min_t (int, sp->max_recv_size, + sp->max_recv_size =min_t (u32, sp->max_recv_size,le32_to_cpu (req->preferred_send_size)); - sp->max_send_size =min_t (int, sp->max_send_size, + sp->max_send_size =min_t (u32, sp->max_send_size,le32_to_cpu (req->max_receive_size)); sp->max_fragmented_send_size =le32_to_cpu (req->max_fragmented_size);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 465/844 dma-mapping: avoid random addr value print out on error path
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit 47322c469d4a63ac45b705ca83680671ff71c975 ]
dma_addr is unitialized in dma_direct_map_phys() when swiotlb is forced and DMA_ATTR_MMIO is set which leads to random value print out in warning. Fix that by just returning DMA_MAPPING_ERROR.
--- kernel/dma/direct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/direct.h +1 -1
@@ -88,7 +88,7 @@ static inline dma_addr_t dma_direct_map_phys(struct device *dev,if (is_swiotlb_force_bounce (dev)) {if (attrs &DMA_ATTR_MMIO ) - goto err_overflow; +return DMA_MAPPING_ERROR ;return swiotlb_map (dev, phys, size, dir, attrs); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 466/844 sparc: Fix page alignment in dma mapping
In reply to Sasha LevinFrom: Stian Halseth <[email protected]>
[ Upstream commit d5b5e8149af0f5efed58653cbebf1cb3258ce49a ]
'phys' may include an offset within the page, while previously used 'base_paddr' was already page-aligned. This caused incorrect DMA mapping in dma_4u_map_phys and dma_4v_map_phys.
Fix both functions by masking 'phys' with IO_PAGE_MASK, covering both generic SPARC code and sun4v.
--- arch/sparc/kernel/iommu.c | 2 ++ arch/sparc/kernel/pci_sun4v.c | 2 ++ 2 files changed, 4 insertions(+)
arch/sparc/kernel/iommu.c +2 -0
@@ -312,6 +312,8 @@ static dma_addr_t dma_4u_map_phys(struct device *dev, phys_addr_t phys,if (direction !=DMA_TO_DEVICE ) iopte_protection |=IOPTE_WRITE ; + phys &=IO_PAGE_MASK ; +for (i =0 ; i < npages; i++, base++, phys +=IO_PAGE_SIZE )iopte_val (*base) = iopte_protection | phys;
arch/sparc/kernel/pci_sun4v.c +2 -0
@@ -410,6 +410,8 @@ static dma_addr_t dma_4v_map_phys(struct device *dev, phys_addr_t phys,iommu_batch_start (dev, prot, entry); + phys &=IO_PAGE_MASK ; +for (i =0 ; i < npages; i++, phys +=IO_PAGE_SIZE ) {long err =iommu_batch_add (phys, mask);if (unlikely (err <0L ))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 467/844 wifi: cfg80211: wext: fix IGTK key ID off-by-one
In reply to Sasha LevinFrom: Johannes Berg <[email protected]>
[ Upstream commit c8d7f21ead727485ebf965e2b4d42d4a4f0840f6 ]
The IGTK key ID must be 4 or 5, but the code checks against key ID + 1, so must check against 5/6 rather than 4/5. Fix that.
--- net/wireless/wext-compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/wext-compat.c +1 -1
@@ -684,7 +684,7 @@ static int cfg80211_wext_siwencodeext(struct net_device *dev, idx = erq->flags &IW_ENCODE_INDEX ;if (cipher ==WLAN_CIPHER_SUITE_AES_CMAC ) { -if (idx <4 || idx >5 ) { +if (idx <5 || idx >6 ) { idx = wdev->wext.default_mgmt_key;if (idx <0 )return -EINVAL ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 468/844 wifi: brcmfmac: Fix potential kernel oops when probe fails
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 243307a0d1b0d01538e202c00454c28b21d4432e ]
When probe of the sdio brcmfmac device fails for some reasons (i.e. missing firmware), the sdiodev->bus is set to error instead of NULL, thus the cleanup later in brcmf_sdio_remove() tries to free resources via invalid bus pointer. This happens because sdiodev->bus is set 2 times:
first in brcmf_sdio_probe() and second time in brcmf_sdiod_probe(). Fix this by chaning the brcmf_sdio_probe() function to return the error code and set sdio->bus only there.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 7 +++---- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 7 ++++--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +3 -4
@@ -951,11 +951,10 @@ int brcmf_sdiod_probe(struct brcmf_sdio_dev *sdiodev) goto out;/* try to attach to the target device */ - sdiodev->bus =brcmf_sdio_probe (sdiodev); -if (IS_ERR (sdiodev->bus)) { - ret =PTR_ERR (sdiodev->bus); + ret =brcmf_sdio_probe (sdiodev); +if (ret) goto out; - } +brcmf_sdiod_host_fixup (sdiodev->func2->card->host); out:if (ret)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +4 -3
@@ -4445,7 +4445,7 @@ brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus)return fwreq; } -struct brcmf_sdio *brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev) +int brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev) {int ret;struct brcmf_sdio *bus;
@@ -4551,11 +4551,12 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) goto fail; } -return bus; +return 0 ; fail:brcmf_sdio_remove (bus); -return ERR_PTR (ret); + sdiodev->bus =NULL ; +return ret; }/* Detach and free everything */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h +1 -1
@@ -358,7 +358,7 @@ void brcmf_sdiod_freezer_uncount(struct brcmf_sdio_dev *sdiodev);int brcmf_sdiod_probe (struct brcmf_sdio_dev *sdiodev);int brcmf_sdiod_remove (struct brcmf_sdio_dev *sdiodev); -struct brcmf_sdio *brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev); +int brcmf_sdio_probe (struct brcmf_sdio_dev *sdiodev);void brcmf_sdio_remove (struct brcmf_sdio *bus);void brcmf_sdio_isr (struct brcmf_sdio *bus,bool in_isr);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 469/844 Remove WARN_ALL_UNSEEDED_RANDOM kernel config option
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
[ Upstream commit 7dff99b354601dd01829e1511711846e04340a69 ]
This config option goes way back - it used to be an internal debug option to random.c (at that point called DEBUG_RANDOM_BOOT), then was renamed and exposed as a config option as CONFIG_WARN_UNSEEDED_RANDOM, and then further renamed to the current CONFIG_WARN_ALL_UNSEEDED_RANDOM.
It was all done with the best of intentions: the more limited rate-limited reports were reporting some cases, but if you wanted to see all the gory details, you'd enable this "ALL" option.
However, it turns out - perhaps not surprisingly - that when people don't care about and fix the first rate-limited cases, they most certainly don't care about any others either, and so warning about all of them isn't actually helping anything.
And the non-ratelimited reporting causes problems, where well-meaning people enable debug options, but the excessive flood of messages that nobody cares about will hide actual real information when things go wrong.
I just got a kernel bug report (which had nothing to do with randomness) where two thirds of the the truncated dmesg was just variations of
random: get_random_u32 called from __get_random_u32_below+0x10/0x70 with crng_init=0
and in the process early boot messages had been lost (in addition to making the messages that _hadn't_ been lost harder to read).
The proper way to find these things for the hypothetical developer that cares - if such a person exists - is almost certainly with boot time tracing. That gives you the option to get call graphs etc too, which is likely a requirement for fixing any problems anyway.
See Documentation/trace/boottime-trace.rst for that option.
And if we for some reason do want to re-introduce actual printing of these things, it will need to have some uniqueness filtering rather than this "just print it all" model.
--- drivers/char/random.c | 12 +----------- kernel/configs/debug.config | 1 - lib/Kconfig.debug | 27 --------------------------- 3 files changed, 1 insertion(+), 39 deletions(-)
drivers/char/random.c +1 -11
@@ -96,8 +96,7 @@ static ATOMIC_NOTIFIER_HEAD(random_ready_notifier);/* Control how we warn userspace. */ static struct ratelimit_state urandom_warning =RATELIMIT_STATE_INIT_FLAGS ("urandom_warning" ,HZ ,3 ,RATELIMIT_MSG_ON_RELEASE ); -static int ratelimit_disable__read_mostly = -IS_ENABLED (CONFIG_WARN_ALL_UNSEEDED_RANDOM ); +static int ratelimit_disable__read_mostly =0 ;module_param_named (ratelimit_disable, ratelimit_disable, int,0644 );MODULE_PARM_DESC (ratelimit_disable,"Disable random ratelimit suppression" );
@@ -168,12 +167,6 @@ int __cold execute_with_initialized_rng(struct notifier_block *nb)return ret; } -#define warn_unseeded_randomness () \ - if (IS_ENABLED(CONFIG_WARN_ALL_UNSEEDED_RANDOM) && !crng_ready()) \ - printk_deferred(KERN_NOTICE "random: %s called from %pS with crng_init=%d\n", \ - __func__, (void *)_RET_IP_, crng_init) - -/********************************************************************* * * Fast key erasure RNG, the "crng".
@@ -434,7 +427,6 @@ static void _get_random_bytes(void *buf, size_t len)*/ void get_random_bytes (void *buf,size_t len) { -warn_unseeded_randomness ();_get_random_bytes (buf, len); }EXPORT_SYMBOL (get_random_bytes);
@@ -523,8 +515,6 @@ type get_random_ ##type(void) \ struct batch_ ##type *batch; \unsigned long next_gen ; \ \ - warn_unseeded_randomness(); \ - \if (!crng_ready ()) { \_get_random_bytes (&ret,sizeof (ret )); \return ret; \
kernel/configs/debug.config +0 -1
@@ -29,7 +29,6 @@ CONFIG_SECTION_MISMATCH_WARN_ONLY=y # CONFIG_UBSAN_ALIGNMENT is not set # CONFIG_UBSAN_DIV_ZERO is not set # CONFIG_UBSAN_TRAP is not set -# CONFIG_WARN_ALL_UNSEEDED_RANDOM is not set CONFIG_DEBUG_FS=y CONFIG_DEBUG_FS_ALLOW_ALL=y CONFIG_DEBUG_IRQFLAGS=y
lib/Kconfig.debug +0 -27
@@ -1687,33 +1687,6 @@ config STACKTRACE It is also used by various kernel debugging features that require stack trace generation. -config WARN_ALL_UNSEEDED_RANDOM - bool "Warn for all uses of unseeded randomness" - default n - help - Some parts of the kernel contain bugs relating to their use of - cryptographically secure random numbers before it's actually possible - to generate those numbers securely. This setting ensures that these - flaws don't go unnoticed, by enabling a message, should this ever - occur. This will allow people with obscure setups to know when things - are going wrong, so that they might contact developers about fixing - it. - - Unfortunately, on some models of some architectures getting - a fully seeded CRNG is extremely difficult, and so this can - result in dmesg getting spammed for a surprisingly long - time. This is really bad from a security perspective, and - so architecture maintainers really need to do what they can - to get the CRNG seeded sooner after the system is booted. - However, since users cannot do anything actionable to - address this, by default this option is disabled. - - Say Y here if you want to receive warnings for all uses of - unseeded randomness. This will be of use primarily for - those developers interested in improving the security of - Linux kernels running on their architecture (or - subarchitecture). - config DEBUG_KOBJECT bool "kobject debugging" depends on DEBUG_KERNEL
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 470/844 Bluetooth: L2CAP: Fix invalid response to L2CAP_ECRED_RECONF_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 7accb1c4321acb617faf934af59d928b0b047e2b ]
This fixes responding with an invalid result caused by checking the wrong size of CID which should have been (cmd_len - sizeof(*req)) and on top of it the wrong result was use L2CAP_CR_LE_INVALID_PARAMS which is invalid/reserved for reconf when running test like L2CAP/ECFC/BI-03-C:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 64
MPS: 64
Source CID: 64
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reserved (0x000c)
Result: Reconfiguration failed - one or more Destination CIDs invalid (0x0003)Fiix L2CAP/ECFC/BI-04-C which expects L2CAP_RECONF_INVALID_MPS (0x0002) when more than one channel gets its MPS reduced:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 16
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 8
MTU: 264
MPS: 99
Source CID: 64
! Source CID: 65
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)Fix L2CAP/ECFC/BI-05-C when SCID is invalid (85 unconnected):
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 65
MPS: 64
! Source CID: 85
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - one or more Destination CIDs invalid (0x0003)Fix L2CAP/ECFC/BI-06-C when MPS < L2CAP_ECRED_MIN_MPS (64):
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 14
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 2 len 6
MTU: 672
! MPS: 63
Source CID: 64
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)
Result: Reconfiguration failed - other unacceptable parameters (0x0004)Fix L2CAP/ECFC/BI-07-C when MPS reduced for more than one channel:
Quoted 1 line
ACL Data RX: Handle 64 flags
0x02dlen 16
LE L2CAP: Enhanced Credit Reconfigure Request (0x19) ident 3 len 8
MTU: 84! MPS: 71
Source CID: 64
! Source CID: 65
< ACL Data TX: Handle 64 flags 0x00 dlen 10
LE L2CAP: Enhanced Credit Reconfigure Respond (0x1a) ident 2 len 2
! Result: Reconfiguration successful (0x0000)
Result: Reconfiguration failed - reduction in size of MPS not allowed for more than one channel at a time (0x0002)--- include/net/bluetooth/l2cap.h | 2 ++ net/bluetooth/l2cap_core.c | 63 +++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 18 deletions(-)
include/net/bluetooth/l2cap.h +2 -0
@@ -493,6 +493,8 @@ struct l2cap_ecred_reconf_req {#define L2CAP_RECONF_SUCCESS 0x0000#define L2CAP_RECONF_INVALID_MTU 0x0001#define L2CAP_RECONF_INVALID_MPS 0x0002 +#define L2CAP_RECONF_INVALID_CID 0x0003 +#define L2CAP_RECONF_INVALID_PARAMS 0x0004struct l2cap_ecred_reconf_rsp {__le16 result;
net/bluetooth/l2cap_core.c +45 -18
101 lines not on this page · raw message
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 471/844 Bluetooth: L2CAP: Fix result of L2CAP_ECRED_CONN_RSP when MTU is too short
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit c28d2bff70444a85b3b86aaf241ece9408c7858c ]
Test L2CAP/ECFC/BV-26-C expect the response to L2CAP_ECRED_CONN_REQ with and MTU value < L2CAP_ECRED_MIN_MTU (64) to be L2CAP_CR_LE_INVALID_PARAMS rather than L2CAP_CR_LE_UNACCEPT_PARAMS.
Also fix not including the correct number of CIDs in the response since the spec requires all CIDs being rejected to be included in the response.
--- include/net/bluetooth/l2cap.h | 6 +++--- net/bluetooth/l2cap_core.c | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-)
include/net/bluetooth/l2cap.h +3 -3
@@ -284,9 +284,9 @@ struct l2cap_conn_rsp {#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007#define L2CAP_CR_LE_ENCRYPTION 0x0008#define L2CAP_CR_LE_INVALID_SCID 0x0009 -#define L2CAP_CR_LE_SCID_IN_USE 0X000A -#define L2CAP_CR_LE_UNACCEPT_PARAMS 0X000B -#define L2CAP_CR_LE_INVALID_PARAMS 0X000C +#define L2CAP_CR_LE_SCID_IN_USE 0x000A +#define L2CAP_CR_LE_UNACCEPT_PARAMS 0x000B +#define L2CAP_CR_LE_INVALID_PARAMS 0x000C/* connect/create channel status */ #define L2CAP_CS_NO_INFO 0x0000
net/bluetooth/l2cap_core.c +8 -6
@@ -5035,13 +5035,15 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,struct l2cap_chan *chan, *pchan;u16 mtu, mps;__le16 psm; -u8 result, len =0 ; +u8 result, rsp_len =0 ;int i, num_scid;bool defer = false;if (!enable_ecred)return -EINVAL ; +memset (pdu,0 ,sizeof (*pdu)); +if (cmd_len <sizeof (*req) || (cmd_len -sizeof (*req)) %sizeof (u16)) { result =L2CAP_CR_LE_INVALID_PARAMS ; goto response;
@@ -5050,6 +5052,9 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, cmd_len -=sizeof (*req); num_scid = cmd_len /sizeof (u16); +/* Always respond with the same number of scids as in the request */ + rsp_len = cmd_len; +if (num_scid >L2CAP_ECRED_MAX_CID ) { result =L2CAP_CR_LE_INVALID_PARAMS ; goto response;
@@ -5059,7 +5064,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, mps =__le16_to_cpu (req->mps);if (mtu <L2CAP_ECRED_MIN_MTU || mps <L2CAP_ECRED_MIN_MPS ) { - result =L2CAP_CR_LE_UNACCEPT_PARAMS ; + result =L2CAP_CR_LE_INVALID_PARAMS ; goto response; }
@@ -5079,8 +5084,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,BT_DBG ("psm 0x%2.2x mtu %u mps %u" ,__le16_to_cpu (psm), mtu, mps); -memset (pdu,0 ,sizeof (*pdu)); -/* Check if we have socket listening on psm */ pchan =l2cap_global_chan_by_psm (BT_LISTEN , psm, &conn->hcon->src, &conn->hcon->dst,LE_LINK );
@@ -5105,7 +5108,6 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,BT_DBG ("scid[%d] 0x%4.4x" , i, scid); pdu->dcid[i] =0x0000 ; - len +=sizeof (*pdu->dcid);/* Check for valid dynamic CID range */ if (scid <L2CAP_CID_DYN_START || scid >L2CAP_CID_LE_DYN_END ) {
@@ -5172,7 +5174,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,return 0 ;l2cap_send_cmd (conn, cmd->ident,L2CAP_ECRED_CONN_RSP , -sizeof (*pdu) + len, pdu); +sizeof (*pdu) + rsp_len, pdu);return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 472/844 Bluetooth: hci_qca: Cleanup on all setup failures
In reply to Sasha LevinFrom: Jinwang Li <[email protected]>
[ Upstream commit 5c4e9a8b18457ad28b57069ef0f14661e3192b2e ]
The setup process previously combined error handling and retry gating under one condition. As a result, the final failed attempt exited without performing cleanup.
Update the failure path to always perform power and port cleanup on setup failure, and reopen the port only when retrying.
--- drivers/bluetooth/hci_qca.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/bluetooth/hci_qca.c +14 -10
@@ -2045,19 +2045,23 @@ static int qca_setup(struct hci_uart *hu) } out: -if (ret && retries <MAX_INIT_RETRIES ) { -bt_dev_warn (hdev,"Retry BT power ON:%d" , retries); +if (ret) {qca_power_shutdown (hu); -if (hu->serdev) { -serdev_device_close (hu->serdev); - ret =serdev_device_open (hu->serdev); -if (ret) { -bt_dev_err (hdev,"failed to open port" ); -return ret; + +if (retries <MAX_INIT_RETRIES ) { +bt_dev_warn (hdev,"Retry BT power ON:%d" , retries); +if (hu->serdev) { +serdev_device_close (hu->serdev); + ret =serdev_device_open (hu->serdev); +if (ret) { +bt_dev_err (hdev,"failed to open port" ); +return ret; + } } + retries++; + goto retry; } - retries++; - goto retry; +return ret; }/* Setup bdaddr */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 473/844 Bluetooth: L2CAP: Fix response to L2CAP_ECRED_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 05761c2c2b5bfec85c47f60c903c461e9b56cf87 ]
Similar to 03dba9cea72f ("Bluetooth: L2CAP: Fix not responding with L2CAP_CR_LE_ENCRYPTION") the result code L2CAP_CR_LE_ENCRYPTION shall be used when BT_SECURITY_MEDIUM is set since that means security mode 2 which mean it doesn't require authentication which results in qualification test L2CAP/ECFC/BV-32-C failing.
--- net/bluetooth/l2cap_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +2 -1
@@ -5096,7 +5096,8 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,if (!smp_sufficient_security (conn->hcon, pchan->sec_level,SMP_ALLOW_STK )) { - result =L2CAP_CR_LE_AUTHENTICATION ; + result = pchan->sec_level ==BT_SECURITY_MEDIUM ? +L2CAP_CR_LE_ENCRYPTION :L2CAP_CR_LE_AUTHENTICATION ; goto unlock; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 474/844 Bluetooth: L2CAP: Fix not checking output MTU is acceptable on L2CAP_ECRED_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit a8d1d73c81d1e70d2aa49fdaf59d933bb783ffe5 ]
Upon receiving L2CAP_ECRED_CONN_REQ the given MTU shall be checked against the suggested MTU of the listening socket as that is required by the likes of PTS L2CAP/ECFC/BV-27-C test which expects L2CAP_CR_LE_UNACCEPT_PARAMS if the MTU is lowers than socket omtu.
In order to be able to set chan->omtu the code now allows setting setsockopt(BT_SNDMTU), but it is only allowed when connection has not been stablished since there is no procedure to reconfigure the output MTU.
--- net/bluetooth/l2cap_core.c | 8 ++++++++ net/bluetooth/l2cap_sock.c | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
net/bluetooth/l2cap_core.c +8 -0
@@ -5101,6 +5101,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, goto unlock; } +/* Check if the listening channel has set an output MTU then the +* requested MTU shall be less than or equal to that value. +*/ +if (pchan->omtu && mtu < pchan->omtu) { + result =L2CAP_CR_LE_UNACCEPT_PARAMS ; + goto unlock; + } + result =L2CAP_CR_LE_SUCCESS ;for (i =0 ; i < num_scid; i++) {
net/bluetooth/l2cap_sock.c +11 -4
@@ -1029,10 +1029,17 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,break ; } -/* Setting is not supported as it's the remote side that -* decides this. -*/ - err = -EPERM ; +/* Only allow setting output MTU when not connected */ +if (sk->sk_state ==BT_CONNECTED ) { + err = -EISCONN ; +break ; + } + + err =copy_safe_from_sockptr (&mtu,sizeof (mtu), optval, optlen); +if (err) +break ; + + chan->omtu = mtu;break ;case BT_RCVMTU :
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 475/844 Bluetooth: L2CAP: Fix missing key size check for L2CAP_LE_CONN_REQ
In reply to Sasha LevinFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 138d7eca445ef37a0333425d269ee59900ca1104 ]
This adds a check for encryption key size upon receiving L2CAP_LE_CONN_REQ which is required by L2CAP/LE/CFC/BV-15-C which expects L2CAP_CR_LE_BAD_KEY_SIZE.
--- net/bluetooth/l2cap_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/l2cap_core.c +7 -0
@@ -4900,6 +4900,13 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn, goto response_unlock; } +/* Check if Key Size is sufficient for the security level */ +if (!l2cap_check_enc_key_size (conn->hcon, pchan)) { + result =L2CAP_CR_LE_BAD_KEY_SIZE ; + chan =NULL ; + goto response_unlock; + } +/* Check for valid dynamic CID range */ if (scid <L2CAP_CID_DYN_START || scid >L2CAP_CID_LE_DYN_END ) { result =L2CAP_CR_LE_INVALID_SCID ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 476/844 net: do not pass flow_id to set_rps_cpu()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 8a8a9fac9efa6423fd74938b940cb7d731780718 ]
Blamed commit made the assumption that the RPS table for each receive queue would have the same size, and that it would not change.
Compute flow_id in set_rps_cpu(), do not assume we can use the value computed by get_rps_cpu(). Otherwise we risk out-of-bound access and/or crashes.
--- net/core/dev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
net/core/dev.c +5 -7
@@ -4988,8 +4988,7 @@ static bool rps_flow_is_active(struct rps_dev_flow *rflow,static struct rps_dev_flow *set_rps_cpu (struct net_device *dev,struct sk_buff *skb, -struct rps_dev_flow *rflow,u16 next_cpu,u32 hash, -u32 flow_id) +struct rps_dev_flow *rflow,u16 next_cpu,u32 hash) {if (next_cpu < nr_cpu_ids) {u32 head;
@@ -5000,6 +4999,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,struct rps_dev_flow *tmp_rflow;unsigned int tmp_cpu;u16 rxq_index; +u32 flow_id;int rc;/* Should we steer this flow to a different hardware queue? */
@@ -5015,6 +5015,7 @@ set_rps_cpu(struct net_device *dev, struct sk_buff *skb,if (!flow_table) goto out; + flow_id =rfs_slot (hash, flow_table); tmp_rflow = &flow_table->flows[flow_id]; tmp_cpu =READ_ONCE (tmp_rflow->cpu);
@@ -5062,7 +5063,6 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,struct rps_dev_flow_table *flow_table;struct rps_map *map;int cpu =-1 ; -u32 flow_id;u32 tcpu;u32 hash;
@@ -5109,8 +5109,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,/* OK, now we know there is a match, * we can look at the local (per receive queue) flow table */ - flow_id =rfs_slot (hash, flow_table); - rflow = &flow_table->flows[flow_id]; + rflow = &flow_table->flows[rfs_slot (hash, flow_table)]; tcpu = rflow->cpu;/*
@@ -5129,8 +5128,7 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb, ((int)(READ_ONCE(per_cpu(softnet_data, tcpu).input_queue_head) - rflow->last_qtail)) >= 0)) { tcpu = next_cpu; - rflow =set_rps_cpu (dev, skb, rflow, next_cpu, hash, - flow_id); + rflow =set_rps_cpu (dev, skb, rflow, next_cpu, hash); }if (tcpu < nr_cpu_ids &&cpu_online (tcpu)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 477/844 tls: Fix race condition in tls_sw_cancel_work_tx()
In reply to Sasha LevinFrom: Hyunwoo Kim <[email protected]>
[ Upstream commit 7bb09315f93dce6acc54bf59e5a95ba7365c2be4 ]
This issue was discovered during a code audit.
After cancel_delayed_work_sync() is called from tls_sk_proto_close(), tx_work_handler() can still be scheduled from paths such as the Delayed ACK handler or ksoftirqd.
As a result, the tx_work_handler() worker may dereference a freed TLS object.
The following is a simple race scenario:
cpu0 cpu1
tls_sk_proto_close()
tls_sw_cancel_work_tx()
tls_write_space()
tls_sw_write_space()
if (!test_and_set_bit(BIT_TX_SCHEDULED, &tx_ctx->tx_bitmask))
set_bit(BIT_TX_SCHEDULED, &ctx->tx_bitmask);
cancel_delayed_work_sync(&ctx->tx_work.work);
schedule_delayed_work(&tx_ctx->tx_work.work, 0);To prevent this race condition, cancel_delayed_work_sync() is replaced with disable_delayed_work_sync().
--- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tls/tls_sw.c +1 -1
@@ -2533,7 +2533,7 @@ void tls_sw_cancel_work_tx(struct tls_context *tls_ctx)set_bit (BIT_TX_CLOSING , &ctx->tx_bitmask);set_bit (BIT_TX_SCHEDULED , &ctx->tx_bitmask); -cancel_delayed_work_sync (&ctx->tx_work.work); +disable_delayed_work_sync (&ctx->tx_work.work); }void tls_sw_release_resources_tx (struct sock *sk)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 478/844 kcm: fix zero-frag skb in frag_list on partial sendmsg error
In reply to Sasha LevinFrom: Jiayuan Chen <[email protected]>
[ Upstream commit ca220141fa8ebae09765a242076b2b77338106b0 ]
Syzkaller reported a warning in kcm_write_msgs() when processing a message with a zero-fragment skb in the frag_list.
When kcm_sendmsg() fills MAX_SKB_FRAGS fragments in the current skb, it allocates a new skb (tskb) and links it into the frag_list before copying data. If the copy subsequently fails (e.g. -EFAULT from user memory), tskb remains in the frag_list with zero fragments:
head skb (msg being assembled, NOT yet in sk_write_queue)
+-----------+
| frags[17] | (MAX_SKB_FRAGS, all filled with data)
| frag_list-+--> tskb
+-----------+ +----------+
| frags[0] | (empty! copy failed before filling)
+----------+For SOCK_SEQPACKET with partial data already copied, the error path saves this message via partial_message for later completion. For SOCK_SEQPACKET, sock_write_iter() automatically sets MSG_EOR, so a subsequent zero-length write(fd, NULL, 0) completes the message and queues it to sk_write_queue. kcm_write_msgs() then walks the frag_list and hits:
WARN_ON(!skb_shinfo(skb)->nr_frags)
TCP has a similar pattern where skbs are enqueued before data copy and cleaned up on failure via tcp_remove_empty_skb(). KCM was missing the equivalent cleanup.
Fix this by tracking the predecessor skb (frag_prev) when allocating a new frag_list entry. On error, if the tail skb has zero frags, use frag_prev to unlink and free it in O(1) without walking the singly-linked frag_list. frag_prev is safe to dereference because the entire message chain is only held locally (or in kcm->seq_skb) and is not added to sk_write_queue until MSG_EOR, so the send path cannot free it underneath us.
Also change the WARN_ON to WARN_ON_ONCE to avoid flooding the log if the condition is somehow hit repeatedly.
There are currently no KCM selftests in the kernel tree; a simple reproducer is available at [1].
[1] https://gist.github.com/mrpre/a94d431c757e8d6f168f4dd1a3749daa
--- net/kcm/kcmsock.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
net/kcm/kcmsock.c +19 -2
@@ -628,7 +628,7 @@ static int kcm_write_msgs(struct kcm_sock *kcm) skb = txm->frag_skb; } -if (WARN_ON (!skb_shinfo (skb)->nr_frags) || +if (WARN_ON_ONCE (!skb_shinfo (skb)->nr_frags) ||WARN_ON_ONCE (!skb_frag_page (&skb_shinfo (skb)->frags[0 ]))) { ret = -EINVAL ; goto out;
@@ -749,7 +749,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) {struct sock *sk = sock->sk;struct kcm_sock *kcm =kcm_sk (sk); -struct sk_buff *skb =NULL , *head =NULL ; +struct sk_buff *skb =NULL , *head =NULL , *frag_prev =NULL ;size_t copy, copied =0 ;long timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT ); int eor = (sock->type == SOCK_DGRAM) ?
@@ -824,6 +824,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)else skb->next = tskb; + frag_prev = skb; skb = tskb; skb->ip_summed =CHECKSUM_UNNECESSARY ;continue ;
@@ -933,6 +934,22 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) out_error:kcm_push (kcm); +/* When MAX_SKB_FRAGS was reached, a new skb was allocated and +* linked into the frag_list before data copy. If the copy +* subsequently failed, this skb has zero frags. Remove it from +* the frag_list to prevent kcm_write_msgs from later hitting +* WARN_ON(!skb_shinfo(skb)->nr_frags). +*/ +if (frag_prev && !skb_shinfo (skb)->nr_frags) { +if (head == frag_prev) +skb_shinfo (head)->frag_list =NULL ; +else + frag_prev->next =NULL ; +kfree_skb (skb); +/* Update skb as it may be saved in partial_message via goto */ + skb = frag_prev; + } +if (sock->type ==SOCK_SEQPACKET ) {/* Wrote some bytes before encountering an * error, return partial success.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 479/844 dpll: zl3073x: fix REF_PHASE_OFFSET_COMP register width for some chip IDs
In reply to Sasha LevinFrom: Ivan Vecera <[email protected]>
[ Upstream commit 4cfe066a82cdf9e83e48b16000f55280efc98325 ]
The REF_PHASE_OFFSET_COMP register is 48-bit wide on most zl3073x chip variants, but only 32-bit wide on chip IDs 0x0E30, 0x0E93..0x0E97 and 0x1F60. The driver unconditionally uses 48-bit read/write operations, which on 32-bit variants causes reading 2 bytes past the register boundary (corrupting the value) and writing 2 bytes into the adjacent register.
Fix this by storing the chip ID in the device structure during probe and adding a helper to detect the affected variants. Use the correct register width for read/write operations and the matching sign extension bit (31 vs 47) when interpreting the phase compensation value.
--- drivers/dpll/zl3073x/core.c | 1 + drivers/dpll/zl3073x/core.h | 28 ++++++++++++++++++++++++++++ drivers/dpll/zl3073x/dpll.c | 7 +++++-- drivers/dpll/zl3073x/ref.c | 25 ++++++++++++++++++++----- drivers/dpll/zl3073x/regs.h | 1 + 5 files changed, 55 insertions(+), 7 deletions(-)
drivers/dpll/zl3073x/core.c +1 -0
@@ -1023,6 +1023,7 @@ int zl3073x_dev_probe(struct zl3073x_dev *zldev,"Unknown or non-match chip ID: 0x%0x\n" , id); } + zldev->chip_id = id;/* Read revision, firmware version and custom config version */ rc =zl3073x_read_u16 (zldev,ZL_REG_REVISION , &revision);
drivers/dpll/zl3073x/core.h +28 -0
@@ -35,6 +35,7 @@ struct zl3073x_dpll;* @dev: pointer to device * @regmap: regmap to access device registers * @multiop_lock: to serialize multiple register operations +* @chip_id: chip ID read from hardware * @ref: array of input references' invariants * @out: array of outs' invariants * @synth: array of synths' invariants
@@ -48,6 +49,7 @@ struct zl3073x_dev {struct device *dev;struct regmap *regmap;struct mutex multiop_lock; +u16 chip_id;/* Invariants */ struct zl3073x_ref ref[ZL3073X_NUM_REFS ];
@@ -144,6 +146,32 @@ int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev,int zl3073x_ref_phase_offsets_update (struct zl3073x_dev *zldev,int channel); +/** +* zl3073x_dev_is_ref_phase_comp_32bit - check ref phase comp register size +* @zldev: pointer to zl3073x device +* +* Some chip IDs have a 32-bit wide ref_phase_offset_comp register instead +* of the default 48-bit. +* +* Return: true if the register is 32-bit, false if 48-bit +*/ +static inline bool +zl3073x_dev_is_ref_phase_comp_32bit (struct zl3073x_dev *zldev) +{ +switch (zldev->chip_id) { +case 0x0E30 : +case 0x0E93 : +case 0x0E94 : +case 0x0E95 : +case 0x0E96 : +case 0x0E97 : +case 0x1F60 : +return true; +default : +return false; + } +} +static inline bool zl3073x_is_n_pin (u8 id) {
drivers/dpll/zl3073x/dpll.c +5 -2
@@ -459,8 +459,11 @@ zl3073x_dpll_input_pin_phase_adjust_get(const struct dpll_pin *dpll_pin, ref_id =zl3073x_input_pin_ref_get (pin->id); ref =zl3073x_ref_state_get (zldev, ref_id); -/* Perform sign extension for 48bit signed value */ - phase_comp =sign_extend64 (ref->phase_comp,47 ); +/* Perform sign extension based on register width */ +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) + phase_comp =sign_extend64 (ref->phase_comp,31 ); +else + phase_comp =sign_extend64 (ref->phase_comp,47 );/* Reverse two's complement negation applied during set and convert * to 32bit signed int
drivers/dpll/zl3073x/ref.c +20 -5
@@ -121,8 +121,16 @@ int zl3073x_ref_state_fetch(struct zl3073x_dev *zldev, u8 index)return rc;/* Read phase compensation register */ - rc =zl3073x_read_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , - &ref->phase_comp); +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) { +u32 val; + + rc =zl3073x_read_u32 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP_32 , + &val); + ref->phase_comp = val; + }else { + rc =zl3073x_read_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , + &ref->phase_comp); + }if (rc)return rc;
@@ -179,9 +187,16 @@ int zl3073x_ref_state_set(struct zl3073x_dev *zldev, u8 index,if (!rc && dref->sync_ctrl != ref->sync_ctrl) rc =zl3073x_write_u8 (zldev,ZL_REG_REF_SYNC_CTRL , ref->sync_ctrl); -if (!rc && dref->phase_comp != ref->phase_comp) - rc =zl3073x_write_u48 (zldev,ZL_REG_REF_PHASE_OFFSET_COMP , - ref->phase_comp); +if (!rc && dref->phase_comp != ref->phase_comp) { +if (zl3073x_dev_is_ref_phase_comp_32bit (zldev)) + rc =zl3073x_write_u32 (zldev, +ZL_REG_REF_PHASE_OFFSET_COMP_32 , + ref->phase_comp); +else + rc =zl3073x_write_u48 (zldev, +ZL_REG_REF_PHASE_OFFSET_COMP , + ref->phase_comp); + }if (rc)return rc;
drivers/dpll/zl3073x/regs.h +1 -0
@@ -194,6 +194,7 @@#define ZL_REF_CONFIG_DIFF_EN BIT(2)#define ZL_REG_REF_PHASE_OFFSET_COMP ZL_REG(10, 0x28, 6) +#define ZL_REG_REF_PHASE_OFFSET_COMP_32 ZL_REG(10, 0x28, 4)#define ZL_REG_REF_SYNC_CTRL ZL_REG(10, 0x2e, 1)#define ZL_REF_SYNC_CTRL_MODE GENMASK(2, 0)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 480/844 tipc: fix duplicate publication key in tipc_service_insert_publ()
In reply to Sasha LevinFrom: Tung Nguyen <[email protected]>
[ Upstream commit 3aa677625c8fad39989496c51bcff3872c1f16f1 ]
TIPC uses named table to store TIPC services represented by type and instance. Each time an application calls TIPC API bind() to bind a type/instance to a socket, an entry is created and inserted into the named table. It looks like this:
named table:
key1, entry1 (type, instance ...)
key2, entry2 (type, instance ...)
In the above table, each entry represents a route for sending data from one socket to the other. For all publications originated from the same node, the key is UNIQUE to identify each entry. It is calculated by this formula:
key = socket portid + number of bindings + 1 (1)
where:
- socket portid: unique and calculated by using linux kernel function get_random_u32_below(). So, the value is randomized.
- number of bindings: the number of times a type/instance pair is bound to a socket. This number is linearly increased, starting from 0.
While the socket portid is unique and randomized by linux kernel, the linear increment of "number of bindings" in formula (1) makes "key" not unique anymore. For example:
- Socket 1 is created with its associated port number 20062001. Type 1000, instance 1 is bound to socket 1:
key1: 20062001 + 0 + 1 = 20062002
Then, bind() is called a second time on Socket 1 to by the same type 1000, instance 1:
key2: 20062001 + 1 + 1 = 20062003
Named table:
key1 (20062002), entry1 (1000, 1 ...)
key2 (20062003), entry2 (1000, 1 ...)
- Socket 2 is created with its associated port number 20062002. Type 1000, instance 1 is bound to socket 2:
key3: 20062002 + 0 + 1 = 20062003
TIPC looks up the named table and finds out that key2 with the same value already exists and rejects the insertion into the named table. This leads to failure of bind() call from application on Socket 2 with error message EINVAL "Invalid argument".
This commit fixes this issue by adding more port id checking to make sure that the key is unique to publications originated from the same port id and node.
--- net/tipc/name_table.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/tipc/name_table.c +4 -2
@@ -348,7 +348,8 @@ static bool tipc_service_insert_publ(struct net *net,/* Return if the publication already exists */ list_for_each_entry (_p, &sr->all_publ, all_publ) { -if (_p->key == key && (!_p->sk.node || _p->sk.node == node)) { +if (_p->key == key && _p->sk.ref == p->sk.ref && + (!_p->sk.node || _p->sk.node == node)) {pr_debug ("Failed to bind duplicate %u,%u,%u/%u:%u/%u\n" , p->sr.type, p->sr.lower, p->sr.upper, node, p->sk.ref, key);
@@ -388,7 +389,8 @@ static struct publication *tipc_service_remove_publ(struct service_range *r,u32 node = sk->node;list_for_each_entry (p, &r->all_publ, all_publ) { -if (p->key != key || (node && node != p->sk.node)) +if (p->key != key || p->sk.ref != sk->ref || + (node && node != p->sk.node))continue ;list_del (&p->all_publ);list_del (&p->local_publ);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 481/844 RDMA/core: Fix stale RoCE GIDs during netdev events at registration
In reply to Sasha LevinFrom: Jiri Pirko <[email protected]>
[ Upstream commit 9af0feae8016ba58ad7ff784a903404986b395b1 ]
RoCE GID entries become stale when netdev properties change during the IB device registration window. This is reproducible with a udev rule that sets a MAC address when a VF netdev appears:
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth4", \
RUN+="/sbin/ip link set eth4 address 88:22:33:44:55:66"After VF creation, show_gids displays GIDs derived from the original random MAC rather than the configured one.
The root cause is a race between netdev event processing and device registration:
CPU 0 (driver) CPU 1 (udev/workqueue)
────────────── ──────────────────────
ib_register_device()
ib_cache_setup_one()
gid_table_setup_one()
_gid_table_setup_one()
← GID table allocated
rdma_roce_rescan_device()
← GIDs populated with
OLD MAC
ip link set eth4 addr NEW_MAC NETDEV_CHANGEADDR queued netdevice_event_work_handler()
ib_enum_all_roce_netdevs()
← Iterates DEVICE_REGISTERED ← Device NOT marked yet, SKIP!
enable_device_and_get()
xa_set_mark(DEVICE_REGISTERED)
← Too late, event was lost
The netdev event handler uses ib_enum_all_roce_netdevs() which only iterates devices marked DEVICE_REGISTERED. However, this mark is set late in the registration process, after the GID cache is already populated. Events arriving in this window are silently dropped.
Fix this by introducing a new xarray mark DEVICE_GID_UPDATES that is set immediately after the GID table is allocated and initialized. Use the new mark in ib_enum_all_roce_netdevs() function to iterate devices instead of DEVICE_REGISTERED.
This is safe because:
- After _gid_table_setup_one(), all required structures exist (port_data, immutable, cache.gid)
- The GID table mutex serializes concurrent access between the initial rescan and event handlers
- Event handlers correctly update stale GIDs even when racing with rescan
- The mark is cleared in ib_cache_cleanup_one() before teardown
This also fixes similar races for IP address events (inetaddr_event, inet6addr_event) which use the same enumeration path.
--- drivers/infiniband/core/cache.c | 13 +++++++++++ drivers/infiniband/core/core_priv.h | 3 +++ drivers/infiniband/core/device.c | 34 ++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 1 deletion(-)
drivers/infiniband/core/cache.c +13 -0
@@ -927,6 +927,13 @@ static int gid_table_setup_one(struct ib_device *ib_dev)if (err)return err; +/* +* Mark the device as ready for GID cache updates. This allows netdev +* event handlers to update the GID cache even before the device is +* fully registered. +*/ +ib_device_enable_gid_updates (ib_dev); +rdma_roce_rescan_device (ib_dev);return err;
@@ -1639,6 +1646,12 @@ void ib_cache_release_one(struct ib_device *device)void ib_cache_cleanup_one (struct ib_device *device) { +/* +* Clear the GID updates mark first to prevent event handlers from +* accessing the device while it's being torn down. +*/ +ib_device_disable_gid_updates (device); +/* The cleanup function waits for all in-progress workqueue * elements and cleans up the GID cache. This function should be * called after the device was removed from the devices list and
drivers/infiniband/core/core_priv.h +3 -0
@@ -100,6 +100,9 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,roce_netdev_callback cb, void *cookie); +void ib_device_enable_gid_updates (struct ib_device *device); +void ib_device_disable_gid_updates (struct ib_device *device); + typedef int (*nldev_callback)(struct ib_device *device, struct sk_buff *skb, struct netlink_callback *cb,
drivers/infiniband/core/device.c +33 -1
@@ -93,6 +93,7 @@ static struct workqueue_struct *ib_unreg_wq; static DEFINE_XARRAY_FLAGS(devices, XA_FLAGS_ALLOC);static DECLARE_RWSEM (devices_rwsem);#define DEVICE_REGISTERED XA_MARK_1 +#define DEVICE_GID_UPDATES XA_MARK_2static u32 highest_client_id;#define CLIENT_REGISTERED XA_MARK_1
@@ -2441,11 +2442,42 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,unsigned long index;down_read (&devices_rwsem); - xa_for_each_marked (&devices, index, dev, DEVICE_REGISTERED) +xa_for_each_marked (&devices, index, dev,DEVICE_GID_UPDATES )ib_enum_roce_netdev (dev, filter, filter_cookie, cb, cookie);up_read (&devices_rwsem); } +/** +* ib_device_enable_gid_updates - Mark device as ready for GID cache updates +* @device: Device to mark +* +* Called after GID table is allocated and initialized. After this mark is set, +* netdevice event handlers can update the device's GID cache. This allows +* events that arrive during device registration to be processed, avoiding +* stale GID entries when netdev properties change during the device +* registration process. +*/ +void ib_device_enable_gid_updates (struct ib_device *device) +{ +down_write (&devices_rwsem); +xa_set_mark (&devices, device->index,DEVICE_GID_UPDATES ); +up_write (&devices_rwsem); +} + +/** +* ib_device_disable_gid_updates - Clear the GID updates mark +* @device: Device to unmark +* +* Called before GID table cleanup to prevent event handlers from accessing +* the device while it's being torn down. +*/ +void ib_device_disable_gid_updates (struct ib_device *device) +{ +down_write (&devices_rwsem); +xa_clear_mark (&devices, device->index,DEVICE_GID_UPDATES ); +up_write (&devices_rwsem); +} +/* * ib_enum_all_devs - enumerate all ib_devices * @cb: Callback to call for each found ib_device
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 482/844 RDMA/bng_re: Remove unnessary validity checks
In reply to Sasha LevinFrom: Siva Reddy Kallam <[email protected]>
[ Upstream commit 7a23af417d9dd57b4382356b2e7442e5d2bf5bea ]
Fix below smatch warning:drivers/infiniband/hw/bng_re/bng_dev.c:113 bng_re_net_ring_free() warn: variable dereferenced before check 'rdev' (see line 107)
current driver has unnessary validity checks. So, removing these unnessary validity checks.
--- drivers/infiniband/hw/bng_re/bng_dev.c | 27 ++++---------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
drivers/infiniband/hw/bng_re/bng_dev.c +4 -23
@@ -54,9 +54,6 @@ static void bng_re_destroy_chip_ctx(struct bng_re_dev *rdev) {struct bng_re_chip_ctx *chip_ctx; -if (!rdev->chip_ctx) -return ; -kfree (rdev->dev_attr); rdev->dev_attr =NULL ;
@@ -124,12 +121,6 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev,struct bnge_fw_msg fw_msg = {};int rc = -EINVAL ; -if (!rdev) -return rc; - -if (!aux_dev) -return rc; -bng_re_init_hwrm_hdr ((void *)&req,HWRM_RING_FREE ); req.ring_type = type; req.ring_id =cpu_to_le16 (fw_ring_id);
@@ -150,10 +141,7 @@ static int bng_re_net_ring_alloc(struct bng_re_dev *rdev,struct hwrm_ring_alloc_input req = {};struct hwrm_ring_alloc_output resp;struct bnge_fw_msg fw_msg = {}; -int rc = -EINVAL ; - -if (!aux_dev) -return rc; +int rc;bng_re_init_hwrm_hdr ((void *)&req,HWRM_RING_ALLOC ); req.enables =0 ;
@@ -184,10 +172,7 @@ static int bng_re_stats_ctx_free(struct bng_re_dev *rdev)struct hwrm_stat_ctx_free_input req = {};struct hwrm_stat_ctx_free_output resp = {};struct bnge_fw_msg fw_msg = {}; -int rc = -EINVAL ; - -if (!aux_dev) -return rc; +int rc;bng_re_init_hwrm_hdr ((void *)&req,HWRM_STAT_CTX_FREE ); req.stat_ctx_id =cpu_to_le32 (rdev->stats_ctx.fw_id);
@@ -208,13 +193,10 @@ static int bng_re_stats_ctx_alloc(struct bng_re_dev *rdev)struct hwrm_stat_ctx_alloc_output resp = {};struct hwrm_stat_ctx_alloc_input req = {};struct bnge_fw_msg fw_msg = {}; -int rc = -EINVAL ; +int rc; stats->fw_id =BNGE_INVALID_STATS_CTX_ID ; -if (!aux_dev) -return rc; -bng_re_init_hwrm_hdr ((void *)&req,HWRM_STAT_CTX_ALLOC ); req.update_period_ms =cpu_to_le32 (1000 ); req.stats_dma_addr =cpu_to_le64 (stats->dma_map);
@@ -486,8 +468,7 @@ static void bng_re_remove(struct auxiliary_device *adev) rdev = dev_info->rdev; -if (rdev) -bng_re_remove_device (rdev, adev); +bng_re_remove_device (rdev, adev);kfree (dev_info); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 483/844 RDMA/bng_re: Unwind bng_re_dev_init properly
In reply to Sasha LevinFrom: Siva Reddy Kallam <[email protected]>
[ Upstream commit 3d2e5d12a2eef0ca8a629a422aa593673235c77c ]
Fix below smatch warning:drivers/infiniband/hw/bng_re/bng_dev.c:270bng_re_dev_init() warn: missing unwind goto?
Current bng_re_dev_init function is not having clear unwinding code. So, added proper unwinding with ladder.
--- drivers/infiniband/hw/bng_re/bng_dev.c | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/infiniband/hw/bng_re/bng_dev.c +15 -14
@@ -285,7 +285,7 @@ static int bng_re_dev_init(struct bng_re_dev *rdev)if (rc) {ibdev_err (&rdev->ibdev,"Failed to register with netedev: %#x\n" , rc); -return -EINVAL ; + goto reg_netdev_fail; }set_bit (BNG_RE_FLAG_NETDEV_REGISTERED , &rdev->flags);
@@ -294,19 +294,16 @@ static int bng_re_dev_init(struct bng_re_dev *rdev)ibdev_err (&rdev->ibdev,"RoCE requires minimum 2 MSI-X vectors, but only %d reserved\n" , rdev->aux_dev->auxr_info->msix_requested); -bnge_unregister_dev (rdev->aux_dev); -clear_bit (BNG_RE_FLAG_NETDEV_REGISTERED , &rdev->flags); -return -EINVAL ; + rc = -EINVAL ; + goto msix_ctx_fail; }ibdev_dbg (&rdev->ibdev,"Got %d MSI-X vectors\n" , rdev->aux_dev->auxr_info->msix_requested); rc =bng_re_setup_chip_ctx (rdev);if (rc) { -bnge_unregister_dev (rdev->aux_dev); -clear_bit (BNG_RE_FLAG_NETDEV_REGISTERED , &rdev->flags);ibdev_err (&rdev->ibdev,"Failed to get chip context\n" ); -return -EINVAL ; + goto msix_ctx_fail; }bng_re_query_hwrm_version (rdev);
@@ -315,16 +312,14 @@ static int bng_re_dev_init(struct bng_re_dev *rdev)if (rc) {ibdev_err (&rdev->ibdev,"Failed to allocate RCFW Channel: %#x\n" , rc); - goto fail; + goto alloc_fw_chl_fail; }/* Allocate nq record memory */ rdev->nqr =kzalloc (sizeof (*rdev->nqr),GFP_KERNEL );if (!rdev->nqr) { -bng_re_destroy_chip_ctx (rdev); -bnge_unregister_dev (rdev->aux_dev); -clear_bit (BNG_RE_FLAG_NETDEV_REGISTERED , &rdev->flags); -return -ENOMEM ; + rc = -ENOMEM ; + goto nq_alloc_fail; } rdev->nqr->num_msix = rdev->aux_dev->auxr_info->msix_requested;
@@ -393,9 +388,15 @@ static int bng_re_dev_init(struct bng_re_dev *rdev) free_ring:bng_re_net_ring_free (rdev, rdev->rcfw.creq.ring_id, type); free_rcfw: +kfree (rdev->nqr); +nq_alloc_fail:bng_re_free_rcfw_channel (&rdev->rcfw); -fail: -bng_re_dev_uninit (rdev); +alloc_fw_chl_fail: +bng_re_destroy_chip_ctx (rdev); +msix_ctx_fail: +bnge_unregister_dev (rdev->aux_dev); +clear_bit (BNG_RE_FLAG_NETDEV_REGISTERED , &rdev->flags); +reg_netdev_fail:return rc; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 484/844 net: wan: farsync: Fix use-after-free bugs caused by unfinished tasklets
In reply to Sasha LevinFrom: Duoming Zhou <[email protected]>
[ Upstream commit bae8a5d2e759da2e0cba33ab2080deee96a09373 ]
When the FarSync T-series card is being detached, the fst_card_info is deallocated in fst_remove_one(). However, the fst_tx_task or fst_int_task may still be running or pending, leading to use-after-free bugs when the already freed fst_card_info is accessed in fst_process_tx_work_q() or fst_process_int_work_q().
A typical race condition is depicted below:
CPU 0 (cleanup) | CPU 1 (tasklet)
| fst_start_xmit()
fst_remove_one() | tasklet_schedule()
unregister_hdlc_device()|
| fst_process_tx_work_q() //handler
kfree(card) //free | do_bottom_half_tx()
| card-> //useThe following KASAN trace was captured:
==================================================================
BUG: KASAN: slab-use-after-free in do_bottom_half_tx+0xb88/0xd00
Read of size 4 at addr ffff88800aad101c by task ksoftirqd/3/32
...
Call Trace:
<IRQ>
dump_stack_lvl+0x55/0x70
print_report+0xcb/0x5d0
? do_bottom_half_tx+0xb88/0xd00
kasan_report+0xb8/0xf0
? do_bottom_half_tx+0xb88/0xd00
do_bottom_half_tx+0xb88/0xd00
? _raw_spin_lock_irqsave+0x85/0xe0
? __pfx__raw_spin_lock_irqsave+0x10/0x10
? __pfx___hrtimer_run_queues+0x10/0x10
fst_process_tx_work_q+0x67/0x90
tasklet_action_common+0x1fa/0x720
? hrtimer_interrupt+0x31f/0x780
handle_softirqs+0x176/0x530
__irq_exit_rcu+0xab/0xe0
sysvec_apic_timer_interrupt+0x70/0x80
...
Allocated by task 41 on cpu 3 at 72.330843s:
kasan_save_stack+0x24/0x50
kasan_save_track+0x17/0x60
__kasan_kmalloc+0x7f/0x90
fst_add_one+0x1a5/0x1cd0
local_pci_probe+0xdd/0x190
pci_device_probe+0x341/0x480
really_probe+0x1c6/0x6a0
__driver_probe_device+0x248/0x310
driver_probe_device+0x48/0x210
__device_attach_driver+0x160/0x320
bus_for_each_drv+0x101/0x190
__device_attach+0x198/0x3a0
device_initial_probe+0x78/0xa0
pci_bus_add_device+0x81/0xc0
pci_bus_add_devices+0x7e/0x190
enable_slot+0x9b9/0x1130
acpiphp_check_bridge.part.0+0x2e1/0x460
acpiphp_hotplug_notify+0x36c/0x3c0
acpi_device_hotplug+0x203/0xb10
acpi_hotplug_work_fn+0x59/0x80
...
Freed by task 41 on cpu 1 at 75.138639s:
kasan_save_stack+0x24/0x50
kasan_save_track+0x17/0x60
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x43/0x70
kfree+0x135/0x410
fst_remove_one+0x2ca/0x540
pci_device_remove+0xa6/0x1d0
device_release_driver_internal+0x364/0x530
pci_stop_bus_device+0x105/0x150
pci_stop_and_remove_bus_device+0xd/0x20
disable_slot+0x116/0x260
acpiphp_disable_and_eject_slot+0x4b/0x190
acpiphp_hotplug_notify+0x230/0x3c0
acpi_device_hotplug+0x203/0xb10
acpi_hotplug_work_fn+0x59/0x80
...
The buggy address belongs to the object at ffff88800aad1000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 28 bytes inside of
freed 1024-byte region
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xaad0
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x100000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000
head: 0100000000000040 ffff888007042dc0 dead000000000122 0000000000000000
head: 0000000000000000 0000000080100010 00000000f5000000 0000000000000000
head: 0100000000000003 ffffea00002ab401 00000000ffffffff 00000000ffffffff
head: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88800aad0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88800aad0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88800aad1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88800aad1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88800aad1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Fix this by ensuring that both fst_tx_task and fst_int_task are properly canceled before the fst_card_info is released. Add tasklet_kill() in fst_remove_one() to synchronize with any pending or running tasklets. Since unregister_hdlc_device() stops data transmission and reception, and fst_disable_intr() prevents further interrupts, it is appropriate to place tasklet_kill() after these calls.
The bugs were identified through static analysis. To reproduce the issue and validate the fix, a FarSync T-series card was simulated in QEMU and delays(e.g., mdelay()) were introduced within the tasklet handler to increase the likelihood of triggering the race condition.
--- drivers/net/wan/farsync.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wan/farsync.c +2 -0
@@ -2550,6 +2550,8 @@ fst_remove_one(struct pci_dev *pdev)fst_disable_intr (card);free_irq (card->irq, card); +tasklet_kill (&fst_tx_task); +tasklet_kill (&fst_int_task);iounmap (card->ctlmem);iounmap (card->mem);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 485/844 netconsole: avoid OOB reads, msg is not nul-terminated
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 82aec772fca2223bc5774bd9af486fd95766e578 ]
msg passed to netconsole from the console subsystem is not guaranteed to be nul-terminated. Before recent
commit 7eab73b18630 ("netconsole: convert to NBCON console infrastructure") the message would be placed in printk_shared_pbufs, a static global buffer, so KASAN had harder time catching OOB accesses. Now we see:
printk: console [netcon_ext0] enabled
BUG: KASAN: slab-out-of-bounds in string+0x1f7/0x240
Read of size 1 at addr ffff88813b6d4c00 by task pr/netcon_ext0/594
CPU: 65 UID: 0 PID: 594 Comm: pr/netcon_ext0 Not tainted 6.19.0-11754-g4246fd6547c9
Call Trace:
kasan_report+0xe4/0x120
string+0x1f7/0x240
vsnprintf+0x655/0xba0
scnprintf+0xba/0x120
netconsole_write+0x3fe/0xa10
nbcon_emit_next_record+0x46e/0x860
nbcon_kthread_func+0x623/0x750
Allocated by task 1:
nbcon_alloc+0x1ea/0x450
register_console+0x26b/0xe10
init_netconsole+0xbb0/0xda0
The buggy address belongs to the object at ffff88813b6d4000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 0 bytes to the right of
allocated 3072-byte region [ffff88813b6d4000, ffff88813b6d4c00)--- drivers/net/netconsole.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/netconsole.c +2 -1
@@ -1524,7 +1524,8 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt,if (release_len) { release =init_utsname ()->release; -scnprintf (nt->buf,MAX_PRINT_CHUNK ,"%s,%s" , release, msg); +scnprintf (nt->buf,MAX_PRINT_CHUNK ,"%s,%.*s" , release, + msg_len, msg); msg_len += release_len; }else {memcpy (nt->buf, msg, msg_len);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 486/844 RDMA/ionic: Fix potential NULL pointer dereference in ionic_query_port
In reply to Sasha LevinFrom: Kamal Heib <[email protected]>
[ Upstream commit fd80bd7105f88189f47d465ca8cb7d115570de30 ]
The function ionic_query_port() calls ib_device_get_netdev() without checking the return value which could lead to NULL pointer dereference, Fix it by checking the return value and return -ENODEV if the 'ndev' is NULL.
--- drivers/infiniband/hw/ionic/ionic_ibdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/ionic/ionic_ibdev.c +2 -0
@@ -81,6 +81,8 @@ static int ionic_query_port(struct ib_device *ibdev, u32 port,return -EINVAL ; ndev =ib_device_get_netdev (ibdev, port); +if (!ndev) +return -ENODEV ;if (netif_running (ndev) &&netif_carrier_ok (ndev)) { attr->state =IB_PORT_ACTIVE ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 487/844 RDMA/efa: Fix typo in efa_alloc_mr()
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit f22c77ce49db0589103d96487dca56f5b2136362 ]
The pattern is to check the entire driver request space, not just sizeof something unrelated.
--- drivers/infiniband/hw/efa/efa_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/efa/efa_verbs.c +1 -1
@@ -1663,7 +1663,7 @@ static struct efa_mr *efa_alloc_mr(struct ib_pd *ibpd, int access_flags,struct efa_mr *mr;if (udata && udata->inlen && - !ib_is_udata_cleared (udata,0 ,sizeof (udata->inlen))) { + !ib_is_udata_cleared (udata,0 , udata->inlen)) {ibdev_dbg (&dev->ibdev,"Incompatible ABI params, udata not cleared\n" );return ERR_PTR (-EINVAL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 488/844 net: Drop the lock in skb_may_tx_timestamp()
In reply to Sasha LevinFrom: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit 983512f3a87fd8dc4c94dfa6b596b6e57df5aad7 ]
skb_may_tx_timestamp() may acquire sock::sk_callback_lock. The lock must not be taken in IRQ context, only softirq is okay. A few drivers receive the timestamp via a dedicated interrupt and complete the TX timestamp from that handler. This will lead to a deadlock if the lock is already write-locked on the same CPU.
Taking the lock can be avoided. The socket (pointed by the skb) will remain valid until the skb is released. The ->sk_socket and ->file member will be set to NULL once the user closes the socket which may happen before the timestamp arrives.
If we happen to observe the pointer while the socket is closing but before the pointer is set to NULL then we may use it because both pointer (and the file's cred member) are RCU freed.
Drop the lock. Use READ_ONCE() to obtain the individual pointer. Add a matching WRITE_ONCE() where the pointer are cleared.
--- include/net/sock.h | 2 +- net/core/skbuff.c | 23 ++++++++++++++++++----- net/socket.c | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-)
include/net/sock.h +1 -1
@@ -2089,7 +2089,7 @@ static inline int sk_rx_queue_get(const struct sock *sk)static inline void sk_set_socket (struct sock *sk,struct socket *sock) { - sk->sk_socket = sock; +WRITE_ONCE (sk->sk_socket, sock);if (sock) {WRITE_ONCE (sk->sk_uid,SOCK_INODE (sock)->i_uid);WRITE_ONCE (sk->sk_ino,SOCK_INODE (sock)->i_ino);
net/core/skbuff.c +18 -5
@@ -5555,15 +5555,28 @@ static void __skb_complete_tx_timestamp(struct sk_buff *skb,static bool skb_may_tx_timestamp (struct sock *sk,bool tsonly) { -bool ret; +struct socket *sock; +struct file *file; +bool ret = false;if (likely (tsonly ||READ_ONCE (sock_net (sk)->core.sysctl_tstamp_allow_data)))return true; -read_lock_bh (&sk->sk_callback_lock); - ret = sk->sk_socket && sk->sk_socket->file && -file_ns_capable (sk->sk_socket->file, &init_user_ns,CAP_NET_RAW ); -read_unlock_bh (&sk->sk_callback_lock); +/* The sk pointer remains valid as long as the skb is. The sk_socket and +* file pointer may become NULL if the socket is closed. Both structures +* (including file->cred) are RCU freed which means they can be accessed +* within a RCU read section. +*/ +rcu_read_lock (); + sock =READ_ONCE (sk->sk_socket); +if (!sock) + goto out; + file =READ_ONCE (sock->file); +if (!file) + goto out; + ret =file_ns_capable (file, &init_user_ns,CAP_NET_RAW ); +out: +rcu_read_unlock ();return ret; }
net/socket.c +1 -1
@@ -674,7 +674,7 @@ static void __sock_release(struct socket *sock, struct inode *inode)iput (SOCK_INODE (sock));return ; } - sock->file =NULL ; +WRITE_ONCE (sock->file,NULL ); }/**
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 489/844 net: usb: pegasus: enable basic endpoint checking
In reply to Sasha LevinFrom: Ziyi Guo <[email protected]>
[ Upstream commit 3d7e6ce34f4fcc7083510c28b17a7c36462a25d4 ]
pegasus_probe() fills URBs with hardcoded endpoint pipes without verifying the endpoint descriptors:
- usb_rcvbulkpipe(dev, 1) for RX data
- usb_sndbulkpipe(dev, 2) for TX data
- usb_rcvintpipe(dev, 3) for status interrupts
A malformed USB device can present these endpoints with transfer types that differ from what the driver assumes.
Add a pegasus_usb_ep enum for endpoint numbers, replacing magic constants throughout. Add usb_check_bulk_endpoints() and usb_check_int_endpoints() calls before any resource allocation to verify endpoint types before use, rejecting devices with mismatched descriptors at probe time, and avoid triggering assertion.
Similar fix to
- commit 90b7f2961798 ("net: usb: rtl8150: enable basic endpoint checking")
- commit 9e7021d2aeae ("net: usb: catc: enable basic endpoint checking")
--- drivers/net/usb/pegasus.c | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-)
drivers/net/usb/pegasus.c +30 -5
@@ -31,6 +31,17 @@ static const char driver_name[] = "pegasus"; BMSR_100FULL | BMSR_ANEGCAPABLE)#define CARRIER_CHECK_DELAY (2 * HZ) +/* +* USB endpoints. +*/ + +enum pegasus_usb_ep { +PEGASUS_USB_EP_CONTROL =0 , +PEGASUS_USB_EP_BULK_IN =1 , +PEGASUS_USB_EP_BULK_OUT =2 , +PEGASUS_USB_EP_INT_IN =3 , +}; +static bool loopback;static bool mii_mode;static char *devid;
@@ -545,7 +556,7 @@ static void read_bulk_callback(struct urb *urb) goto tl_sched; goon:usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus); rx_status =usb_submit_urb (pegasus->rx_urb,GFP_ATOMIC );
@@ -585,7 +596,7 @@ static void rx_fixup(struct tasklet_struct *t)return ; }usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus); try_again:
@@ -713,7 +724,7 @@ static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb, ((__le16 *) pegasus->tx_buff)[0 ] =cpu_to_le16 (l16);skb_copy_from_linear_data (skb, pegasus->tx_buff +2 , skb->len);usb_fill_bulk_urb (pegasus->tx_urb, pegasus->usb, -usb_sndbulkpipe (pegasus->usb,2 ), +usb_sndbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_OUT ), pegasus->tx_buff, count, write_bulk_callback, pegasus);if ((res =usb_submit_urb (pegasus->tx_urb,GFP_ATOMIC ))) {
@@ -840,7 +851,7 @@ static int pegasus_open(struct net_device *net)set_registers (pegasus, EthID,6 , net->dev_addr);usb_fill_bulk_urb (pegasus->rx_urb, pegasus->usb, -usb_rcvbulkpipe (pegasus->usb,1 ), +usb_rcvbulkpipe (pegasus->usb,PEGASUS_USB_EP_BULK_IN ), pegasus->rx_skb->data,PEGASUS_MTU , read_bulk_callback, pegasus);if ((res =usb_submit_urb (pegasus->rx_urb,GFP_KERNEL ))) {
@@ -851,7 +862,7 @@ static int pegasus_open(struct net_device *net) }usb_fill_int_urb (pegasus->intr_urb, pegasus->usb, -usb_rcvintpipe (pegasus->usb,3 ), +usb_rcvintpipe (pegasus->usb,PEGASUS_USB_EP_INT_IN ), pegasus->intr_buff,sizeof (pegasus->intr_buff), intr_callback, pegasus, pegasus->intr_interval);if ((res =usb_submit_urb (pegasus->intr_urb,GFP_KERNEL ))) {
@@ -1136,10 +1147,24 @@ static int pegasus_probe(struct usb_interface *intf,pegasus_t *pegasus;int dev_index = id - pegasus_ids;int res = -ENOMEM ; +static const u8 bulk_ep_addr[] = { +PEGASUS_USB_EP_BULK_IN |USB_DIR_IN , +PEGASUS_USB_EP_BULK_OUT |USB_DIR_OUT , +0 }; +static const u8 int_ep_addr[] = { +PEGASUS_USB_EP_INT_IN |USB_DIR_IN , +0 };if (pegasus_blacklisted (dev))return -ENODEV ; +/* Verify that all required endpoints are present */ +if (!usb_check_bulk_endpoints (intf, bulk_ep_addr) || + !usb_check_int_endpoints (intf, int_ep_addr)) { +dev_err (&intf->dev,"Missing or invalid endpoints\n" ); +return -ENODEV ; + } + net =alloc_etherdev (sizeof (struct pegasus ));if (!net) goto out;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 490/844 erofs: fix interlaced plain identification for encoded extents
In reply to Sasha LevinFrom: Gao Xiang <[email protected]>
[ Upstream commit 4a2d046e4b13202a6301a993961f5b30ae4d7119 ]
Only plain data whose start position and on-disk physical length are both aligned to the block size should be classified as interlaced plain extents. Otherwise, it must be treated as shifted plain extents.
This issue was found by syzbot using a crafted compressed image containing plain extents with unaligned physical lengths, which can cause OOB read in z_erofs_transform_plain().
--- fs/erofs/zmap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/erofs/zmap.c +5 -4
@@ -513,6 +513,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,unsigned int recsz =z_erofs_extent_recsize (vi->z_advise);erofs_off_t pos =round_up (Z_EROFS_MAP_HEADER_END (erofs_iloc (inode) + vi->inode_isize + vi->xattr_isize), recsz); +unsigned int bmask = sb->s_blocksize -1 ;bool in_mbox =erofs_inode_in_metabox (inode);erofs_off_t lend = inode->i_size;erofs_off_t l, r, mid, pa, la, lstart;
@@ -596,17 +597,17 @@ static int z_erofs_map_blocks_ext(struct inode *inode, map->m_flags |=EROFS_MAP_MAPPED |EROFS_MAP_FULL_MAPPED |EROFS_MAP_ENCODED ; fmt = map->m_plen >>Z_EROFS_EXTENT_PLEN_FMT_BIT ; +if (map->m_plen &Z_EROFS_EXTENT_PLEN_PARTIAL ) + map->m_flags |=EROFS_MAP_PARTIAL_REF ; + map->m_plen &=Z_EROFS_EXTENT_PLEN_MASK ;if (fmt) map->m_algorithmformat = fmt -1 ; -else if (interlaced && !erofs_blkoff (sb, map->m_pa)) +else if (interlaced && !((map->m_pa | map->m_plen) & bmask)) map->m_algorithmformat =Z_EROFS_COMPRESSION_INTERLACED ;else map->m_algorithmformat =Z_EROFS_COMPRESSION_SHIFTED ; -if (map->m_plen &Z_EROFS_EXTENT_PLEN_PARTIAL ) - map->m_flags |=EROFS_MAP_PARTIAL_REF ; - map->m_plen &=Z_EROFS_EXTENT_PLEN_MASK ; } } map->m_llen = lend - map->m_la;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 491/844 RDMA/umem: Fix double dma_buf_unpin in failure path
In reply to Sasha LevinFrom: Jacob Moroni <[email protected]>
[ Upstream commit 104016eb671e19709721c1b0048dd912dc2e96be ]
In ib_umem_dmabuf_get_pinned_with_dma_device(), the call to ib_umem_dmabuf_map_pages() can fail. If this occurs, the dmabuf is immediately unpinned but the umem_dmabuf->pinned flag is still set. Then, when ib_umem_release() is called, it calls ib_umem_dmabuf_revoke() which will call dma_buf_unpin() again.
Fix this by removing the immediate unpin upon failure and just let the ib_umem_release/revoke path handle it. This also ensures the proper unmap-unpin unwind ordering if the dmabuf_map_pages call happened to fail due to dma_resv_wait_timeout (and therefore has a non-NULL umem_dmabuf->sgt).
--- drivers/infiniband/core/umem_dmabuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/core/umem_dmabuf.c +1 -3
@@ -221,13 +221,11 @@ ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device, err =ib_umem_dmabuf_map_pages (umem_dmabuf);if (err) - goto err_unpin; + goto err_release;dma_resv_unlock (umem_dmabuf->attach->dmabuf->resv);return umem_dmabuf; -err_unpin: -dma_buf_unpin (umem_dmabuf->attach); err_release:dma_resv_unlock (umem_dmabuf->attach->dmabuf->resv);ib_umem_release (&umem_dmabuf->umem);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 492/844 tcp: re-enable acceptance of FIN packets when RWIN is 0
In reply to Sasha LevinFrom: Simon Baatz <[email protected]>
[ Upstream commit 1e3bb184e94125bae7c1703472109a646d0f79d9 ]
Commit 2bd99aef1b19 ("tcp: accept bare FIN packets under memory pressure") allowed accepting FIN packets in tcp_data_queue() even when the receive window was closed, to prevent ACK/FIN loops with broken clients.
Such a FIN packet is in sequence, but because the FIN consumes a sequence number, it extends beyond the window. Before commit 9ca48d616ed7 ("tcp: do not accept packets beyond window"), tcp_sequence() only required the seq to be within the window. After that change, the entire packet (including the FIN) must fit within the window. As a result, such FIN packets are now dropped and the handling path is no longer reached.
Be more lenient by not counting the sequence number consumed by the FIN when calling tcp_sequence(), restoring the previous behavior for cases where only the FIN extends beyond the window.
--- net/ipv4/tcp_input.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
net/ipv4/tcp_input.c +14 -4
@@ -4611,15 +4611,24 @@ static enum skb_drop_reason tcp_disordered_ack_check(const struct sock *sk,*/ static enum skb_drop_reason tcp_sequence (const struct sock *sk, -u32 seq,u32 end_seq) +u32 seq,u32 end_seq, +const struct tcphdr *th) {const struct tcp_sock *tp =tcp_sk (sk); +u32 seq_limit;if (before (end_seq, tp->rcv_wup))return SKB_DROP_REASON_TCP_OLD_SEQUENCE ; -if (after (end_seq, tp->rcv_nxt +tcp_receive_window (tp))) { -if (after (seq, tp->rcv_nxt +tcp_receive_window (tp))) + seq_limit = tp->rcv_nxt +tcp_receive_window (tp); +if (unlikely (after (end_seq, seq_limit))) { +/* Some stacks are known to handle FIN incorrectly; allow the +* FIN to extend beyond the window and check it in detail later. +*/ +if (!after (end_seq - th->fin, seq_limit)) +return SKB_NOT_DROPPED_YET ; + +if (after (seq, seq_limit))return SKB_DROP_REASON_TCP_INVALID_SEQUENCE ;/* Only accept this packet if receive queue is empty. */
@@ -6145,7 +6154,8 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, step1:/* Step 1: check sequence number */ - reason =tcp_sequence (sk,TCP_SKB_CB (skb)->seq,TCP_SKB_CB (skb)->end_seq); + reason =tcp_sequence (sk,TCP_SKB_CB (skb)->seq, +TCP_SKB_CB (skb)->end_seq, th);if (reason) {/* RFC793, page 37: "In all states except SYN-SENT, all reset * (RST) segments are validated by checking their SEQ-fields."
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 493/844 dpll: zl3073x: Remove redundant cleanup in devm_dpll_init()
In reply to Sasha LevinFrom: Felix Gu <[email protected]>
[ Upstream commit 676c7af91fcd740d34e7cb788cbc58e3bcafde39 ]
The devm_add_action_or_reset() function already executes the cleanup action on failure before returning an error, so the explicit goto error and subsequent zl3073x_dev_dpll_fini() call causes double cleanup.
--- drivers/dpll/zl3073x/core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/dpll/zl3073x/core.c +1 -5
@@ -978,11 +978,7 @@ zl3073x_devm_dpll_init(struct zl3073x_dev *zldev, u8 num_dplls) }/* Add devres action to release DPLL related resources */ - rc =devm_add_action_or_reset (zldev->dev, zl3073x_dev_dpll_fini, zldev); -if (rc) - goto error; - -return 0 ; +return devm_add_action_or_reset (zldev->dev, zl3073x_dev_dpll_fini, zldev); error:zl3073x_dev_dpll_fini (zldev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 494/844 net: mana: Fix double destroy_workqueue on service rescan PCI path
In reply to Sasha LevinFrom: Dipayaan Roy <[email protected]>
[ Upstream commit f975a0955276579e2176a134366ed586071c7c6a ]
While testing corner cases in the driver, a use-after-free crash was found on the service rescan PCI path.
When mana_serv_reset() calls mana_gd_suspend(), mana_gd_cleanup() destroys gc->service_wq. If the subsequent mana_gd_resume() fails with -ETIMEDOUT or -EPROTO, the code falls through to mana_serv_rescan() which triggers pci_stop_and_remove_bus_device(). This invokes the PCI .remove callback (mana_gd_remove), which calls mana_gd_cleanup() a second time, attempting to destroy the already- freed workqueue. Fix this by NULL-checking gc->service_wq in mana_gd_cleanup() and setting it to NULL after destruction.
Call stack of issue for reference:
[Sat Feb 21 18:53:48 2026] Call Trace: [Sat Feb 21 18:53:48 2026] <TASK> [Sat Feb 21 18:53:48 2026] mana_gd_cleanup+0x33/0x70 [mana] [Sat Feb 21 18:53:48 2026] mana_gd_remove+0x3a/0xc0 [mana] [Sat Feb 21 18:53:48 2026] pci_device_remove+0x41/0xb0 [Sat Feb 21 18:53:48 2026] device_remove+0x46/0x70 [Sat Feb 21 18:53:48 2026] device_release_driver_internal+0x1e3/0x250 [Sat Feb 21 18:53:48 2026] device_release_driver+0x12/0x20 [Sat Feb 21 18:53:48 2026] pci_stop_bus_device+0x6a/0x90 [Sat Feb 21 18:53:48 2026] pci_stop_and_remove_bus_device+0x13/0x30 [Sat Feb 21 18:53:48 2026] mana_do_service+0x180/0x290 [mana] [Sat Feb 21 18:53:48 2026] mana_serv_func+0x24/0x50 [mana] [Sat Feb 21 18:53:48 2026] process_one_work+0x190/0x3d0 [Sat Feb 21 18:53:48 2026] worker_thread+0x16e/0x2e0 [Sat Feb 21 18:53:48 2026] kthread+0xf7/0x130 [Sat Feb 21 18:53:48 2026] ? __pfx_worker_thread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ? __pfx_kthread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ret_from_fork+0x269/0x350 [Sat Feb 21 18:53:48 2026] ? __pfx_kthread+0x10/0x10 [Sat Feb 21 18:53:48 2026] ret_from_fork_asm+0x1a/0x30 [Sat Feb 21 18:53:48 2026] </TASK>
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 5 ++++- drivers/net/ethernet/microsoft/mana/mana_en.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/microsoft/mana/gdma_main.c +4 -1
@@ -1946,7 +1946,10 @@ static void mana_gd_cleanup(struct pci_dev *pdev)mana_gd_remove_irqs (pdev); -destroy_workqueue (gc->service_wq); +if (gc->service_wq) { +destroy_workqueue (gc->service_wq); + gc->service_wq =NULL ; + }dev_dbg (&pdev->dev,"mana gdma cleanup successful\n" ); }
drivers/net/ethernet/microsoft/mana/mana_en.c +3 -1
@@ -3690,7 +3690,9 @@ void mana_rdma_remove(struct gdma_dev *gd) }WRITE_ONCE (gd->rdma_teardown, true); -flush_workqueue (gc->service_wq); + +if (gc->service_wq) +flush_workqueue (gc->service_wq);if (gd->adev)remove_adev (gd);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 495/844 team: avoid NETDEV_CHANGEMTU event when unregistering slave
In reply to Sasha LevinFrom: Tetsuo Handa <[email protected]>
[ Upstream commit bb4c698633c0e19717586a6524a33196cff01a32 ]
syzbot is reporting
unregister_netdevice: waiting for netdevsim0 to become free. Usage count = 3
ref_tracker: netdev@ffff88807dcf8618 has 1/2 users at
__netdev_tracker_alloc include/linux/netdevice.h:4400 [inline]
netdev_hold include/linux/netdevice.h:4429 [inline]
inetdev_init+0x201/0x4e0 net/ipv4/devinet.c:286
inetdev_event+0x251/0x1610 net/ipv4/devinet.c:1600
notifier_call_chain+0x19d/0x3a0 kernel/notifier.c:85
call_netdevice_notifiers_mtu net/core/dev.c:2318 [inline]
netif_set_mtu_ext+0x5aa/0x800 net/core/dev.c:9886
netif_set_mtu+0xd7/0x1b0 net/core/dev.c:9907
dev_set_mtu+0x126/0x260 net/core/dev_api.c:248
team_port_del+0xb07/0xcb0 drivers/net/team/team_core.c:1333
team_del_slave drivers/net/team/team_core.c:1936 [inline]
team_device_event+0x207/0x5b0 drivers/net/team/team_core.c:2929
notifier_call_chain+0x19d/0x3a0 kernel/notifier.c:85
call_netdevice_notifiers_extack net/core/dev.c:2281 [inline]
call_netdevice_notifiers net/core/dev.c:2295 [inline]
__dev_change_net_namespace+0xcb7/0x2050 net/core/dev.c:12592
do_setlink+0x2ce/0x4590 net/core/rtnetlink.c:3060
rtnl_changelink net/core/rtnetlink.c:3776 [inline]
__rtnl_newlink net/core/rtnetlink.c:3935 [inline]
rtnl_newlink+0x15a9/0x1be0 net/core/rtnetlink.c:4072
rtnetlink_rcv_msg+0x7d5/0xbe0 net/core/rtnetlink.c:6958
netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550
netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894problem. Ido Schimmel found steps to reproduce
ip link add name team1 type team
ip link add name dummy1 mtu 1499 master team1 type dummy ip netns add ns1
ip link set dev dummy1 netns ns1
ip -n ns1 link del dev dummy1
and also found that the same issue was fixed in the bond driver in commit f51048c3e07b ("bonding: avoid NETDEV_CHANGEMTU event when unregistering slave").
Let's do similar thing for the team driver, with commit ad7c7b2172c3 ("net:
hold netdev instance lock during sysfs operations") and commit 303a8487a657 ("net: s/__dev_set_mtu/__netif_set_mtu/") also applied.
--- drivers/net/team/team_core.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/net/team/team_core.c +21 -5
@@ -1292,7 +1292,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev,static void __team_port_change_port_removed (struct team_port *port); -static int team_port_del (struct team *team,struct net_device *port_dev) +static int team_port_del (struct team *team,struct net_device *port_dev,bool unregister) {struct net_device *dev = team->dev;struct team_port *port;
@@ -1330,7 +1330,13 @@ static int team_port_del(struct team *team, struct net_device *port_dev)__team_port_change_port_removed (port);team_port_set_orig_dev_addr (port); -dev_set_mtu (port_dev, port->orig.mtu); +if (unregister) { +netdev_lock_ops (port_dev); +__netif_set_mtu (port_dev, port->orig.mtu); +netdev_unlock_ops (port_dev); + }else { +dev_set_mtu (port_dev, port->orig.mtu); + }kfree_rcu (port, rcu);netdev_info (dev,"Port device %s removed\n" , portname);netdev_compute_master_upper_features (team->dev, true);
@@ -1634,7 +1640,7 @@ static void team_uninit(struct net_device *dev)ASSERT_RTNL ();list_for_each_entry_safe (port, tmp, &team->port_list, list) -team_port_del (team, port->dev); +team_port_del (team, port->dev, false);__team_change_mode (team,NULL );/* cleanup */ __team_options_unregister (team, team_options,ARRAY_SIZE (team_options));
@@ -1933,7 +1939,16 @@ static int team_del_slave(struct net_device *dev, struct net_device *port_dev)ASSERT_RTNL (); -return team_port_del (team, port_dev); +return team_port_del (team, port_dev, false); +} + +static int team_del_slave_on_unregister (struct net_device *dev,struct net_device *port_dev) +{ +struct team *team =netdev_priv (dev); + +ASSERT_RTNL (); + +return team_port_del (team, port_dev, true); } static netdev_features_t team_fix_features(struct net_device *dev,
@@ -2926,7 +2941,7 @@ static int team_device_event(struct notifier_block *unused, !!netif_oper_up(port->dev));break ;case NETDEV_UNREGISTER : -team_del_slave (port->team->dev, dev); +team_del_slave_on_unregister (port->team->dev, dev);break ;case NETDEV_FEAT_CHANGE :if (!port->team->notifier_ctx) {
@@ -2999,3 +3014,4 @@ MODULE_LICENSE("GPL v2");MODULE_AUTHOR ("Jiri Pirko <[email protected]>" );MODULE_DESCRIPTION ("Ethernet team device driver" );MODULE_ALIAS_RTNL_LINK (DRV_NAME ); +MODULE_IMPORT_NS ("NETDEV_INTERNAL" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 496/844 net/mlx5: DR, Fix circular locking dependency in dump
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit 2700b7e603af39ca55fe9fc876ca123efd44680f ]
Fix a circular locking dependency between dbg_mutex and the domain rx/tx mutexes that could lead to a deadlock.
The dump path in dr_dump_domain_all() was acquiring locks in the order:
dbg_mutex -> rx.mutex -> tx.mutex
While the table/matcher creation paths acquire locks in the order:
rx.mutex -> tx.mutex -> dbg_mutex
This inverted lock ordering creates a circular dependency. Fix this by changing dr_dump_domain_all() to acquire the domain lock before dbg_mutex, matching the order used in mlx5dr_table_create() and mlx5dr_matcher_create().
Lockdep splat:
======================================================
WARNING: possible circular locking dependency detected 6.19.0-rc6net_next_e817c4e #1 Not tainted
------------------------------------------------------
sos/30721 is trying to acquire lock:
ffff888102df5900 (&dmn->info.rx.mutex){+.+.}-{4:4}, at:dr_dump_start+0x131/0x450 [mlx5_core]
but task is already holding lock:
ffff888102df5bc0 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}, at:dr_dump_start+0x10b/0x450 [mlx5_core]
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&dmn->dump_info.dbg_mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_matcher_create+0x377/0x5e0 [mlx5_core]
mlx5_cmd_dr_create_flow_group+0x62/0xd0 [mlx5_core]
mlx5_create_flow_group+0x113/0x1c0 [mlx5_core]
mlx5_chains_create_prio+0x453/0x2290 [mlx5_core]
mlx5_chains_get_table+0x2e2/0x980 [mlx5_core]
esw_chains_create+0x1e6/0x3b0 [mlx5_core]
esw_create_offloads_fdb_tables.cold+0x62/0x63f [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #1 (&dmn->info.tx.mutex){+.+.}-{4:4}:
__mutex_lock+0x91/0x1060
mlx5dr_table_create+0x11d/0x530 [mlx5_core]
mlx5_cmd_dr_create_flow_table+0x62/0x140 [mlx5_core]
__mlx5_create_flow_table+0x46f/0x960 [mlx5_core]
mlx5_create_flow_table+0x16/0x20 [mlx5_core]
esw_create_offloads_fdb_tables+0x136/0x240 [mlx5_core]
esw_offloads_enable+0x76f/0xd20 [mlx5_core]
mlx5_eswitch_enable_locked+0x35a/0x500 [mlx5_core]
mlx5_devlink_eswitch_mode_set+0x561/0x950 [mlx5_core]
devlink_nl_eswitch_set_doit+0x67/0xe0
genl_family_rcv_msg_doit+0xe0/0x130
genl_rcv_msg+0x188/0x290
netlink_rcv_skb+0x4b/0xf0
genl_rcv+0x24/0x40
netlink_unicast+0x1ed/0x2c0
netlink_sendmsg+0x210/0x450
__sock_sendmsg+0x38/0x60
__sys_sendto+0x119/0x180
__x64_sys_sendto+0x20/0x30
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53-> #0 (&dmn->info.rx.mutex){+.+.}-{4:4}:
__lock_acquire+0x18b6/0x2eb0
lock_acquire+0xd3/0x2c0
__mutex_lock+0x91/0x1060
dr_dump_start+0x131/0x450 [mlx5_core]
seq_read_iter+0xe3/0x410
seq_read+0xfb/0x130
full_proxy_read+0x53/0x80
vfs_read+0xba/0x330
ksys_read+0x65/0xe0
do_syscall_64+0x70/0xd00
entry_SYSCALL_64_after_hwframe+0x4b/0x53
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(&dmn->dump_info.dbg_mutex);
lock(&dmn->info.tx.mutex);
lock(&dmn->dump_info.dbg_mutex); lock(&dmn->info.rx.mutex);
*** DEADLOCK ***
--- drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_dbg.c +2 -2
@@ -1050,8 +1050,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn)struct mlx5dr_table *tbl;int ret; -mutex_lock (&dmn->dump_info.dbg_mutex);mlx5dr_domain_lock (dmn); +mutex_lock (&dmn->dump_info.dbg_mutex); ret =dr_dump_domain (file, dmn);if (ret <0 )
@@ -1064,8 +1064,8 @@ static int dr_dump_domain_all(struct seq_file *file, struct mlx5dr_domain *dmn) } unlock_mutex: -mlx5dr_domain_unlock (dmn);mutex_unlock (&dmn->dump_info.dbg_mutex); +mlx5dr_domain_unlock (dmn);return ret; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 497/844 net/mlx5: LAG, disable MPESW in lag_disable_change()
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit bd7b9f83fb9f85228c3ac9748d9cba9fab7fb5a2 ]
mlx5_lag_disable_change() unconditionally called mlx5_disable_lag() when LAG was active, which is incorrect for MLX5_LAG_MODE_MPESW. Hnece, call mlx5_disable_mpesw() when running in MPESW mode.
--- drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c | 8 ++++++-- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c | 8 ++++---- drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c +6 -2
@@ -1654,8 +1654,12 @@ void mlx5_lag_disable_change(struct mlx5_core_dev *dev)mutex_lock (&ldev->lock); ldev->mode_changes_in_progress++; -if (__mlx5_lag_is_active (ldev)) -mlx5_disable_lag (ldev); +if (__mlx5_lag_is_active (ldev)) { +if (ldev->mode ==MLX5_LAG_MODE_MPESW ) +mlx5_lag_disable_mpesw (ldev); +else +mlx5_disable_lag (ldev); + }mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (dev->priv.hca_devcom_comp);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.c +4 -4
@@ -65,7 +65,7 @@ static int mlx5_mpesw_metadata_set(struct mlx5_lag *ldev)return err; } -static int enable_mpesw (struct mlx5_lag *ldev) +static int mlx5_lag_enable_mpesw (struct mlx5_lag *ldev) {struct mlx5_core_dev *dev0;int err;
@@ -124,7 +124,7 @@ static int enable_mpesw(struct mlx5_lag *ldev)return err; } -static void disable_mpesw (struct mlx5_lag *ldev) +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {if (ldev->mode ==MLX5_LAG_MODE_MPESW ) {mlx5_mpesw_metadata_cleanup (ldev);
@@ -150,9 +150,9 @@ static void mlx5_mpesw_work(struct work_struct *work) }if (mpesww->op ==MLX5_MPESW_OP_ENABLE ) - mpesww->result =enable_mpesw (ldev); + mpesww->result =mlx5_lag_enable_mpesw (ldev);else if (mpesww->op ==MLX5_MPESW_OP_DISABLE ) -disable_mpesw (ldev); +mlx5_lag_disable_mpesw (ldev); unlock:mutex_unlock (&ldev->lock);mlx5_devcom_comp_unlock (devcom);
drivers/net/ethernet/mellanox/mlx5/core/lag/mpesw.h +5 -0
@@ -31,5 +31,10 @@ int mlx5_lag_mpesw_do_mirred(struct mlx5_core_dev *mdev,bool mlx5_lag_is_mpesw (struct mlx5_core_dev *dev);void mlx5_lag_mpesw_disable (struct mlx5_core_dev *dev);int mlx5_lag_mpesw_enable (struct mlx5_core_dev *dev); +#ifdef CONFIG_MLX5_ESWITCH +void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev); +#else +static inline void mlx5_lag_disable_mpesw (struct mlx5_lag *ldev) {} +#endif /* CONFIG_MLX5_ESWITCH */ #endif /* __MLX5_LAG_MPESW_H__ */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 498/844 net/mlx5: E-switch, Clear legacy flag when moving to switchdev
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit d7073e8b978ae925f1f0f08754f33f84d8547ea7 ]
The cited commit introduced MLX5_PRIV_FLAGS_SWITCH_LEGACY to identify when a transition to legacy mode is requested via devlink. However, the logic failed to clear this flag if the mode was subsequently changed back to MLX5_ESWITCH_OFFLOADS (switchdev). Consequently, if a user toggled from legacy to switchdev, the flag remained set, leaving the driver with wrong state indicating
Fix this by explicitly clearing the MLX5_PRIV_FLAGS_SWITCH_LEGACY bit when the requested mode is MLX5_ESWITCH_OFFLOADS.
--- drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c +2 -0
@@ -4068,6 +4068,8 @@ int mlx5_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode,if (mlx5_mode ==MLX5_ESWITCH_LEGACY ) esw->dev->priv.flags |=MLX5_PRIV_FLAGS_SWITCH_LEGACY ; +if (mlx5_mode ==MLX5_ESWITCH_OFFLOADS ) + esw->dev->priv.flags &= ~MLX5_PRIV_FLAGS_SWITCH_LEGACY ;mlx5_eswitch_disable_locked (esw);if (mlx5_mode ==MLX5_ESWITCH_OFFLOADS ) {if (mlx5_devlink_trap_get_num_active (esw->dev)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 499/844 net/mlx5: Fix missing devlink lock in SRIOV enable error path
In reply to Sasha LevinFrom: Shay Drory <[email protected]>
[ Upstream commit 60253042c0b87b61596368489c44d12ba720d11c ]
The cited commit miss to add locking in the error path of mlx5_sriov_enable(). When pci_enable_sriov() fails, mlx5_device_disable_sriov() is called to clean up. This cleanup function now expects to be called with the devlink instance lock held.
Add the missing devl_lock(devlink) and devl_unlock(devlink)
--- drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/sriov.c +2 -0
@@ -193,7 +193,9 @@ static int mlx5_sriov_enable(struct pci_dev *pdev, int num_vfs) err =pci_enable_sriov (pdev, num_vfs);if (err) {mlx5_core_warn (dev,"pci_enable_sriov failed : %d\n" , err); +devl_lock (devlink);mlx5_device_disable_sriov (dev, num_vfs, true, true); +devl_unlock (devlink); }return err; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 500/844 net/mlx5e: Fix "scheduling while atomic" in IPsec MAC address query
In reply to Sasha LevinFrom: Jianbo Liu <[email protected]>
[ Upstream commit 859380694f434597407632c29f30fdb5e763e6cc ]
Fix a "scheduling while atomic" bug in mlx5e_ipsec_init_macs() by replacing mlx5_query_mac_address() with ether_addr_copy() to get the local MAC address directly from netdev->dev_addr.
The issue occurs because mlx5_query_mac_address() queries the hardware which involves mlx5_cmd_exec() that can sleep, but it is called from the mlx5e_ipsec_handle_event workqueue which runs in atomic context.
The MAC address is already available in netdev->dev_addr, so no need to query hardware. This avoids the sleeping call and resolves the bug.
Call trace: BUG: scheduling while atomic: kworker/u112:2/69344/0x00000200 __schedule+0x7ab/0xa20 schedule+0x1c/0xb0 schedule_timeout+0x6e/0xf0 __wait_for_common+0x91/0x1b0 cmd_exec+0xa85/0xff0 [mlx5_core] mlx5_cmd_exec+0x1f/0x50 [mlx5_core] mlx5_query_nic_vport_mac_address+0x7b/0xd0 [mlx5_core] mlx5_query_mac_address+0x19/0x30 [mlx5_core] mlx5e_ipsec_init_macs+0xc1/0x720 [mlx5_core] mlx5e_ipsec_build_accel_xfrm_attrs+0x422/0x670 [mlx5_core] mlx5e_ipsec_handle_event+0x2b9/0x460 [mlx5_core] process_one_work+0x178/0x2e0 worker_thread+0x2ea/0x430
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +1 -2
@@ -259,7 +259,6 @@ static void mlx5e_ipsec_init_limits(struct mlx5e_ipsec_sa_entry *sa_entry,static void mlx5e_ipsec_init_macs (struct mlx5e_ipsec_sa_entry *sa_entry,struct mlx5_accel_esp_xfrm_attrs *attrs) { -struct mlx5_core_dev *mdev =mlx5e_ipsec_sa2dev (sa_entry);struct mlx5e_ipsec_addr *addrs = &attrs->addrs;struct net_device *netdev = sa_entry->dev;struct xfrm_state *x = sa_entry->x;
@@ -276,7 +275,7 @@ static void mlx5e_ipsec_init_macs(struct mlx5e_ipsec_sa_entry *sa_entry, attrs->type != XFRM_DEV_OFFLOAD_PACKET)return ; -mlx5_query_mac_address (mdev, addr); +ether_addr_copy (addr, netdev->dev_addr);switch (attrs->dir) {case XFRM_DEV_OFFLOAD_IN : src = attrs->dmac;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 501/844 net: consume xmit errors of GSO frames
In reply to Sasha LevinFrom: Jakub Kicinski <[email protected]>
[ Upstream commit 7aa767d0d3d04e50ae94e770db7db8197f666970 ]
udpgro_frglist.sh and udpgro_bench.sh are the flakiest tests currently in NIPA. They fail in the same exact way, TCP GRO test stalls occasionally and the test gets killed after 10min.
These tests use veth to simulate GRO. They attach a trivial ("return XDP_PASS;") XDP program to the veth to force TSO off and NAPI on.
Digging into the failure mode we can see that the connection is completely stuck after a burst of drops. The sender's snd_nxt is at sequence number N [1], but the receiver claims to have received (rcv_nxt) up to N + 3 * MSS [2]. Last piece of the puzzle is that senders rtx queue is not empty (let's say the block in the rtx queue is at sequence number N - 4 * MSS [3]).
In this state, sender sends a retransmission from the rtx queue with a single segment, and sequence numbers N-4*MSS:N-3*MSS [3]. Receiver sees it and responds with an ACK all the way up to N + 3 * MSS [2]. But sender will reject this ack as TCP_ACK_UNSENT_DATA because it has no recollection of ever sending data that far out [1]. And we are stuck.
The root cause is the mess of the xmit return codes. veth returns an error when it can't xmit a frame. We end up with a loss event like this:
-------------------------------------------------
| GSO super frame 1 | GSO super frame 2 | |-----------------------------------------------| | seg | seg | seg | seg | seg | seg | seg | seg | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
-------------------------------------------------
x ok ok <ok>| ok ok ok <x>
\\
snd_nxt
"x" means packet lost by veth, and "ok" means it went thru. Since veth has TSO disabled in this test it sees individual segments. Segment 1 is on the retransmit queue and will be resent.
So why did the sender not advance snd_nxt even tho it clearly did send up to seg 8? tcp_write_xmit() interprets the return code from the core to mean that data has not been sent at all. Since TCP deals with GSO super frames, not individual segment the crux of the problem is that loss of a single segment can be interpreted as loss of all. TCP only sees the last return code for the last segment of the GSO frame (in <> brackets in the diagram above).
Of course for the problem to occur we need a setup or a device without a Qdisc. Otherwise Qdisc layer disconnects the protocol layer from the device errors completely.
We have multiple ways to fix this.
1) make veth not return an error when it lost a packet. While this is what I think we did in the past, the issue keeps reappearing and it's annoying to debug. The game of whack a mole is not great.
2) fix the damn return codes
We only talk about NETDEV_TX_OK and NETDEV_TX_BUSY in the documentation, so maybe we should make the return code from ndo_start_xmit() a boolean. I like that the most, but perhaps some ancient, not-really-networking protocol would suffer.
3) make TCP ignore the errors
It is not entirely clear to me what benefit TCP gets from interpreting the result of ip_queue_xmit()? Specifically once the connection is established and we're pushing data - packet loss is just packet loss?
4) this fix
Ignore the rc in the Qdisc-less+GSO case, since it's unreliable. We already always return OK in the TCQ_F_CAN_BYPASS case. In the Qdisc-less case let's be a bit more conservative and only mask the GSO errors. This path is taken by non-IP-"networks" like CAN, MCTP etc, so we could regress some ancient thing. This is the simplest, but also maybe the hackiest fix?
Similar fix has been proposed by Eric in the past but never committed because original reporter was working with an OOT driver and wasn't providing feedback (see Link).
--- net/core/dev.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
net/core/dev.c +18 -5
@@ -4818,6 +4818,8 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev)* to -1 or to their cpu id, but not to our id. */ if (READ_ONCE (txq->xmit_lock_owner) != cpu) { +bool is_list = false; +if (dev_xmit_recursion ()) goto recursion_alert;
@@ -4828,17 +4830,28 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev)HARD_TX_LOCK (dev, txq, cpu);if (!netif_xmit_stopped (txq)) { + is_list = !!skb->next; +dev_xmit_recursion_inc (); skb =dev_hard_start_xmit (skb, dev, txq, &rc);dev_xmit_recursion_dec (); -if (dev_xmit_complete (rc)) { -HARD_TX_UNLOCK (dev, txq); - goto out; - } + +/* GSO segments a single SKB into +* a list of frames. TCP expects error +* to mean none of the data was sent. +*/ +if (is_list) + rc =NETDEV_TX_OK ; }HARD_TX_UNLOCK (dev, txq); +if (!skb)/* xmit completed */ + goto out; +net_crit_ratelimited ("Virtual device %s asks to queue packet!\n" , dev->name); +/* NETDEV_TX_BUSY or queue was stopped */ +if (!is_list) + rc = -ENETDOWN ; }else {/* Recursion is detected! It is possible, * unfortunately
@@ -4846,10 +4859,10 @@ int __dev_queue_xmit(struct sk_buff *skb, struct net_device *sb_dev) recursion_alert:net_crit_ratelimited ("Dead loop on virtual device %s, fix it urgently!\n" , dev->name); + rc = -ENETDOWN ; } } - rc = -ENETDOWN ;rcu_read_unlock_bh ();dev_core_stats_tx_dropped_inc (dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 502/844 dpaa2-switch: validate num_ifs to prevent out-of-bounds write
In reply to Sasha LevinFrom: Junrui Luo <[email protected]>
[ Upstream commit 8a5752c6dcc085a3bfc78589925182e4e98468c5 ]
The driver obtains sw_attr.num_ifs from firmware via dpsw_get_attributes() but never validates it against DPSW_MAX_IF (64). This value controls iteration in dpaa2_switch_fdb_get_flood_cfg(), which writes port indices into the fixed-size cfg->if_id[DPSW_MAX_IF] array. When firmware reports num_ifs >= 64, the loop can write past the array bounds.
Add a bound check for num_ifs in dpaa2_switch_init().
dpaa2_switch_fdb_get_flood_cfg() appends the control interface (port num_ifs) after all matched ports. When num_ifs == DPSW_MAX_IF and all ports match the flood filter, the loop fills all 64 slots and the control interface write overflows by one entry.
The check uses >= because num_ifs == DPSW_MAX_IF is also functionally broken.
build_if_id_bitmap() silently drops any ID >= 64:
if (id[i] < DPSW_MAX_IF)
bmap[id[i] / 64] |= ...--- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +7 -0
@@ -3034,6 +3034,13 @@ static int dpaa2_switch_init(struct fsl_mc_device *sw_dev) goto err_close; } +if (ethsw->sw_attr.num_ifs >=DPSW_MAX_IF ) { +dev_err (dev,"DPSW num_ifs %u exceeds max %u\n" , + ethsw->sw_attr.num_ifs,DPSW_MAX_IF ); + err = -EINVAL ; + goto err_close; + } + err =dpsw_get_api_version (ethsw->mc_io,0 , ðsw->major, ðsw->minor);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 503/844 netfilter: nf_conntrack_h323: fix OOB read in decode_choice()
In reply to Sasha LevinFrom: Vahagn Vardanian <[email protected]>
[ Upstream commit baed0d9ba91d4f390da12d5039128ee897253d60 ]
In decode_choice(), the boundary check before get_len() uses the variable len, which is still 0 from its initialization at the top of the function:
unsigned int type, ext, len = 0;
...
if (ext || (son->attr & OPEN)) {
BYTE_ALIGN(bs);
if (nf_h323_error_boundary(bs, len, 0)) /* len is 0 here */
return H323_ERROR_BOUND;
len = get_len(bs); /* OOB read */When the bitstream is exactly consumed (bs->cur == bs->end), the check nf_h323_error_boundary(bs, 0, 0) evaluates to (bs->cur + 0 > bs->end), which is false. The subsequent get_len() call then dereferences *bs->cur++, reading 1 byte past the end of the buffer. If that byte has bit 7 set, get_len() reads a second byte as well.
This can be triggered remotely by sending a crafted Q.931 SETUP message with a User-User Information Element containing exactly 2 bytes of PER-encoded data ({0x08, 0x00}) to port 1720 through a firewall with the nf_conntrack_h323 helper active. The decoder fully consumes the PER buffer before reaching this code path, resulting in a 1-2 byte heap-buffer-overflow read confirmed by AddressSanitizer.
Fix this by checking for 2 bytes (the maximum that get_len() may read) instead of the uninitialized len. This matches the pattern used at every other get_len() call site in the same file, where the caller checks for 2 bytes of available data before calling get_len().
--- net/netfilter/nf_conntrack_h323_asn1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_conntrack_h323_asn1.c +1 -1
@@ -796,7 +796,7 @@ static int decode_choice(struct bitstr *bs, const struct field_t *f,if (ext || (son->attr &OPEN )) {BYTE_ALIGN (bs); -if (nf_h323_error_boundary (bs, len,0 )) +if (nf_h323_error_boundary (bs,2 ,0 ))return H323_ERROR_BOUND ; len =get_len (bs);if (nf_h323_error_boundary (bs, len,0 ))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 504/844 x86/acpi/boot: Correct acpi_is_processor_usable() check again
In reply to Sasha LevinFrom: Yazen Ghannam <[email protected]>
[ Upstream commit adbf61cc47cb72b102682e690ad323e1eda652c2 ]
ACPI v6.3 defined a new "Online Capable" MADT LAPIC flag. This bit is used in conjunction with the "Enabled" MADT LAPIC flag to determine if a CPU can be enabled/hotplugged by the OS after boot.
Before the new bit was defined, the "Enabled" bit was explicitly described like this (ACPI v6.0 wording provided):
"If zero, this processor is unusable, and the operating system support will not attempt to use it"
This means that CPU hotplug (based on MADT) is not possible. Many BIOS implementations follow this guidance. They may include LAPIC entries in MADT for unavailable CPUs, but since these entries are marked with "Enabled=0" it is expected that the OS will completely ignore these entries.
However, QEMU will do the same (include entries with "Enabled=0") for the purpose of allowing CPU hotplug within the guest.
Comment from QEMU function pc_madt_cpu_entry():
/* ACPI spec says that LAPIC entry for non present
* CPU may be omitted from MADT or it must be marked
* as disabled. However omitting non present CPU from
* MADT breaks hotplug on linux. So possible CPUs
* should be put in MADT but kept disabled. */
Recent Linux topology changes broke the QEMU use case. A following fix for the QEMU use case broke bare metal topology enumeration.
Rework the Linux MADT LAPIC flags check to allow the QEMU use case only for guests and to maintain the ACPI spec behavior for bare metal.
Remove an unnecessary check added to fix a bare metal case introduced by the QEMU "fix".
[ bp: Change logic as Michal suggested. ]
[ mingo: Removed misapplied -stable tag. ]
--- arch/x86/kernel/acpi/boot.c | 12 ++++++++---- arch/x86/kernel/cpu/topology.c | 15 --------------- 2 files changed, 8 insertions(+), 19 deletions(-)
arch/x86/kernel/acpi/boot.c +8 -4
@@ -35,6 +35,7 @@#include <asm/smp.h> #include <asm/i8259.h> #include <asm/setup.h> +#include <asm/hypervisor.h> #include "sleep.h" /* To include x86_acpi_suspend_lowlevel */ static int __initdata acpi_force =0 ;
@@ -164,11 +165,14 @@ static bool __init acpi_is_processor_usable(u32 lapic_flags)if (lapic_flags &ACPI_MADT_ENABLED )return true; -if (!acpi_support_online_capable || - (lapic_flags &ACPI_MADT_ONLINE_CAPABLE )) -return true; +if (acpi_support_online_capable) +return lapic_flags &ACPI_MADT_ONLINE_CAPABLE ; -return false; +/* +* QEMU expects legacy "Enabled=0" LAPIC entries to be counted as usable +* in order to support CPU hotplug in guests. +*/ +return !hypervisor_is_type (X86_HYPER_NATIVE ); } static int __init
arch/x86/kernel/cpu/topology.c +0 -15
@@ -27,7 +27,6 @@#include <xen/xen.h> #include <asm/apic.h> -#include <asm/hypervisor.h> #include <asm/io_apic.h> #include <asm/mpspec.h> #include <asm/msr.h>
@@ -236,20 +235,6 @@ static __init void topo_register_apic(u32 apic_id, u32 acpi_id, bool present) cpuid_to_apicid[cpu] = apic_id;topo_set_cpuids (cpu, apic_id, acpi_id); }else { -u32 pkgid =topo_apicid (apic_id,TOPO_PKG_DOMAIN ); - -/* -* Check for present APICs in the same package when running -* on bare metal. Allow the bogosity in a guest. -*/ -if (hypervisor_is_type (X86_HYPER_NATIVE ) && -topo_unit_count (pkgid,TOPO_PKG_DOMAIN , phys_cpu_present_map)) { -pr_info_once ("Ignoring hot-pluggable APIC ID %x in present package.\n" , - apic_id); - topo_info.nr_rejected_cpus++; -return ; - } - topo_info.nr_disabled_cpus++; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 505/844 rpmsg: core: fix race in driver_override_show() and use core helper
In reply to Sasha LevinFrom: Gui-Dong Han <[email protected]>
[ Upstream commit 42023d4b6d2661a40ee2dcf7e1a3528a35c638ca ]
The driver_override_show function reads the driver_override string without holding the device_lock. However, the store function modifies and frees the string while holding the device_lock. This creates a race condition where the string can be freed by the store function while being read by the show function, leading to a use-after-free.
To fix this, replace the rpmsg_string_attr macro with explicit show and store functions. The new driver_override_store uses the standard driver_set_override helper. Since the introduction of driver_set_override, the comments in include/linux/rpmsg.h have stated that this helper must be used to set or clear driver_override, but the implementation was not updated until now.
Because driver_set_override modifies and frees the string while holding the device_lock, the new driver_override_show now correctly holds the device_lock during the read operation to prevent the race.
Additionally, since rpmsg_string_attr has only ever been used for driver_override, removing the macro simplifies the code.
--- drivers/rpmsg/rpmsg_core.c | 66 ++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 39 deletions(-)
drivers/rpmsg/rpmsg_core.c +27 -39
@@ -352,50 +352,38 @@ field##_show(struct device *dev, \ } \static DEVICE_ATTR_RO (field); -#define rpmsg_string_attr (field, member) \ -static ssize_t \ -field##_store(struct device *dev, struct device_attribute *attr, \ - const char *buf, size_t sz) \ -{ \ - struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ - const char *old; \ - char *new; \ - \ - new = kstrndup(buf, sz, GFP_KERNEL); \ - if (!new) \ - return -ENOMEM; \ - new[strcspn(new, "\n")] = '\0'; \ - \ - device_lock(dev); \ - old = rpdev->member; \ - if (strlen(new)) { \ - rpdev->member = new; \ - } else { \ - kfree(new); \ - rpdev->member = NULL; \ - } \ - device_unlock(dev); \ - \ - kfree(old); \ - \ - return sz; \ -} \ -static ssize_t \ -field##_show(struct device *dev, \ - struct device_attribute *attr, char *buf) \ -{ \ - struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ - \ - return sprintf(buf, "%s\n", rpdev->member); \ -} \ -static DEVICE_ATTR_RW(field) -/* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */ rpmsg_show_attr (name, id.name,"%s\n" );rpmsg_show_attr (src, src,"0x%x\n" );rpmsg_show_attr (dst, dst,"0x%x\n" );rpmsg_show_attr (announce, announce ?"true" :"false" ,"%s\n" ); -rpmsg_string_attr (driver_override, driver_override); + +static ssize_t driver_override_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct rpmsg_device *rpdev =to_rpmsg_device (dev); +int ret; + + ret =driver_set_override (dev, &rpdev->driver_override, buf, count); +if (ret) +return ret; + +return count; +} + +static ssize_t driver_override_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct rpmsg_device *rpdev =to_rpmsg_device (dev); +ssize_t len; + +device_lock (dev); + len =sysfs_emit (buf,"%s\n" , rpdev->driver_override); +device_unlock (dev); +return len; +} +static DEVICE_ATTR_RW (driver_override);static ssize_t modalias_show (struct device *dev,struct device_attribute *attr,char *buf)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 506/844 clk: renesas: rzg2l: Fix intin variable size
In reply to Sasha LevinFrom: Chris Brandt <[email protected]>
[ Upstream commit a00655d98cd885472c311f01dff3e668d1288d0a ]
INTIN is a 12-bit register value, so u8 is too small.
--- drivers/clk/renesas/rzg2l-cpg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/renesas/rzg2l-cpg.c +1 -1
@@ -122,8 +122,8 @@ struct div_hw_data {struct rzg2l_pll5_param {u32 pl5_fracin; +u16 pl5_intin;u8 pl5_refdiv; -u8 pl5_intin;u8 pl5_postdiv1;u8 pl5_postdiv2;u8 pl5_spread;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 507/844 clk: renesas: rzg2l: Select correct div round macro
In reply to Sasha LevinFrom: Chris Brandt <[email protected]>
[ Upstream commit f9451374dcfdfe669ee55b58ee6c11e8638980e4 ]
Variable foutvco_rate is an unsigned long, not an unsigned long long.
--- drivers/clk/renesas/rzg2l-cpg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/renesas/rzg2l-cpg.c +2 -2
@@ -572,8 +572,8 @@ rzg2l_cpg_get_foutpostdiv_rate(struct rzg2l_pll5_param *params, foutvco_rate =div_u64 (mul_u32_u32 (EXTAL_FREQ_IN_MEGA_HZ *MEGA , (params->pl5_intin <<24 ) + params->pl5_fracin), params->pl5_refdiv) >>24 ; - foutpostdiv_rate =DIV_ROUND_CLOSEST_ULL (foutvco_rate, - params->pl5_postdiv1 * params->pl5_postdiv2); + foutpostdiv_rate =DIV_ROUND_CLOSEST (foutvco_rate, + params->pl5_postdiv1 * params->pl5_postdiv2);return foutpostdiv_rate; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 508/844 hfsplus: ensure sb->s_fs_info is always cleaned up
In reply to Sasha LevinFrom: Mehdi Ben Hadj Khelifa <[email protected]>
[ Upstream commit 126fb0ce99431126b44a6c360192668c818f641f ]
When hfsplus was converted to the new mount api a bug was introduced by changing the allocation pattern of sb->s_fs_info. If setup_bdev_super() fails after a new superblock has been allocated by sget_fc(), but before hfsplus_fill_super() takes ownership of the filesystem-specific s_fs_info data it was leaked.
Fix this by freeing sb->s_fs_info in hfsplus_kill_super().
--- fs/hfsplus/super.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
fs/hfsplus/super.c +9 -4
@@ -350,8 +350,6 @@ static void hfsplus_put_super(struct super_block *sb)hfs_btree_close (sbi->ext_tree);kfree (sbi->s_vhdr_buf);kfree (sbi->s_backup_vhdr_buf); -call_rcu (&sbi->rcu, delayed_free); -hfs_dbg ("finished\n" ); }
@@ -656,7 +654,6 @@ static int hfsplus_fill_super(struct super_block *sb, struct fs_context *fc) out_unload_nls:unload_nls (sbi->nls);unload_nls (nls); -kfree (sbi);return err; }
@@ -715,10 +712,18 @@ static int hfsplus_init_fs_context(struct fs_context *fc)return 0 ; } +static void hfsplus_kill_super (struct super_block *sb) +{ +struct hfsplus_sb_info *sbi =HFSPLUS_SB (sb); + +kill_block_super (sb); +call_rcu (&sbi->rcu, delayed_free); +} +static struct file_system_type hfsplus_fs_type = { .owner =THIS_MODULE , .name ="hfsplus" , - .kill_sb = kill_block_super, + .kill_sb = hfsplus_kill_super, .fs_flags =FS_REQUIRES_DEV , .init_fs_context = hfsplus_init_fs_context, };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 509/844 memory: mtk-smi: fix device leaks on common probe
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 6cfa038bddd710f544076ea2ef7792fc82fbedd6 ]
Make sure to drop the reference taken when looking up the SMI device during common probe on late probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/memory/mtk-smi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/memory/mtk-smi.c +2 -0
@@ -674,6 +674,7 @@ static int mtk_smi_larb_probe(struct platform_device *pdev) err_pm_disable:pm_runtime_disable (dev);device_link_remove (dev, larb->smi_common_dev); +put_device (larb->smi_common_dev);return ret; }
@@ -917,6 +918,7 @@ static void mtk_smi_common_remove(struct platform_device *pdev)if (common->plat->type ==MTK_SMI_GEN2_SUB_COMM )device_link_remove (&pdev->dev, common->smi_common_dev);pm_runtime_disable (&pdev->dev); +put_device (common->smi_common_dev); }static int __maybe_unused mtk_smi_common_resume (struct device *dev)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 510/844 memory: mtk-smi: fix device leak on larb probe
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 9dae65913b32d05dbc8ff4b8a6bf04a0e49a8eb6 ]
Make sure to drop the reference taken when looking up the SMI device during larb probe on late probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/memory/mtk-smi.c | 1 + 1 file changed, 1 insertion(+)
drivers/memory/mtk-smi.c +1 -0
@@ -685,6 +685,7 @@ static void mtk_smi_larb_remove(struct platform_device *pdev)device_link_remove (&pdev->dev, larb->smi_common_dev);pm_runtime_disable (&pdev->dev);component_del (&pdev->dev, &mtk_smi_larb_component_ops); +put_device (larb->smi_common_dev); }static int __maybe_unused mtk_smi_larb_resume (struct device *dev)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 511/844 arm64: dts: ti: am62p-verdin: Fix SD regulator startup delay
In reply to Sasha LevinFrom: Francesco Dolcini <[email protected]>
[ Upstream commit de86dbc0fb00bd3773db4b05d9f5926f0faa2244 ]
The power switch used to power the SD card interface might have more than 2ms turn-on time, increase the startup delay to 20ms to prevent failures.
--- arch/arm64/boot/dts/ti/k3-am62p-verdin.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am62p-verdin.dtsi +1 -1
@@ -112,7 +112,7 @@ reg_sd1_vmmc: regulator-sdhci1-vmmc { regulator-max-microvolt = <3300000>; regulator-min-microvolt = <3300000>; regulator-name = "+V3.3_SD"; - startup-delay-us = <2000>; + startup-delay-us = <20000>; }; reg_sd1_vqmmc: regulator-sdhci1-vqmmc {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 512/844 drm/panthor: fix for dma-fence safe access rules
In reply to Sasha LevinFrom: Chia-I Wu <[email protected]>
[ Upstream commit efe24898485c5c831e629d9c6fb9350c35cb576f ]
Commit 506aa8b02a8d6 ("dma-fence: Add safe access helpers and document the rules") details the dma-fence safe access rules. The most common culprit is that drm_sched_fence_get_timeline_name may race with group_free_queue.
--- drivers/gpu/drm/panthor/panthor_sched.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/panthor/panthor_sched.c +4 -0
@@ -23,6 +23,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/pm_runtime.h> +#include <linux/rcupdate.h> #include "panthor_devfreq.h" #include "panthor_device.h"
@@ -939,6 +940,9 @@ static void group_release_work(struct work_struct *work) release_work);u32 i; +/* dma-fences may still be accessing group->queues under rcu lock. */ +synchronize_rcu (); +for (i =0 ; i < group->queue_count; i++)group_free_queue (group, group->queues[i]);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 513/844 ASoC: SOF: ipc4-control: If there is no data do not send bytes update
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit 2fa74713744dc5e908fff851c20f5f89fd665fb7 ]
When the bytes control have no data (payload) then there is no need to send an IPC message as there is nothing to send.
--- sound/soc/sof/ipc4-control.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
sound/soc/sof/ipc4-control.c +10 -2
@@ -412,8 +412,16 @@ static int sof_ipc4_set_get_bytes_data(struct snd_sof_dev *sdev,int ret =0 ;/* Send the new data to the firmware only if it is powered up */ -if (set && !pm_runtime_active (sdev->dev)) -return 0 ; +if (set) { +if (!pm_runtime_active (sdev->dev)) +return 0 ; + +if (!data->size) { +dev_dbg (sdev->dev,"%s: No data to be sent.\n" , + scontrol->name); +return 0 ; + } + } msg->extension =SOF_IPC4_MOD_EXT_MSG_PARAM_ID (data->type);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 514/844 ASoC: SOF: ipc4-topology: Correct the allocation size for bytes controls
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit a653820700b81c9e6f05ac23b7969ecec1a18e85 ]
The size of the data behind of scontrol->ipc_control_data for bytes controls is:
[1] sizeof(struct sof_ipc4_control_data) + // kernel only struct
[2] sizeof(struct sof_abi_hdr)) + payload
The max_size specifies the size of [2] and it is coming from topology.
Change the function to take this into account and allocate adequate amount of memory behind scontrol->ipc_control_data.
With the change we will allocate [1] amount more memory to be able to hold the full size of data.
--- sound/soc/sof/ipc4-topology.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
sound/soc/sof/ipc4-topology.c +27 -8
@@ -2870,22 +2870,41 @@ static int sof_ipc4_control_load_bytes(struct snd_sof_dev *sdev, struct snd_sof_struct sof_ipc4_msg *msg;int ret; -if (scontrol->max_size < (sizeof (*control_data) +sizeof (struct sof_abi_hdr ))) { -dev_err (sdev->dev,"insufficient size for a bytes control %s: %zu.\n" , +/* +* The max_size is coming from topology and indicates the maximum size +* of sof_abi_hdr plus the payload, which excludes the local only +* 'struct sof_ipc4_control_data' +*/ +if (scontrol->max_size <sizeof (struct sof_abi_hdr )) { +dev_err (sdev->dev, +"insufficient maximum size for a bytes control %s: %zu.\n" , scontrol->name, scontrol->max_size);return -EINVAL ; } -if (scontrol->priv_size > scontrol->max_size -sizeof (*control_data)) { -dev_err (sdev->dev,"scontrol %s bytes data size %zu exceeds max %zu.\n" , - scontrol->name, scontrol->priv_size, - scontrol->max_size -sizeof (*control_data)); +if (scontrol->priv_size > scontrol->max_size) { +dev_err (sdev->dev, +"bytes control %s initial data size %zu exceeds max %zu.\n" , + scontrol->name, scontrol->priv_size, scontrol->max_size); +return -EINVAL ; + } + +if (scontrol->priv_size <sizeof (struct sof_abi_hdr )) { +dev_err (sdev->dev, +"bytes control %s initial data size %zu is insufficient.\n" , + scontrol->name, scontrol->priv_size);return -EINVAL ; } - scontrol->size =sizeof (struct sof_ipc4_control_data ) + scontrol->priv_size; +/* +* The used size behind the cdata pointer, which can be smaller than +* the maximum size +*/ + scontrol->size =sizeof (*control_data) + scontrol->priv_size; - scontrol->ipc_control_data =kzalloc (scontrol->max_size,GFP_KERNEL ); +/* Allocate the cdata: local struct size + maximum payload size */ + scontrol->ipc_control_data =kzalloc (sizeof (*control_data) + scontrol->max_size, +GFP_KERNEL );if (!scontrol->ipc_control_data)return -ENOMEM ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 515/844 ASoC: SOF: ipc4-control: Use the correct size for scontrol->ipc_control_data
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit c1876fc33c5976837e4c73719c7582617efc6919 ]
The size of the data behind scontrol->ipc_control_data is stored in scontrol->size, use this when copying data for backup/restore.
--- sound/soc/sof/ipc4-control.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/sof/ipc4-control.c +3 -3
@@ -66,7 +66,7 @@ static int sof_ipc4_set_get_kcontrol_data(struct snd_sof_control *scontrol,* configuration */ memcpy (scontrol->ipc_control_data, scontrol->old_ipc_control_data, - scontrol->max_size); + scontrol->size);kfree (scontrol->old_ipc_control_data); scontrol->old_ipc_control_data =NULL ;/* Send the last known good configuration to firmware */
@@ -567,7 +567,7 @@ static int sof_ipc4_bytes_ext_put(struct snd_sof_control *scontrol,if (!scontrol->old_ipc_control_data) {/* Create a backup of the current, valid bytes control */ scontrol->old_ipc_control_data =kmemdup (scontrol->ipc_control_data, - scontrol->max_size,GFP_KERNEL ); + scontrol->size,GFP_KERNEL );if (!scontrol->old_ipc_control_data)return -ENOMEM ; }
@@ -575,7 +575,7 @@ static int sof_ipc4_bytes_ext_put(struct snd_sof_control *scontrol,/* Copy the whole binary data which includes the ABI header and the payload */ if (copy_from_user (data, tlvd->tlv, header.length)) {memcpy (scontrol->ipc_control_data, scontrol->old_ipc_control_data, - scontrol->max_size); + scontrol->size);kfree (scontrol->old_ipc_control_data); scontrol->old_ipc_control_data =NULL ;return -EFAULT ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 516/844 ASoC: SOF: ipc4-control: Keep the payload size up to date
In reply to Sasha LevinFrom: Peter Ujfalusi <[email protected]>
[ Upstream commit ebcfdbe4add923dfb690e6fb9d158da87ae0b6bf ]
When the bytes data is read from the firmware, the size of the payload can be different than what it was previously.
For example when the topology did not contained payload data at all for the control, the data size was 0.
For get operation allow maximum size of payload to be read and then update the sizes according to the completed message.
Similarly, keep the size in sync when updating the data in firmware.
With the change we will be able to read data from firmware for bytes controls which did not had initial payload defined in topology.
--- sound/soc/sof/ipc4-control.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
sound/soc/sof/ipc4-control.c +19 -4
@@ -426,13 +426,21 @@ static int sof_ipc4_set_get_bytes_data(struct snd_sof_dev *sdev, msg->extension =SOF_IPC4_MOD_EXT_MSG_PARAM_ID (data->type); msg->data_ptr = data->data; - msg->data_size = data->size; +if (set) + msg->data_size = data->size; +else + msg->data_size = scontrol->max_size -sizeof (*data); ret =sof_ipc4_set_get_kcontrol_data (scontrol, set, lock); -if (ret <0 ) +if (ret <0 ) {dev_err (sdev->dev,"Failed to %s for %s\n" , set ?"set bytes update" :"get bytes" , scontrol->name); + }else if (!set) { +/* Update the sizes according to the received payload data */ + data->size = msg->data_size; + scontrol->size =sizeof (*cdata) +sizeof (*data) + data->size; + } msg->data_ptr =NULL ; msg->data_size =0 ;
@@ -448,6 +456,7 @@ static int sof_ipc4_bytes_put(struct snd_sof_control *scontrol,struct snd_sof_dev *sdev =snd_soc_component_get_drvdata (scomp);struct sof_abi_hdr *data = cdata->data;size_t size; +int ret;if (scontrol->max_size >sizeof (ucontrol->value.bytes.data)) { dev_err_ratelimited(scomp->dev,
@@ -469,9 +478,12 @@ static int sof_ipc4_bytes_put(struct snd_sof_control *scontrol,/* copy from kcontrol */ memcpy (data, ucontrol->value.bytes.data, size); -sof_ipc4_set_get_bytes_data (sdev, scontrol, true, true); + ret =sof_ipc4_set_get_bytes_data (sdev, scontrol, true, true); +if (!ret) +/* Update the cdata size */ + scontrol->size =sizeof (*cdata) + size; -return 0 ; +return ret; } static int sof_ipc4_bytes_get(struct snd_sof_control *scontrol,
@@ -581,6 +593,9 @@ static int sof_ipc4_bytes_ext_put(struct snd_sof_control *scontrol,return -EFAULT ; } +/* Update the cdata size */ + scontrol->size =sizeof (*cdata) + header.length; +return sof_ipc4_set_get_bytes_data (sdev, scontrol, true, true); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 517/844 PCI: j721e: Add config guards for Cadence Host and Endpoint library APIs
In reply to Sasha LevinFrom: Siddharth Vadapalli <[email protected]>
[ Upstream commit 4b361b1e92be255ff923453fe8db74086cc7cf66 ]
Commit under Fixes enabled loadable module support for the driver under the assumption that it shall be the sole user of the Cadence Host and Endpoint library APIs. This assumption guarantees that we won't end up in a case where the driver is built-in and the library support is built as a loadable module.
With the introduction of [1], this assumption is no longer valid. The SG2042 driver could be built as a loadable module, implying that the Cadence Host library is also selected as a loadable module. However, the pci-j721e.c driver could be built-in as indicated by CONFIG_PCI_J721E=y due to which the Cadence Endpoint library is built-in. Despite the library drivers being built as specified by their respective consumers, since the 'pci-j721e.c' driver has references to the Cadence Host library APIs as well, we run into a build error as reported at [0].
Fix this by adding config guards as a temporary workaround. The proper fix is to split the 'pci-j721e.c' driver into independent Host and Endpoint drivers as aligned at [2].
[0]: https://lore.kernel.org/r/[email protected]/
[1]: commit 1c72774df028 ("PCI: sg2042: Add Sophgo SG2042 PCIe driver") [2]: https://lore.kernel.org/r/[email protected]/
--- drivers/pci/controller/cadence/pci-j721e.c | 41 +++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-)
drivers/pci/controller/cadence/pci-j721e.c +25 -16
@@ -620,9 +620,11 @@ static int j721e_pcie_probe(struct platform_device *pdev)gpiod_set_value_cansleep (pcie->reset_gpio,1 ); } - ret =cdns_pcie_host_setup (rc); -if (ret <0 ) - goto err_pcie_setup; +if (IS_ENABLED (CONFIG_PCI_J721E_HOST )) { + ret =cdns_pcie_host_setup (rc); +if (ret <0 ) + goto err_pcie_setup; + }break ;case PCI_MODE_EP :
@@ -632,9 +634,11 @@ static int j721e_pcie_probe(struct platform_device *pdev) goto err_get_sync; } - ret =cdns_pcie_ep_setup (ep); -if (ret <0 ) - goto err_pcie_setup; +if (IS_ENABLED (CONFIG_PCI_J721E_EP )) { + ret =cdns_pcie_ep_setup (ep); +if (ret <0 ) + goto err_pcie_setup; + }break ; }
@@ -659,10 +663,11 @@ static void j721e_pcie_remove(struct platform_device *pdev)struct cdns_pcie_ep *ep;struct cdns_pcie_rc *rc; -if (pcie->mode ==PCI_MODE_RC ) { +if (IS_ENABLED (CONFIG_PCI_J721E_HOST ) && + pcie->mode ==PCI_MODE_RC ) { rc = container_of(cdns_pcie, struct cdns_pcie_rc, pcie);cdns_pcie_host_disable (rc); - }else { + }else if (IS_ENABLED (CONFIG_PCI_J721E_EP )) { ep = container_of(cdns_pcie, struct cdns_pcie_ep, pcie);cdns_pcie_ep_disable (ep); }
@@ -728,10 +733,12 @@ static int j721e_pcie_resume_noirq(struct device *dev)gpiod_set_value_cansleep (pcie->reset_gpio,1 ); } - ret =cdns_pcie_host_link_setup (rc); -if (ret <0 ) { -clk_disable_unprepare (pcie->refclk); -return ret; +if (IS_ENABLED (CONFIG_PCI_J721E_HOST )) { + ret =cdns_pcie_host_link_setup (rc); +if (ret <0 ) { +clk_disable_unprepare (pcie->refclk); +return ret; + } }/*
@@ -741,10 +748,12 @@ static int j721e_pcie_resume_noirq(struct device *dev)for (enum cdns_pcie_rp_bar bar =RP_BAR0 ; bar <=RP_NO_BAR ; bar++) rc->avail_ib_bar[bar] = true; - ret =cdns_pcie_host_init (rc); -if (ret) { -clk_disable_unprepare (pcie->refclk); -return ret; +if (IS_ENABLED (CONFIG_PCI_J721E_HOST )) { + ret =cdns_pcie_host_init (rc); +if (ret) { +clk_disable_unprepare (pcie->refclk); +return ret; + } } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 518/844 fpga: dfl: use subsys_initcall to allow built-in drivers to be added
In reply to Sasha LevinFrom: Thadeu Lima de Souza Cascardo <[email protected]>
[ Upstream commit 267f53140c9d0bf270bbe0148082e9b8e5011273 ]
The dfl code adds a bus. If it is built-in and there is a built-in driver as well, the dfl module_init may be called after the driver module_init, leading to a failure to register the driver as the bus has not been added yet.
Use subsys_initcall, which guarantees it will be called before the drivers init code.
Without the fix, we see failures like this:
[ 0.479475] Driver 'intel-m10-bmc' was unable to register with bus_type 'dfl' because the bus was not initialized.
--- drivers/fpga/dfl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl.c +1 -1
@@ -2018,7 +2018,7 @@ static void __exit dfl_fpga_exit(void)bus_unregister (&dfl_bus_type); } -module_init (dfl_fpga_init); +subsys_initcall (dfl_fpga_init);module_exit (dfl_fpga_exit);MODULE_DESCRIPTION ("FPGA Device Feature List (DFL) Support" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 519/844 drm/tests: shmem: Swap names of export tests
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 89f23d42006630dd94c01a8c916f8c648141ad8e ]
GEM SHMEM has 2 helpers for exporting S/G tables. Swap the names of the rsp. tests, so that each matches the helper it tests.
--- drivers/gpu/drm/tests/drm_gem_shmem_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +3 -3
@@ -194,7 +194,7 @@ static void drm_gem_shmem_test_vmap(struct kunit *test)* scatter/gather table large enough to accommodate the backing memory * is successfully exported. */ -static void drm_gem_shmem_test_get_pages_sgt (struct kunit *test) +static void drm_gem_shmem_test_get_sg_table (struct kunit *test) {struct drm_device *drm_dev = test->priv;struct drm_gem_shmem_object *shmem;
@@ -236,7 +236,7 @@ static void drm_gem_shmem_test_get_pages_sgt(struct kunit *test)* backing pages are pinned and a scatter/gather table large enough to * accommodate the backing memory is successfully exported. */ -static void drm_gem_shmem_test_get_sg_table (struct kunit *test) +static void drm_gem_shmem_test_get_pages_sgt (struct kunit *test) {struct drm_device *drm_dev = test->priv;struct drm_gem_shmem_object *shmem;
@@ -366,8 +366,8 @@ static struct kunit_case drm_gem_shmem_test_cases[] = {KUNIT_CASE (drm_gem_shmem_test_obj_create_private),KUNIT_CASE (drm_gem_shmem_test_pin_pages),KUNIT_CASE (drm_gem_shmem_test_vmap), -KUNIT_CASE (drm_gem_shmem_test_get_pages_sgt),KUNIT_CASE (drm_gem_shmem_test_get_sg_table), +KUNIT_CASE (drm_gem_shmem_test_get_pages_sgt),KUNIT_CASE (drm_gem_shmem_test_madvise), KUNIT_CASE(drm_gem_shmem_test_purge), {}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 520/844 drm/tests: shmem: Add clean-up action to unpin pages
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit b47b9ecef309459278eb52f02b50eefdeaac4f6d ]
Automatically unpin pages on cleanup. The test currently fails with the error
[ 58.246263] drm-kunit-mock-device drm_gem_shmem_test_get_sg_table.drm-kunit-mock-device: [drm] drm_WARN_ON(refcount_read(&shmem->pages_pin_count))
while cleaning up the GEM object. The pin count has to be zero at this point.
--- drivers/gpu/drm/tests/drm_gem_shmem_test.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +6 -0
@@ -34,6 +34,9 @@ KUNIT_DEFINE_ACTION_WRAPPER(sg_free_table_wrapper, sg_free_table,KUNIT_DEFINE_ACTION_WRAPPER (drm_gem_shmem_free_wrapper, drm_gem_shmem_free, struct drm_gem_shmem_object *); +KUNIT_DEFINE_ACTION_WRAPPER (drm_gem_shmem_unpin_wrapper, drm_gem_shmem_unpin, + struct drm_gem_shmem_object *); +/* * Test creating a shmem GEM object backed by shmem buffer. The test * case succeeds if the GEM object is successfully allocated with the
@@ -212,6 +215,9 @@ static void drm_gem_shmem_test_get_sg_table(struct kunit *test) ret =drm_gem_shmem_pin (shmem);KUNIT_ASSERT_EQ (test, ret,0 ); + ret =kunit_add_action_or_reset (test, drm_gem_shmem_unpin_wrapper, shmem); +KUNIT_ASSERT_EQ (test, ret,0 ); + sgt =drm_gem_shmem_get_sg_table (shmem);KUNIT_ASSERT_NOT_ERR_OR_NULL (test, sgt);KUNIT_EXPECT_NULL (test, shmem->sgt);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 521/844 drm/tests: shmem: Hold reservation lock around vmap/vunmap
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit cda83b099f117f2a28a77bf467af934cb39e49cf ]
Acquire and release the GEM object's reservation lock around vmap and vunmap operations. The tests use vmap_locked, which led to errors such as show below.
[ 122.292030] WARNING: CPU: 3 PID: 1413 at drivers/gpu/drm/drm_gem_shmem_helper.c:390 drm_gem_shmem_vmap_locked+0x3a3/0x6f0
[ 122.468066] WARNING: CPU: 3 PID: 1413 at drivers/gpu/drm/drm_gem_shmem_helper.c:293 drm_gem_shmem_pin_locked+0x1fe/0x350
[ 122.563504] WARNING: CPU: 3 PID: 1413 at drivers/gpu/drm/drm_gem_shmem_helper.c:234 drm_gem_shmem_get_pages_locked+0x23c/0x370
[ 122.662248] WARNING: CPU: 2 PID: 1413 at drivers/gpu/drm/drm_gem_shmem_helper.c:452 drm_gem_shmem_vunmap_locked+0x101/0x330
Only export the new vmap/vunmap helpers for Kunit tests. These are not interfaces for regular drivers.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 33 ++++++++++++++++++++++ drivers/gpu/drm/tests/drm_gem_shmem_test.c | 6 ++-- include/drm/drm_gem_shmem_helper.h | 9 ++++++ 3 files changed, 46 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +33 -0
@@ -15,6 +15,8 @@#include <asm/set_memory.h> #endif +#include <kunit/visibility.h> +#include <drm/drm.h> #include <drm/drm_device.h> #include <drm/drm_drv.h>
@@ -894,6 +896,37 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev, }EXPORT_SYMBOL_GPL (drm_gem_shmem_prime_import_no_map); +/* +* Kunit helpers +*/ + +#if IS_ENABLED (CONFIG_KUNIT ) +int drm_gem_shmem_vmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map) +{ +struct drm_gem_object *obj = &shmem->base; +int ret; + + ret =dma_resv_lock_interruptible (obj->resv,NULL ); +if (ret) +return ret; + ret =drm_gem_shmem_vmap_locked (shmem, map); +dma_resv_unlock (obj->resv); + +return ret; +} +EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_vmap); + +void drm_gem_shmem_vunmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map) +{ +struct drm_gem_object *obj = &shmem->base; + +dma_resv_lock_interruptible (obj->resv,NULL ); +drm_gem_shmem_vunmap_locked (shmem, map); +dma_resv_unlock (obj->resv); +} +EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_vunmap); +#endif +MODULE_DESCRIPTION ("DRM SHMEM memory-management helpers" );MODULE_IMPORT_NS ("DMA_BUF" );MODULE_LICENSE ("GPL" );
drivers/gpu/drm/tests/drm_gem_shmem_test.c +4 -2
@@ -19,6 +19,8 @@#include <drm/drm_gem_shmem_helper.h> #include <drm/drm_kunit_helpers.h> +MODULE_IMPORT_NS ("EXPORTED_FOR_KUNIT_TESTING" ); +#define TEST_SIZE SZ_1M#define TEST_BYTE 0xae
@@ -176,7 +178,7 @@ static void drm_gem_shmem_test_vmap(struct kunit *test) ret =kunit_add_action_or_reset (test, drm_gem_shmem_free_wrapper, shmem);KUNIT_ASSERT_EQ (test, ret,0 ); - ret =drm_gem_shmem_vmap_locked (shmem, &map); + ret =drm_gem_shmem_vmap (shmem, &map);KUNIT_ASSERT_EQ (test, ret,0 );KUNIT_ASSERT_NOT_NULL (test, shmem->vaddr);KUNIT_ASSERT_FALSE (test,iosys_map_is_null (&map));
@@ -186,7 +188,7 @@ static void drm_gem_shmem_test_vmap(struct kunit *test)for (i =0 ; i <TEST_SIZE ; i++)KUNIT_EXPECT_EQ (test,iosys_map_rd (&map, i, u8),TEST_BYTE ); -drm_gem_shmem_vunmap_locked (shmem, &map); +drm_gem_shmem_vunmap (shmem, &map);KUNIT_EXPECT_NULL (test, shmem->vaddr);KUNIT_EXPECT_EQ (test,refcount_read (&shmem->vmap_use_count),0 ); }
include/drm/drm_gem_shmem_helper.h +9 -0
@@ -303,4 +303,13 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev, .gem_prime_import = drm_gem_shmem_prime_import_no_map, \ .dumb_create = drm_gem_shmem_dumb_create +/* +* Kunit helpers +*/ + +#if IS_ENABLED (CONFIG_KUNIT ) +int drm_gem_shmem_vmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map); +void drm_gem_shmem_vunmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map); +#endif +#endif /* __DRM_GEM_SHMEM_HELPER_H__ */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 522/844 drm/tests: shmem: Hold reservation lock around madvise
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 607d07d8cc0b835a8701259f08a03dc149b79b4f ]
Acquire and release the GEM object's reservation lock around calls to the object's madvide operation. The tests use drm_gem_shmem_madvise_locked(), which led to errors such as show below.
[ 58.339389] WARNING: CPU: 1 PID: 1352 at drivers/gpu/drm/drm_gem_shmem_helper.c:499 drm_gem_shmem_madvise_locked+0xde/0x140
Only export the new helper drm_gem_shmem_madvise() for Kunit tests. This is not an interface for regular drivers.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +++++++++++++++ drivers/gpu/drm/tests/drm_gem_shmem_test.c | 8 ++++---- include/drm/drm_gem_shmem_helper.h | 1 + 3 files changed, 20 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +15 -0
@@ -925,6 +925,21 @@ void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem, struct iosys_map * dma_resv_unlock(obj->resv); }EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_vunmap); + +int drm_gem_shmem_madvise (struct drm_gem_shmem_object *shmem,int madv) +{ +struct drm_gem_object *obj = &shmem->base; +int ret; + + ret =dma_resv_lock_interruptible (obj->resv,NULL ); +if (ret) +return ret; + ret =drm_gem_shmem_madvise_locked (shmem, madv); +dma_resv_unlock (obj->resv); + +return ret; +} +EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_madvise);#endif MODULE_DESCRIPTION ("DRM SHMEM memory-management helpers" );
drivers/gpu/drm/tests/drm_gem_shmem_test.c +4 -4
@@ -292,17 +292,17 @@ static void drm_gem_shmem_test_madvise(struct kunit *test) ret =kunit_add_action_or_reset (test, drm_gem_shmem_free_wrapper, shmem);KUNIT_ASSERT_EQ (test, ret,0 ); - ret =drm_gem_shmem_madvise_locked (shmem,1 ); + ret =drm_gem_shmem_madvise (shmem,1 );KUNIT_EXPECT_TRUE (test, ret);KUNIT_ASSERT_EQ (test, shmem->madv,1 );/* Set madv to a negative value */ - ret =drm_gem_shmem_madvise_locked (shmem,-1 ); + ret =drm_gem_shmem_madvise (shmem,-1 );KUNIT_EXPECT_FALSE (test, ret);KUNIT_ASSERT_EQ (test, shmem->madv,-1 );/* Check that madv cannot be set back to a positive value */ - ret =drm_gem_shmem_madvise_locked (shmem,0 ); + ret =drm_gem_shmem_madvise (shmem,0 );KUNIT_EXPECT_FALSE (test, ret);KUNIT_ASSERT_EQ (test, shmem->madv,-1 ); }
@@ -330,7 +330,7 @@ static void drm_gem_shmem_test_purge(struct kunit *test) ret =drm_gem_shmem_is_purgeable (shmem);KUNIT_EXPECT_FALSE (test, ret); - ret =drm_gem_shmem_madvise_locked (shmem,1 ); + ret =drm_gem_shmem_madvise (shmem,1 );KUNIT_EXPECT_TRUE (test, ret);/* The scatter/gather table will be freed by drm_gem_shmem_free */
include/drm/drm_gem_shmem_helper.h +1 -0
@@ -310,6 +310,7 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,#if IS_ENABLED (CONFIG_KUNIT )int drm_gem_shmem_vmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map);void drm_gem_shmem_vunmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map); +int drm_gem_shmem_madvise (struct drm_gem_shmem_object *shmem,int madv);#endif #endif /* __DRM_GEM_SHMEM_HELPER_H__ */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 523/844 drm/tests: shmem: Hold reservation lock around purge
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 3f41307d589c2f25d556d47b165df808124cd0c4 ]
Acquire and release the GEM object's reservation lock around calls to the object's purge operation. The tests use drm_gem_shmem_purge_locked(), which led to errors such as show below.
[ 58.709128] WARNING: CPU: 1 PID: 1354 at drivers/gpu/drm/drm_gem_shmem_helper.c:515 drm_gem_shmem_purge_locked+0x51c/0x740
Only export the new helper drm_gem_shmem_purge() for Kunit tests. This is not an interface for regular drivers.
--- drivers/gpu/drm/drm_gem_shmem_helper.c | 15 +++++++++++++++ drivers/gpu/drm/tests/drm_gem_shmem_test.c | 4 +++- include/drm/drm_gem_shmem_helper.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_shmem_helper.c +15 -0
@@ -940,6 +940,21 @@ int drm_gem_shmem_madvise(struct drm_gem_shmem_object *shmem, int madv) return ret; }EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_madvise); + +int drm_gem_shmem_purge (struct drm_gem_shmem_object *shmem) +{ +struct drm_gem_object *obj = &shmem->base; +int ret; + + ret =dma_resv_lock_interruptible (obj->resv,NULL ); +if (ret) +return ret; +drm_gem_shmem_purge_locked (shmem); +dma_resv_unlock (obj->resv); + +return 0 ; +} +EXPORT_SYMBOL_IF_KUNIT (drm_gem_shmem_purge);#endif MODULE_DESCRIPTION ("DRM SHMEM memory-management helpers" );
drivers/gpu/drm/tests/drm_gem_shmem_test.c +3 -1
@@ -340,7 +340,9 @@ static void drm_gem_shmem_test_purge(struct kunit *test) ret =drm_gem_shmem_is_purgeable (shmem);KUNIT_EXPECT_TRUE (test, ret); -drm_gem_shmem_purge_locked (shmem); + ret =drm_gem_shmem_purge (shmem); +KUNIT_ASSERT_EQ (test, ret,0 ); +KUNIT_EXPECT_NULL (test, shmem->pages);KUNIT_EXPECT_NULL (test, shmem->sgt);KUNIT_EXPECT_EQ (test, shmem->madv,-1 );
include/drm/drm_gem_shmem_helper.h +1 -0
@@ -311,6 +311,7 @@ struct drm_gem_object *drm_gem_shmem_prime_import_no_map(struct drm_device *dev,int drm_gem_shmem_vmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map);void drm_gem_shmem_vunmap (struct drm_gem_shmem_object *shmem,struct iosys_map *map);int drm_gem_shmem_madvise (struct drm_gem_shmem_object *shmem,int madv); +int drm_gem_shmem_purge (struct drm_gem_shmem_object *shmem);#endif #endif /* __DRM_GEM_SHMEM_HELPER_H__ */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 524/844 drm/xe: Fix ggtt fb alignment
In reply to Sasha LevinFrom: Tvrtko Ursulin <[email protected]>
[ Upstream commit a61bf068f1fe359203f1af191cb523b77dc32752 ]
Pass the correct alignment from intel_fb_pin_to_ggtt() down to __xe_pin_fb_vma().
--- drivers/gpu/drm/xe/display/xe_fb_pin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +1 -1
@@ -378,7 +378,7 @@ intel_fb_pin_to_ggtt(const struct drm_framebuffer *fb, { *out_flags =0 ; -return __xe_pin_fb_vma (to_intel_framebuffer (fb), view, phys_alignment); +return __xe_pin_fb_vma (to_intel_framebuffer (fb), view, alignment); }void intel_fb_unpin_vma (struct i915_vma *vma,unsigned long flags)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 525/844 Revert "PCI: dw-rockchip: Don't wait for link since we can detect Link Up"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit fc6298086bfacaa7003b0bd1da4e4f42b29f7d77 ]
This reverts commit ec9fd499b9c60a187ac8d6414c3c343c77d32e42.
While this fake hotplugging was a nice idea, it has shown that this feature
does not handle PCIe switches correctly:pci_bus 0004:43: busn_res: can not insert [bus 43-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:43: busn_res: [bus 43-41] end is updated to 43pci_bus 0004:43: busn_res: can not insert [bus 43] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:00.0: devices behind bridge are unusable because [bus 43] cannot be assigned for them pci_bus 0004:44: busn_res: can not insert [bus 44-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:44: busn_res: [bus 44-41] end is updated to 44pci_bus 0004:44: busn_res: can not insert [bus 44] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:02.0: devices behind bridge are unusable because [bus 44] cannot be assigned for them pci_bus 0004:45: busn_res: can not insert [bus 45-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:45: busn_res: [bus 45-41] end is updated to 45pci_bus 0004:45: busn_res: can not insert [bus 45] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:06.0: devices behind bridge are unusable because [bus 45] cannot be assigned for them pci_bus 0004:46: busn_res: can not insert [bus 46-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:46: busn_res: [bus 46-41] end is updated to 46pci_bus 0004:46: busn_res: can not insert [bus 46] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:0e.0: devices behind bridge are unusable because [bus 46] cannot be assigned for them pci_bus 0004:42: busn_res: [bus 42-41] end is updated to 46pci_bus 0004:42: busn_res: can not insert [bus 42-46] under [bus 41] (conflicts with (null) [bus 41]) pci 0004:41:00.0: devices behind bridge are unusable because [bus 42-46] cannot be assigned for them pcieport 0004:40:00.0: bridge has subordinate 41 but max busn 46
During the initial scan, PCI core doesn't see the switch and since the Root Port is not hot plug capable, the secondary bus number gets assigned as the subordinate bus number. This means, the PCI core assumes that only one bus will appear behind the Root Port since the Root Port is not hot plug capable.
This works perfectly fine for PCIe endpoints connected to the Root Port, since they don't extend the bus. However, if a PCIe switch is connected, then there is a problem when the downstream busses starts showing up and the PCI core doesn't extend the subordinate bus number and bridge resources after initial scan during boot.
The long term plan is to migrate this driver to the upcoming pwrctrl APIs that are supposed to handle this problem elegantly.
--- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +0 -1
@@ -588,7 +588,6 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev, pp = &rockchip->pci.pp; pp->ops = &rockchip_pcie_host_ops; - pp->use_linkup_irq = true; ret =dw_pcie_host_init (pp);if (ret) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 526/844 PCI: dwc: Add L1 Substates context to ltssm_status of debugfs
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit 679ec639f29cbdaf36bd79bf3e98240fffa335ee ]
DWC core couldn't distinguish LTSSM state among L1.0, L1.1 and L1.2. But the vendor glue driver may implement additional logic to convey this information. So add two pseudo definitions for vendor glue drivers to translate their internal L1 Substates for debugfs to show.
Stable-dep-of: 180c3cfe3678 ("Revert "PCI: dw-rockchip: Enumerate endpoints based on dll_link_up IRQ"")
--- drivers/pci/controller/dwc/pcie-designware-debugfs.c | 2 ++ drivers/pci/controller/dwc/pcie-designware.h | 4 ++++ 2 files changed, 6 insertions(+)
drivers/pci/controller/dwc/pcie-designware-debugfs.c +2 -0
@@ -485,6 +485,8 @@ static const char *ltssm_status_string(enum dw_pcie_ltssm ltssm)DW_PCIE_LTSSM_NAME (DW_PCIE_LTSSM_RCVRY_EQ1 );DW_PCIE_LTSSM_NAME (DW_PCIE_LTSSM_RCVRY_EQ2 );DW_PCIE_LTSSM_NAME (DW_PCIE_LTSSM_RCVRY_EQ3 ); +DW_PCIE_LTSSM_NAME (DW_PCIE_LTSSM_L1_1 ); +DW_PCIE_LTSSM_NAME (DW_PCIE_LTSSM_L1_2 );default : str ="DW_PCIE_LTSSM_UNKNOWN" ;break ;
drivers/pci/controller/dwc/pcie-designware.h +4 -0
@@ -392,6 +392,10 @@ enum dw_pcie_ltssm {DW_PCIE_LTSSM_RCVRY_EQ2 =0x22 ,DW_PCIE_LTSSM_RCVRY_EQ3 =0x23 , +/* Vendor glue drivers provide pseudo L1 substates from get_ltssm() */ +DW_PCIE_LTSSM_L1_1 =0x141 , +DW_PCIE_LTSSM_L1_2 =0x142 , + DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF, };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 527/844 PCI: dw-rockchip: Change get_ltssm() to provide L1 Substates info
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit f994bb8f1c94726e0124356ccd31c3c23a8a69f4 ]
Rename rockchip_pcie_get_ltssm() to rockchip_pcie_get_ltssm_reg() and add rockchip_pcie_get_ltssm() to get_ltssm() callback in order to show the proper L1 Substates. The PCIE_CLIENT_LTSSM_STATUS[5:0] register returns the same LTSSM layout as enum dw_pcie_ltssm. So the driver just need to convey L1 PM Substates by returning the proper value defined in pcie-designware.h.
cat /sys/kernel/debug/dwc_pcie_a40000000.pcie/ltssm_status L1_2 (0x142)
Stable-dep-of: 180c3cfe3678 ("Revert "PCI: dw-rockchip: Enumerate endpoints based on dll_link_up IRQ"")
--- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +25 -4
@@ -68,6 +68,11 @@#define PCIE_CLKREQ_NOT_READY FIELD_PREP_WM16(BIT(0), 0)#define PCIE_CLKREQ_PULL_DOWN FIELD_PREP_WM16(GENMASK(13, 12), 1) +/* RASDES TBA information */ +#define PCIE_CLIENT_CDM_RASDES_TBA_INFO_CMN 0x154 +#define PCIE_CLIENT_CDM_RASDES_TBA_L1_1 BIT(4) +#define PCIE_CLIENT_CDM_RASDES_TBA_L1_2 BIT(5) +/* Hot Reset Control Register */ #define PCIE_CLIENT_HOT_RESET_CTRL 0x180#define PCIE_LTSSM_APP_DLY2_EN BIT(1)
@@ -183,11 +188,26 @@ static int rockchip_pcie_init_irq_domain(struct rockchip_pcie *rockchip)return 0 ; } -static u32 rockchip_pcie_get_ltssm (struct rockchip_pcie *rockchip) +static u32 rockchip_pcie_get_ltssm_reg (struct rockchip_pcie *rockchip) {return rockchip_pcie_readl_apb (rockchip,PCIE_CLIENT_LTSSM_STATUS ); } +static enum dw_pcie_ltssm rockchip_pcie_get_ltssm (struct dw_pcie *pci) +{ +struct rockchip_pcie *rockchip =to_rockchip_pcie (pci); +u32 val =rockchip_pcie_readl_apb (rockchip, +PCIE_CLIENT_CDM_RASDES_TBA_INFO_CMN ); + +if (val &PCIE_CLIENT_CDM_RASDES_TBA_L1_1 ) +return DW_PCIE_LTSSM_L1_1 ; + +if (val &PCIE_CLIENT_CDM_RASDES_TBA_L1_2 ) +return DW_PCIE_LTSSM_L1_2 ; + +return rockchip_pcie_get_ltssm_reg (rockchip) &PCIE_LTSSM_STATUS_MASK ; +} +static void rockchip_pcie_enable_ltssm (struct rockchip_pcie *rockchip) { rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
@@ -203,7 +223,7 @@ static void rockchip_pcie_disable_ltssm(struct rockchip_pcie *rockchip)static bool rockchip_pcie_link_up (struct dw_pcie *pci) {struct rockchip_pcie *rockchip =to_rockchip_pcie (pci); -u32 val =rockchip_pcie_get_ltssm (rockchip); +u32 val =rockchip_pcie_get_ltssm_reg (rockchip);return FIELD_GET (PCIE_LINKUP_MASK , val) ==PCIE_LINKUP ; }
@@ -493,6 +513,7 @@ static const struct dw_pcie_ops dw_pcie_ops = { .link_up = rockchip_pcie_link_up, .start_link = rockchip_pcie_start_link, .stop_link = rockchip_pcie_stop_link, + .get_ltssm = rockchip_pcie_get_ltssm, };static irqreturn_t rockchip_pcie_rc_sys_irq_thread (int irq,void *arg)
@@ -507,7 +528,7 @@ static irqreturn_t rockchip_pcie_rc_sys_irq_thread(int irq, void *arg)rockchip_pcie_writel_apb (rockchip, reg,PCIE_CLIENT_INTR_STATUS_MISC );dev_dbg (dev,"PCIE_CLIENT_INTR_STATUS_MISC: %#x\n" , reg); -dev_dbg (dev,"LTSSM_STATUS: %#x\n" ,rockchip_pcie_get_ltssm (rockchip)); +dev_dbg (dev,"LTSSM_STATUS: %#x\n" ,rockchip_pcie_get_ltssm_reg (rockchip));if (reg &PCIE_RDLH_LINK_UP_CHGED ) {if (rockchip_pcie_link_up (pci)) {
@@ -534,7 +555,7 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)rockchip_pcie_writel_apb (rockchip, reg,PCIE_CLIENT_INTR_STATUS_MISC );dev_dbg (dev,"PCIE_CLIENT_INTR_STATUS_MISC: %#x\n" , reg); -dev_dbg (dev,"LTSSM_STATUS: %#x\n" ,rockchip_pcie_get_ltssm (rockchip)); +dev_dbg (dev,"LTSSM_STATUS: %#x\n" ,rockchip_pcie_get_ltssm_reg (rockchip));if (reg &PCIE_LINK_REQ_RST_NOT_INT ) {dev_dbg (dev,"hot reset or link-down reset\n" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 528/844 Revert "PCI: dw-rockchip: Enumerate endpoints based on dll_link_up IRQ"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 180c3cfe36786d261a55da52a161f9e279b19a6f ]
This reverts commit 0e0b45ab5d770a748487ba0ae8f77d1fb0f0de3e.
While this fake hotplugging was a nice idea, it has shown that this feature
does not handle PCIe switches correctly:pci_bus 0004:43: busn_res: can not insert [bus 43-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:43: busn_res: [bus 43-41] end is updated to 43pci_bus 0004:43: busn_res: can not insert [bus 43] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:00.0: devices behind bridge are unusable because [bus 43] cannot be assigned for them pci_bus 0004:44: busn_res: can not insert [bus 44-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:44: busn_res: [bus 44-41] end is updated to 44pci_bus 0004:44: busn_res: can not insert [bus 44] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:02.0: devices behind bridge are unusable because [bus 44] cannot be assigned for them pci_bus 0004:45: busn_res: can not insert [bus 45-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:45: busn_res: [bus 45-41] end is updated to 45pci_bus 0004:45: busn_res: can not insert [bus 45] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:06.0: devices behind bridge are unusable because [bus 45] cannot be assigned for them pci_bus 0004:46: busn_res: can not insert [bus 46-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:46: busn_res: [bus 46-41] end is updated to 46pci_bus 0004:46: busn_res: can not insert [bus 46] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:0e.0: devices behind bridge are unusable because [bus 46] cannot be assigned for them pci_bus 0004:42: busn_res: [bus 42-41] end is updated to 46pci_bus 0004:42: busn_res: can not insert [bus 42-46] under [bus 41] (conflicts with (null) [bus 41]) pci 0004:41:00.0: devices behind bridge are unusable because [bus 42-46] cannot be assigned for them pcieport 0004:40:00.0: bridge has subordinate 41 but max busn 46
During the initial scan, PCI core doesn't see the switch and since the Root Port is not hot plug capable, the secondary bus number gets assigned as the subordinate bus number. This means, the PCI core assumes that only one bus will appear behind the Root Port since the Root Port is not hot plug capable.
This works perfectly fine for PCIe endpoints connected to the Root Port, since they don't extend the bus. However, if a PCIe switch is connected, then there is a problem when the downstream busses starts showing up and the PCI core doesn't extend the subordinate bus number and bridge resources after initial scan during boot.
The long term plan is to migrate this driver to the upcoming pwrctrl APIs that are supposed to handle this problem elegantly.
--- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 59 +------------------ 1 file changed, 3 insertions(+), 56 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +3 -56
@@ -516,34 +516,6 @@ static const struct dw_pcie_ops dw_pcie_ops = { .get_ltssm = rockchip_pcie_get_ltssm, }; -static irqreturn_t rockchip_pcie_rc_sys_irq_thread (int irq,void *arg) -{ -struct rockchip_pcie *rockchip = arg; -struct dw_pcie *pci = &rockchip->pci; -struct dw_pcie_rp *pp = &pci->pp; -struct device *dev = pci->dev; -u32 reg; - - reg =rockchip_pcie_readl_apb (rockchip,PCIE_CLIENT_INTR_STATUS_MISC ); -rockchip_pcie_writel_apb (rockchip, reg,PCIE_CLIENT_INTR_STATUS_MISC ); - -dev_dbg (dev,"PCIE_CLIENT_INTR_STATUS_MISC: %#x\n" , reg); -dev_dbg (dev,"LTSSM_STATUS: %#x\n" ,rockchip_pcie_get_ltssm_reg (rockchip)); - -if (reg &PCIE_RDLH_LINK_UP_CHGED ) { -if (rockchip_pcie_link_up (pci)) { -msleep (PCIE_RESET_CONFIG_WAIT_MS ); -dev_dbg (dev,"Received Link up event. Starting enumeration!\n" ); -/* Rescan the bus to enumerate endpoint devices */ -pci_lock_rescan_remove (); -pci_rescan_bus (pp->bridge->bus); -pci_unlock_rescan_remove (); - } - } - -return IRQ_HANDLED ; -} -static irqreturn_t rockchip_pcie_ep_sys_irq_thread (int irq,void *arg) {struct rockchip_pcie *rockchip = arg;
@@ -576,29 +548,14 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)return IRQ_HANDLED ; } -static int rockchip_pcie_configure_rc (struct platform_device *pdev, -struct rockchip_pcie *rockchip) +static int rockchip_pcie_configure_rc (struct rockchip_pcie *rockchip) { -struct device *dev = &pdev->dev;struct dw_pcie_rp *pp; -int irq, ret;u32 val;if (!IS_ENABLED (CONFIG_PCIE_ROCKCHIP_DW_HOST ))return -ENODEV ; - irq =platform_get_irq_byname (pdev,"sys" ); -if (irq <0 ) -return irq; - - ret =devm_request_threaded_irq (dev, irq,NULL , - rockchip_pcie_rc_sys_irq_thread, -IRQF_ONESHOT ,"pcie-sys-rc" , rockchip); -if (ret) { -dev_err (dev,"failed to request PCIe sys IRQ\n" ); -return ret; - } -/* LTSSM enable control mode */ val =FIELD_PREP_WM16 (PCIE_LTSSM_ENABLE_ENHANCE ,1 );rockchip_pcie_writel_apb (rockchip, val,PCIE_CLIENT_HOT_RESET_CTRL );
@@ -610,17 +567,7 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev, pp = &rockchip->pci.pp; pp->ops = &rockchip_pcie_host_ops; - ret =dw_pcie_host_init (pp); -if (ret) { -dev_err (dev,"failed to initialize host\n" ); -return ret; - } - -/* unmask DLL up/down indicator */ - val =FIELD_PREP_WM16 (PCIE_RDLH_LINK_UP_CHGED ,0 ); -rockchip_pcie_writel_apb (rockchip, val,PCIE_CLIENT_INTR_MASK_MISC ); - -return ret; +return dw_pcie_host_init (pp); } static int rockchip_pcie_configure_ep(struct platform_device *pdev,
@@ -739,7 +686,7 @@ static int rockchip_pcie_probe(struct platform_device *pdev)switch (data->mode) {case DW_PCIE_RC_TYPE : - ret =rockchip_pcie_configure_rc (pdev, rockchip); + ret =rockchip_pcie_configure_rc (rockchip);if (ret) goto deinit_clk;break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 529/844 Revert "PCI: qcom: Don't wait for link if we can detect Link Up"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit e9ce5b3804436301ab343bc14203a4c14b336d1b ]
This reverts commit 36971d6c5a9a134c15760ae9fd13c6d5f9a36abb.
While this fake hotplugging was a nice idea, it has shown that this feature
does not handle PCIe switches correctly:pci_bus 0004:43: busn_res: can not insert [bus 43-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:43: busn_res: [bus 43-41] end is updated to 43pci_bus 0004:43: busn_res: can not insert [bus 43] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:00.0: devices behind bridge are unusable because [bus 43] cannot be assigned for them pci_bus 0004:44: busn_res: can not insert [bus 44-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:44: busn_res: [bus 44-41] end is updated to 44pci_bus 0004:44: busn_res: can not insert [bus 44] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:02.0: devices behind bridge are unusable because [bus 44] cannot be assigned for them pci_bus 0004:45: busn_res: can not insert [bus 45-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:45: busn_res: [bus 45-41] end is updated to 45pci_bus 0004:45: busn_res: can not insert [bus 45] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:06.0: devices behind bridge are unusable because [bus 45] cannot be assigned for them pci_bus 0004:46: busn_res: can not insert [bus 46-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:46: busn_res: [bus 46-41] end is updated to 46pci_bus 0004:46: busn_res: can not insert [bus 46] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:0e.0: devices behind bridge are unusable because [bus 46] cannot be assigned for them pci_bus 0004:42: busn_res: [bus 42-41] end is updated to 46pci_bus 0004:42: busn_res: can not insert [bus 42-46] under [bus 41] (conflicts with (null) [bus 41]) pci 0004:41:00.0: devices behind bridge are unusable because [bus 42-46] cannot be assigned for them pcieport 0004:40:00.0: bridge has subordinate 41 but max busn 46
During the initial scan, PCI core doesn't see the switch and since the Root Port is not hot plug capable, the secondary bus number gets assigned as the subordinate bus number. This means, the PCI core assumes that only one bus will appear behind the Root Port since the Root Port is not hot plug capable.
This works perfectly fine for PCIe endpoints connected to the Root Port, since they don't extend the bus. However, if a PCIe switch is connected, then there is a problem when the downstream busses starts showing up and the PCI core doesn't extend the subordinate bus number and bridge resources after initial scan during boot.
The long term plan is to migrate this driver to the upcoming pwrctrl APIs that are supposed to handle this problem elegantly.
--- drivers/pci/controller/dwc/pcie-qcom.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +1 -4
@@ -1957,10 +1957,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)platform_set_drvdata (pdev, pcie); - irq =platform_get_irq_byname_optional (pdev,"global" ); -if (irq >0 ) - pp->use_linkup_irq = true; - ret =dw_pcie_host_init (pp);if (ret) {dev_err (dev,"cannot initialize host\n" );
@@ -1974,6 +1970,7 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_host_deinit; } + irq =platform_get_irq_byname_optional (pdev,"global" );if (irq >0 ) { ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, qcom_pcie_global_irq_thread,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 530/844 Revert "PCI: qcom: Enable MSI interrupts together with Link up if 'Global IRQ' is supported"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 7ebdefb87942073679e56cfbc5a72e8fc5441bfc ]
This reverts commit ba4a2e2317b9faeca9193ed6d3193ddc3cf2aba3.
Since the Link up IRQ support is going away, revert the MSI logic that got added for it too.
--- drivers/pci/controller/dwc/pcie-qcom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +1 -3
@@ -136,7 +136,6 @@/* PARF_INT_ALL_{STATUS/CLEAR/MASK} register fields */ #define PARF_INT_ALL_LINK_UP BIT(13) -#define PARF_INT_MSI_DEV_0_7 GENMASK(30, 23)/* PARF_NO_SNOOP_OVERRIDE register fields */ #define WR_NO_SNOOP_OVERRIDE_EN BIT(1)
@@ -1981,8 +1980,7 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_host_deinit; } -writel_relaxed (PARF_INT_ALL_LINK_UP |PARF_INT_MSI_DEV_0_7 , - pcie->parf +PARF_INT_ALL_MASK ); +writel_relaxed (PARF_INT_ALL_LINK_UP , pcie->parf +PARF_INT_ALL_MASK ); }qcom_pcie_icc_opp_update (pcie);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 531/844 Revert "PCI: qcom: Enumerate endpoints based on Link up event in 'global_irq' interrupt"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 9a9793b55854422652ea92625e48277c4651c0fd ]
This reverts commit 4581403f67929d02c197cb187c4e1e811c9e762a.
While this fake hotplugging was a nice idea, it has shown that this feature
does not handle PCIe switches correctly:pci_bus 0004:43: busn_res: can not insert [bus 43-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:43: busn_res: [bus 43-41] end is updated to 43pci_bus 0004:43: busn_res: can not insert [bus 43] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:00.0: devices behind bridge are unusable because [bus 43] cannot be assigned for them pci_bus 0004:44: busn_res: can not insert [bus 44-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:44: busn_res: [bus 44-41] end is updated to 44pci_bus 0004:44: busn_res: can not insert [bus 44] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:02.0: devices behind bridge are unusable because [bus 44] cannot be assigned for them pci_bus 0004:45: busn_res: can not insert [bus 45-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:45: busn_res: [bus 45-41] end is updated to 45pci_bus 0004:45: busn_res: can not insert [bus 45] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:06.0: devices behind bridge are unusable because [bus 45] cannot be assigned for them pci_bus 0004:46: busn_res: can not insert [bus 46-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:46: busn_res: [bus 46-41] end is updated to 46pci_bus 0004:46: busn_res: can not insert [bus 46] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:0e.0: devices behind bridge are unusable because [bus 46] cannot be assigned for them pci_bus 0004:42: busn_res: [bus 42-41] end is updated to 46pci_bus 0004:42: busn_res: can not insert [bus 42-46] under [bus 41] (conflicts with (null) [bus 41]) pci 0004:41:00.0: devices behind bridge are unusable because [bus 42-46] cannot be assigned for them pcieport 0004:40:00.0: bridge has subordinate 41 but max busn 46
During the initial scan, PCI core doesn't see the switch and since the Root Port is not hot plug capable, the secondary bus number gets assigned as the subordinate bus number. This means, the PCI core assumes that only one bus will appear behind the Root Port since the Root Port is not hot plug capable.
This works perfectly fine for PCIe endpoints connected to the Root Port, since they don't extend the bus. However, if a PCIe switch is connected, then there is a problem when the downstream busses starts showing up and the PCI core doesn't extend the subordinate bus number and bridge resources after initial scan during boot.
The long term plan is to migrate this driver to the upcoming pwrctrl APIs that are supposed to handle this problem elegantly.
--- drivers/pci/controller/dwc/pcie-qcom.c | 58 +------------------------- 1 file changed, 1 insertion(+), 57 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +1 -57
@@ -55,9 +55,6 @@#define PARF_AXI_MSTR_WR_ADDR_HALT_V2 0x1a8#define PARF_Q2A_FLUSH 0x1ac#define PARF_LTSSM 0x1b0 -#define PARF_INT_ALL_STATUS 0x224 -#define PARF_INT_ALL_CLEAR 0x228 -#define PARF_INT_ALL_MASK 0x22c#define PARF_SID_OFFSET 0x234#define PARF_BDF_TRANSLATE_CFG 0x24c#define PARF_DBI_BASE_ADDR_V2 0x350
@@ -134,9 +131,6 @@/* PARF_LTSSM register fields */ #define LTSSM_EN BIT(8) -/* PARF_INT_ALL_{STATUS/CLEAR/MASK} register fields */ -#define PARF_INT_ALL_LINK_UP BIT(13) -/* PARF_NO_SNOOP_OVERRIDE register fields */ #define WR_NO_SNOOP_OVERRIDE_EN BIT(1)#define RD_NO_SNOOP_OVERRIDE_EN BIT(3)
@@ -1634,32 +1628,6 @@ static void qcom_pcie_init_debugfs(struct qcom_pcie *pcie) qcom_pcie_link_transition_count); } -static irqreturn_t qcom_pcie_global_irq_thread (int irq,void *data) -{ -struct qcom_pcie *pcie = data; -struct dw_pcie_rp *pp = &pcie->pci->pp; -struct device *dev = pcie->pci->dev; -u32 status =readl_relaxed (pcie->parf +PARF_INT_ALL_STATUS ); - -writel_relaxed (status, pcie->parf +PARF_INT_ALL_CLEAR ); - -if (FIELD_GET (PARF_INT_ALL_LINK_UP , status)) { -msleep (PCIE_RESET_CONFIG_WAIT_MS ); -dev_dbg (dev,"Received Link up event. Starting enumeration!\n" ); -/* Rescan the bus to enumerate endpoint devices */ -pci_lock_rescan_remove (); -pci_rescan_bus (pp->bridge->bus); -pci_unlock_rescan_remove (); - -qcom_pcie_icc_opp_update (pcie); - }else { -dev_WARN_ONCE (dev,1 ,"Received unknown event. INT_STATUS: 0x%08x\n" , - status); - } - -return IRQ_HANDLED ; -} -static void qcom_pci_free_msi (void *ptr) {struct dw_pcie_rp *pp = (struct dw_pcie_rp *)ptr;
@@ -1804,8 +1772,7 @@ static int qcom_pcie_probe(struct platform_device *pdev)struct dw_pcie_rp *pp;struct resource *res;struct dw_pcie *pci; -int ret, irq; -char *name; +int ret; pcie_cfg =of_device_get_match_data (dev);if (!pcie_cfg) {
@@ -1962,27 +1929,6 @@ static int qcom_pcie_probe(struct platform_device *pdev) goto err_phy_exit; } - name =devm_kasprintf (dev,GFP_KERNEL ,"qcom_pcie_global_irq%d" , -pci_domain_nr (pp->bridge->bus)); -if (!name) { - ret = -ENOMEM ; - goto err_host_deinit; - } - - irq =platform_get_irq_byname_optional (pdev,"global" ); -if (irq >0 ) { - ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , - qcom_pcie_global_irq_thread, -IRQF_ONESHOT , name, pcie); -if (ret) { -dev_err_probe (&pdev->dev, ret, -"Failed to request Global IRQ\n" ); - goto err_host_deinit; - } - -writel_relaxed (PARF_INT_ALL_LINK_UP , pcie->parf +PARF_INT_ALL_MASK ); - } -qcom_pcie_icc_opp_update (pcie);if (pcie->mhi)
@@ -1990,8 +1936,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)return 0 ; -err_host_deinit: -dw_pcie_host_deinit (pp); err_phy_exit:list_for_each_entry_safe (port, tmp, &pcie->ports, list) {phy_exit (port->phy);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 532/844 Revert "PCI: dwc: Don't wait for link up if driver can detect Link Up event"
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 142d5869f6eec3110adda0ad2d931f5b3c22371d ]
This reverts commit 8d3bf19f1b585a3cc0027f508b64c33484db8d0d.
While this fake hotplugging was a nice idea, it has shown that this feature
does not handle PCIe switches correctly:pci_bus 0004:43: busn_res: can not insert [bus 43-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:43: busn_res: [bus 43-41] end is updated to 43pci_bus 0004:43: busn_res: can not insert [bus 43] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:00.0: devices behind bridge are unusable because [bus 43] cannot be assigned for them pci_bus 0004:44: busn_res: can not insert [bus 44-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:44: busn_res: [bus 44-41] end is updated to 44pci_bus 0004:44: busn_res: can not insert [bus 44] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:02.0: devices behind bridge are unusable because [bus 44] cannot be assigned for them pci_bus 0004:45: busn_res: can not insert [bus 45-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:45: busn_res: [bus 45-41] end is updated to 45pci_bus 0004:45: busn_res: can not insert [bus 45] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:06.0: devices behind bridge are unusable because [bus 45] cannot be assigned for them pci_bus 0004:46: busn_res: can not insert [bus 46-41] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci_bus 0004:46: busn_res: [bus 46-41] end is updated to 46pci_bus 0004:46: busn_res: can not insert [bus 46] under [bus 42-41] (conflicts with (null) [bus 42-41]) pci 0004:42:0e.0: devices behind bridge are unusable because [bus 46] cannot be assigned for them pci_bus 0004:42: busn_res: [bus 42-41] end is updated to 46pci_bus 0004:42: busn_res: can not insert [bus 42-46] under [bus 41] (conflicts with (null) [bus 41]) pci 0004:41:00.0: devices behind bridge are unusable because [bus 42-46] cannot be assigned for them pcieport 0004:40:00.0: bridge has subordinate 41 but max busn 46
During the initial scan, PCI core doesn't see the switch and since the Root Port is not hot plug capable, the secondary bus number gets assigned as the subordinate bus number. This means, the PCI core assumes that only one bus will appear behind the Root Port since the Root Port is not hot plug capable.
This works perfectly fine for PCIe endpoints connected to the Root Port, since they don't extend the bus. However, if a PCIe switch is connected, then there is a problem when the downstream busses starts showing up and the PCI core doesn't extend the subordinate bus number and bridge resources after initial scan during boot.
So revert the change that skipped dw_pcie_wait_for_link() if the Link up IRQ was used by a vendor glue driver.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 10 ++-------- drivers/pci/controller/dwc/pcie-designware.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +2 -8
@@ -665,14 +665,8 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) goto err_remove_edma; } -/* -* Note: Skip the link up delay only when a Link Up IRQ is present. -* If there is no Link Up IRQ, we should not bypass the delay -* because that would require users to manually rescan for devices. -*/ -if (!pp->use_linkup_irq) -/* Ignore errors, the link may come up later */ -dw_pcie_wait_for_link (pci); +/* Ignore errors, the link may come up later */ +dw_pcie_wait_for_link (pci); ret =pci_host_probe (bridge);if (ret)
drivers/pci/controller/dwc/pcie-designware.h +0 -1
@@ -442,7 +442,6 @@ struct dw_pcie_rp {bool use_atu_msg;int msg_atu_index;struct resource *msg_res; -bool use_linkup_irq;struct pci_eq_presets presets;struct pci_config_window *cfg;bool ecam_enabled;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 533/844 PCI: Use resource_set_range() that correctly sets ->end
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 11721c45a8266a9d0c9684153d20e37159465f96 ]
__pci_read_base() sets resource start and end addresses when resource is larger than 4G but pci_bus_addr_t or resource_size_t are not capable of representing 64-bit PCI addresses. This creates a problematic resource that has non-zero flags but the start and end addresses do not yield to resource size of 0 but 1.
Replace custom resource addresses setup with resource_set_range() that correctly sets end address as -1 which results in resource_size() returning 0.
For consistency, also use resource_set_range() in the other branch that does size based resource setup.
--- drivers/pci/probe.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/pci/probe.c +2 -4
@@ -287,8 +287,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,if ((sizeof (pci_bus_addr_t) <8 ||sizeof (resource_size_t) <8 ) && sz64 >0x100000000ULL ) { res->flags |=IORESOURCE_UNSET |IORESOURCE_DISABLED ; - res->start =0 ; - res->end =0 ; +resource_set_range (res,0 ,0 );pci_err (dev,"%s: can't handle BAR larger than 4GB (size %#010llx)\n" , res_name, (unsigned long long )sz64); goto out;
@@ -297,8 +296,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,if ((sizeof (pci_bus_addr_t) <8 ) && l) {/* Above 32-bit boundary; try to reallocate */ res->flags |=IORESOURCE_UNSET ; - res->start =0 ; - res->end = sz64 -1 ; +resource_set_range (res,0 , sz64);pci_info (dev,"%s: can't handle BAR above 4GB (bus address %#010llx)\n" , res_name, (unsigned long long )l64); goto out;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 534/844 net: qrtr: Drop the MHI auto_queue feature for IPCR DL channels
In reply to Sasha LevinFrom: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 51731792a25cb312ca94cdccfa139eb46de1b2ef ]
MHI stack offers the 'auto_queue' feature, which allows the MHI stack to auto queue the buffers for the RX path (DL channel). Though this feature simplifies the client driver design, it introduces race between the client drivers and the MHI stack. For instance, with auto_queue, the 'dl_callback' for the DL channel may get called before the client driver is fully probed. This means, by the time the dl_callback gets called, the client driver's structures might not be initialized, leading to NULL ptr dereference.
Currently, the drivers have to workaround this issue by initializing the internal structures before calling mhi_prepare_for_transfer_autoqueue(). But even so, there is a chance that the client driver's internal code path may call the MHI queue APIs before mhi_prepare_for_transfer_autoqueue() is called, leading to similar NULL ptr dereference. This issue has been reported on the Qcom X1E80100 CRD machines affecting boot.
So to properly fix all these races, drop the MHI 'auto_queue' feature altogether and let the client driver (QRTR) manage the RX buffers manually. In the QRTR driver, queue the RX buffers based on the ring length during probe and recycle the buffers in 'dl_callback' once they are consumed. This also warrants removing the setting of 'auto_queue' flag from controller drivers.
Currently, this 'auto_queue' feature is only enabled for IPCR DL channel. So only the QRTR client driver requires the modification.
--- drivers/accel/qaic/mhi_controller.c | 44 ----------------- drivers/bus/mhi/host/pci_generic.c | 20 +------- drivers/net/wireless/ath/ath11k/mhi.c | 4 -- drivers/net/wireless/ath/ath12k/mhi.c | 4 -- net/qrtr/mhi.c | 69 ++++++++++++++++++++++----- 5 files changed, 60 insertions(+), 81 deletions(-)
drivers/accel/qaic/mhi_controller.c +0 -44
@@ -39,7 +39,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -55,7 +54,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -71,7 +69,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -87,7 +84,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -103,7 +99,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -119,7 +114,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -135,7 +129,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -151,7 +144,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -167,7 +159,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -183,7 +174,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -199,7 +189,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -215,7 +204,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -231,7 +219,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -247,7 +234,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -263,7 +249,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -279,7 +264,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -295,7 +279,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -311,7 +294,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -327,7 +309,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -343,7 +324,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -359,7 +339,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -375,7 +354,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -391,7 +369,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -407,7 +384,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -423,7 +399,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -439,7 +414,6 @@ static const struct mhi_channel_config aic100_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, .wake_capable = false, }, };
@@ -458,7 +432,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -474,7 +447,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -490,7 +462,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -506,7 +477,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -522,7 +492,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -538,7 +507,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -554,7 +522,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -570,7 +537,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -586,7 +552,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -602,7 +567,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -618,7 +582,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -634,7 +597,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -650,7 +612,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -666,7 +627,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -682,7 +642,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -698,7 +657,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -714,7 +672,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, .wake_capable = false, }, {
@@ -730,7 +687,6 @@ static const struct mhi_channel_config aic200_channels[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, .wake_capable = false, }, };
drivers/bus/mhi/host/pci_generic.c +2 -18
@@ -94,22 +94,6 @@ struct mhi_pci_dev_info { .doorbell_mode_switch = false, \ } -#define MHI_CHANNEL_CONFIG_DL_AUTOQUEUE (ch_num, ch_name, el_count, ev_ring) \ - { \ - .num = ch_num, \ - .name = ch_name, \ - .num_elements = el_count, \ - .event_ring = ev_ring, \ - .dir = DMA_FROM_DEVICE, \ - .ee_mask = BIT(MHI_EE_AMSS), \ - .pollcfg = 0, \ - .doorbell = MHI_DB_BRST_DISABLE, \ - .lpm_notify = false, \ - .offload_channel = false, \ - .doorbell_mode_switch = false, \ - .auto_queue = true, \ - } -#define MHI_EVENT_CONFIG_CTRL (ev_ring, el_count) \ { \ .num_elements = el_count, \
@@ -329,7 +313,7 @@ static const struct mhi_channel_config modem_qcom_v1_mhi_channels[] = {MHI_CHANNEL_CONFIG_UL (14 ,"QMI" ,4 ,0 ),MHI_CHANNEL_CONFIG_DL (15 ,"QMI" ,4 ,0 ),MHI_CHANNEL_CONFIG_UL (20 ,"IPCR" ,8 ,0 ), -MHI_CHANNEL_CONFIG_DL_AUTOQUEUE (21 ,"IPCR" ,8 ,0 ), +MHI_CHANNEL_CONFIG_DL (21 ,"IPCR" ,8 ,0 ),MHI_CHANNEL_CONFIG_UL_FP (34 ,"FIREHOSE" ,32 ,0 ),MHI_CHANNEL_CONFIG_DL_FP (35 ,"FIREHOSE" ,32 ,0 ), MHI_CHANNEL_CONFIG_UL(46, "IP_SW0", 64, 2),
@@ -762,7 +746,7 @@ static const struct mhi_channel_config mhi_telit_fn980_hw_v1_channels[] = {MHI_CHANNEL_CONFIG_UL (14 ,"QMI" ,32 ,0 ),MHI_CHANNEL_CONFIG_DL (15 ,"QMI" ,32 ,0 ),MHI_CHANNEL_CONFIG_UL (20 ,"IPCR" ,16 ,0 ), -MHI_CHANNEL_CONFIG_DL_AUTOQUEUE (21 ,"IPCR" ,16 ,0 ), +MHI_CHANNEL_CONFIG_DL (21 ,"IPCR" ,16 ,0 ),MHI_CHANNEL_CONFIG_HW_UL (100 ,"IP_HW0" ,128 ,1 ), MHI_CHANNEL_CONFIG_HW_DL(101, "IP_HW0", 128, 2), };
drivers/net/wireless/ath/ath11k/mhi.c +0 -4
@@ -34,7 +34,6 @@ static const struct mhi_channel_config ath11k_mhi_channels_qca6390[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, }, { .num = 21,
@@ -48,7 +47,6 @@ static const struct mhi_channel_config ath11k_mhi_channels_qca6390[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, }, };
@@ -99,7 +97,6 @@ static const struct mhi_channel_config ath11k_mhi_channels_qcn9074[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, }, { .num = 21,
@@ -113,7 +110,6 @@ static const struct mhi_channel_config ath11k_mhi_channels_qcn9074[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, }, };
drivers/net/wireless/ath/ath12k/mhi.c +0 -4
@@ -31,7 +31,6 @@ static const struct mhi_channel_config ath12k_mhi_channels_qcn9274[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, }, { .num = 21,
@@ -45,7 +44,6 @@ static const struct mhi_channel_config ath12k_mhi_channels_qcn9274[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, }, };
@@ -96,7 +94,6 @@ static const struct mhi_channel_config ath12k_mhi_channels_wcn7850[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = false, }, { .num = 21,
@@ -110,7 +107,6 @@ static const struct mhi_channel_config ath12k_mhi_channels_wcn7850[] = { .lpm_notify = false, .offload_channel = false, .doorbell_mode_switch = false, - .auto_queue = true, }, };
net/qrtr/mhi.c +58 -11
108 lines not on this page · raw message
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 535/844 phy: qcom: edp: Make the number of clocks flexible
In reply to Sasha LevinFrom: Abel Vesa <[email protected]>
[ Upstream commit 7d51b709262c5aa31d2b9cd31444112c1b2dae03 ]
On X Elite, the DP PHY needs another clock called ref, while all other platforms do not.
The current X Elite devices supported upstream work fine without this clock, because the boot firmware leaves this clock enabled. But we should not rely on that. Also, even though this change breaks the ABI, it is needed in order to make the driver disables this clock along with the other ones, for a proper bring-down of the entire PHY.
So in order to handle these clocks on different platforms, make the driver get all the clocks regardless of how many there are provided.
--- drivers/phy/qualcomm/phy-qcom-edp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/phy/qualcomm/phy-qcom-edp.c +8 -8
@@ -103,7 +103,9 @@ struct qcom_edp {struct phy_configure_opts_dp dp_opts; -struct clk_bulk_data clks[2 ]; +struct clk_bulk_data *clks; +int num_clks; +struct regulator_bulk_data supplies[2 ];bool is_edp;
@@ -218,7 +220,7 @@ static int qcom_edp_phy_init(struct phy *phy)if (ret)return ret; - ret =clk_bulk_prepare_enable (ARRAY_SIZE (edp->clks), edp->clks); + ret =clk_bulk_prepare_enable (edp->num_clks, edp->clks);if (ret) goto out_disable_supplies;
@@ -885,7 +887,7 @@ static int qcom_edp_phy_exit(struct phy *phy) {struct qcom_edp *edp =phy_get_drvdata (phy); -clk_bulk_disable_unprepare (ARRAY_SIZE (edp->clks), edp->clks); +clk_bulk_disable_unprepare (edp->num_clks, edp->clks);regulator_bulk_disable (ARRAY_SIZE (edp->supplies), edp->supplies);return 0 ;
@@ -1092,11 +1094,9 @@ static int qcom_edp_phy_probe(struct platform_device *pdev)if (IS_ERR (edp->pll))return PTR_ERR (edp->pll); - edp->clks[0 ].id ="aux" ; - edp->clks[1 ].id ="cfg_ahb" ; - ret =devm_clk_bulk_get (dev,ARRAY_SIZE (edp->clks), edp->clks); -if (ret) -return ret; + edp->num_clks =devm_clk_bulk_get_all (dev, &edp->clks); +if (edp->num_clks <0 ) +return dev_err_probe (dev, edp->num_clks,"failed to get clocks\n" ); edp->supplies[0 ].supply ="vdda-phy" ; edp->supplies[1 ].supply ="vdda-pll" ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 536/844 arm64: dts: qcom: sdm630: Add missing MDSS reset
In reply to Sasha LevinFrom: Alexey Minnekhanov <[email protected]>
[ Upstream commit 0c1d1591f898d54eaa4c8f2a1535ab21bf4e42e4 ]
If the OS does not support recovering the state left by the bootloader it needs a way to reset display hardware, so that it can start from a clean state. Add a reference to the relevant reset.
It fixes display init issue appeared in Linux v6.17: without reset device boots into black screen and you need to turn display off/on to "fix" it. Also sometimes it can boot into solid blue color with these messages in kernel log:
hw recovery is not complete for ctl:2 [drm:dpu_encoder_phys_vid_prepare_for_kickoff:569] [dpu error]enc33
intf1 ctl 2 reset failure: -22
[drm:dpu_encoder_frame_done_timeout:2727] [dpu error]enc33 frame
done timeout
--- arch/arm64/boot/dts/qcom/sdm630.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sdm630.dtsi +1 -0
@@ -1563,6 +1563,7 @@ mdss: display-subsystem@c900000 { reg-names = "mdss_phys", "vbif_phys"; power-domains = <&mmcc MDSS_GDSC>; + resets = <&mmcc MDSS_BCR>; clocks = <&mmcc MDSS_AHB_CLK>, <&mmcc MDSS_AXI_CLK>,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 537/844 dm-verity: correctly handle dm_bufio_client_create() failure
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
[ Upstream commit 119f4f04186fa4f33ee6bd39af145cdaff1ff17f ]
If either of the calls to dm_bufio_client_create() in verity_fec_ctr() fails, then dm_bufio_client_destroy() is later called with an ERR_PTR() argument. That causes a crash. Fix this.
--- drivers/md/dm-verity-fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-verity-fec.c +2 -2
@@ -534,9 +534,9 @@ void verity_fec_dtr(struct dm_verity *v)mempool_exit (&f->output_pool);kmem_cache_destroy (f->cache); -if (f->data_bufio) +if (!IS_ERR_OR_NULL (f->data_bufio))dm_bufio_client_destroy (f->data_bufio); -if (f->bufio) +if (!IS_ERR_OR_NULL (f->bufio))dm_bufio_client_destroy (f->bufio);if (f->dev)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 538/844 media: uvcvideo: Fix support for V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 4238bd6dc6ba36f44d89a60338223d5a4f708cbf ]
The VIDIOC_G_EXT_CTRLS with which V4L2_CTRL_WHICH_(MIN|MAX)_VAL can only work for controls that have previously announced support for it.
This patch fixes the following v4l2-compliance error:
info: checking extended control 'User Controls' (0x00980001)
fail: v4l2-test-controls.cpp(980): ret != EINVAL (got 13)
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
--- drivers/media/usb/uvc/uvc_ctrl.c | 14 ++++++++++++-- drivers/media/usb/uvc/uvc_v4l2.c | 10 ++++++---- drivers/media/usb/uvc/uvcvideo.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-)
drivers/media/usb/uvc/uvc_ctrl.c +12 -2
@@ -1432,7 +1432,7 @@ static bool uvc_ctrl_is_readable(u32 which, struct uvc_control *ctrl,* auto_exposure=1, exposure_time_absolute=251. */ int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, -const struct v4l2_ext_controls *ctrls, +const struct v4l2_ext_controls *ctrls,u32 which,unsigned long ioctl) {struct uvc_control_mapping *master_map =NULL ;
@@ -1442,14 +1442,24 @@ int uvc_ctrl_is_accessible(struct uvc_video_chain *chain, u32 v4l2_id,s32 val;int ret;int i; +/* +* There is no need to check the ioctl, all the ioctls except +* VIDIOC_G_EXT_CTRLS use which=V4L2_CTRL_WHICH_CUR_VAL. +*/ +bool is_which_min_max = which ==V4L2_CTRL_WHICH_MIN_VAL || + which ==V4L2_CTRL_WHICH_MAX_VAL ;if (__uvc_query_v4l2_class (chain, v4l2_id,0 ) >=0 ) -return -EACCES ; +return is_which_min_max ? -EINVAL : -EACCES ; ctrl =uvc_find_control (chain, v4l2_id, &mapping);if (!ctrl)return -EINVAL ; +if ((!(ctrl->info.flags &UVC_CTRL_FLAG_GET_MIN ) || + !(ctrl->info.flags &UVC_CTRL_FLAG_GET_MAX )) && is_which_min_max) +return -EINVAL ; +if (ioctl ==VIDIOC_G_EXT_CTRLS )return uvc_ctrl_is_readable (ctrls->which, ctrl, mapping);
drivers/media/usb/uvc/uvc_v4l2.c +6 -4
@@ -765,14 +765,15 @@ static int uvc_ioctl_query_ext_ctrl(struct file *file, void *priv,static int uvc_ctrl_check_access (struct uvc_video_chain *chain,struct v4l2_ext_controls *ctrls, -unsigned long ioctl) +u32 which,unsigned long ioctl) {struct v4l2_ext_control *ctrl = ctrls->controls;unsigned int i;int ret =0 ;for (i =0 ; i < ctrls->count; ++ctrl, ++i) { - ret =uvc_ctrl_is_accessible (chain, ctrl->id, ctrls, ioctl); + ret =uvc_ctrl_is_accessible (chain, ctrl->id, ctrls, which, + ioctl);if (ret)break ; }
@@ -806,7 +807,7 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *priv, which =V4L2_CTRL_WHICH_CUR_VAL ; } - ret =uvc_ctrl_check_access (chain, ctrls,VIDIOC_G_EXT_CTRLS ); + ret =uvc_ctrl_check_access (chain, ctrls, which,VIDIOC_G_EXT_CTRLS );if (ret <0 )return ret;
@@ -840,7 +841,8 @@ static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,if (!ctrls->count)return 0 ; - ret =uvc_ctrl_check_access (chain, ctrls, ioctl); + ret =uvc_ctrl_check_access (chain, ctrls,V4L2_CTRL_WHICH_CUR_VAL , + ioctl);if (ret <0 )return ret;
drivers/media/usb/uvc/uvcvideo.h +1 -1
@@ -787,7 +787,7 @@ int uvc_ctrl_get(struct uvc_video_chain *chain, u32 which, struct v4l2_ext_control *xctrl);int uvc_ctrl_set (struct uvc_fh *handle,struct v4l2_ext_control *xctrl);int uvc_ctrl_is_accessible (struct uvc_video_chain *chain,u32 v4l2_id, -const struct v4l2_ext_controls *ctrls, +const struct v4l2_ext_controls *ctrls,u32 which,unsigned long ioctl); int uvc_xu_ctrl_query(struct uvc_video_chain *chain,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 539/844 media: mediatek: encoder: Fix uninitialized scalar variable issue
In reply to Sasha LevinFrom: Irui Wang <[email protected]>
[ Upstream commit 88e935de7cf8795d7a6a51385db87ecb361a7050 ]
UNINIT checker finds some instances of variables that are used without being initialized, for example using the uninitialized value enc_result.is_key_frm can result in unpredictable behavior, so initialize these variables after declaring.
--- .../media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/mtk_vcodec_enc.c +3 -3
@@ -850,7 +850,7 @@ static void vb2ops_venc_buf_queue(struct vb2_buffer *vb)static int vb2ops_venc_start_streaming (struct vb2_queue *q,unsigned int count) {struct mtk_vcodec_enc_ctx *ctx =vb2_get_drv_priv (q); -struct venc_enc_param param; +struct venc_enc_param param = { };int ret;int i;
@@ -1004,7 +1004,7 @@ static int mtk_venc_encode_header(void *priv)int ret;struct vb2_v4l2_buffer *src_buf, *dst_buf;struct mtk_vcodec_mem bs_buf; -struct venc_done_result enc_result; +struct venc_done_result enc_result = { }; dst_buf =v4l2_m2m_dst_buf_remove (ctx->m2m_ctx);if (!dst_buf) {
@@ -1125,7 +1125,7 @@ static void mtk_venc_worker(struct work_struct *work)struct vb2_v4l2_buffer *src_buf, *dst_buf;struct venc_frm_buf frm_buf;struct mtk_vcodec_mem bs_buf; -struct venc_done_result enc_result; +struct venc_done_result enc_result = { };int ret, i;/* check dst_buf, dst_buf may be removed in device_run
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 540/844 media: mtk-mdp: Fix error handling in probe function
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 8a8a3232abac5b972058a5f2cb3e33199d2a8648 ]
Add mtk_mdp_unregister_m2m_device() on the error handling path to prevent resource leak.
Add check for the return value of vpu_get_plat_device() to prevent null pointer dereference. And vpu_get_plat_device() increases the reference count of the returned platform device. Add platform_device_put() to prevent reference leak.
--- .../media/platform/mediatek/mdp/mtk_mdp_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/mdp/mtk_mdp_core.c +14 -2
@@ -194,11 +194,17 @@ static int mtk_mdp_probe(struct platform_device *pdev) } mdp->vpu_dev =vpu_get_plat_device (pdev); +if (!mdp->vpu_dev) { +dev_err (&pdev->dev,"Failed to get vpu device\n" ); + ret = -ENODEV ; + goto err_vpu_get_dev; + } + ret =vpu_wdt_reg_handler (mdp->vpu_dev, mtk_mdp_reset_handler, mdp,VPU_RST_MDP );if (ret) {dev_err (&pdev->dev,"Failed to register reset handler\n" ); - goto err_m2m_register; + goto err_reg_handler; }platform_set_drvdata (pdev, mdp);
@@ -206,7 +212,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) ret =vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 ));if (ret) {dev_err (&pdev->dev,"Failed to set vb2 dma mag seg size\n" ); - goto err_m2m_register; + goto err_reg_handler; }pm_runtime_enable (dev);
@@ -214,6 +220,12 @@ static int mtk_mdp_probe(struct platform_device *pdev)return 0 ; +err_reg_handler: +platform_device_put (mdp->vpu_dev); + +err_vpu_get_dev: +mtk_mdp_unregister_m2m_device (mdp); + err_m2m_register:v4l2_device_unregister (&mdp->v4l2_dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 541/844 media: mtk-mdp: Fix a reference leak bug in mtk_mdp_remove()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit f128bab57b8018e526b7eda854ca20069863af47 ]
In mtk_mdp_probe(), vpu_get_plat_device() increases the reference count of the returned platform device. Add platform_device_put() to prevent reference leak.
--- drivers/media/platform/mediatek/mdp/mtk_mdp_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/mdp/mtk_mdp_core.c +1 -0
@@ -254,6 +254,7 @@ static void mtk_mdp_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);vb2_dma_contig_clear_max_seg_size (&pdev->dev); +platform_device_put (mdp->vpu_dev);mtk_mdp_unregister_m2m_device (mdp);v4l2_device_unregister (&mdp->v4l2_dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 542/844 media: chips-media: wave5: Fix PM runtime usage count underflow
In reply to Sasha LevinFrom: Xulin Sun <[email protected]>
[ Upstream commit 9cf4452e824c1e2d41c9c0b13cc8a32a0a7dec38 ]
Replace pm_runtime_put_sync() with pm_runtime_dont_use_autosuspend() in the remove path to properly pair with pm_runtime_use_autosuspend() from probe. This allows pm_runtime_disable() to handle reference count cleanup correctly regardless of current suspend state.
The driver calls pm_runtime_put_sync() unconditionally in remove, but the device may already be suspended due to autosuspend configured in probe. When autosuspend has already suspended the device, the usage count is 0, and pm_runtime_put_sync() decrements it to -1.
This causes the following warning on module unload:
------------[ cut here ]------------
WARNING: CPU: 1 PID: 963 at kernel/kthread.c:1430
kthread_destroy_worker+0x84/0x98
...
vdec 30210000.video-codec: Runtime PM usage count underflow!--- drivers/media/platform/chips-media/wave5/wave5-vpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +1 -1
@@ -356,7 +356,7 @@ static void wave5_vpu_remove(struct platform_device *pdev)hrtimer_cancel (&dev->hrtimer); } -pm_runtime_put_sync (&pdev->dev); +pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_disable (&pdev->dev);mutex_destroy (&dev->dev_lock);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 543/844 media: chips-media: wave5: Fix kthread worker destruction in polling mode
In reply to Sasha LevinFrom: Xulin Sun <[email protected]>
[ Upstream commit 5a0c122e834b2f7f029526422c71be922960bf03 ]
Fix the cleanup order in polling mode (irq < 0) to prevent kernel warnings during module removal. Cancel the hrtimer before destroying the kthread worker to ensure work queues are empty.
In polling mode, the driver uses hrtimer to periodically trigger wave5_vpu_timer_callback() which queues work via kthread_queue_work(). The kthread_destroy_worker() function validates that both work queues are empty with WARN_ON(!list_empty(&worker->work_list)) and WARN_ON(!list_empty(&worker->delayed_work_list)).
The original code called kthread_destroy_worker() before hrtimer_cancel(), creating a race condition where the timer could fire during worker destruction and queue new work, triggering the WARN_ON.
This causes the following warning on every module unload in polling mode:
------------[ cut here ]------------
WARNING: CPU: 2 PID: 1034 at kernel/kthread.c:1430
kthread_destroy_worker+0x84/0x98
Modules linked in: wave5(-) rpmsg_ctrl rpmsg_char ...
Call trace:
kthread_destroy_worker+0x84/0x98
wave5_vpu_remove+0xc8/0xe0 [wave5]
platform_remove+0x30/0x58
...
---[ end trace 0000000000000000 ]------ drivers/media/platform/chips-media/wave5/wave5-vpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -1
@@ -352,8 +352,9 @@ static void wave5_vpu_remove(struct platform_device *pdev)struct vpu_device *dev =dev_get_drvdata (&pdev->dev);if (dev->irq <0 ) { -kthread_destroy_worker (dev->worker);hrtimer_cancel (&dev->hrtimer); +kthread_cancel_work_sync (&dev->work); +kthread_destroy_worker (dev->worker); }pm_runtime_dont_use_autosuspend (&pdev->dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 544/844 media: chips-media: wave5: Fix device cleanup order to prevent kernel panic
In reply to Sasha LevinFrom: Xulin Sun <[email protected]>
[ Upstream commit b74cedac643b02aefa7da881b58a3792859d9748 ]
Move video device unregistration to the beginning of the remove function to ensure all video operations are stopped before cleaning up the worker thread and disabling PM runtime. This prevents hardware register access after the device has been powered down.
In polling mode, the hrtimer periodically triggers wave5_vpu_timer_callback() which queues work to the kthread worker. The worker executes wave5_vpu_irq_work_fn() which reads hardware registers via wave5_vdi_read_register().
The original cleanup order disabled PM runtime and powered down hardware before unregistering video devices. When autosuspend triggers and powers off the hardware, the video devices are still registered and the worker thread can still be triggered by the hrtimer, causing it to attempt reading registers from powered-off hardware. This results in a bus error (synchronous external abort) and kernel panic.
This causes random kernel panics during encoding operations:
Internal error: synchronous external abort: 0000000096000010
[#1] PREEMPT SMP
Modules linked in: wave5 rpmsg_ctrl rpmsg_char ...
CPU: 0 UID: 0 PID: 1520 Comm: vpu_irq_thread
Tainted: G M W
pc : wave5_vdi_read_register+0x10/0x38 [wave5]
lr : wave5_vpu_irq_work_fn+0x28/0x60 [wave5]
Call trace:
wave5_vdi_read_register+0x10/0x38 [wave5]
kthread_worker_fn+0xd8/0x238
kthread+0x104/0x120
ret_from_fork+0x10/0x20
Code: aa1e03e9 d503201f f9416800 8b214000 (b9400000)
---[ end trace 0000000000000000 ]---
Kernel panic - not syncing: synchronous external abort:
Fatal exception--- drivers/media/platform/chips-media/wave5/wave5-vpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +4 -3
@@ -351,6 +351,10 @@ static void wave5_vpu_remove(struct platform_device *pdev) {struct vpu_device *dev =dev_get_drvdata (&pdev->dev); +wave5_vpu_enc_unregister_device (dev); +wave5_vpu_dec_unregister_device (dev); +v4l2_device_unregister (&dev->v4l2_dev); +if (dev->irq <0 ) {hrtimer_cancel (&dev->hrtimer);kthread_cancel_work_sync (&dev->work);
@@ -364,9 +368,6 @@ static void wave5_vpu_remove(struct platform_device *pdev)mutex_destroy (&dev->hw_lock);reset_control_assert (dev->resets);clk_bulk_disable_unprepare (dev->num_clks, dev->clks); -wave5_vpu_enc_unregister_device (dev); -wave5_vpu_dec_unregister_device (dev); -v4l2_device_unregister (&dev->v4l2_dev);wave5_vdi_release (&pdev->dev);ida_destroy (&dev->inst_ida); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 545/844 media: chips-media: wave5: Fix SError of kernel panic when closed
In reply to Sasha LevinFrom: Jackson Lee <[email protected]>
[ Upstream commit cbb9c0d50e471483cced55f5b7db4569dcd959a6 ]
SError of kernel panic rarely happened while testing fluster. The root cause was to enter suspend mode because timeout of autosuspend delay happened.
[ 48.834439] SError Interrupt on CPU0, code 0x00000000bf000000 -- SError [ 48.834455] CPU: 0 UID: 0 PID: 1067 Comm: v4l2h265dec0:sr Not tainted 6.12.9-gc9e21a1ebd75-dirty #7 [ 48.834461] Hardware name: ti Texas Instruments J721S2 EVM/Texas Instruments J721S2 EVM, BIOS 2025.01-00345-gbaf3aaa8ecfa 01/01/2025 [ 48.834464] pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 48.834468] pc : wave5_dec_clr_disp_flag+0x40/0x80 [wave5] [ 48.834488] lr : wave5_dec_clr_disp_flag+0x40/0x80 [wave5] [ 48.834495] sp : ffff8000856e3a30 [ 48.834497] x29: ffff8000856e3a30 x28: ffff0008093f6010 x27: ffff000809158130 [ 48.834504] x26: 0000000000000000 x25: ffff00080b625000 x24: ffff000804a9ba80 [ 48.834509] x23: ffff000802343028 x22: ffff000809158150 x21: ffff000802218000 [ 48.834513] x20: ffff0008093f6000 x19: ffff0008093f6000 x18: 0000000000000000 [ 48.834518] x17: 0000000000000000 x16: 0000000000000000 x15: 0000ffff74009618 [ 48.834523] x14: 000000010000000c x13: 0000000000000000 x12: 0000000000000000 [ 48.834527] x11: ffffffffffffffff x10: ffffffffffffffff x9 : ffff000802343028 [ 48.834532] x8 : ffff00080b6252a0 x7 : 0000000000000038 x6 : 0000000000000000 [ 48.834536] x5 : ffff00080b625060 x4 : 0000000000000000 x3 : 0000000000000000 [ 48.834541] x2 : 0000000000000000 x1 : ffff800084bf0118 x0 : ffff800084bf0000 [ 48.834547] Kernel panic - not syncing: Asynchronous SError Interrupt [ 48.834549] CPU: 0 UID: 0 PID: 1067 Comm: v4l2h265dec0:sr Not tainted 6.12.9-gc9e21a1ebd75-dirty #7 [ 48.834554] Hardware name: ti Texas Instruments J721S2 EVM/Texas Instruments J721S2 EVM, BIOS 2025.01-00345-gbaf3aaa8ecfa 01/01/2025 [ 48.834556] Call trace: [ 48.834559] dump_backtrace+0x94/0xec [ 48.834574] show_stack+0x18/0x24 [ 48.834579] dump_stack_lvl+0x38/0x90 [ 48.834585] dump_stack+0x18/0x24 [ 48.834588] panic+0x35c/0x3e0 [ 48.834592] nmi_panic+0x40/0x8c [ 48.834595] arm64_serror_panic+0x64/0x70 [ 48.834598] do_serror+0x3c/0x78 [ 48.834601] el1h_64_error_handler+0x34/0x4c [ 48.834605] el1h_64_error+0x64/0x68 [ 48.834608] wave5_dec_clr_disp_flag+0x40/0x80 [wave5] [ 48.834615] wave5_vpu_dec_clr_disp_flag+0x54/0x80 [wave5] [ 48.834622] wave5_vpu_dec_buf_queue+0x19c/0x1a0 [wave5] [ 48.834628] __enqueue_in_driver+0x3c/0x74 [videobuf2_common] [ 48.834639] vb2_core_qbuf+0x508/0x61c [videobuf2_common] [ 48.834646] vb2_qbuf+0xa4/0x168 [videobuf2_v4l2] [ 48.834656] v4l2_m2m_qbuf+0x80/0x238 [v4l2_mem2mem] [ 48.834666] v4l2_m2m_ioctl_qbuf+0x18/0x24 [v4l2_mem2mem] [ 48.834673] v4l_qbuf+0x48/0x5c [videodev] [ 48.834704] __video_do_ioctl+0x180/0x3f0 [videodev] [ 48.834725] video_usercopy+0x2ec/0x68c [videodev] [ 48.834745] video_ioctl2+0x18/0x24 [videodev] [ 48.834766] v4l2_ioctl+0x40/0x60 [videodev] [ 48.834786] __arm64_sys_ioctl+0xa8/0xec [ 48.834793] invoke_syscall+0x44/0x100 [ 48.834800] el0_svc_common.constprop.0+0xc0/0xe0 [ 48.834804] do_el0_svc+0x1c/0x28 [ 48.834809] el0_svc+0x30/0xd0 [ 48.834813] el0t_64_sync_handler+0xc0/0xc4 [ 48.834816] el0t_64_sync+0x190/0x194 [ 48.834820] SMP: stopping secondary CPUs [ 48.834831] Kernel Offset: disabled [ 48.834833] CPU features: 0x08,00002002,80200000,4200421b [ 48.834837] Memory Limit: none [ 49.161404] ---[ end Kernel panic - not syncing: Asynchronous SError Interrupt ]---
--- .../platform/chips-media/wave5/wave5-vpu-dec.c | 5 ++--- .../platform/chips-media/wave5/wave5-vpu-enc.c | 3 --- .../media/platform/chips-media/wave5/wave5-vpu.c | 2 +- .../platform/chips-media/wave5/wave5-vpuapi.c | 15 --------------- 4 files changed, 3 insertions(+), 22 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +2 -3
@@ -1243,6 +1243,7 @@ static void wave5_vpu_dec_buf_queue_dst(struct vb2_buffer *vb)struct vpu_instance *inst =vb2_get_drv_priv (vb->vb2_queue);struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx; +pm_runtime_resume_and_get (inst->dev->dev); vbuf->sequence = inst->queued_dst_buf_num++;if (inst->state ==VPU_INST_STATE_PIC_RUN ) {
@@ -1275,6 +1276,7 @@ static void wave5_vpu_dec_buf_queue_dst(struct vb2_buffer *vb) }else {v4l2_m2m_buf_queue (m2m_ctx, vbuf); } +pm_runtime_put_autosuspend (inst->dev->dev); }static void wave5_vpu_dec_buf_queue (struct vb2_buffer *vb)
@@ -1827,9 +1829,6 @@ static int wave5_vpu_open_dec(struct file *filp)if (ret) goto cleanup_inst; -if (list_empty (&dev->instances)) -pm_runtime_use_autosuspend (inst->dev->dev); -list_add_tail (&inst->list, &dev->instances);mutex_unlock (&dev->dev_lock);
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +0 -3
@@ -1773,9 +1773,6 @@ static int wave5_vpu_open_enc(struct file *filp)if (ret) goto cleanup_inst; -if (list_empty (&dev->instances)) -pm_runtime_use_autosuspend (inst->dev->dev); -list_add_tail (&inst->list, &dev->instances);mutex_unlock (&dev->dev_lock);
drivers/media/platform/chips-media/wave5/wave5-vpu.c +1 -1
@@ -322,7 +322,7 @@ static int wave5_vpu_probe(struct platform_device *pdev)dev_info (&pdev->dev,"Product Code: 0x%x\n" , dev->product_code);dev_info (&pdev->dev,"Firmware Revision: %u\n" , fw_revision); -pm_runtime_set_autosuspend_delay (&pdev->dev,100 ); +pm_runtime_set_autosuspend_delay (&pdev->dev,500 );pm_runtime_use_autosuspend (&pdev->dev);pm_runtime_enable (&pdev->dev);wave5_vpu_sleep_wake (&pdev->dev, true,NULL ,0 );
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +0 -15
@@ -207,8 +207,6 @@ int wave5_vpu_dec_close(struct vpu_instance *inst, u32 *fail_res)int retry =0 ;struct vpu_device *vpu_dev = inst->dev;int i; -int inst_count =0 ; -struct vpu_instance *inst_elm; *fail_res =0 ;if (!inst->codec_info)
@@ -250,11 +248,6 @@ int wave5_vpu_dec_close(struct vpu_instance *inst, u32 *fail_res)wave5_vdi_free_dma_memory (vpu_dev, &p_dec_info->vb_task); -list_for_each_entry (inst_elm, &vpu_dev->instances, list) - inst_count++; -if (inst_count ==1 ) -pm_runtime_dont_use_autosuspend (vpu_dev->dev); - unlock_and_return:mutex_unlock (&vpu_dev->hw_lock);pm_runtime_put_sync (inst->dev->dev);
@@ -720,8 +713,6 @@ int wave5_vpu_enc_close(struct vpu_instance *inst, u32 *fail_res)int ret;int retry =0 ;struct vpu_device *vpu_dev = inst->dev; -int inst_count =0 ; -struct vpu_instance *inst_elm; *fail_res =0 ;if (!inst->codec_info)
@@ -764,12 +755,6 @@ int wave5_vpu_enc_close(struct vpu_instance *inst, u32 *fail_res) }wave5_vdi_free_dma_memory (vpu_dev, &p_enc_info->vb_task); - -list_for_each_entry (inst_elm, &vpu_dev->instances, list) - inst_count++; -if (inst_count ==1 ) -pm_runtime_dont_use_autosuspend (vpu_dev->dev); -mutex_unlock (&vpu_dev->hw_lock);pm_runtime_put_sync (inst->dev->dev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 546/844 media: chips-media: wave5: Fix Null reference while testing fluster
In reply to Sasha LevinFrom: Jackson Lee <[email protected]>
[ Upstream commit e66ff2b08e4ee1c4d3b84f24818e5bcc178cc3a4 ]
When multi instances are created/destroyed, many interrupts happens and structures for decoder are removed.
"struct vpu_instance" this structure is shared for all flow in the decoder, so if the structure is not protected by lock, Null dereference could happens sometimes.
IRQ Handler was spilt to two phases and Lock was added as well.
--- .../platform/chips-media/wave5/wave5-helper.c | 28 +++++- .../platform/chips-media/wave5/wave5-helper.h | 1 + .../chips-media/wave5/wave5-vpu-dec.c | 5 + .../chips-media/wave5/wave5-vpu-enc.c | 5 + .../platform/chips-media/wave5/wave5-vpu.c | 97 +++++++++++++++++-- .../platform/chips-media/wave5/wave5-vpuapi.h | 6 ++ 6 files changed, 131 insertions(+), 11 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-helper.c +27 -1
@@ -27,6 +27,11 @@ const char *state_to_str(enum vpu_instance_state state) } } +int wave5_kfifo_alloc (struct vpu_instance *inst) +{ +return kfifo_alloc (&inst->irq_status,16 *sizeof (int ),GFP_KERNEL ); +} +void wave5_cleanup_instance (struct vpu_instance *inst,struct file *filp) {int i;
@@ -49,7 +54,7 @@ void wave5_cleanup_instance(struct vpu_instance *inst, struct file *filp)v4l2_fh_del (&inst->v4l2_fh, filp);v4l2_fh_exit (&inst->v4l2_fh); } -list_del_init (&inst->list); +kfifo_free (&inst->irq_status);ida_free (&inst->dev->inst_ida, inst->id);kfree (inst->codec_info);kfree (inst);
@@ -61,8 +66,29 @@ int wave5_vpu_release_device(struct file *filp, {struct vpu_instance *inst =file_to_vpu_inst (filp);int ret =0 ; +unsigned long flags;v4l2_m2m_ctx_release (inst->v4l2_fh.m2m_ctx); +/* +* To prevent Null reference exception, the existing irq handler were +* separated to two modules. +* One is to queue interrupt reason into the irq handler, +* the other is irq_thread to call the wave5_vpu_dec_finish_decode +* to get decoded frame. +* The list of instances should be protected between all flow of the +* decoding process, but to protect the list in the irq_handler, spin lock +* should be used, and mutex should be used in the irq_thread because spin lock +* is not able to be used because mutex is already being used +* in the wave5_vpu_dec_finish_decode. +* So the spin lock and mutex were used to protect the list in the release function. +*/ + ret =mutex_lock_interruptible (&inst->dev->irq_lock); +if (ret) +return ret; +spin_lock_irqsave (&inst->dev->irq_spinlock, flags); +list_del_init (&inst->list); +spin_unlock_irqrestore (&inst->dev->irq_spinlock, flags); +mutex_unlock (&inst->dev->irq_lock);if (inst->state !=VPU_INST_STATE_NONE ) {u32 fail_res;
drivers/media/platform/chips-media/wave5/wave5-helper.h +1 -0
@@ -33,4 +33,5 @@ void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp,unsigned int width, unsigned int height, const struct v4l2_frmsize_stepwise *frmsize); +int wave5_kfifo_alloc (struct vpu_instance *inst);#endif
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +5 -0
@@ -1810,6 +1810,11 @@ static int wave5_vpu_open_dec(struct file *filp) inst->xfer_func =V4L2_XFER_FUNC_DEFAULT ;init_completion (&inst->irq_done); + ret =wave5_kfifo_alloc (inst); +if (ret) { +dev_err (inst->dev->dev,"failed to allocate fifo\n" ); + goto cleanup_inst; + } inst->id =ida_alloc (&inst->dev->inst_ida,GFP_KERNEL );if (inst->id <0 ) {
drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c +5 -0
@@ -1759,6 +1759,11 @@ static int wave5_vpu_open_enc(struct file *filp) inst->frame_rate =30 ;init_completion (&inst->irq_done); + ret =wave5_kfifo_alloc (inst); +if (ret) { +dev_err (inst->dev->dev,"failed to allocate fifo\n" ); + goto cleanup_inst; + } inst->id =ida_alloc (&inst->dev->inst_ida,GFP_KERNEL );if (inst->id <0 ) {
drivers/media/platform/chips-media/wave5/wave5-vpu.c +87 -10
171 lines not on this page · raw message
drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +6 -0
@@ -8,6 +8,7 @@#ifndef VPUAPI_H_INCLUDED #define VPUAPI_H_INCLUDED +#include <linux/kfifo.h> #include <linux/idr.h> #include <linux/genalloc.h> #include <media/v4l2-device.h>
@@ -747,6 +748,7 @@ struct vpu_device {struct video_device *video_dev_enc;struct mutex dev_lock;/* lock for the src, dst v4l2 queues */ struct mutex hw_lock;/* lock hw configurations */ +struct mutex irq_lock;int irq;enum product_id product;struct vpu_attr attr;
@@ -764,7 +766,10 @@ struct vpu_device {struct kthread_worker *worker;int vpu_poll_interval;int num_clks; +struct task_struct *irq_thread; +struct semaphore irq_sem;/* signal to irq_thread when interrupt happens*/ struct reset_control *resets; +spinlock_t irq_spinlock;/* protect instances list */ };struct vpu_instance ;
@@ -788,6 +793,7 @@ struct vpu_instance {enum v4l2_ycbcr_encoding ycbcr_enc;enum v4l2_quantization quantization; +struct kfifo irq_status;enum vpu_instance_state state;enum vpu_instance_type type;const struct vpu_instance_ops *ops;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 547/844 media: v4l2-mem2mem: Add a kref to the v4l2_m2m_dev structure
In reply to Sasha LevinFrom: Nicolas Dufresne <[email protected]>
[ Upstream commit db6b97a4f8041e479be9ef4b8b07022636c96f50 ]
Adding a reference count to the v4l2_m2m_dev structure allow safely sharing it across multiple hardware nodes. This can be used to prevent running jobs concurrently on m2m cores that have some internal resource sharing.
Stable-dep-of: e0203ddf9af7 ("media: verisilicon: Avoid G2 bus error while decoding H.264 and HEVC")
--- drivers/media/v4l2-core/v4l2-mem2mem.c | 23 +++++++++++++++++++++++ include/media/v4l2-mem2mem.h | 21 +++++++++++++++++++++ 2 files changed, 44 insertions(+)
drivers/media/v4l2-core/v4l2-mem2mem.c +23 -0
@@ -90,6 +90,7 @@ static const char * const m2m_entity_name[] = {* @job_work: worker to run queued jobs. * @job_queue_flags: flags of the queue status, %QUEUE_PAUSED. * @m2m_ops: driver callbacks +* @kref: device reference count */ struct v4l2_m2m_dev {struct v4l2_m2m_ctx *curr_ctx;
@@ -109,6 +110,8 @@ struct v4l2_m2m_dev {unsigned long job_queue_flags;const struct v4l2_m2m_ops *m2m_ops; + +struct kref kref; }; static struct v4l2_m2m_queue_ctx *get_queue_ctx(struct v4l2_m2m_ctx *m2m_ctx,
@@ -1200,6 +1203,7 @@ struct v4l2_m2m_dev *v4l2_m2m_init(const struct v4l2_m2m_ops *m2m_ops)INIT_LIST_HEAD (&m2m_dev->job_queue);spin_lock_init (&m2m_dev->job_spinlock);INIT_WORK (&m2m_dev->job_work, v4l2_m2m_device_run_work); +kref_init (&m2m_dev->kref);return m2m_dev; }
@@ -1211,6 +1215,25 @@ void v4l2_m2m_release(struct v4l2_m2m_dev *m2m_dev) }EXPORT_SYMBOL_GPL (v4l2_m2m_release); +void v4l2_m2m_get (struct v4l2_m2m_dev *m2m_dev) +{ +kref_get (&m2m_dev->kref); +} +EXPORT_SYMBOL_GPL (v4l2_m2m_get); + +static void v4l2_m2m_release_from_kref (struct kref *kref) +{ + struct v4l2_m2m_dev *m2m_dev = container_of(kref, struct v4l2_m2m_dev, kref); + +v4l2_m2m_release (m2m_dev); +} + +void v4l2_m2m_put (struct v4l2_m2m_dev *m2m_dev) +{ +kref_put (&m2m_dev->kref, v4l2_m2m_release_from_kref); +} +EXPORT_SYMBOL_GPL (v4l2_m2m_put); +struct v4l2_m2m_ctx *v4l2_m2m_ctx_init (struct v4l2_m2m_dev *m2m_dev,void *drv_priv,int (*queue_init)(void *priv,struct vb2_queue *src_vq,struct vb2_queue *dst_vq))
include/media/v4l2-mem2mem.h +21 -0
@@ -547,6 +547,27 @@ v4l2_m2m_register_media_controller(struct v4l2_m2m_dev *m2m_dev,*/ void v4l2_m2m_release (struct v4l2_m2m_dev *m2m_dev); +/** +* v4l2_m2m_get() - take a reference to the m2m_dev structure +* +* @m2m_dev: opaque pointer to the internal data to handle M2M context +* +* This is used to share the M2M device across multiple devices. This +* can be used to avoid scheduling two hardware nodes concurrently. +*/ +void v4l2_m2m_get (struct v4l2_m2m_dev *m2m_dev); + +/** +* v4l2_m2m_put() - remove a reference to the m2m_dev structure +* +* @m2m_dev: opaque pointer to the internal data to handle M2M context +* +* Once the M2M device has no more references, v4l2_m2m_release() will be +* called automatically. Users of this method should never call +* v4l2_m2m_release() directly. See v4l2_m2m_get() for more details. +*/ +void v4l2_m2m_put (struct v4l2_m2m_dev *m2m_dev); +/** * v4l2_m2m_ctx_init() - allocate and initialize a m2m context *
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 548/844 media: verisilicon: Avoid G2 bus error while decoding H.264 and HEVC
In reply to Sasha LevinFrom: Ming Qian <[email protected]>
[ Upstream commit e0203ddf9af7c8e170e1e99ce83b4dc07f0cd765 ]
For the i.MX8MQ platform, there is a hardware limitation: the g1 VPU and g2 VPU cannot decode simultaneously; otherwise, it will cause below bus error and produce corrupted pictures, even potentially lead to system hang.
[ 110.527986] hantro-vpu 38310000.video-codec: frame decode timed out. [ 110.583517] hantro-vpu 38310000.video-codec: bus error detected.
Therefore, it is necessary to ensure that g1 and g2 operate alternately. This allows for successful multi-instance decoding of H.264 and HEVC.
To achieve this, g1 and g2 share the same v4l2_m2m_dev, and then the v4l2_m2m_dev can handle the scheduling.
--- drivers/media/platform/verisilicon/hantro.h | 2 + .../media/platform/verisilicon/hantro_drv.c | 42 +++++++++++++++++-- .../media/platform/verisilicon/imx8m_vpu_hw.c | 8 ++++ 3 files changed, 49 insertions(+), 3 deletions(-)
drivers/media/platform/verisilicon/hantro.h +2 -0
@@ -77,6 +77,7 @@ struct hantro_irq {* @double_buffer: core needs double buffering * @legacy_regs: core uses legacy register set * @late_postproc: postproc must be set up at the end of the job +* @shared_devices: an array of device ids that cannot run concurrently */ struct hantro_variant {unsigned int enc_offset;
@@ -101,6 +102,7 @@ struct hantro_variant { unsigned int double_buffer : 1; unsigned int legacy_regs : 1; unsigned int late_postproc : 1; +const struct of_device_id *shared_devices; };/**
drivers/media/platform/verisilicon/hantro_drv.c +39 -3
72 lines not on this page · raw message
drivers/media/platform/verisilicon/imx8m_vpu_hw.c +8 -0
@@ -343,6 +343,12 @@ const struct hantro_variant imx8mq_vpu_variant = { .num_regs = ARRAY_SIZE(imx8mq_reg_names) }; +static const struct of_device_id imx8mq_vpu_shared_resources[]__initconst = { + { .compatible ="nxp,imx8mq-vpu-g1" , }, + { .compatible ="nxp,imx8mq-vpu-g2" , }, + {/* sentinel */ } +}; +const struct hantro_variant imx8mq_vpu_g1_variant = { .dec_fmts = imx8m_vpu_dec_fmts, .num_dec_fmts =ARRAY_SIZE (imx8m_vpu_dec_fmts),
@@ -356,6 +362,7 @@ const struct hantro_variant imx8mq_vpu_g1_variant = { .num_irqs = ARRAY_SIZE(imx8mq_irqs), .clk_names = imx8mq_g1_clk_names, .num_clocks = ARRAY_SIZE(imx8mq_g1_clk_names), + .shared_devices = imx8mq_vpu_shared_resources, };const struct hantro_variant imx8mq_vpu_g2_variant = {
@@ -371,6 +378,7 @@ const struct hantro_variant imx8mq_vpu_g2_variant = { .num_irqs = ARRAY_SIZE(imx8mq_g2_irqs), .clk_names = imx8mq_g2_clk_names, .num_clocks = ARRAY_SIZE(imx8mq_g2_clk_names), + .shared_devices = imx8mq_vpu_shared_resources, };const struct hantro_variant imx8mm_vpu_g1_variant = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 549/844 media: verisilicon: AV1: Fix enable cdef computation
In reply to Sasha LevinFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit e0f99b810e1181374370f91cd996d761549e147f ]
If all the fields of the CDEF parameters are zero (which is the default), then av1_enable_cdef register needs to be unset
(despite the V4L2_AV1_SEQUENCE_FLAG_ENABLE_CDEF possibly being set).
--- .../platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +8 -2
@@ -1396,8 +1396,16 @@ static void rockchip_vpu981_av1_dec_set_cdef(struct hantro_ctx *ctx)u16 luma_sec_strength =0 ;u32 chroma_pri_strength =0 ;u16 chroma_sec_strength =0 ; +bool enable_cdef;int i; + enable_cdef = !(cdef->bits ==0 && + cdef->damping_minus_3 ==0 && + cdef->y_pri_strength[0 ] ==0 && + cdef->y_sec_strength[0 ] ==0 && + cdef->uv_pri_strength[0 ] ==0 && + cdef->uv_sec_strength[0 ] ==0 ); +hantro_reg_write (vpu, &av1_enable_cdef, enable_cdef);hantro_reg_write (vpu, &av1_cdef_bits, cdef->bits);hantro_reg_write (vpu, &av1_cdef_damping, cdef->damping_minus_3);
@@ -1953,8 +1961,6 @@ static void rockchip_vpu981_av1_dec_set_parameters(struct hantro_ctx *ctx) !!(ctrls->frame->flags & V4L2_AV1_FRAME_FLAG_SHOW_FRAME));hantro_reg_write (vpu, &av1_switchable_motion_mode, !!(ctrls->frame->flags &V4L2_AV1_FRAME_FLAG_IS_MOTION_MODE_SWITCHABLE )); -hantro_reg_write (vpu, &av1_enable_cdef, - !!(ctrls->sequence->flags &V4L2_AV1_SEQUENCE_FLAG_ENABLE_CDEF ));hantro_reg_write (vpu, &av1_allow_masked_compound, !!(ctrls->sequence->flags &V4L2_AV1_SEQUENCE_FLAG_ENABLE_MASKED_COMPOUND ));
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 550/844 media: verisilicon: AV1: Fix tx mode bit setting
In reply to Sasha LevinFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit cb3f945c012ab152fd2323e0df34c2b640071738 ]
AV1 specification describes 3 possibles tx modes: 4x4 only, largest and select. The hardware allows 5 possibles tx modes: 4x4 only, 8x8, 16x16, 32x32 and select. Since the both aren't exactly matching we need to add a mapping function to set the correct mode on hardware.
--- .../verisilicon/rockchip_vpu981_hw_av1_dec.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +26 -1
@@ -72,6 +72,14 @@ : AV1_DIV_ROUND_UP_POW2((_value_), (_n_))); \ }) +enum rockchip_av1_tx_mode { +ROCKCHIP_AV1_TX_MODE_ONLY_4X4 =0 , +ROCKCHIP_AV1_TX_MODE_8X8 =1 , + ROCKCHIP_AV1_TX_MODE_16x16 =2 , + ROCKCHIP_AV1_TX_MODE_32x32 =3 , +ROCKCHIP_AV1_TX_MODE_SELECT =4 , +}; +struct rockchip_av1_film_grain {u8 scaling_lut_y[256 ];u8 scaling_lut_cb[256 ];
@@ -1935,11 +1943,26 @@ static void rockchip_vpu981_av1_dec_set_reference_frames(struct hantro_ctx *ctx)rockchip_vpu981_av1_dec_set_other_frames (ctx); } +static int rockchip_vpu981_av1_get_hardware_tx_mode (enum v4l2_av1_tx_mode tx_mode) +{ +switch (tx_mode) { +case V4L2_AV1_TX_MODE_ONLY_4X4 : +return ROCKCHIP_AV1_TX_MODE_ONLY_4X4 ; +case V4L2_AV1_TX_MODE_LARGEST : +return ROCKCHIP_AV1_TX_MODE_32x32; +case V4L2_AV1_TX_MODE_SELECT : +return ROCKCHIP_AV1_TX_MODE_SELECT ; + } + +return ROCKCHIP_AV1_TX_MODE_32x32; +} +static void rockchip_vpu981_av1_dec_set_parameters (struct hantro_ctx *ctx) {struct hantro_dev *vpu = ctx->dev;struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls; +int tx_mode;hantro_reg_write (vpu, &av1_skip_mode, !!(ctrls->frame->flags &V4L2_AV1_FRAME_FLAG_SKIP_MODE_PRESENT ));
@@ -2005,7 +2028,9 @@ static void rockchip_vpu981_av1_dec_set_parameters(struct hantro_ctx *ctx) !!(ctrls->frame->flags & V4L2_AV1_FRAME_FLAG_ALLOW_HIGH_PRECISION_MV));hantro_reg_write (vpu, &av1_comp_pred_mode, (ctrls->frame->flags &V4L2_AV1_FRAME_FLAG_REFERENCE_SELECT ) ?2 :0 ); -hantro_reg_write (vpu, &av1_transform_mode, (ctrls->frame->tx_mode ==1 ) ?3 :4 ); + + tx_mode =rockchip_vpu981_av1_get_hardware_tx_mode (ctrls->frame->tx_mode); +hantro_reg_write (vpu, &av1_transform_mode, tx_mode);hantro_reg_write (vpu, &av1_max_cb_size, (ctrls->sequence->flags &V4L2_AV1_SEQUENCE_FLAG_USE_128X128_SUPERBLOCK ) ?7 :6 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 551/844 arm64: dts: qcom: x1e80100: Add missing TCSR ref clock to the DP PHYs
In reply to Sasha LevinFrom: Abel Vesa <[email protected]>
[ Upstream commit 0907cab01ff9746ecf08592edd9bd85d2636be58 ]
The DP PHYs on X1E80100 need the ref clock which is provided by the TCSR CC.
The current X Elite devices supported upstream work fine without this clock, because the boot firmware leaves this clock enabled. But we should not rely on that. Also, even though this change breaks the ABI, it is needed in order to make the driver disables this clock along with the other ones, for a proper bring-down of the entire PHY.
So lets attach it to each of the DP PHYs in order to do that.
--- arch/arm64/boot/dts/qcom/hamoa.dtsi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/hamoa.dtsi +8 -4
@@ -5896,9 +5896,11 @@ mdss_dp2_phy: phy@aec2a00 { <0 0x0aec2000 0 0x1c8>; clocks = <&dispcc DISP_CC_MDSS_DPTX2_AUX_CLK>, - <&dispcc DISP_CC_MDSS_AHB_CLK>; + <&dispcc DISP_CC_MDSS_AHB_CLK>, + <&tcsr TCSR_EDP_CLKREF_EN>; clock-names = "aux", - "cfg_ahb"; + "cfg_ahb", + "ref"; power-domains = <&rpmhpd RPMHPD_MX>;
@@ -5916,9 +5918,11 @@ mdss_dp3_phy: phy@aec5a00 { <0 0x0aec5000 0 0x1c8>; clocks = <&dispcc DISP_CC_MDSS_DPTX3_AUX_CLK>, - <&dispcc DISP_CC_MDSS_AHB_CLK>; + <&dispcc DISP_CC_MDSS_AHB_CLK>, + <&tcsr TCSR_EDP_CLKREF_EN>; clock-names = "aux", - "cfg_ahb"; + "cfg_ahb", + "ref"; power-domains = <&rpmhpd RPMHPD_MX>;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 552/844 arm64: dts: qcom: sm8750: Fix BAM DMA probing
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 1c6192ec9c4ab8bdb7b2cf8763b7ef7e38671ffe ]
Bindings always required "qcom,num-ees" and "num-channels" properties, as reported by dtbs_check:
sm8750-mtp.dtb: dma-controller@1dc4000 (qcom,bam-v1.7.4): 'anyOf' conditional failed, one must be fixed:
'qcom,powered-remotely' is a required property
'num-channels' is a required property
'qcom,num-ees' is a required property
'clocks' is a required property
'clock-names' is a required property
However since commit 5068b5254812 ("dmaengine: qcom: bam_dma: Fix DT error handling for num-channels/ees") missing properties are actually fatal and BAM does not probe:
bam-dma-engine 1dc4000.dma-controller: num-channels unspecified in dt bam-dma-engine 1dc4000.dma-controller: probe with driver bam-dma-engine failed with error -22
--- arch/arm64/boot/dts/qcom/sm8750.dtsi | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/qcom/sm8750.dtsi +2 -0
@@ -2073,6 +2073,8 @@ cryptobam: dma-controller@1dc4000 { <&apps_smmu 0x481 0>; qcom,ee = <0>; + qcom,num-ees = <4>; + num-channels = <20>; qcom,controlled-remotely; };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 553/844 ARM: omap2: Fix reference count leaks in omap_control_init()
In reply to Sasha LevinFrom: Wentao Liang <[email protected]>
[ Upstream commit 93a04ab480c8bbcb7d9004be139c538c8a0c1bc8 ]
The of_get_child_by_name() function increments the reference count of child nodes, causing multiple reference leaks in omap_control_init():
1. scm_conf node never released in normal/error paths
2. clocks node leak when checking existence
3. Missing scm_conf release before np in error paths
Fix these leaks by adding proper of_node_put() calls and separate error handling.
--- arch/arm/mach-omap2/control.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/arm/mach-omap2/control.c +10 -4
@@ -732,7 +732,7 @@ int __init omap2_control_base_init(void)*/ int __init omap_control_init (void ) { -struct device_node *np, *scm_conf; +struct device_node *np, *scm_conf, *clocks_node;const struct of_device_id *match;const struct omap_prcm_init_data *data;int ret;
@@ -753,16 +753,19 @@ int __init omap_control_init(void)if (IS_ERR (syscon)) { ret =PTR_ERR (syscon); - goto of_node_put; + goto err_put_scm_conf; } -if (of_get_child_by_name (scm_conf,"clocks" )) { + clocks_node =of_get_child_by_name (scm_conf,"clocks" ); +if (clocks_node) { +of_node_put (clocks_node); ret =omap2_clk_provider_init (scm_conf, data->index, syscon,NULL );if (ret) - goto of_node_put; + goto err_put_scm_conf; } +of_node_put (scm_conf); }else {/* No scm_conf found, direct access */ ret = omap2_clk_provider_init(np, data->index, NULL,
@@ -780,6 +783,9 @@ int __init omap_control_init(void)return 0 ; +err_put_scm_conf: +if (scm_conf) +of_node_put (scm_conf); of_node_put:of_node_put (np);return ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 554/844 arm64: kernel: initialize missing kexec_buf->random field
In reply to Sasha LevinFrom: Yeoreum Yun <[email protected]>
[ Upstream commit 15dd20dda979ebab72f6df97845828e78d63ab91 ]
Commit bf454ec31add ("kexec_file: allow to place kexec_buf randomly") introduced the kexec_buf->random field to enable random placement of kexec_buf.
However, this field was never properly initialized for kexec images that do not need to be placed randomly, leading to the following UBSAN warning:
[ +0.364528] ------------[ cut here ]------------ [ +0.000019] UBSAN: invalid-load in ./include/linux/kexec.h:210:12 [ +0.000131] load of value 2 is not a valid value for type 'bool' (aka '_Bool') [ +0.000003] CPU: 4 UID: 0 PID: 927 Comm: kexec Not tainted 6.18.0-rc7+ #3 PREEMPT(full) [ +0.000002] Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015 [ +0.000000] Call trace: [ +0.000001] show_stack+0x24/0x40 (C) [ +0.000006] __dump_stack+0x28/0x48 [ +0.000002] dump_stack_lvl+0x7c/0xb0 [ +0.000002] dump_stack+0x18/0x34 [ +0.000001] ubsan_epilogue+0x10/0x50 [ +0.000002] __ubsan_handle_load_invalid_value+0xc8/0xd0 [ +0.000003] locate_mem_hole_callback+0x28c/0x2a0 [ +0.000003] kexec_locate_mem_hole+0xf4/0x2f0 [ +0.000001] kexec_add_buffer+0xa8/0x178 [ +0.000002] image_load+0xf0/0x258 [ +0.000001] __arm64_sys_kexec_file_load+0x510/0x718 [ +0.000002] invoke_syscall+0x68/0xe8 [ +0.000001] el0_svc_common+0xb0/0xf8 [ +0.000002] do_el0_svc+0x28/0x48 [ +0.000001] el0_svc+0x40/0xe8 [ +0.000002] el0t_64_sync_handler+0x84/0x140 [ +0.000002] el0t_64_sync+0x1bc/0x1c0
To address this, initialise kexec_buf->random field properly.
--- arch/arm64/kernel/kexec_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kernel/kexec_image.c +1 -1
@@ -41,7 +41,7 @@ static void *image_load(struct kimage *image,struct arm64_image_header *h;u64 flags, value;bool be_image, be_kernel; -struct kexec_buf kbuf; +struct kexec_buf kbuf = {};unsigned long text_offset, kernel_segment_number;struct kexec_segment *kernel_segment;int ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 555/844 powerpc/pseries: Fix MSI-X allocation failure when quota is exceeded
In reply to Sasha LevinFrom: Nam Cao <[email protected]>
[ Upstream commit c0215e2d72debcd9cbc1c002fb012d50a3140387 ]
Nilay reported that since commit daaa574aba6f ("powerpc/pseries/msi: Switch to msi_create_parent_irq_domain()"), the NVMe driver cannot enable MSI-X when the device's MSI-X table size is larger than the firmware's MSI quota for the device.
This is because the commit changes how rtas_prepare_msi_irqs() is called:
- Before, it is called when interrupts are allocated at the global interrupt domain with nvec_in being the number of allocated interrupts. rtas_prepare_msi_irqs() can return a positive number and the allocation will be retried.
- Now, it is called at the creation of per-device interrupt domain with nvec_in being the number of interrupts that the device supports. If rtas_prepare_msi_irqs() returns positive, domain creation just fails.
For Nilay's NVMe driver case, rtas_prepare_msi_irqs() returns a positive number (the quota). This causes per-device interrupt domain creation to fail and thus the NVMe driver cannot enable MSI-X.
Rework to make this scenario works again:
- pseries_msi_ops_prepare() only prepares as many interrupts as the quota permit.
- pseries_irq_domain_alloc() fails if the device's quota is exceeded.
Now, if the quota is exceeded, pseries_msi_ops_prepare() will only prepare as allowed by the quota. If device drivers attempt to allocate more interrupts than the quota permits, pseries_irq_domain_alloc() will return an error code and msi_handle_pci_fail() will allow device drivers a retry.
--- arch/powerpc/platforms/pseries/msi.c | 44 ++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-)
arch/powerpc/platforms/pseries/msi.c +41 -3
@@ -19,6 +19,11 @@#include "pseries.h" +struct pseries_msi_device { +unsigned int msi_quota; +unsigned int msi_used; +}; +static int query_token, change_token;#define RTAS_QUERY_FN 0
@@ -433,8 +438,28 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *devstruct msi_domain_info *info = domain->host_data;struct pci_dev *pdev =to_pci_dev (dev);int type = (info->flags &MSI_FLAG_PCI_MSIX ) ?PCI_CAP_ID_MSIX :PCI_CAP_ID_MSI ; +int ret; + + struct pseries_msi_device *pseries_dev __free(kfree) + =kmalloc (sizeof (*pseries_dev),GFP_KERNEL ); +if (!pseries_dev) +return -ENOMEM ; + +while (1 ) { + ret =rtas_prepare_msi_irqs (pdev, nvec, type, arg); +if (!ret) +break ; +else if (ret >0 ) + nvec = ret; +else +return ret; + } -return rtas_prepare_msi_irqs (pdev, nvec, type, arg); + pseries_dev->msi_quota = nvec; + pseries_dev->msi_used =0 ; + + arg->scratchpad[0 ].ptr =no_free_ptr (pseries_dev); +return 0 ; }/*
@@ -443,9 +468,13 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev*/ static void pseries_msi_ops_teardown (struct irq_domain *domain,msi_alloc_info_t *arg) { +struct pseries_msi_device *pseries_dev = arg->scratchpad[0 ].ptr;struct pci_dev *pdev =to_pci_dev (domain->dev);rtas_disable_msi (pdev); + +WARN_ON (pseries_dev->msi_used); +kfree (pseries_dev); }static void pseries_msi_shutdown (struct irq_data *d)
@@ -546,12 +575,18 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virq unsigned int nr_irqs, void *arg) { struct pci_controller *phb = domain->host_data; +struct pseries_msi_device *pseries_dev;msi_alloc_info_t *info = arg;struct msi_desc *desc = info->desc;struct pci_dev *pdev =msi_desc_to_pci_dev (desc);int hwirq;int i, ret; + pseries_dev = info->scratchpad[0 ].ptr; + +if (pseries_dev->msi_used + nr_irqs > pseries_dev->msi_quota) +return -ENOSPC ; + hwirq =rtas_query_irq_number (pci_get_pdn (pdev), desc->msi_index);if (hwirq <0 ) {dev_err (&pdev->dev,"Failed to query HW IRQ: %d\n" , hwirq);
@@ -567,9 +602,10 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virq goto out;irq_domain_set_hwirq_and_chip (domain, virq + i, hwirq + i, - &pseries_msi_irq_chip, domain->host_data); + &pseries_msi_irq_chip, pseries_dev); } + pseries_dev->msi_used++;return 0 ; out:
@@ -582,9 +618,11 @@ static void pseries_irq_domain_free(struct irq_domain *domain, unsigned int virq unsigned int nr_irqs) {struct irq_data *d =irq_domain_get_irq_data (domain, virq); -struct pci_controller *phb =irq_data_get_irq_chip_data (d); +struct pseries_msi_device *pseries_dev =irq_data_get_irq_chip_data (d); +struct pci_controller *phb = domain->host_data;pr_debug ("%s bridge %pOF %d #%d\n" , __func__, phb->dn, virq, nr_irqs); + pseries_dev->msi_used -= nr_irqs;irq_domain_free_irqs_parent (domain, virq, nr_irqs); }
Signature · 1 line
2.51.0