From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35A7662177; Wed, 13 Mar 2024 16:42:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348148; cv=none; b=G0+F2WJ4t3NYkD2Tl8KPvbRi6dYjajJzfYzoUt3axH61a3+H+pZADyBDzTPuyJhWHypxVRXc93JwTFuvWsZMvq12OrMxY2ZPROfvOra0bXuoO3pRwZGkrBe5aW0YERsLwh9UM4Mg3HBbEznEXsx6mMzWaBratnZgnU0sR0RRyLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348148; c=relaxed/simple; bh=IdN3gYeyWAVlGPzwpeyM5dTBSOISdvZ318vw8Bk+/9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uqJEochHxLJvEmPRvVo9wmIarDZpc90SJX5moG/0G6pP+DG00wphbzfk2CCPu9FtPHWEZCRrF0u6zqbePMv4NluEILpUVXk3GVsC5wljbOwERQGXGCmjcILZ5OqpjUDPQ5v48+DANC4sOXGDdPoUAcegi/JRoZvp3Uh0H0Cd/sM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P5n7akvF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P5n7akvF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 178EAC43394; Wed, 13 Mar 2024 16:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348147; bh=IdN3gYeyWAVlGPzwpeyM5dTBSOISdvZ318vw8Bk+/9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P5n7akvFAb60dniAxSygVLRftsmwFrHHXCzL3VY4EwrW6uJ5Lo5R/aOX+F7llvY3U KZDdzk3WX4VaYGMS5P3sQG4qsQn2+wz0mtLqhzMfZmSNy6MvFCuanjomsdDnJdXMF+ DGkizFNXa/GUEzmtsGmzHT3w05K0W7b1LYcUc5x72wv5KvjRimQdxaDxckgE8KaYat 5/M3DbqPIExaL2yFn7jZ93RWdnoXb7XSz9Oin32cH/5PzJyG7fdBByWtYcz3JCPpaa ID0U/VCuk7KGHj1RRKkJtFG4caCUYG8MIn7glLaGr3njw9Vz77EFEz3BwKibE7GZxi rJU9/v/Aapo1Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yann Gautier , Ulf Hansson , Sasha Levin Subject: [PATCH 5.15 01/76] mmc: mmci: stm32: use a buffer for unaligned DMA requests Date: Wed, 13 Mar 2024 12:41:08 -0400 Message-ID: <20240313164223.615640-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yann Gautier [ Upstream commit 970dc9c11a17994ab878016b536612ab00d1441d ] In SDIO mode, the sg list for requests can be unaligned with what the STM32 SDMMC internal DMA can support. In that case, instead of failing, use a temporary bounce buffer to copy from/to the sg list. This buffer is limited to 1MB. But for that we need to also limit max_req_size to 1MB. It has not shown any throughput penalties for SD-cards or eMMC. Signed-off-by: Yann Gautier Link: https://lore.kernel.org/r/20220328145114.334577-1-yann.gautier@foss.s= t.com Signed-off-by: Ulf Hansson Stable-dep-of: 6b1ba3f9040b ("mmc: mmci: stm32: fix DMA API overlapping map= pings warning") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/mmc/host/mmci_stm32_sdmmc.c | 88 +++++++++++++++++++++++------ 1 file changed, 71 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_st= m32_sdmmc.c index 4cceb9bab0361..11ae0cb479239 100644 --- a/drivers/mmc/host/mmci_stm32_sdmmc.c +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c @@ -43,6 +43,9 @@ struct sdmmc_lli_desc { struct sdmmc_idma { dma_addr_t sg_dma; void *sg_cpu; + dma_addr_t bounce_dma_addr; + void *bounce_buf; + bool use_bounce_buffer; }; =20 struct sdmmc_dlyb { @@ -54,6 +57,8 @@ struct sdmmc_dlyb { static int sdmmc_idma_validate_data(struct mmci_host *host, struct mmc_data *data) { + struct sdmmc_idma *idma =3D host->dma_priv; + struct device *dev =3D mmc_dev(host->mmc); struct scatterlist *sg; int i; =20 @@ -61,41 +66,69 @@ static int sdmmc_idma_validate_data(struct mmci_host *h= ost, * idma has constraints on idmabase & idmasize for each element * excepted the last element which has no constraint on idmasize */ + idma->use_bounce_buffer =3D false; for_each_sg(data->sg, sg, data->sg_len - 1, i) { if (!IS_ALIGNED(sg->offset, sizeof(u32)) || !IS_ALIGNED(sg->length, SDMMC_IDMA_BURST)) { - dev_err(mmc_dev(host->mmc), + dev_dbg(mmc_dev(host->mmc), "unaligned scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length); - return -EINVAL; + goto use_bounce_buffer; } } =20 if (!IS_ALIGNED(sg->offset, sizeof(u32))) { - dev_err(mmc_dev(host->mmc), + dev_dbg(mmc_dev(host->mmc), "unaligned last scatterlist: ofst:%x length:%d\n", data->sg->offset, data->sg->length); - return -EINVAL; + goto use_bounce_buffer; } =20 + return 0; + +use_bounce_buffer: + if (!idma->bounce_buf) { + idma->bounce_buf =3D dmam_alloc_coherent(dev, + host->mmc->max_req_size, + &idma->bounce_dma_addr, + GFP_KERNEL); + if (!idma->bounce_buf) { + dev_err(dev, "Unable to map allocate DMA bounce buffer.\n"); + return -ENOMEM; + } + } + + idma->use_bounce_buffer =3D true; + return 0; } =20 static int _sdmmc_idma_prep_data(struct mmci_host *host, struct mmc_data *data) { - int n_elem; + struct sdmmc_idma *idma =3D host->dma_priv; =20 - n_elem =3D dma_map_sg(mmc_dev(host->mmc), - data->sg, - data->sg_len, - mmc_get_dma_dir(data)); + if (idma->use_bounce_buffer) { + if (data->flags & MMC_DATA_WRITE) { + unsigned int xfer_bytes =3D data->blksz * data->blocks; =20 - if (!n_elem) { - dev_err(mmc_dev(host->mmc), "dma_map_sg failed\n"); - return -EINVAL; - } + sg_copy_to_buffer(data->sg, data->sg_len, + idma->bounce_buf, xfer_bytes); + dma_wmb(); + } + } else { + int n_elem; + + n_elem =3D dma_map_sg(mmc_dev(host->mmc), + data->sg, + data->sg_len, + mmc_get_dma_dir(data)); =20 + if (!n_elem) { + dev_err(mmc_dev(host->mmc), "dma_map_sg failed\n"); + return -EINVAL; + } + } return 0; } =20 @@ -112,8 +145,19 @@ static int sdmmc_idma_prep_data(struct mmci_host *host, static void sdmmc_idma_unprep_data(struct mmci_host *host, struct mmc_data *data, int err) { - dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, - mmc_get_dma_dir(data)); + struct sdmmc_idma *idma =3D host->dma_priv; + + if (idma->use_bounce_buffer) { + if (data->flags & MMC_DATA_READ) { + unsigned int xfer_bytes =3D data->blksz * data->blocks; + + sg_copy_from_buffer(data->sg, data->sg_len, + idma->bounce_buf, xfer_bytes); + } + } else { + dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, + mmc_get_dma_dir(data)); + } } =20 static int sdmmc_idma_setup(struct mmci_host *host) @@ -137,6 +181,8 @@ static int sdmmc_idma_setup(struct mmci_host *host) host->mmc->max_segs =3D SDMMC_LLI_BUF_LEN / sizeof(struct sdmmc_lli_desc); host->mmc->max_seg_size =3D host->variant->stm32_idmabsize_mask; + + host->mmc->max_req_size =3D SZ_1M; } else { host->mmc->max_segs =3D 1; host->mmc->max_seg_size =3D host->mmc->max_req_size; @@ -154,8 +200,16 @@ static int sdmmc_idma_start(struct mmci_host *host, un= signed int *datactrl) struct scatterlist *sg; int i; =20 - if (!host->variant->dma_lli || data->sg_len =3D=3D 1) { - writel_relaxed(sg_dma_address(data->sg), + if (!host->variant->dma_lli || data->sg_len =3D=3D 1 || + idma->use_bounce_buffer) { + u32 dma_addr; + + if (idma->use_bounce_buffer) + dma_addr =3D idma->bounce_dma_addr; + else + dma_addr =3D sg_dma_address(data->sg); + + writel_relaxed(dma_addr, host->base + MMCI_STM32_IDMABASE0R); writel_relaxed(MMCI_STM32_IDMAEN, host->base + MMCI_STM32_IDMACTRLR); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0134350A88; Wed, 13 Mar 2024 16:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348149; cv=none; b=QA0O96Ze4HAJ3w9XWEZ4IUJbTgoVDUgo+hMT3Yk1A9Ik1BM2ziaSTh6tRKB3b2f4kWLjRlr9Gv4Dl5iocPwPjSMua95jZAS5wC46OrE61y6dUcD5FHDockIAf5av8DZv8AczsEhMwBT/KQBbvlW156csGvA687jknacCvDUOLgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348149; c=relaxed/simple; bh=BKKvaSPOJcIzN9AKZ4t/6eH1vXhiFpdAhQlKssnCZxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aaDbcuqk+qV4sNvbXYCAgpdBswYsXb4HogOR2D97RKgbXWP5rPtGCaV4HaaVNHzBgmI8X3nTFTSFoMYHMkHt8zHEDRLcBFRkuG7BeG9rFT7uO91PDoIEL1jLP77GB0qoh5bxGtLYTv0okJJ4HvmJo7esCoXTdpjzTkmAUVoG0o4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CahHFGXW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CahHFGXW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F54FC43390; Wed, 13 Mar 2024 16:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348148; bh=BKKvaSPOJcIzN9AKZ4t/6eH1vXhiFpdAhQlKssnCZxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CahHFGXWtHcL18LsOZS2utOmDNW+yieTLJvMpSaT/6wqC/8HTMB1/2aTfT1FiR4dC 8WTku8vWfOR+xptNQ4onOoIIuwNc4l/0UbXaSIkuE09Q/fQ+KwghKln+UfoE/kFH4B wYxacbZIR6/I6vYx6eDnGhVOjGJbHN8HEm+OpGGOoJDsEb8uxLMNAnWo/JVgkg+0ht aZW4Myt1nzp3aWeVEw7h8sNmolv8THsCYC2aYfdYrG7PNVlwwVoq5tHXJUSYSMgRO8 jbwllfsFWUsdY36BRpqhICZHfXUDCbCaKxMXPgEoaGWhW0LqfqPcF8o13bAn5vrb3L xGesmZuznfTcQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe Kerello , Ulf Hansson , Sasha Levin Subject: [PATCH 5.15 02/76] mmc: mmci: stm32: fix DMA API overlapping mappings warning Date: Wed, 13 Mar 2024 12:41:09 -0400 Message-ID: <20240313164223.615640-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christophe Kerello [ Upstream commit 6b1ba3f9040be5efc4396d86c9752cdc564730be ] Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning: DMA-API: mmci-pl18x 48220000.mmc: cacheline tracking EEXIST, overlapping mappings aren't supported WARNING: CPU: 1 PID: 51 at kernel/dma/debug.c:568 add_dma_entry+0x234/0x2f4 Modules linked in: CPU: 1 PID: 51 Comm: kworker/1:2 Not tainted 6.1.28 #1 Hardware name: STMicroelectronics STM32MP257F-EV1 Evaluation Board (DT) Workqueue: events_freezable mmc_rescan Call trace: add_dma_entry+0x234/0x2f4 debug_dma_map_sg+0x198/0x350 __dma_map_sg_attrs+0xa0/0x110 dma_map_sg_attrs+0x10/0x2c sdmmc_idma_prep_data+0x80/0xc0 mmci_prep_data+0x38/0x84 mmci_start_data+0x108/0x2dc mmci_request+0xe4/0x190 __mmc_start_request+0x68/0x140 mmc_start_request+0x94/0xc0 mmc_wait_for_req+0x70/0x100 mmc_send_tuning+0x108/0x1ac sdmmc_execute_tuning+0x14c/0x210 mmc_execute_tuning+0x48/0xec mmc_sd_init_uhs_card.part.0+0x208/0x464 mmc_sd_init_card+0x318/0x89c mmc_attach_sd+0xe4/0x180 mmc_rescan+0x244/0x320 DMA API debug brings to light leaking dma-mappings as dma_map_sg and dma_unmap_sg are not correctly balanced. If an error occurs in mmci_cmd_irq function, only mmci_dma_error function is called and as this API is not managed on stm32 variant, dma_unmap_sg is never called in this error path. Signed-off-by: Christophe Kerello Fixes: 46b723dd867d ("mmc: mmci: add stm32 sdmmc variant") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240207143951.938144-1-christophe.kerello@= foss.st.com Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/mmc/host/mmci_stm32_sdmmc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mmc/host/mmci_stm32_sdmmc.c b/drivers/mmc/host/mmci_st= m32_sdmmc.c index 11ae0cb479239..e3201a621870a 100644 --- a/drivers/mmc/host/mmci_stm32_sdmmc.c +++ b/drivers/mmc/host/mmci_stm32_sdmmc.c @@ -200,6 +200,8 @@ static int sdmmc_idma_start(struct mmci_host *host, uns= igned int *datactrl) struct scatterlist *sg; int i; =20 + host->dma_in_progress =3D true; + if (!host->variant->dma_lli || data->sg_len =3D=3D 1 || idma->use_bounce_buffer) { u32 dma_addr; @@ -238,9 +240,30 @@ static int sdmmc_idma_start(struct mmci_host *host, un= signed int *datactrl) return 0; } =20 +static void sdmmc_idma_error(struct mmci_host *host) +{ + struct mmc_data *data =3D host->data; + struct sdmmc_idma *idma =3D host->dma_priv; + + if (!dma_inprogress(host)) + return; + + writel_relaxed(0, host->base + MMCI_STM32_IDMACTRLR); + host->dma_in_progress =3D false; + data->host_cookie =3D 0; + + if (!idma->use_bounce_buffer) + dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, + mmc_get_dma_dir(data)); +} + static void sdmmc_idma_finalize(struct mmci_host *host, struct mmc_data *d= ata) { + if (!dma_inprogress(host)) + return; + writel_relaxed(0, host->base + MMCI_STM32_IDMACTRLR); + host->dma_in_progress =3D false; =20 if (!data->host_cookie) sdmmc_idma_unprep_data(host, data, 0); @@ -566,6 +589,7 @@ static struct mmci_host_ops sdmmc_variant_ops =3D { .dma_setup =3D sdmmc_idma_setup, .dma_start =3D sdmmc_idma_start, .dma_finalize =3D sdmmc_idma_finalize, + .dma_error =3D sdmmc_idma_error, .set_clkreg =3D mmci_sdmmc_set_clkreg, .set_pwrreg =3D mmci_sdmmc_set_pwrreg, .busy_complete =3D sdmmc_busy_complete, --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72737627E8; Wed, 13 Mar 2024 16:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348150; cv=none; b=FrkATvDBd3Ppxg5ZJXcbBK+04O1MCXIF2RJOl+YEDCoKybAnUPCpPcmGUfpy0aJz/c9sXEh+Tbl7NVrTI2HWdn+3FgfrL1zvBG1R28t7WbzB5q7pi2L8EsqZBIYMe1WEcdXV/JWs/45UH+jFk+dhZAPgxeRx9C69Ze5zkNX+qeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348150; c=relaxed/simple; bh=ZnVYI0EVRMPAR8YuEzTHJ8BKEfsGMglMjd5MZe0BcTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sKlfmIqyZBzvPp/tLoh0OX85Jg9F67GTRWUlZZJgv5v7z4o05cfb7GKl/vDoK+ksWrVbbqWOW1Kfu4jsefQOcq3Mjq3LlnNnNDlelIiiA9uqVYsfFN2gdF+vxuVfASuhAVprUmB52a+9xvuVGD9HfrnR4xiVki4f8mF/gj42n44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QdVz807g; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QdVz807g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D227C433B1; Wed, 13 Mar 2024 16:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348150; bh=ZnVYI0EVRMPAR8YuEzTHJ8BKEfsGMglMjd5MZe0BcTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QdVz807gDjqumUkrg7+XL1zFfu2v43PCeqQlpbXVHDB/tTzHmGVVqckBY8keOhV0E Jlq7DM/aFgGwnWx0mlDRzHrkBSqbctC2qEL6OXKnaDd59HiH9MBMOSaCS1tFYZofjH 22hcdLvbOM6l33Dld5UJg3o5i1vwop7sKTiv0TBwXPqj1aikFueR+d9j52PGMdmn1S 1Jkh5B3UbfF2BTzNM0fAPpeUK6uqnzvKQGoGuvMEh7ZzUF8k1EyfBkerPEufy3qMjp ZonZnLHDrTw1e5yXbA7rF/v3OnF6eBOCc9erJKmkzW97erEyj6CDbA1RWBEdEUiqZM RWf/cZa4vcFsA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleksij Rempel , Jiri Pirko , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 03/76] net: lan78xx: fix runtime PM count underflow on link stop Date: Wed, 13 Mar 2024 12:41:10 -0400 Message-ID: <20240313164223.615640-4-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleksij Rempel [ Upstream commit 1eecc7ab82c42133b748e1895275942a054a7f67 ] Current driver has some asymmetry in the runtime PM calls. On lan78xx_open() it will call usb_autopm_get() and unconditionally usb_autopm_put(). And on lan78xx_stop() it will call only usb_autopm_put(). So far, it was working only because this driver do not activate autosuspend by default, so it was visible only by warning "Runtime PM usage count underflow!". Since, with current driver, we can't use runtime PM with active link, execute lan78xx_open()->usb_autopm_put() only in error case. Otherwise, keep ref counting high as long as interface is open. Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Eth= ernet device driver") Signed-off-by: Oleksij Rempel Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/usb/lan78xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index c8b42892655a1..77cb30259dca7 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2960,7 +2960,8 @@ static int lan78xx_open(struct net_device *net) done: mutex_unlock(&dev->dev_mutex); =20 - usb_autopm_put_interface(dev->intf); + if (ret < 0) + usb_autopm_put_interface(dev->intf); =20 return ret; } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC1ED6280A; Wed, 13 Mar 2024 16:42:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348152; cv=none; b=UjJb0BtmqKIA8IyIXB8KKef3TGwBeBvHfsRZ9s4Yp7pKof4dtRzwyYpGQl56gBVe3qOHELws4V08Ar4/mv3KUG0G4YyOtQGKHTuf7WtpDdTZmTZL66egKY9wd1hcDy6gEkYv0EMWRIfu8mGHFELEnAXDcWILyV73Jhtgowsn+bU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348152; c=relaxed/simple; bh=tDLapTrYVVfBn92f5DQJ5rKP0LhQm5cgNKUSlLYd3iQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qmLxpNpCqEisPqEqlTcsm+cFK4vs0CaRzku7X7Vr2w7YakB/SEoPjbx8K/JikKgp/bY0KCOkZBSlBKYUtWESsuX3GloT5pvkM0J7CBGJS0spyTbL/kKM+osDJdD6w6ONDF3aRiKAw6CYOic9ezUY6q4yVyO8gPRyBKkyHhpOUjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r6LMPOsB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r6LMPOsB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C842C43390; Wed, 13 Mar 2024 16:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348151; bh=tDLapTrYVVfBn92f5DQJ5rKP0LhQm5cgNKUSlLYd3iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6LMPOsBJ+qptjWCiw5gNr5XtEz3QSKAKMP//cjFh+DIO0iMscGtYHIsXkKk9zkpg +kZiFbzLD6/KWqfkeio8sDP17WvMEtytcvaZwI7BIca/GOsDxrlocdkSOlYPaFhSOf fdC5JhD5sWM3t7gH7d477T/WPd1PdVh8/JfbU5GNJjpw/Cy4NBBdAiXXP3RLIPunAP piShabUAyc5HzTsa7c+8AyvThpSgFXiDzelp1G/3nF9gQkyLs8z3eKii/Bks/prDX9 5KuRvNcpT03SmrWTb6y0+hKn0O+4+0Kz+tRqeCh6ZpierBB9+wfiLE5YfHs/F+DVrK 8XSrsOKDovOXw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maciej Fijalkowski , Pavel Vazharov , Magnus Karlsson , Chandan Kumar Rout , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 04/76] ixgbe: {dis, en}able irqs in ixgbe_txrx_ring_{dis, en}able Date: Wed, 13 Mar 2024 12:41:11 -0400 Message-ID: <20240313164223.615640-5-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maciej Fijalkowski [ Upstream commit cbf996f52c4e658b3fb4349a869a62fd2d4c3c1c ] Currently routines that are supposed to toggle state of ring pair do not take care of associated interrupt with queue vector that these rings belong to. This causes funky issues such as dead interface due to irq misconfiguration, as per Pavel's report from Closes: tag. Add a function responsible for disabling single IRQ in EIMC register and call this as a very first thing when disabling ring pair during xsk_pool setup. For enable let's reuse ixgbe_irq_enable_queues(). Besides this, disable/enable NAPI as first/last thing when dealing with closing or opening ring pair that xsk_pool is being configured on. Reported-by: Pavel Vazharov Closes: https://lore.kernel.org/netdev/CAJEV1ijxNyPTwASJER1bcZzS9nMoZJqfR86= nu_3jFFVXzZQ4NA@mail.gmail.com/ Fixes: 024aa5800f32 ("ixgbe: added Rx/Tx ring disable/enable functions") Signed-off-by: Maciej Fijalkowski Acked-by: Magnus Karlsson Tested-by: Chandan Kumar Rout (A Contingent Worke= r at Intel) Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 56 ++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/et= hernet/intel/ixgbe/ixgbe_main.c index cb9e9d70b338c..d7eabc526f782 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -2941,8 +2941,8 @@ static void ixgbe_check_lsc(struct ixgbe_adapter *ada= pter) static inline void ixgbe_irq_enable_queues(struct ixgbe_adapter *adapter, u64 qmask) { - u32 mask; struct ixgbe_hw *hw =3D &adapter->hw; + u32 mask; =20 switch (hw->mac.type) { case ixgbe_mac_82598EB: @@ -10380,6 +10380,44 @@ static void ixgbe_reset_rxr_stats(struct ixgbe_rin= g *rx_ring) memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats)); } =20 +/** + * ixgbe_irq_disable_single - Disable single IRQ vector + * @adapter: adapter structure + * @ring: ring index + **/ +static void ixgbe_irq_disable_single(struct ixgbe_adapter *adapter, u32 ri= ng) +{ + struct ixgbe_hw *hw =3D &adapter->hw; + u64 qmask =3D BIT_ULL(ring); + u32 mask; + + switch (adapter->hw.mac.type) { + case ixgbe_mac_82598EB: + mask =3D qmask & IXGBE_EIMC_RTX_QUEUE; + IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, mask); + break; + case ixgbe_mac_82599EB: + case ixgbe_mac_X540: + case ixgbe_mac_X550: + case ixgbe_mac_X550EM_x: + case ixgbe_mac_x550em_a: + mask =3D (qmask & 0xFFFFFFFF); + if (mask) + IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask); + mask =3D (qmask >> 32); + if (mask) + IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask); + break; + default: + break; + } + IXGBE_WRITE_FLUSH(&adapter->hw); + if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) + synchronize_irq(adapter->msix_entries[ring].vector); + else + synchronize_irq(adapter->pdev->irq); +} + /** * ixgbe_txrx_ring_disable - Disable Rx/Tx/XDP Tx rings * @adapter: adapter structure @@ -10396,6 +10434,11 @@ void ixgbe_txrx_ring_disable(struct ixgbe_adapter = *adapter, int ring) tx_ring =3D adapter->tx_ring[ring]; xdp_ring =3D adapter->xdp_ring[ring]; =20 + ixgbe_irq_disable_single(adapter, ring); + + /* Rx/Tx/XDP Tx share the same napi context. */ + napi_disable(&rx_ring->q_vector->napi); + ixgbe_disable_txr(adapter, tx_ring); if (xdp_ring) ixgbe_disable_txr(adapter, xdp_ring); @@ -10404,9 +10447,6 @@ void ixgbe_txrx_ring_disable(struct ixgbe_adapter *= adapter, int ring) if (xdp_ring) synchronize_rcu(); =20 - /* Rx/Tx/XDP Tx share the same napi context. */ - napi_disable(&rx_ring->q_vector->napi); - ixgbe_clean_tx_ring(tx_ring); if (xdp_ring) ixgbe_clean_tx_ring(xdp_ring); @@ -10434,9 +10474,6 @@ void ixgbe_txrx_ring_enable(struct ixgbe_adapter *a= dapter, int ring) tx_ring =3D adapter->tx_ring[ring]; xdp_ring =3D adapter->xdp_ring[ring]; =20 - /* Rx/Tx/XDP Tx share the same napi context. */ - napi_enable(&rx_ring->q_vector->napi); - ixgbe_configure_tx_ring(adapter, tx_ring); if (xdp_ring) ixgbe_configure_tx_ring(adapter, xdp_ring); @@ -10445,6 +10482,11 @@ void ixgbe_txrx_ring_enable(struct ixgbe_adapter *= adapter, int ring) clear_bit(__IXGBE_TX_DISABLED, &tx_ring->state); if (xdp_ring) clear_bit(__IXGBE_TX_DISABLED, &xdp_ring->state); + + /* Rx/Tx/XDP Tx share the same napi context. */ + napi_enable(&rx_ring->q_vector->napi); + ixgbe_irq_enable_queues(adapter, BIT_ULL(ring)); + IXGBE_WRITE_FLUSH(&adapter->hw); } =20 /** --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B681B629F9; Wed, 13 Mar 2024 16:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348152; cv=none; b=SsJS50Plu5K6lsRKTFfoeC7Zbda1WnDVbtEv1CjAtikSbrMc8ET3QY4DtAjiZcvqoRrj96nl3eitIsgPgz/8qRAuUmoiTErT2sGiZZUmVn94E2HzfdsGt8s37v0KbzRfvO27ibJlDrGs4Qu1x0L2HqsjqvhvhGZ5d1pZ5oALsLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348152; c=relaxed/simple; bh=sBSg5rfKvh3atIZHujnBMgH/0FxhtiJyLtx8D1IvtHo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lHxWp71axoIT74xTwj1vN09x7bBwKPQlLvLy3Ldihd+7XOkb3cVkAOZGrJl5GnZwnjn9drXLbk2v1GapXHHlQQBiV41rFVI9PQ7SfD54rxUXhLD+0uA7PhasBRi5Quik8vSeU+FyCemEnmq5NUNsr7+92JnYlTASaqE0xxn+y84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UgJ2BAxA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UgJ2BAxA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE0D8C32791; Wed, 13 Mar 2024 16:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348152; bh=sBSg5rfKvh3atIZHujnBMgH/0FxhtiJyLtx8D1IvtHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UgJ2BAxAf9/jek3zXtxlTE6U71X8jAY5pZiXb9jTepcbR4Sp2ztDMhp35gJNhJf9L KJ+Dr2FiTmF/Kt2viiFmwfm9MYUIkJsg+zC5bLR/wt+YeCrKBmMZs4hg4NPI89oUPr qCg78pESq5FnkU4vNCK/HIpe1uSJhsOKs2h9VRV7KMu9EwsCdHl3rWw1N8L2qDiL/O R1JSEncASYCl6hXB/S2lzFC8a3WinYZbBozuCqaK5Dld21TL3VpNRyHV8tDTlIM74D Pz1DOGGMy2Z8SPZq3tQikHq1p7u+1UubTyAkFBElzQBKoHmU6Qti3tgQv8GGy6E12z v/BmB/uP9wSHw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maciej Fijalkowski , Chandan Kumar Rout , Magnus Karlsson , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 05/76] i40e: disable NAPI right after disabling irqs when handling xsk_pool Date: Wed, 13 Mar 2024 12:41:12 -0400 Message-ID: <20240313164223.615640-6-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Maciej Fijalkowski [ Upstream commit d562b11c1eac7d73f4c778b4cbe5468f86b1f20d ] Disable NAPI before shutting down queues that this particular NAPI contains so that the order of actions in i40e_queue_pair_disable() mirrors what we do in i40e_queue_pair_enable(). Fixes: 123cecd427b6 ("i40e: added queue pair disable/enable functions") Signed-off-by: Maciej Fijalkowski Tested-by: Chandan Kumar Rout (A Contingent Worke= r at Intel) Acked-by: Magnus Karlsson Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethe= rnet/intel/i40e/i40e_main.c index 3d2b92a952a65..7b522d55f3684 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -13558,9 +13558,9 @@ int i40e_queue_pair_disable(struct i40e_vsi *vsi, i= nt queue_pair) return err; =20 i40e_queue_pair_disable_irq(vsi, queue_pair); + i40e_queue_pair_toggle_napi(vsi, queue_pair, false /* off */); err =3D i40e_queue_pair_toggle_rings(vsi, queue_pair, false /* off */); i40e_clean_rx_ring(vsi->rx_rings[queue_pair]); - i40e_queue_pair_toggle_napi(vsi, queue_pair, false /* off */); i40e_queue_pair_clean_rings(vsi, queue_pair); i40e_queue_pair_reset_stats(vsi, queue_pair); =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCCEF1361D2; Wed, 13 Mar 2024 16:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348154; cv=none; b=s2aEcTPbpor4QbUjmxPK3sK9Bsfav9Brl7gzu9xfw2+D42HzcMuuZ03fIjWDxHL7TBWtd3Aisd6mLyqq3SpNJnaJ3GrwAHOUeJTraj2chC3pGSCM+PPB6njdMumcd8FuR5alqqYo0+wipDG0mz07QtYI3V+QbTWRsKvFN33tmTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348154; c=relaxed/simple; bh=4zVB3pbegpCJmWix2xtZJr4g8LMPicBl373W8BWcsAs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=miWkDHIgcDXrW6m+begq57wKMM8mbrOwxt/a+raDJNs4T+gxjF/ulMqSBEX+CEQBt1LIbcIQszuIdvora7qBn07wBrLn5sIx3enGp8iMaYFhhhYJ7F/kZwCFgY543wB5kgV9xzI/KIWkO6y1BkZShd+7fsVVRWIv4FhjtJuCjj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AEf6eXMH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AEf6eXMH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7040C3279A; Wed, 13 Mar 2024 16:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348153; bh=4zVB3pbegpCJmWix2xtZJr4g8LMPicBl373W8BWcsAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEf6eXMHfLtekMV0zMHOfRLKVMA8HpINahDN2uJAv/N8VVA3keXs7r5PqT8p3Am4n 41SQ3rl4fo8t70TA172HA2PfUhYbRxIFTu8YpNGw0tHphv8PoPBoDONP7CCIaxval4 0dS3u4TH8hjhqNBEahhDMcf4BD3Ibc7xrmeBXe6YVB8bOTLjw8yfyh3ngWfCVB2dcV /tKuf2+Y46w6p+kLqvVzUq4KHlxx34T+BjHRSAzvh0wiw9qOe+osGkn79L030hyR5B DxuJfaTeEUVHsBtIooqMnTFQbPmeVv2Z+hrnQTUUvvn6AnuRH8C3C/YuQflyAhFw8k Ue/6STCGFBpaQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Steven Rostedt (Google)" , Jamal Hadi Salim , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 06/76] tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string Date: Wed, 13 Mar 2024 12:41:13 -0400 Message-ID: <20240313164223.615640-7-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: "Steven Rostedt (Google)" [ Upstream commit 51270d573a8d9dd5afdc7934de97d66c0e14b5fd ] I'm updating __assign_str() and will be removing the second parameter. To make sure that it does not break anything, I make sure that it matches the __string() field, as that is where the string is actually going to be saved in. To make sure there's nothing that breaks, I added a WARN_ON() to make sure that what was used in __string() is the same that is used in __assign_str(). In doing this change, an error was triggered as __assign_str() now expects the string passed in to be a char * value. I instead had the following warning: include/trace/events/qdisc.h: In function =E2=80=98trace_event_raw_event_qd= isc_reset=E2=80=99: include/trace/events/qdisc.h:91:35: error: passing argument 1 of 'strcmp' f= rom incompatible pointer type [-Werror=3Dincompatible-pointer-types] 91 | __assign_str(dev, qdisc_dev(q)); That's because the qdisc_enqueue() and qdisc_reset() pass in qdisc_dev(q) to __assign_str() and to __string(). But that function returns a pointer to struct net_device and not a string. It appears that these events are just saving the pointer as a string and then reading it as a string as well. Use qdisc_dev(q)->name to save the device instead. Fixes: a34dac0b90552 ("net_sched: add tracepoints for qdisc_reset() and qdi= sc_destroy()") Signed-off-by: Steven Rostedt (Google) Reviewed-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- include/trace/events/qdisc.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/trace/events/qdisc.h b/include/trace/events/qdisc.h index 59c945b66f9c7..5180da19d837f 100644 --- a/include/trace/events/qdisc.h +++ b/include/trace/events/qdisc.h @@ -81,14 +81,14 @@ TRACE_EVENT(qdisc_reset, TP_ARGS(q), =20 TP_STRUCT__entry( - __string( dev, qdisc_dev(q) ) - __string( kind, q->ops->id ) - __field( u32, parent ) - __field( u32, handle ) + __string( dev, qdisc_dev(q)->name ) + __string( kind, q->ops->id ) + __field( u32, parent ) + __field( u32, handle ) ), =20 TP_fast_assign( - __assign_str(dev, qdisc_dev(q)); + __assign_str(dev, qdisc_dev(q)->name); __assign_str(kind, q->ops->id); __entry->parent =3D q->parent; __entry->handle =3D q->handle; @@ -106,14 +106,14 @@ TRACE_EVENT(qdisc_destroy, TP_ARGS(q), =20 TP_STRUCT__entry( - __string( dev, qdisc_dev(q) ) - __string( kind, q->ops->id ) - __field( u32, parent ) - __field( u32, handle ) + __string( dev, qdisc_dev(q)->name ) + __string( kind, q->ops->id ) + __field( u32, parent ) + __field( u32, handle ) ), =20 TP_fast_assign( - __assign_str(dev, qdisc_dev(q)); + __assign_str(dev, qdisc_dev(q)->name); __assign_str(kind, q->ops->id); __entry->parent =3D q->parent; __entry->handle =3D q->handle; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24398136671; Wed, 13 Mar 2024 16:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348155; cv=none; b=WXR6V9/kD5W5dbqrcikK3MNrylLjYQlPc9K9SwL+Q3FyTu6Bovb+VEHTq7Vh903b4C1TD/3+7jXpyVFKe33ZJIO8b0wQAWeaPA/HAD1npw9ilXt/sbCsfrvoo9MFTksocq49hP9NINUgG0nFKg7MJ/83cUJcvzgcILHWjCpEDvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348155; c=relaxed/simple; bh=4Tmnb5SPgyP3HB7S9PBks/WqTz6e9grTcyBGu1v9p6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f7qCT3Sz8sX1iydO2JX/S0WAuu3Rp9yDrufFrTNBn8H8hlitaqQxc7d+8dW8RIHeJWhuPc6JvLiIJoJLMoDuF2yodewl7RNnwNATFScpZMztSNyo3cobnAzbCtcsy4QVPXnvTdvDJ3DkKmRPDafYL8UYg5CbNOkasINpBSTHeys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a/I4UEBz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="a/I4UEBz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17C4DC433B1; Wed, 13 Mar 2024 16:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348155; bh=4Tmnb5SPgyP3HB7S9PBks/WqTz6e9grTcyBGu1v9p6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/I4UEBzdT5ldf1H2vGbAcxNt0P+o5OoWfAWKik0YG/0J3cHpWJ00Rl9T9IVqmsMv pYA/zqNSIUHHF1B/v2Utkke5OeJqswDyvTc/x/XfGZvY/0ufFd+JRrYJgBF/3hY30Z f/I6IQvgoxVU1XrM91EUgxEPFJd1eV7FU8jO/pVXSnaHTqm4HvXPA6FhQKURcuOUAv hxRybKw+ciStX6CV1W+caqjS6HEpApprY6yZ6mUFxq7SKkyJWZlcur27wL/wnBqyB4 8U+6QK7I9CVrB3XbUxYtB1pR6STd96qGArBTIkO11evg0uo4GhT7jYB131/nPCj8Yc ByavWldR/8iuA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Dumazet , syzbot+6a1423ff3f97159aae64@syzkaller.appspotmail.com, Jiri Pirko , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 07/76] geneve: make sure to pull inner header in geneve_rx() Date: Wed, 13 Mar 2024 12:41:14 -0400 Message-ID: <20240313164223.615640-8-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit 1ca1ba465e55b9460e4e75dec9fff31e708fec74 ] syzbot triggered a bug in geneve_rx() [1] Issue is similar to the one I fixed in commit 8d975c15c0cd ("ip6_tunnel: make sure to pull inner header in __ip6_tnl_rcv()") We have to save skb->network_header in a temporary variable in order to be able to recompute the network_header pointer after a pskb_inet_may_pull() call. pskb_inet_may_pull() makes sure the needed headers are in skb->head. [1] BUG: KMSAN: uninit-value in IP_ECN_decapsulate include/net/inet_ecn.h:302 [= inline] BUG: KMSAN: uninit-value in geneve_rx drivers/net/geneve.c:279 [inline] BUG: KMSAN: uninit-value in geneve_udp_encap_recv+0x36f9/0x3c10 drivers/ne= t/geneve.c:391 IP_ECN_decapsulate include/net/inet_ecn.h:302 [inline] geneve_rx drivers/net/geneve.c:279 [inline] geneve_udp_encap_recv+0x36f9/0x3c10 drivers/net/geneve.c:391 udp_queue_rcv_one_skb+0x1d39/0x1f20 net/ipv4/udp.c:2108 udp_queue_rcv_skb+0x6ae/0x6e0 net/ipv4/udp.c:2186 udp_unicast_rcv_skb+0x184/0x4b0 net/ipv4/udp.c:2346 __udp4_lib_rcv+0x1c6b/0x3010 net/ipv4/udp.c:2422 udp_rcv+0x7d/0xa0 net/ipv4/udp.c:2604 ip_protocol_deliver_rcu+0x264/0x1300 net/ipv4/ip_input.c:205 ip_local_deliver_finish+0x2b8/0x440 net/ipv4/ip_input.c:233 NF_HOOK include/linux/netfilter.h:314 [inline] ip_local_deliver+0x21f/0x490 net/ipv4/ip_input.c:254 dst_input include/net/dst.h:461 [inline] ip_rcv_finish net/ipv4/ip_input.c:449 [inline] NF_HOOK include/linux/netfilter.h:314 [inline] ip_rcv+0x46f/0x760 net/ipv4/ip_input.c:569 __netif_receive_skb_one_core net/core/dev.c:5534 [inline] __netif_receive_skb+0x1a6/0x5a0 net/core/dev.c:5648 process_backlog+0x480/0x8b0 net/core/dev.c:5976 __napi_poll+0xe3/0x980 net/core/dev.c:6576 napi_poll net/core/dev.c:6645 [inline] net_rx_action+0x8b8/0x1870 net/core/dev.c:6778 __do_softirq+0x1b7/0x7c5 kernel/softirq.c:553 do_softirq+0x9a/0xf0 kernel/softirq.c:454 __local_bh_enable_ip+0x9b/0xa0 kernel/softirq.c:381 local_bh_enable include/linux/bottom_half.h:33 [inline] rcu_read_unlock_bh include/linux/rcupdate.h:820 [inline] __dev_queue_xmit+0x2768/0x51c0 net/core/dev.c:4378 dev_queue_xmit include/linux/netdevice.h:3171 [inline] packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276 packet_snd net/packet/af_packet.c:3081 [inline] packet_sendmsg+0x8aef/0x9f10 net/packet/af_packet.c:3113 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg net/socket.c:745 [inline] __sys_sendto+0x735/0xa10 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b Uninit was created at: slab_post_alloc_hook mm/slub.c:3819 [inline] slab_alloc_node mm/slub.c:3860 [inline] kmem_cache_alloc_node+0x5cb/0xbc0 mm/slub.c:3903 kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560 __alloc_skb+0x352/0x790 net/core/skbuff.c:651 alloc_skb include/linux/skbuff.h:1296 [inline] alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6394 sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2783 packet_alloc_skb net/packet/af_packet.c:2930 [inline] packet_snd net/packet/af_packet.c:3024 [inline] packet_sendmsg+0x70c2/0x9f10 net/packet/af_packet.c:3113 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg net/socket.c:745 [inline] __sys_sendto+0x735/0xa10 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b Fixes: 2d07dc79fe04 ("geneve: add initial netdev driver for GENEVE tunnels") Reported-and-tested-by: syzbot+6a1423ff3f97159aae64@syzkaller.appspotmail.c= om Signed-off-by: Eric Dumazet Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/geneve.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 605332f36d9df..9569b5cc595ec 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -219,7 +219,7 @@ static void geneve_rx(struct geneve_dev *geneve, struct= geneve_sock *gs, struct genevehdr *gnvh =3D geneve_hdr(skb); struct metadata_dst *tun_dst =3D NULL; unsigned int len; - int err =3D 0; + int nh, err =3D 0; void *oiph; =20 if (ip_tunnel_collect_metadata() || gs->collect_md) { @@ -263,9 +263,23 @@ static void geneve_rx(struct geneve_dev *geneve, struc= t geneve_sock *gs, goto drop; } =20 - oiph =3D skb_network_header(skb); + /* Save offset of outer header relative to skb->head, + * because we are going to reset the network header to the inner header + * and might change skb->head. + */ + nh =3D skb_network_header(skb) - skb->head; + skb_reset_network_header(skb); =20 + if (!pskb_inet_may_pull(skb)) { + DEV_STATS_INC(geneve->dev, rx_length_errors); + DEV_STATS_INC(geneve->dev, rx_errors); + goto drop; + } + + /* Get the outer header. */ + oiph =3D skb->head + nh; + if (geneve_get_sk_family(gs) =3D=3D AF_INET) err =3D IP_ECN_decapsulate(oiph, skb); #if IS_ENABLED(CONFIG_IPV6) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 451A81369A3; Wed, 13 Mar 2024 16:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348156; cv=none; b=oIrzD13+206j+spYwVFQ+XFkIyxEfu1zolF0iiRonjF52nwi2S6X00j67RlvXYnoLiZ66GhNYyj6/mncevF1EMqsCxsqHaz+++JvsAUhJyXNU1U555UUZcKYXvi6s+DGDVWn75MtJ5hGi0Zw8l70T+eXtgwz8Pu0iYDinz4lHzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348156; c=relaxed/simple; bh=bxywz7gfC5Zr9syRS/KzdmYrKoUf25nSuiCn3skB54w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u7QL9PNk2esBedNCPRdWxdoG7BM4Kh5yUKHr4VFkkIDZAGS5VnEjeg3mp5AqTIkZJAngf770I6+vxlo7KWxcNvntL2UOSPO0vJJuliCpqQpEh/JmeeFwXPH5OsmdTZ/ipSCyn97GqCY9DZPdKheqQW73b5oNNObQgHxIhvLhCGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DpJd3Ut1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DpJd3Ut1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E8BBC43141; Wed, 13 Mar 2024 16:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348156; bh=bxywz7gfC5Zr9syRS/KzdmYrKoUf25nSuiCn3skB54w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpJd3Ut1mNg9pdAZvTIPCGNWXo6Gh9Pc2+j3qthgZgmKRlPdFViSaGiT4P5IyBzAe LqPr5w4FxfpZn+GmAgiTXej1LQpl2CNS10eaf7GVgGp3eyrkADXnvkNGMQ9PqDxMLO b4bjAdsnJVaPhizAE27dTTLToMrO3jfohU+Xn7dSp/EuOQpdBe3JcvrTJ/Gcjm6Hz9 +tG4uCflEvnyeOIfn82GhdT1cUwG8HzFL6kwRuLcaWz/7jrC7+OKEamBlpHcdUuyL2 UGSx5Nr04//H4LJYskq8SP0czEzBp6Y93OTT8OfpSYQ9XR1RArFYvKhVBaaJIFmvR9 cx/8n9WM4EXXQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Horatiu Vultur , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 08/76] net: sparx5: Fix use after free inside sparx5_del_mact_entry Date: Wed, 13 Mar 2024 12:41:15 -0400 Message-ID: <20240313164223.615640-9-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Horatiu Vultur [ Upstream commit 89d72d4125e94aa3c2140fedd97ce07ba9e37674 ] Based on the static analyzis of the code it looks like when an entry from the MAC table was removed, the entry was still used after being freed. More precise the vid of the mac_entry was used after calling devm_kfree on the mac_entry. The fix consists in first using the vid of the mac_entry to delete the entry from the HW and after that to free it. Fixes: b37a1bae742f ("net: sparx5: add mactable support") Signed-off-by: Horatiu Vultur Reviewed-by: Simon Horman Link: https://lore.kernel.org/r/20240301080608.3053468-1-horatiu.vultur@mic= rochip.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c b/driv= ers/net/ethernet/microchip/sparx5/sparx5_mactable.c index 9a8e4f201eb1f..6ba93fa984f26 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c @@ -344,10 +344,10 @@ int sparx5_del_mact_entry(struct sparx5 *sparx5, list) { if ((vid =3D=3D 0 || mact_entry->vid =3D=3D vid) && ether_addr_equal(addr, mact_entry->mac)) { + sparx5_mact_forget(sparx5, addr, mact_entry->vid); + list_del(&mact_entry->list); devm_kfree(sparx5->dev, mact_entry); - - sparx5_mact_forget(sparx5, addr, mact_entry->vid); } } mutex_unlock(&sparx5->mact_lock); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8AB513774E; Wed, 13 Mar 2024 16:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348157; cv=none; b=GHk80/YxjAv3VRLqj6nNzd0LIPlJTfX2K3gQ+UcIqJdhVPMkMRI5A1n6jfP8oX52VassADza3hHqJKiy67YXcwE7r3DQ/HVQwRJW1McDPEAfsyzVaN15no6TBEl5d91WUKXREdL6BMTrMDJO0qxYP1lOS/y4RowaqiOBDu0M4p8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348157; c=relaxed/simple; bh=4FrnG+R/9EakgivZSNNtZb5j+1oO4df+JTS9AuAuvMY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SN6DMe1LRbvbpKqpWBsj/VX1ok7mLJfM4WmRRgTD2WbFZQpWRsL1w8p1lIdptJxlJra7dLFhiwiAtY46nvdkNwj7p1IAv2p/g7+qxMZCG/ydz6jMoF7uIAGrXftyMj9CsNklSCjDkb2WvIkFSMYoyxQqiv9yQfvbKMZBwhclgUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ijlko+Zn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ijlko+Zn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70620C4160D; Wed, 13 Mar 2024 16:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348157; bh=4FrnG+R/9EakgivZSNNtZb5j+1oO4df+JTS9AuAuvMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijlko+Zn8Oc0sPe4Isu8fhKfx6RqixVDkSeb4fnKvVypjIbM0nRjQgsobZCHscwAH NyVbDKH6M4UmQP37qxo9RhMd9Fgjkd4B3EAnEDdeUW0+W+crJTvQrs5LpoZfe5kpm4 PsUQJJPcXOOnx5wsE2akN+9PVrKhyN0oggLpAm/c+2cPY6BvW9YEWZJqCYntshXMNV BpkMZKWwVqJs4ojzmg9H/v8UIyurbzXTI0mfmlLYEaAZ2tWrOUlw61CKpsTWMq6mo9 szEcWliT1c7+XAZYuc8x5GQS39LKcSL2PN9rq7GbV8rCdUYmzC3wZxKSXbTDgn8xuA mSarRwCQuoXzg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Rand Deeb , Simon Horman , Tony Nguyen , Sasha Levin Subject: [PATCH 5.15 09/76] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Date: Wed, 13 Mar 2024 12:41:16 -0400 Message-ID: <20240313164223.615640-10-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rand Deeb [ Upstream commit 06e456a05d669ca30b224b8ed962421770c1496c ] The function ice_bridge_setlink() may encounter a NULL pointer dereference if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently in nla_for_each_nested(). To address this issue, add a check to ensure that br_spec is not NULL before proceeding with the nested attribute iteration. Fixes: b1edc14a3fbf ("ice: Implement ice_bridge_getlink and ice_bridge_setl= ink") Signed-off-by: Rand Deeb Reviewed-by: Simon Horman Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethern= et/intel/ice/ice_main.c index d4c29e2562a1c..3cc344d5228b6 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6987,6 +6987,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlm= sghdr *nlh, pf_sw =3D pf->first_sw; /* find the attribute in the netlink message */ br_spec =3D nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); + if (!br_spec) + return -EINVAL; =20 nla_for_each_nested(attr, br_spec, rem) { __u16 mode; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97AD662A18; Wed, 13 Mar 2024 16:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348158; cv=none; b=F7EHFEcPWqRz+RB/kv2jCRRYxoGkLpUPfw5RG9W8N0fTN5KznJRv9/I3Os/yFxl+9GAgTrH2Gm07BnYFg/RhOHmx9FIfuEMV0yPeRWTYIWhX9/iOPBOJ8iPBh1nTtN8ILNT2mZNNgTkmpLccADnxOBM7lr94z3maMuymOmhu3gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348158; c=relaxed/simple; bh=uluSOor6bSfADRUR1NgLFqQdGoyycJAvcJU/PAgnK9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uu/7NrWTWRL98uGPi1npMGKDGQ0Bkebvi13KbqshDJRLff8iLg7MmYz/eJEt7/8UPK6QJ3zdE4bNBpCPR6EZjcbXySObe+ecT8KLuQJE1t1W/BjTUjxNSD5H7ZcZ4reqkru1LlD7P79ezxC0f5L6ZmPQF/SBbdcKIDyGDFH4VRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LiAoQnxk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LiAoQnxk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90EC8C433A6; Wed, 13 Mar 2024 16:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348158; bh=uluSOor6bSfADRUR1NgLFqQdGoyycJAvcJU/PAgnK9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LiAoQnxktQsxFZNC9DUMs5VIzB4jaPM1Gk1u2TQxTpiHF5oQfpno9J2rpDy32qfNI eb7Ex/1dKnHu2aKeSkjC0fjkK/JIZcpXxXd7MAxSTybQTSXr6Hv7ClXGWUtf/ZPrVI 6spkMz0X/lE6riS7/zT4P1NHkmN07l6URyhjRWZKVEVXYDIq2Hj+EDLJhRP6PDLYln vhcgWvjVTUbp0H45laPv4IJ5qG7NPJI5xTMCPMm/Xe74FY6gIRJzHJtfI44FJ39gjH 3UHzcx+aAIrr33MzjDmGFzoQylKoqqt+tNsjGDfZuuNi/rczdi6qf+caRW79sCQhxI fVVZIdnY/h+lQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eric Dumazet , syzbot , David Ahern , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 10/76] net/ipv6: avoid possible UAF in ip6_route_mpath_notify() Date: Wed, 13 Mar 2024 12:41:17 -0400 Message-ID: <20240313164223.615640-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit 685f7d531264599b3f167f1e94bbd22f120e5fab ] syzbot found another use-after-free in ip6_route_mpath_notify() [1] Commit f7225172f25a ("net/ipv6: prevent use after free in ip6_route_mpath_notify") was not able to fix the root cause. We need to defer the fib6_info_release() calls after ip6_route_mpath_notify(), in the cleanup phase. [1] BUG: KASAN: slab-use-after-free in rt6_fill_node+0x1460/0x1ac0 Read of size 4 at addr ffff88809a07fc64 by task syz-executor.2/23037 CPU: 0 PID: 23037 Comm: syz-executor.2 Not tainted 6.8.0-rc4-syzkaller-0103= 5-gea7f3cfaa588 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 01/25/2024 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2e0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:377 [inline] print_report+0x167/0x540 mm/kasan/report.c:488 kasan_report+0x142/0x180 mm/kasan/report.c:601 rt6_fill_node+0x1460/0x1ac0 inet6_rt_notify+0x13b/0x290 net/ipv6/route.c:6184 ip6_route_mpath_notify net/ipv6/route.c:5198 [inline] ip6_route_multipath_add net/ipv6/route.c:5404 [inline] inet6_rtm_newroute+0x1d0f/0x2300 net/ipv6/route.c:5517 rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 RIP: 0033:0x7f73dd87dda9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 f= f 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f73de6550c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f73dd9ac050 RCX: 00007f73dd87dda9 RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005 RBP: 00007f73dd8ca47a R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000006e R14: 00007f73dd9ac050 R15: 00007ffdbdeb7858 Allocated by task 23037: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:372 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:389 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:3981 [inline] __kmalloc+0x22e/0x490 mm/slub.c:3994 kmalloc include/linux/slab.h:594 [inline] kzalloc include/linux/slab.h:711 [inline] fib6_info_alloc+0x2e/0xf0 net/ipv6/ip6_fib.c:155 ip6_route_info_create+0x445/0x12b0 net/ipv6/route.c:3758 ip6_route_multipath_add net/ipv6/route.c:5298 [inline] inet6_rtm_newroute+0x744/0x2300 net/ipv6/route.c:5517 rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 Freed by task 16: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x4e/0x60 mm/kasan/generic.c:640 poison_slab_object+0xa6/0xe0 mm/kasan/common.c:241 __kasan_slab_free+0x34/0x70 mm/kasan/common.c:257 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2121 [inline] slab_free mm/slub.c:4299 [inline] kfree+0x14a/0x380 mm/slub.c:4409 rcu_do_batch kernel/rcu/tree.c:2190 [inline] rcu_core+0xd76/0x1810 kernel/rcu/tree.c:2465 __do_softirq+0x2bb/0x942 kernel/softirq.c:553 Last potentially related work creation: kasan_save_stack+0x3f/0x60 mm/kasan/common.c:47 __kasan_record_aux_stack+0xae/0x100 mm/kasan/generic.c:586 __call_rcu_common kernel/rcu/tree.c:2715 [inline] call_rcu+0x167/0xa80 kernel/rcu/tree.c:2829 fib6_info_release include/net/ip6_fib.h:341 [inline] ip6_route_multipath_add net/ipv6/route.c:5344 [inline] inet6_rtm_newroute+0x114d/0x2300 net/ipv6/route.c:5517 rtnetlink_rcv_msg+0x885/0x1040 net/core/rtnetlink.c:6597 netlink_rcv_skb+0x1e3/0x430 net/netlink/af_netlink.c:2543 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline] netlink_unicast+0x7ea/0x980 net/netlink/af_netlink.c:1367 netlink_sendmsg+0xa3b/0xd70 net/netlink/af_netlink.c:1908 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x221/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2584 ___sys_sendmsg net/socket.c:2638 [inline] __sys_sendmsg+0x2b0/0x3a0 net/socket.c:2667 do_syscall_64+0xf9/0x240 entry_SYSCALL_64_after_hwframe+0x6f/0x77 The buggy address belongs to the object at ffff88809a07fc00 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 100 bytes inside of freed 512-byte region [ffff88809a07fc00, ffff88809a07fe00) The buggy address belongs to the physical page: page:ffffea0002681f00 refcount:1 mapcount:0 mapping:0000000000000000 index:= 0x0 pfn:0x9a07c head:ffffea0002681f00 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000840(slab|head|node=3D0|zone=3D1|lastcpupid=3D0x7ff) page_type: 0xffffffff() raw: 00fff00000000840 ffff888014c41c80 dead000000000122 0000000000000000 raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1d20c0(_= _GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__G= FP_HARDWALL), pid 23028, tgid 23027 (syz-executor.4), ts 2340253595219, fre= e_ts 2339107097036 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x1ea/0x210 mm/page_alloc.c:1533 prep_new_page mm/page_alloc.c:1540 [inline] get_page_from_freelist+0x33ea/0x3580 mm/page_alloc.c:3311 __alloc_pages+0x255/0x680 mm/page_alloc.c:4567 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page+0x5f/0x160 mm/slub.c:2190 allocate_slab mm/slub.c:2354 [inline] new_slab+0x84/0x2f0 mm/slub.c:2407 ___slab_alloc+0xd17/0x13e0 mm/slub.c:3540 __slab_alloc mm/slub.c:3625 [inline] __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] __do_kmalloc_node mm/slub.c:3980 [inline] __kmalloc+0x2e0/0x490 mm/slub.c:3994 kmalloc include/linux/slab.h:594 [inline] kzalloc include/linux/slab.h:711 [inline] new_dir fs/proc/proc_sysctl.c:956 [inline] get_subdir fs/proc/proc_sysctl.c:1000 [inline] sysctl_mkdir_p fs/proc/proc_sysctl.c:1295 [inline] __register_sysctl_table+0xb30/0x1440 fs/proc/proc_sysctl.c:1376 neigh_sysctl_register+0x416/0x500 net/core/neighbour.c:3859 devinet_sysctl_register+0xaf/0x1f0 net/ipv4/devinet.c:2644 inetdev_init+0x296/0x4d0 net/ipv4/devinet.c:286 inetdev_event+0x338/0x15c0 net/ipv4/devinet.c:1555 notifier_call_chain+0x18f/0x3b0 kernel/notifier.c:93 call_netdevice_notifiers_extack net/core/dev.c:1987 [inline] call_netdevice_notifiers net/core/dev.c:2001 [inline] register_netdevice+0x15b2/0x1a20 net/core/dev.c:10340 br_dev_newlink+0x27/0x100 net/bridge/br_netlink.c:1563 rtnl_newlink_create net/core/rtnetlink.c:3497 [inline] __rtnl_newlink net/core/rtnetlink.c:3717 [inline] rtnl_newlink+0x158f/0x20a0 net/core/rtnetlink.c:3730 page last free pid 11583 tgid 11583 stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1140 [inline] free_unref_page_prepare+0x968/0xa90 mm/page_alloc.c:2346 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2486 kasan_depopulate_vmalloc_pte+0x74/0x90 mm/kasan/shadow.c:415 apply_to_pte_range mm/memory.c:2619 [inline] apply_to_pmd_range mm/memory.c:2663 [inline] apply_to_pud_range mm/memory.c:2699 [inline] apply_to_p4d_range mm/memory.c:2735 [inline] __apply_to_page_range+0x8ec/0xe40 mm/memory.c:2769 kasan_release_vmalloc+0x9a/0xb0 mm/kasan/shadow.c:532 __purge_vmap_area_lazy+0x163f/0x1a10 mm/vmalloc.c:1770 drain_vmap_area_work+0x40/0xd0 mm/vmalloc.c:1804 process_one_work kernel/workqueue.c:2633 [inline] process_scheduled_works+0x913/0x1420 kernel/workqueue.c:2706 worker_thread+0xa5f/0x1000 kernel/workqueue.c:2787 kthread+0x2ef/0x390 kernel/kthread.c:388 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242 Memory state around the buggy address: ffff88809a07fb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88809a07fb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88809a07fc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809a07fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809a07fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb Fixes: 3b1137fe7482 ("net: ipv6: Change notifications for multipath add to = RTA_MULTIPATH") Reported-by: syzbot Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Link: https://lore.kernel.org/r/20240303144801.702646-1-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/ipv6/route.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 75eab4032f017..3a95466e10a95 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -5346,19 +5346,7 @@ static int ip6_route_multipath_add(struct fib6_confi= g *cfg, err_nh =3D NULL; list_for_each_entry(nh, &rt6_nh_list, next) { err =3D __ip6_ins_rt(nh->fib6_info, info, extack); - fib6_info_release(nh->fib6_info); - - if (!err) { - /* save reference to last route successfully inserted */ - rt_last =3D nh->fib6_info; - - /* save reference to first route for notification */ - if (!rt_notif) - rt_notif =3D nh->fib6_info; - } =20 - /* nh->fib6_info is used or freed at this point, reset to NULL*/ - nh->fib6_info =3D NULL; if (err) { if (replace && nhn) NL_SET_ERR_MSG_MOD(extack, @@ -5366,6 +5354,12 @@ static int ip6_route_multipath_add(struct fib6_confi= g *cfg, err_nh =3D nh; goto add_errout; } + /* save reference to last route successfully inserted */ + rt_last =3D nh->fib6_info; + + /* save reference to first route for notification */ + if (!rt_notif) + rt_notif =3D nh->fib6_info; =20 /* Because each route is added like a single route we remove * these flags after the first nexthop: if there is a collision, @@ -5426,8 +5420,7 @@ static int ip6_route_multipath_add(struct fib6_config= *cfg, =20 cleanup: list_for_each_entry_safe(nh, nh_safe, &rt6_nh_list, next) { - if (nh->fib6_info) - fib6_info_release(nh->fib6_info); + fib6_info_release(nh->fib6_info); list_del(&nh->next); kfree(nh); } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5AFB13791A; Wed, 13 Mar 2024 16:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348159; cv=none; b=N5cSpolQIPeG5q/BHBRGFa1pcc2Lp+4w2LmKT0Ti46FvhztbVed90X03kQ+TI9uLVbaBonE+sHjX2nbxfP/7KcT7xxmpV0/8IJNsjaONyj3f858eR7ItnrcrwFM6cY3rDu8qJg0cLE9k4gALqZWrMIpy5RhMD8Wm0TnB5T6PCoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348159; c=relaxed/simple; bh=fSzkZ1cPR6tfVQ5HUKnOSH0wQjQfYth45/o1vkdhC+U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pmt82xqwpcHKpnJPxEcj+NTvsfrunkEobS/Nl+q7ql5Qkm9R4JJ3fsSEjzPtDsfyGfX6z1D8gTkcna9b0fJhl0Ssgb3vEg9qkzfia4M+5EHTDVcU5eeu6U169WlPcxIfl8Tar76vIkxtl/fgyfypigETwcvhPn8rvwvuSgNatbk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dzQoALsT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dzQoALsT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4F03C433F1; Wed, 13 Mar 2024 16:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348159; bh=fSzkZ1cPR6tfVQ5HUKnOSH0wQjQfYth45/o1vkdhC+U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzQoALsTuDfdzWB3sknNPHPbwRwlATWIPWjjqyI03UuUeugtu89y26iJsI9dkUfkH ThM2I2VLXUKxyIkpMOmsCDa1BxN6E4zJ0IjmJrbyOwMXFA3HrkZO8bcVDrRTA25xV4 rhxNn1F/dpDKMj0HLqx9IaBt6r3SREXeTYK6GkE4J36vbFngHeZzmzPfgahf0OF5UU bEnbj2be1RfjoBDbOjpVW/FS9E9gAHgqYPWwRdKaGmgFtNB55xzxvjTE/2JARkx1mK yDqSMBa703RwBj9zt3gFyXaJx7In5NY5Axlh42x/N3V21dKjA6L9Fyom8g7LsIrhYU pO03LO9aolDKQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , =?UTF-8?q?Tobias=20B=C3=B6hm?= , Martin KaFai Lau , Sasha Levin Subject: [PATCH 5.15 11/76] cpumap: Zero-initialise xdp_rxq_info struct before running XDP program Date: Wed, 13 Mar 2024 12:41:18 -0400 Message-ID: <20240313164223.615640-12-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Toke H=C3=B8iland-J=C3=B8rgensen [ Upstream commit 2487007aa3b9fafbd2cb14068f49791ce1d7ede5 ] When running an XDP program that is attached to a cpumap entry, we don't initialise the xdp_rxq_info data structure being used in the xdp_buff that backs the XDP program invocation. Tobias noticed that this leads to random values being returned as the xdp_md->rx_queue_index value for XDP programs running in a cpumap. This means we're basically returning the contents of the uninitialised memory, which is bad. Fix this by zero-initialising the rxq data structure before running the XDP program. Fixes: 9216477449f3 ("bpf: cpumap: Add the possibility to attach an eBPF pr= ogram to cpumap") Reported-by: Tobias B=C3=B6hm Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen Link: https://lore.kernel.org/r/20240305213132.11955-1-toke@redhat.com Signed-off-by: Martin KaFai Lau Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/bpf/cpumap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 8d1c4b3ee7604..f7de5b313cc5b 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -221,7 +221,7 @@ static int cpu_map_bpf_prog_run_xdp(struct bpf_cpu_map_= entry *rcpu, void **frames, int n, struct xdp_cpumap_stats *stats) { - struct xdp_rxq_info rxq; + struct xdp_rxq_info rxq =3D {}; struct xdp_buff xdp; int i, nframes =3D 0; =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36588139579; Wed, 13 Mar 2024 16:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348161; cv=none; b=tz+rEdHT1lA8b+kDkv+YdXlM4Dvehg02qkEb3PToa7EJRb8U7GhYsSbj/zLDLuD0VhJVMWai4fyOPowM/9z8sjI6zVcJCaPvf5TwPRki+Xw6SxCLBF+/M9P2mBHLTE1IuOckp+j09o1bbAD+6YU1yNzYvneGhcN3mrtD2q5aaqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348161; c=relaxed/simple; bh=BJMqZs3HypZYIgRRS3ZNRgnZRiqh9LAfOakZLpvame4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rMzGBxWx8ISuiOlA1RJbchNN8QdmfeXCOT533KlySW4HVkocOsBK20yXrWs4IFN1SZShpgomhNhx54dLkd++5SvXPlBTZ75N1MQFF72WrfvAaBTD47kysFHiFFdFhMLcsPKt9n2FwbEj1E27N/cbASb3mzwSW58S+cznfR/yFuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jZlyfmtw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jZlyfmtw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4508C433C7; Wed, 13 Mar 2024 16:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348160; bh=BJMqZs3HypZYIgRRS3ZNRgnZRiqh9LAfOakZLpvame4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jZlyfmtwrRtLfiCbXW/8pnac+o21uKiJ0pt0HJCKRbC43Dhm+RjTE9ESOxGpWOOvL YWFqeC6jd67kk1bTXLv/qEOlb3IMYeUaWFBERcboJGH8FJ6OOTplhclObDbPHDnZoI yTJDoq1bNIiFau+ja6sqxN9h3YC6OfuIapTYDIKtMtYCrtfXTcuqJkw4D9AquU9qPb MR6QFMcuUc17C2mhG50x9EiW/kk8JE5prMHPFrpqabFEdK1SlrypnLsynD6cnChN6b LLW27v0e07c/SzUyByYfekNBpaX7dxvVbjWk1Id2SCcK+deaNOpQ8cJpBkMnVu50fr uZsjM+FDsOSow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Edward Adam Davis , syzbot+d4faee732755bba9838e@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 12/76] net/rds: fix WARNING in rds_conn_connect_if_down Date: Wed, 13 Mar 2024 12:41:19 -0400 Message-ID: <20240313164223.615640-13-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Edward Adam Davis [ Upstream commit c055fc00c07be1f0df7375ab0036cebd1106ed38 ] If connection isn't established yet, get_mr() will fail, trigger connection= after get_mr(). Fixes: 584a8279a44a ("RDS: RDMA: return appropriate error on rdma map failu= res") Reported-and-tested-by: syzbot+d4faee732755bba9838e@syzkaller.appspotmail.c= om Signed-off-by: Edward Adam Davis Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/rds/rdma.c | 3 +++ net/rds/send.c | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/net/rds/rdma.c b/net/rds/rdma.c index 6f1a50d50d06d..c29c7a59f2053 100644 --- a/net/rds/rdma.c +++ b/net/rds/rdma.c @@ -301,6 +301,9 @@ static int __rds_rdma_map(struct rds_sock *rs, struct r= ds_get_mr_args *args, kfree(sg); } ret =3D PTR_ERR(trans_private); + /* Trigger connection so that its ready for the next retry */ + if (ret =3D=3D -ENODEV) + rds_conn_connect_if_down(cp->cp_conn); goto out; } =20 diff --git a/net/rds/send.c b/net/rds/send.c index 53444397de669..d6462d1471c14 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -1314,12 +1314,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *= msg, size_t payload_len) =20 /* Parse any control messages the user may have included. */ ret =3D rds_cmsg_send(rs, rm, msg, &allocated_mr, &vct); - if (ret) { - /* Trigger connection so that its ready for the next retry */ - if (ret =3D=3D -EAGAIN) - rds_conn_connect_if_down(conn); + if (ret) goto out; - } =20 if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) { printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n", --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54B1613959F; Wed, 13 Mar 2024 16:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348162; cv=none; b=lSkOrkYOe3SzVx1L4XgEpgZgcaXIVWsJ8nUf77g8cG8pP8RUottDEeaBxH/gLio1yyKPQDVUQkXAseUXzSE9qKlw3ZM4PVE9Hrqblotud74e7guodI8isG8z8GQ8DJyd7KHXOoPgaH3QHRNF25ECjfvOXfVfUyPMnzC5q3cpHuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348162; c=relaxed/simple; bh=Y0qmczXQKt4PXOHrKH1s+dGEO4SYk47hEsGX3+xvWyE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g4rF44fsxpl8UdWfQIPLXeta0t8rqRIWFzJXFGIFzIPV9EliEitobdCLqjGztL+a6AKS1UFcxkFP56UYviIVHFvIT4AFxIAtF1H2BKrK5JHMsO4VvBAplJm0I2Aumx/B1Pi1xiLPfm88tob2Hz+ijGvOXJrzA9NxRlZEUaFZppY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T+uOunmh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T+uOunmh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18798C433F1; Wed, 13 Mar 2024 16:42:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348161; bh=Y0qmczXQKt4PXOHrKH1s+dGEO4SYk47hEsGX3+xvWyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T+uOunmh59+FrDYBvW8rwzXVJbF0P7BpwU4OI0sQqDxTKE+UqOhw+ziJ/tJlDuxW1 wR5WbxfWmprNotTfvmuhymljoL2i4/WSRJArGLpFBIhOp4numjh6DfG9qAFZPjUJMV dfVKUZ9g8nT6IeN/p5GqzEmb99FNu/VSNZVQ0yTDf5IZNpOCIr+hRISl5xM7MDp4X4 xVWY32W5rXD6MxbZlPjMbk0irDW3jjB+TdOzz8bAPeRI72p+VWjFgytdTmYf/eG6o+ MhjwHNK0hudGt6dHvXSRoIod9bKzsVvXm/NnNI8++UzXt1PFadCO4l69xMPwEimH9V 3rNPjT5GECqpg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 13/76] netfilter: nft_ct: fix l3num expectations with inet pseudo family Date: Wed, 13 Mar 2024 12:41:20 -0400 Message-ID: <20240313164223.615640-14-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Florian Westphal [ Upstream commit 99993789966a6eb4f1295193dc543686899892d3 ] Following is rejected but should be allowed: table inet t { ct expectation exp1 { [..] l3proto ip Valid combos are: table ip t, l3proto ip table ip6 t, l3proto ip6 table inet t, l3proto ip OR l3proto ip6 Disallow inet pseudeo family, the l3num must be a on-wire protocol known to conntrack. Retain NFPROTO_INET case to make it clear its rejected intentionally rather as oversight. Fixes: 8059918a1377 ("netfilter: nft_ct: sanitize layer 3 and 4 protocol nu= mber in custom expectations") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netfilter/nft_ct.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c index 7c667629c5149..69214993b5a2c 100644 --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -1192,14 +1192,13 @@ static int nft_ct_expect_obj_init(const struct nft_= ctx *ctx, switch (priv->l3num) { case NFPROTO_IPV4: case NFPROTO_IPV6: - if (priv->l3num !=3D ctx->family) - return -EINVAL; + if (priv->l3num =3D=3D ctx->family || ctx->family =3D=3D NFPROTO_INET) + break; =20 - fallthrough; - case NFPROTO_INET: - break; + return -EINVAL; + case NFPROTO_INET: /* tuple.src.l3num supports NFPROTO_IPV4/6 only */ default: - return -EOPNOTSUPP; + return -EAFNOSUPPORT; } =20 priv->l4proto =3D nla_get_u8(tb[NFTA_CT_EXPECT_L4PROTO]); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00B9C13957D; Wed, 13 Mar 2024 16:42:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348163; cv=none; b=m+uUxUW6ydSCPB8jjxUvTcaL6dfBmfajwrfbSaPZ1r8u2gNAPvBH52HRVYGe1H41e1V1sV3WqYhMgg71rODyLFqtrrZ8RBG9+cXDdFAh2NA4rCJu38Z6M4kRpPFohSVBlGmU84M915e0Rm8MyjbMgp8p2b9X+VrwM14nNpfqUvY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348163; c=relaxed/simple; bh=3UekCyyDHThKiG9v+4KxnUS74Ovcmcs7JvlE63gLlaQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pYNTxrUqgGO42i880jbLEHxyGOIkuN/kn78DFqOehjV+uJMQjsRhb/8s7fwlFX03+pi8Cvuq2IuwrqpzcqmHiNC5Bylih3sNCzL3V+E4l9elo5pUQaLNoVAM5FG6xpki99s2iXzlFzjIgKDw6zLdwx7O59OCo7Mjl3GfPz7Uwy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IuSobHWq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IuSobHWq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2064CC43390; Wed, 13 Mar 2024 16:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348162; bh=3UekCyyDHThKiG9v+4KxnUS74Ovcmcs7JvlE63gLlaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IuSobHWqBfO9lKL6Kr2eiwzF53TrKjFwAWgqBcc/ACh9bM+GZGNkD7bXu4lk1fNL1 Y+pU0jRaQdHX050pSdnUgmqC5aFwjW3aGyeKr8EvQJ2UhlJW324TkuvFOq63yo+YQd B5ubaLq6jK9h8wBBVpa+5gdYhFlrKRldOsDG5n6NSE3uQzm/TaIbabgiIP1/N5c+8D ueHEC/alVHg8LAmhrCxKmhrOh1sR3fE5fw6v2X3R4PMENq09/9Tx7lliR7Bg9jnMcF cc4cckHuM/9y7Opfd83e4WTnrAf8na6nTZIJJhElDtsXx0a+oV1G7Ah8WSN/4obHxG KKVjZDx80jj2Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lena Wang , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.15 14/76] netfilter: nf_conntrack_h323: Add protection for bmp length out of range Date: Wed, 13 Mar 2024 12:41:21 -0400 Message-ID: <20240313164223.615640-15-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Lena Wang [ Upstream commit 767146637efc528b5e3d31297df115e85a2fd362 ] UBSAN load reports an exception of BRK#5515 SHIFT_ISSUE:Bitwise shifts that are out of bounds for their data type. vmlinux get_bitmap(b=3D75) + 712 vmlinux decode_seq(bs=3D0xFFFFFFD008037000, f=3D0xFFFFFFD008037018, level= =3D134443100) + 1956 vmlinux decode_choice(base=3D0xFFFFFFD0080370F0, level=3D23843636) + 1216 vmlinux decode_seq(f=3D0xFFFFFFD0080371A8, level=3D134443500) + 812 vmlinux decode_choice(base=3D0xFFFFFFD008037280, level=3D0) + 1216 vmlinux DecodeRasMessage() + 304 vmlinux ras_help() + 684 vmlinux nf_confirm() + 188 Due to abnormal data in skb->data, the extension bitmap length exceeds 32 when decoding ras message then uses the length to make a shift operation. It will change into negative after several loop. UBSAN load could detect a negative shift as an undefined behaviour and reports exception. So we add the protection to avoid the length exceeding 32. Or else it will return out of range error and stop decoding. Fixes: 5e35941d9901 ("[NETFILTER]: Add H.323 conntrack/NAT helper") Signed-off-by: Lena Wang Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netfilter/nf_conntrack_h323_asn1.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/netfilter/nf_conntrack_h323_asn1.c b/net/netfilter/nf_conn= track_h323_asn1.c index e697a824b0018..540d97715bd23 100644 --- a/net/netfilter/nf_conntrack_h323_asn1.c +++ b/net/netfilter/nf_conntrack_h323_asn1.c @@ -533,6 +533,8 @@ static int decode_seq(struct bitstr *bs, const struct f= ield_t *f, /* Get fields bitmap */ if (nf_h323_error_boundary(bs, 0, f->sz)) return H323_ERROR_BOUND; + if (f->sz > 32) + return H323_ERROR_RANGE; bmp =3D get_bitmap(bs, f->sz); if (base) *(unsigned int *)base =3D bmp; @@ -589,6 +591,8 @@ static int decode_seq(struct bitstr *bs, const struct f= ield_t *f, bmp2_len =3D get_bits(bs, 7) + 1; if (nf_h323_error_boundary(bs, 0, bmp2_len)) return H323_ERROR_BOUND; + if (bmp2_len > 32) + return H323_ERROR_RANGE; bmp2 =3D get_bitmap(bs, bmp2_len); bmp |=3D bmp2 >> f->sz; if (base) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E1D913A89C; Wed, 13 Mar 2024 16:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348164; cv=none; b=RFHSlvmYRuARkWUOIzy7ZW0vkSHvr90MnRmUxR63LRpXdRAxIUioVBOPnPHTJ/8qsBDRvQXz5P3f/Rxxa2E/wDMaVUvzaa/99bIx05IRzl+SXDYJ57QfKdTb3nPB0JSiFO1DbySLbb+X7IdvzDpm7L+lHawbD2D0ASR0vVsANQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348164; c=relaxed/simple; bh=/PQF0yX/ENGcXAUA1kKDscSZKucRJsSGt8v8NkP/bHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YHWl7ki8xft168CGkkZJCcwcCyct7P1GzArtsF+DQ/zaen+cT0Hlfp9UXAXGhK6qiWNn9bLoGfE2QUnMcznctlNb1jEa1mULN9kQ5keIkopLtPZ08YoB5AZavUTg7p1CTWesiCaTv/E4aY+jqD3I6gN8Ginl0q8jUW8j5W4J3oo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=flo1eiRL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="flo1eiRL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BDA5C433F1; Wed, 13 Mar 2024 16:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348164; bh=/PQF0yX/ENGcXAUA1kKDscSZKucRJsSGt8v8NkP/bHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=flo1eiRLsyoVLnrKIErZZC9bQS++9UqX08CRX2pi7eQgAcOmx7RN4/YRhy0TWx423 OuAzJf7Umf1gwPJBapv/Ih0YDbj8TjcrksWllDJTIFUC14BJM9x8NmJPwDufRFYQ+C hy1o8s5D6tkCuIpICgh8VKLDf4wFHzUYtHINjrC8lzigvT/5/xrcxPGxxXSwIW4Sxc UUegtwg4kk2gFldVQZbIzsB9e7ZubT6RKWnEOO8bqHFCOMaVLPV2wsew2cUTa7UTKM DTM4RvguIItC0ahbWVHcoZCVsel0Rw/+QXofrL4hTO+0mycKJjimh29ALWc1URyUUl 7Q7oVAiiksQ/w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Gao Xiang , Jingbo Xu , Chao Yu , Sasha Levin Subject: [PATCH 5.15 15/76] erofs: apply proper VMA alignment for memory mapped files on THP Date: Wed, 13 Mar 2024 12:41:22 -0400 Message-ID: <20240313164223.615640-16-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Gao Xiang [ Upstream commit 4127caee89612a84adedd78c9453089138cd5afe ] There are mainly two reasons that thp_get_unmapped_area() should be used for EROFS as other filesystems: - It's needed to enable PMD mappings as a FSDAX filesystem, see commit 74d2fad1334d ("thp, dax: add thp_get_unmapped_area for pmd mappings"); - It's useful together with large folios and CONFIG_READ_ONLY_THP_FOR_FS which enable THPs for mmapped files (e.g. shared libraries) even without FSDAX. See commit 1854bc6e2420 ("mm/readahead: Align file mappings for non-DAX"). Fixes: 06252e9ce05b ("erofs: dax support for non-tailpacking regular file") Fixes: ce529cc25b18 ("erofs: enable large folios for iomap mode") Fixes: e6687b89225e ("erofs: enable large folios for fscache mode") Reviewed-by: Jingbo Xu Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20240306053138.2240206-1-hsiangkao@linux.al= ibaba.com Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- fs/erofs/data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 16a41d0db55a3..a859bf0f31df2 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -340,4 +340,5 @@ const struct file_operations erofs_file_fops =3D { .read_iter =3D erofs_file_read_iter, .mmap =3D erofs_file_mmap, .splice_read =3D generic_file_splice_read, + .get_unmapped_area =3D thp_get_unmapped_area, }; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2219C13AA3A; Wed, 13 Mar 2024 16:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348165; cv=none; b=n2ZJtUviQjS2Dh1tsDERcuauOcIpCB5h0cjO4DC001z88zqjX2fuCCWqNfhK3pSXqG1PUHZvePpODxwOVyAkqF8GHBokU3Kj8WrWzz6i7jteeRROSzGMTf0SJfCxDDS8zUpud3D+aKTSNR3g9/NrUcPMm5EsKqnCVPHlAugv65M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348165; c=relaxed/simple; bh=rWMYncKdMocrxg/cIRj1vKvh3WgJfF1dzGcufwTEIFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t1yLof09aT/XbEtJ+ORY8rC6KEzr7suT5qVfTj8PFN52TArMsTmUiO2Slqipa5YtgI3EKR/81nZT/YmFGZaq8WhYRtIPEoDQCXO0wK1ZddlCSdLRNVI27pCyuwr/1eM7p0gmUd/JYhTJJdxCT4HLTK0ZH5ScZdTgQGzEh8qOThQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rms4OHVa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rms4OHVa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E02BC433C7; Wed, 13 Mar 2024 16:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348165; bh=rWMYncKdMocrxg/cIRj1vKvh3WgJfF1dzGcufwTEIFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rms4OHVakEouPbnK9qk8bySPUEdwICpNfi73j0xRQn6X06Qzu089Hf6mPptg5f1BT n50/hTlha3hxu3y3bw5d/xSdVDg1OIh+A7/bIdMSf132V/9vL2AvFJb3WBE9rFrjT1 kFeIfjQ8DGMs9GZM13D+PCwQ16Q6XW2ohUNMA5NLJCYx4e1Z3GlRCVUgsIA6BVM+N5 DDPgcV94VObMsJ3L5l65gxcPu2Vr20hrcl00cmcSv9Ip4fy6FyXQ43LyE01jyGToUz uCdJ/USV98pjBPZ7tBW2kOBUf2XLdDwY2ZLBtO8vAUab+zsm4pvN1MQsU3qziEZYIe B8KMF5FfNXrcA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 16/76] netrom: Fix a data-race around sysctl_netrom_default_path_quality Date: Wed, 13 Mar 2024 12:41:23 -0400 Message-ID: <20240313164223.615640-17-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit 958d6145a6d9ba9e075c921aead8753fb91c9101 ] We need to protect the reader reading sysctl_netrom_default_path_quality because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index ddd5cbd455e39..55cd51977fbc2 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -153,7 +153,7 @@ static int __must_check nr_add_node(ax25_address *nr, c= onst char *mnemonic, nr_neigh->digipeat =3D NULL; nr_neigh->ax25 =3D NULL; nr_neigh->dev =3D dev; - nr_neigh->quality =3D sysctl_netrom_default_path_quality; + nr_neigh->quality =3D READ_ONCE(sysctl_netrom_default_path_quality); nr_neigh->locked =3D 0; nr_neigh->count =3D 0; nr_neigh->number =3D nr_neigh_no++; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79A0113AA39; Wed, 13 Mar 2024 16:42:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348166; cv=none; b=R7ZdY3KdFUgApDbMH2wA6r/CEI6ISYyEQJBJrl0XJayTKYrEL/ln4sVRHSMPLLaecgJNlaaEa3nyym+z+m11kKw+mJfqPGg6e770QYvlY0crCH9vG7MagqMEBsnHnhrWA1yWpbEYhUiYBCUr2xASYqukdEizxy47wxnnhebyDP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348166; c=relaxed/simple; bh=8EiflNOk+oftE/DLdH6Lfvnb/5Rj6PubTRnwm9TnOBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HVGRs1lMIMG2xEnYppvSzDipyfsndtsaXqxFe+Tr6BlYNWk8cIJUms/Ph9aYPEQt+bq/U/FDEYmPrwVtlcRnVW31K/IrV7HydCvPh5xeNBEb4BoFtnPMX6yFJcAAGTDoNvHOEyU0iMmcfy/mlXs+PW+fn4Z73GgFNRz6zXpsuIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=met0NpR/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="met0NpR/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CD8FC43394; Wed, 13 Mar 2024 16:42:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348166; bh=8EiflNOk+oftE/DLdH6Lfvnb/5Rj6PubTRnwm9TnOBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=met0NpR/CQ+bUeFa6h/GyzlyFuripGAZ3tUGPKWgtZpLwB/aNyvinRPjZYnqJChwb eo7pb3UfQdUAGk3XyO2XvklxsW6z1F5TUgEASubhK6C6NAgZyEn+I1oaatqbdeF5P7 yv/46Ud74XAe7ua2ruQAOA5rqlvo13YLfv/sbcrrgmeVZsVk3jtaMHr7cTvyQGe2Ta jF3rbvWJGQXQ1jE/FH+8FMQ8oVK/623LZWHD7foAWlnf7kQWAXRID2ktlxO/tftDLw APsh5oum8A6QVLcOrkR3dWb/bLuXMrlT47BO88iQmoyysbYojkjd62rIM/MuLAfbMW tR+qHKbbjPEtg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 17/76] netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser Date: Wed, 13 Mar 2024 12:41:24 -0400 Message-ID: <20240313164223.615640-18-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit cfd9f4a740f772298308b2e6070d2c744fb5cf79 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index 55cd51977fbc2..e5d24462d5100 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -766,7 +766,7 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25) if (ax25 !=3D NULL) { ret =3D nr_add_node(nr_src, "", &ax25->dest_addr, ax25->digipeat, ax25->ax25_dev->dev, 0, - sysctl_netrom_obsolescence_count_initialiser); + READ_ONCE(sysctl_netrom_obsolescence_count_initialiser)); if (ret) return ret; } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D34013B7A3; Wed, 13 Mar 2024 16:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348167; cv=none; b=hOe8c05L5pottobUyMhGckheBAVti1yuYITefeQaLmHG3DqCd1VYN1dGdDLQ3LZjhxQYggi6WOPiKKoCXy0C95AUzFB6zbdrKuQg3QCV/9tsvwB2uJuUvv5U3eHekvQN2W8SrzmGRWzhqU6zyRU+yUX3LgWPrtYy74g1yjzu65g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348167; c=relaxed/simple; bh=gnQIEhthbcxCrWwdE1rXnIZF674rQKVPTnmEWr6Yt1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WVIXrhzSpElEtnqtQarpofSCXyyjQEnultM/YiD6WnR5jSdM5j/zrnpo+HdiKp/mQ28zGbFj7/H/yVotqaZ9CrCGBf68goHpDlBCgIekp9MqWt+fp+G5oayU+V8KFn/Urjt+5SA+JdXNGqXcSXZh9INqIyyF9iBDRAemMaE1eow= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=edRCbHWC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="edRCbHWC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A992C43390; Wed, 13 Mar 2024 16:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348167; bh=gnQIEhthbcxCrWwdE1rXnIZF674rQKVPTnmEWr6Yt1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=edRCbHWCvc98WanTg/7NWHOxQJRzJabJ5o1PG0IU2nUp6TEdKwFbpe2SadjGmQ+kX rVXtTo9L0D+CXmQ8NEUtDr53uxDFDG+k4V1vzkOHvZtsaJ9m8lrzK3ks3vElhCBIWH inbd81PzAEPFjbNe8l5lQHw79dpFPLUv+Hga0MrSSFwZ46HiUb4UnuyubVGaF1sTfc AefENY0nWjDr2OUsgAQGdXCKDero6la5jWkfNA10arGxKCfaFNA38UitD23ASaPNP7 9OItHhc/OCGewJRsX94+rPXIFssFKBKrMJWLqj9APDSU8s0vBpSvHoah3Gq6noPloD v5P0+67C+YjSw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 18/76] netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser Date: Wed, 13 Mar 2024 12:41:25 -0400 Message-ID: <20240313164223.615640-19-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit 119cae5ea3f9e35cdada8e572cc067f072fa825a ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/nr_dev.c | 2 +- net/netrom/nr_out.c | 2 +- net/netrom/nr_subr.c | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 29e418c8c6c30..4caee8754b794 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c @@ -81,7 +81,7 @@ static int nr_header(struct sk_buff *skb, struct net_devi= ce *dev, buff[6] |=3D AX25_SSSID_SPARE; buff +=3D AX25_ADDR_LEN; =20 - *buff++ =3D sysctl_netrom_network_ttl_initialiser; + *buff++ =3D READ_ONCE(sysctl_netrom_network_ttl_initialiser); =20 *buff++ =3D NR_PROTO_IP; *buff++ =3D NR_PROTO_IP; diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c index 44929657f5b71..5e531394a724b 100644 --- a/net/netrom/nr_out.c +++ b/net/netrom/nr_out.c @@ -204,7 +204,7 @@ void nr_transmit_buffer(struct sock *sk, struct sk_buff= *skb) dptr[6] |=3D AX25_SSSID_SPARE; dptr +=3D AX25_ADDR_LEN; =20 - *dptr++ =3D sysctl_netrom_network_ttl_initialiser; + *dptr++ =3D READ_ONCE(sysctl_netrom_network_ttl_initialiser); =20 if (!nr_route_frame(skb, NULL)) { kfree_skb(skb); diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c index e2d2af924cff4..c3bbd5880850b 100644 --- a/net/netrom/nr_subr.c +++ b/net/netrom/nr_subr.c @@ -182,7 +182,8 @@ void nr_write_internal(struct sock *sk, int frametype) *dptr++ =3D nr->my_id; *dptr++ =3D frametype; *dptr++ =3D nr->window; - if (nr->bpqext) *dptr++ =3D sysctl_netrom_network_ttl_initialiser; + if (nr->bpqext) + *dptr++ =3D READ_ONCE(sysctl_netrom_network_ttl_initialiser); break; =20 case NR_DISCREQ: @@ -236,7 +237,7 @@ void __nr_transmit_reply(struct sk_buff *skb, int mine,= unsigned char cmdflags) dptr[6] |=3D AX25_SSSID_SPARE; dptr +=3D AX25_ADDR_LEN; =20 - *dptr++ =3D sysctl_netrom_network_ttl_initialiser; + *dptr++ =3D READ_ONCE(sysctl_netrom_network_ttl_initialiser); =20 if (mine) { *dptr++ =3D 0; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 804CD13C9ED; Wed, 13 Mar 2024 16:42:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348168; cv=none; b=Y1UE5ciboWxeeFtSR8sP5hyvUFi0FdlinyxrRPA9US+dgcfkUXj1KPhNiFP8l0ssxnM9PgGBIKaql8QHfTOeNwYQwyjFUNmQj+TiEPeFXbrW85MH1DGDVQmFVRulOqEKXIB1YVWbPiO7tRh4UquXDJsgnLhN6gGIvfoEb1n1YQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348168; c=relaxed/simple; bh=v1F9PhDK0oX3T92o4m74/kx58+E0UmC3jFyT+LVR/fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o/CDER+q0jU7jQKP7t8Cp9+EV124uyodd2HKDpYo6WSUILVf94Pn0Rp+fK4lNBP1iWOFEXwzs6dW9XSrDo4ScQ2FCNY+5644tO1JuQcskpnu4ZNE0ulaFKFG3cqCDG11+YVq/esfkV131FzcMqCBdxdJ8VjvYG/IOojnVA+qi1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=u888Gcl5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u888Gcl5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48622C433C7; Wed, 13 Mar 2024 16:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348168; bh=v1F9PhDK0oX3T92o4m74/kx58+E0UmC3jFyT+LVR/fs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u888Gcl57wl516iyMboqeO/8aFh4AWRVAOvK+YpkUr3/UTnwmPGAx2Mm1REnsFp6j jpZBdV1GT5WhG5KqCnR/ewBBuU2WotoAopnOLZ6SX7pE3djBozDsBbN5DWPFd96W2q xBSjmv7FFCzGvEgWNaBSEX6dBxOe42UYPfmVq8vT1jNHgAlaJA+s5f3CUDg+R43Bw+ /0ksBVE0iWxQ4y6M9h7sRr3o05KCNoqM5mPVnaToO6Foyx8SD6FKAh351KjrrKV5xo E5aGoRhBErQAKDXaWUirxc1y6LHgIV0Q5s2trKD2UpfGwz3ShrG2hCQCvmZym1DzRa W7RokUBoRTwEg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 19/76] netrom: Fix a data-race around sysctl_netrom_transport_timeout Date: Wed, 13 Mar 2024 12:41:26 -0400 Message-ID: <20240313164223.615640-20-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit 60a7a152abd494ed4f69098cf0f322e6bb140612 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 24747163122bb..6857510967448 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -453,7 +453,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, nr_init_timers(sk); =20 nr->t1 =3D - msecs_to_jiffies(sysctl_netrom_transport_timeout); + msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_timeout)); nr->t2 =3D msecs_to_jiffies(sysctl_netrom_transport_acknowledge_delay); nr->n2 =3D --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D3813D2E6; Wed, 13 Mar 2024 16:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348169; cv=none; b=dEh4oV7kvenDmI3OLhz1EVRQ8F2vMcYkWFjK86Sx57dTMRXRCceLitlrrRtLZVa6mwAuxdg1deUzbgNJoBPbDERAxccP8sfxy02ZFXx9W544WqLS6lkM74KXLWRmA4VkUu+p7SOrH6R+xMBrxuwwrQBZXA2lPWmXwptlucODylo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348169; c=relaxed/simple; bh=was6sneh7FZD+9dPqJzYCOv8b8gK1yrXIKN6t46lAZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VMJOQRmyle+BqPAuS1uhBJG9mOyIHBya6xWpxeCy19Vy/tbMG3P+OBvQf9GUbnSOwUi1fDDpcIPRMUxEHi9GnRGlIo/r8jnqT7htoUMoNq0DW8Jx+x8c3cSlCTlfcDwmNyrEB7v3zUUw8N4R6rdLdth4OsI1w8aPNubknRHtTVs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iRnL/H2x; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iRnL/H2x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48702C433F1; Wed, 13 Mar 2024 16:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348169; bh=was6sneh7FZD+9dPqJzYCOv8b8gK1yrXIKN6t46lAZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iRnL/H2x4HOPgIuKXtreAVHav5RX4+ZBgCFgeQKpty/QIGtfQc3lJ9VLgDzaFC3Eq SnloBzhathjFiE+pIzmQLNRQOv3UBqKVvkqJ0RNgm4EcorLnrEbnaLnwc2TJMJzVyt 0DNdiS2VVy5bTrc73Cj9MrF4MOZB78rAasNbBZWQBvwtxvPcZLN/4qExHDLBAOKXmZ 8PZmC+heo1MR44hCU6CEzqOdw1GZrKl5SxjGYvA0j+yCBkcdlXKzXAOM4zXqmQ/tK9 e09z5NgOv2za78nWxQhXjv8MU5EfwADdw/T+Uj0fKxErt/ObkWYwnSV54MfmqqCD4s sVn0dlk6i5NHA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 20/76] netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries Date: Wed, 13 Mar 2024 12:41:27 -0400 Message-ID: <20240313164223.615640-21-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit e799299aafed417cc1f32adccb2a0e5268b3f6d5 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 6857510967448..678a7bbd84bf2 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -457,7 +457,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, nr->t2 =3D msecs_to_jiffies(sysctl_netrom_transport_acknowledge_delay); nr->n2 =3D - msecs_to_jiffies(sysctl_netrom_transport_maximum_tries); + msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_maximum_tries)); nr->t4 =3D msecs_to_jiffies(sysctl_netrom_transport_busy_delay); nr->idle =3D --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20E1413D30D; Wed, 13 Mar 2024 16:42:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348170; cv=none; b=bfH6SXm0cB7ECHY7XXmb5DNHESc/xouMdTXxZ1E1WuwrvoxnvFN4qfF4u0MSbRb9biG8ZlhdYlvigLQGymnCzWXWWo+g6nP2AX81L03Az4XecMBMHKxmFT5FqT4Q/sJS/stYPUlBlF1JRpirIBVrupNGr9Ea1/ajk1dY2INrJhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348170; c=relaxed/simple; bh=67liw3T/StQ4cXBr9axLBR840ACqH5dgsHUqaBCJwWg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CjCmlGLwEJC5eQPANMfw6KLEG1KIJBno/k+0suAh8DZMAatBOpivrjlJAHLBBEWz0+WmUpX1iuhD28tsb3wXl0Zi6z7bI0+vInNNaOTtCGrrqMZrwHEpWxv7WdASrUhtqY2dMBAoFO+HJUx+G8kpPAx2aULzfHbzqnmN1ZiYSq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ro7x6/Os; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ro7x6/Os" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D4A9C433C7; Wed, 13 Mar 2024 16:42:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348170; bh=67liw3T/StQ4cXBr9axLBR840ACqH5dgsHUqaBCJwWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ro7x6/OsWSIq+nrlafX+VJbbLrbi67cH4Xqu0b9mRoermmf4DolJbdFlRzyENU0ZX 2F6u3IbIQjXT4nx4TGBWIYhHHl4Ac7zXKf0L6jg5I+eN/Op3SE/IRmsAP3oXLFDimX vlQaSz1rfG4TXgVIqjJn3H+03polxDFEAh2aSLMRCB7+F/AjkR5xpZnn/89yQLFzBK CCQxBkzOnBe8m3zFqNWHD2TU9pIjzyKXTnf2dxi8WzYy0CsSEfih0H1hLCznZSDS5t w9ulrmwDUwBLuYQYBQF7OTzcL2ybKkpw4zf2WPVO6+t/EZXgrhS0+TF6NRaWDUTLfC w1f0x5crzunww== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 21/76] netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay Date: Wed, 13 Mar 2024 12:41:28 -0400 Message-ID: <20240313164223.615640-22-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit 806f462ba9029d41aadf8ec93f2f99c5305deada ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 678a7bbd84bf2..5a5cca18ae0c6 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -455,7 +455,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, nr->t1 =3D msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_timeout)); nr->t2 =3D - msecs_to_jiffies(sysctl_netrom_transport_acknowledge_delay); + msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_acknowledge_delay)); nr->n2 =3D msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_maximum_tries)); nr->t4 =3D --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7128213EFE4; Wed, 13 Mar 2024 16:42:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348171; cv=none; b=oSPjOMjW/2RWASxbgR1COQg36uUx85sH9kBgPJM/xnUjj+x5wHu3PxC7934GIajM5GrmGqPMWpA6xWF0q2x3n0W1qSpVFOup+tJbZhy6kkLSNuyPV18EfFGn0pbeshan2epdAJhbvMwWqzx0xTcb/6qmfuumzN9KnqCy1JbbF9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348171; c=relaxed/simple; bh=JupO535FDJs874LcX2bRQiX9YuUvDP4z5KRR1MTFWag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jPBbWa6rRttuwOLxm+1eV8VQZfKMH6tbkViB2ZGPKdEFHoPMlmR8GNN59gFUbLsV/jSvEsYRGXc21ariKC9t3V87f3+mwh44VM2NZ8Q/isLKnMfHPf1XotpzdyO3F6pX71IXFaLifeIN7aE91nu2wZGHDdXSsle9o4zG+TuTnxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uHRAPNgf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uHRAPNgf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D735C43394; Wed, 13 Mar 2024 16:42:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348171; bh=JupO535FDJs874LcX2bRQiX9YuUvDP4z5KRR1MTFWag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uHRAPNgfAXAsch/Zh7PDup8SA1XgwNbmGPP0efN2VKV0kQOzxVnEKhXPJ2oNUt8Lx hBhVE8OsWLLs/OV6/9p8eRTyAgSYcXy929Z4Wh2IJOVpKY1Ym/HF4By/yPdZQp/2qx B5DNTrvMFXjF/va1TR6O0rnILicAZabe1ioQrpT7DR7wiPtXcVSONmEZOzrktB/R8u xbPlK4AtnpRxvbgNSrpwsJT6IxDz2kEeT10CelGDmk7XpGORcn4iY4nZaNsdv4R8C9 Yjx0+1zFVk4oXY7bcv9289ZgkNuhtXSDQAB16Htj4QF80+3ubAzkUSHWZAY4JO38zm Ug+M2De00r31g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 22/76] netrom: Fix a data-race around sysctl_netrom_transport_busy_delay Date: Wed, 13 Mar 2024 12:41:29 -0400 Message-ID: <20240313164223.615640-23-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit 43547d8699439a67b78d6bb39015113f7aa360fd ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 5a5cca18ae0c6..76d66eb0de255 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -459,7 +459,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, nr->n2 =3D msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_maximum_tries)); nr->t4 =3D - msecs_to_jiffies(sysctl_netrom_transport_busy_delay); + msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_busy_delay)); nr->idle =3D msecs_to_jiffies(sysctl_netrom_transport_no_activity_timeout); nr->window =3D sysctl_netrom_transport_requested_window_size; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FFF313F434; Wed, 13 Mar 2024 16:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348172; cv=none; b=bpNCEHqA00tTRviAozyDjyA9RghIZ7QKhO6TSrVkZcl9p9qGTKOmKHWsJmvwJ+6/Jc3JU+fX4yUw0MRGROutR314tRwKPjvePAQmcSqGN3JGfLOyqenqWLLhjPGuhR7jHhERHU8J6Ele8UR7WRWhZn01WUdv2SrqN+FHVkgSKsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348172; c=relaxed/simple; bh=A45mpmaNrioN7F+79MkqmOhHiGCPFpIHmheKJHJxoKk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FB54B8/GGy94w8f3bHkFGycBYLUbjcodKfCg2EErY5hv3VVfmIAWvw6laR08uncRiZvq9JIcRWX4WsloKgPaFD233+Ot+c1ghHHDWq3BLJ5I+w3vQUbLkVvHI3KfcvWNEHX/VRmTGFTIfZawO4Tx7hw2tvB3J9cJPlKdUthxa1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lfqXwO05; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lfqXwO05" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D97FC433F1; Wed, 13 Mar 2024 16:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348172; bh=A45mpmaNrioN7F+79MkqmOhHiGCPFpIHmheKJHJxoKk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfqXwO051bFHCoDctVnN8PVdrDC7k/XGuOzap5bvsyAHCK2cGrrvY5Zhmh5LjZIiY Mlgl/JBfVJUlKVc0aBINOuNkqzGrM9plLqCxOfXuCGel3X6r5scptwu1Bp9SkjkcX5 vjiUq30pcb2sb4OeJaknx+0zxpWdIDVg1N5i8pGnprbJmvkHvNVfUvTs8xnoeYfA7p B16l2LOdw0FFlA0iRwmG9H1SfysFmVhiWANZ8A2gm4NO3R+EiQphYAsSJ8Jx+kbsQR HsII7QWsQHG2FMlo00WUKH+zAboN31oRafJurh0tBu/K8Fg1l8QRKLvqVjR3oolOIl geqrN8rdY2wxQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 23/76] netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size Date: Wed, 13 Mar 2024 12:41:30 -0400 Message-ID: <20240313164223.615640-24-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit a2e706841488f474c06e9b33f71afc947fb3bf56 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 76d66eb0de255..d780adf54e19e 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -462,7 +462,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_busy_delay)); nr->idle =3D msecs_to_jiffies(sysctl_netrom_transport_no_activity_timeout); - nr->window =3D sysctl_netrom_transport_requested_window_size; + nr->window =3D READ_ONCE(sysctl_netrom_transport_requested_window_size); =20 nr->bpqext =3D 1; nr->state =3D NR_STATE_0; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29154633F5; Wed, 13 Mar 2024 16:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348173; cv=none; b=LX97koj31RD7tVug5MVEQi7sTCopAsIgUC8a/iwxn3UP+1PChoDnAYi/ozktp5xRvl1QHiKgF3y1RHZBTN05T21qsZlFwilhzPhPkBSNEeh5Yipftw9euoM3GX4r+2vYHuOSzEXuCaBKMdvDmke/b3CPhxu7V1CPbt4GDQzLC24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348173; c=relaxed/simple; bh=g43Mh+Ckbo7u84Iinkv4s2Oe8nqvUxcd3wBs+YIKlwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TM0r0cUgGSPQ/TArKtTiodC5ZNVknn4qUegobK8GaGBPxKCR9mB1uazhmHB/32/4Zcec5vLpUuEXKnGWLD1cMmapye3aR62BZuyI5L/+YL6iiQ+BOaIP5FyCwdHkTzNpO1zwbAzX7Af6emLrKMVzoBW1z8p4OSyAiu8TcZS7XO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=la5YW2Gw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="la5YW2Gw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D3BBC433C7; Wed, 13 Mar 2024 16:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348173; bh=g43Mh+Ckbo7u84Iinkv4s2Oe8nqvUxcd3wBs+YIKlwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=la5YW2Gwq7KIqMxEjxF7c/kZ87AVjgcIBpNpWbtJPjL4uzpLoprd5PJh6BLojlpg0 8IQepAXmSGtLmkNgxITlphRU6uvmvJpcN1YHpPqHOhcK9e2o5m4eJe+Ln6Qy408j1i gSrTx10zOE9P3W2oI0XuC9tfw1oU2nN9FL1e3QtYfdRNlyCj8XWWMUpUKx1m2QZblw KcF7/vNu4kCXFOZzCyW22rr4CtXEPXjkRaAbJnWtDUlQkix+LaDtdPX99GGFeMrcZ6 8YnnH/z+2irlqqc2udKnRqmagnWaSVlgkmUeLMMWm9d/R+ijF3MJH9vxLlWStmci7/ vhx3k/gntSiDA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 24/76] netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout Date: Wed, 13 Mar 2024 12:41:31 -0400 Message-ID: <20240313164223.615640-25-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit f99b494b40431f0ca416859f2345746199398e2b ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index d780adf54e19e..376b6af431448 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -461,7 +461,7 @@ static int nr_create(struct net *net, struct socket *so= ck, int protocol, nr->t4 =3D msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_busy_delay)); nr->idle =3D - msecs_to_jiffies(sysctl_netrom_transport_no_activity_timeout); + msecs_to_jiffies(READ_ONCE(sysctl_netrom_transport_no_activity_timeout)); nr->window =3D READ_ONCE(sysctl_netrom_transport_requested_window_size); =20 nr->bpqext =3D 1; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3B281420CC; Wed, 13 Mar 2024 16:42:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348174; cv=none; b=AH7f3jKvsISf3NvjqZwESGAXPgRt1jWkCT1zMM2QJovlx/fxWWvPejWiP13tEZG0eCOYHE/0Fd59g+aPm1PdMjTTS4uYr4/XxtzSYWq6Uo05VlD//135TVWuHfZAqRKxiTJJlUGJZNUMUWqgk45UZ4y2zTiZkiMkBqaPSIkJDnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348174; c=relaxed/simple; bh=H4DfSV2MBlhDn7HAlV8mC+leAoVxNyHqkIWIC7yYs+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qTxu71f8iepXCgp1bd70uTo+1g4FkHxFNjMPif9CNpupnWEoc8TmqYNntFgBFD4EBLiu7gSOWAd1A9GuXXNlEMCMv0pbX4h16aiOgtRgIYzQ4tj7urg0iWaTAMLt+rc4ZWg9bMAFQG6T3Yg6pU/vkca1P3iKW0sQxbuw3UiA8Yw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fbYXXriC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fbYXXriC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 643EBC43394; Wed, 13 Mar 2024 16:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348174; bh=H4DfSV2MBlhDn7HAlV8mC+leAoVxNyHqkIWIC7yYs+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbYXXriCqeIPpqtmHHHXgZHNGLCk+s7MsIrIwM9i1ssAo6cqhmR8cKjTTeGrloTYT jXDzO4AortCT84P6jCHvjh4soqD76REpHvg5yTNbEF3+JTp21kXVhETlEanz4XJnih e+YsK52cBw/dFc9yB7SGCLrkis4QUP1kevg4Zf65FwroNnxWRW542DMnSmxFr/1+Nv ISQPMkUfzzoki+eoHztNj3siXnzwSICoe3R2Ju5sL72HKArbrhIkyjnbiew7ibklWe qpGhe9Z6Uj4GOKIrYq+9wRxGNCYNE1ogikkqWeVfg0D3IPBf67vPcLSuJ4VykRuCIY nsU5AMvKY7czQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 25/76] netrom: Fix a data-race around sysctl_netrom_routing_control Date: Wed, 13 Mar 2024 12:41:32 -0400 Message-ID: <20240313164223.615640-26-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit b5dffcb8f71bdd02a4e5799985b51b12f4eeaf76 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index e5d24462d5100..56bec5b5b37c7 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -780,7 +780,7 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25) return ret; } =20 - if (!sysctl_netrom_routing_control && ax25 !=3D NULL) + if (!READ_ONCE(sysctl_netrom_routing_control) && ax25 !=3D NULL) return 0; =20 /* Its Time-To-Live has expired */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4819314262B; Wed, 13 Mar 2024 16:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348175; cv=none; b=mp+wWBVS2/WkOMyfQFP/RetsHvnOWdJFtSmBWgx7v+h1PYYE816tRYqJOS8gaHuOhMWSD5vT/UnUOHYijnxO9QXnN+W8WtlwRTt4qs8M9vlH29KyLIUVozfKdMQnTNcrDqAq4N+kan4+wBQjhrEVlETrQ2SqAcEjP/44pes98Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348175; c=relaxed/simple; bh=6/1EAGfa4zAXJ6ZaPmxIK8PFTioJivkuGr5IEuxC0DM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=le5DjEMW5Ed5HF1XK4ILMJYFi7t2/tKqB5yE37wcIOSV7ldMuQ1bMhSTaxNNDjNRXusPYLqD1ZqkMMQ2E7Y+k3v7EsIdbP5Xc3WUlqP/c4CmGr03Q/sxe66o7Z9Vc0sGw/Vr+n/LQCE4FXc1Rlaxp2L2dKfbWTooX0wkvI37jS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d5h+qGV3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d5h+qGV3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70A79C43390; Wed, 13 Mar 2024 16:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348175; bh=6/1EAGfa4zAXJ6ZaPmxIK8PFTioJivkuGr5IEuxC0DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d5h+qGV3109rByx2IKOoqGuxJDvncs9nJvE6m50OegmvQPgx+jjexDvTnS1xhemq0 J1gcc3oLUXjXU/CJA+t4iMFnFQ2T9aY3u2OPBjLP8tMAMNvwFMGtWwCNj99RFfoatx DwGqeEDt4eV3g9FdLERjVN2ZB03K00mBjuGJxP9aqIzZ0pK0MABvLmYjLTKHLOn5Tq 4+gB2pIxl6EEWWyCag1YMjXfMbUiV0+7SQ0SnVNcVthDs+jiV0/y7uwCFgTqc+ZNml w/qsbxx8nI2tILQh8+i+etWTlwu3UrJ93DPU0TSGhvUoB5832FRPJeTV96/dy5OMPK WjmVo+iAwMtTQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 26/76] netrom: Fix a data-race around sysctl_netrom_link_fails_count Date: Wed, 13 Mar 2024 12:41:33 -0400 Message-ID: <20240313164223.615640-27-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit bc76645ebdd01be9b9994dac39685a3d0f6f7985 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/nr_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index 56bec5b5b37c7..983c5ad9724f1 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -728,7 +728,7 @@ void nr_link_failed(ax25_cb *ax25, int reason) nr_neigh->ax25 =3D NULL; ax25_cb_put(ax25); =20 - if (++nr_neigh->failed < sysctl_netrom_link_fails_count) { + if (++nr_neigh->failed < READ_ONCE(sysctl_netrom_link_fails_count)) { nr_neigh_put(nr_neigh); return; } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4518313F431; Wed, 13 Mar 2024 16:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348176; cv=none; b=sCsbxFm1ubHdOb3Wxbi+GCrUnIuVbxw/rtd/rqsq05rqGDHQJCf5QT31rid/zbBjfO0HkcKzmEiQfN6tGRxUfEgGwhoisl9aFeC36kONlFbRlFvWBakE9l1xF92iBZeZmNshNMFyKSCYy5MQrQBSsvIOrTraLVEmFh87Vpa0+08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348176; c=relaxed/simple; bh=t9cB5tJirBxb/oPgBSz64yZsV3dGZtpPI1QZkEyTRRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TIdbwAhRi1gNS3lyIhaWECubxqKrWowiofxTRPbP+RmQ0iAVOrHJFKQDoXkYmfgnOxfUOuV5N8XaBpngVV25kJTNGIV4IJSTY4NY/szghwOPQ5EiBYZ9XnOl+7d0JpY97YJ2GAhIormYV9J0yL86sGR4FUvnaizCs+AkXih1qCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rLAoBrj5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rLAoBrj5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70C1EC433F1; Wed, 13 Mar 2024 16:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348176; bh=t9cB5tJirBxb/oPgBSz64yZsV3dGZtpPI1QZkEyTRRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLAoBrj5p4QOguTkykSVXFiJ7RCgawKCf1ElncdcmRVeMuCfS/uyGxJGcVN0gUG37 SkWvc1gKxSgD+JSfxCr6CmXmONVUv2vLiizesuQ+OwXxQjQi/IGmrXxWfOVVXksCV/ 1ghYB23gmUUsvWsNRPova60Xpq6aBfNS6aPsvv1YUhrA6076K8ve2+APzQRFpL41X2 a9lfFXuvulLkqgyvBgtacgtv1JXId1cTDDsUaFn7FomKfSjdOB19LgTsL3Tg4G/RMg KkZZHYYzY8HQ0qYk3BHHp0V+ZtgSnxzs0TS7BjMBhKgm1hVjLqsztE81QDBtyVHcpZ k0JyA4mtMehMg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jason Xing , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 27/76] netrom: Fix data-races around sysctl_net_busy_read Date: Wed, 13 Mar 2024 12:41:34 -0400 Message-ID: <20240313164223.615640-28-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Xing [ Upstream commit d380ce70058a4ccddc3e5f5c2063165dc07672c6 ] We need to protect the reader reading the sysctl value because the value can be changed concurrently. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jason Xing Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- net/netrom/af_netrom.c | 2 +- net/netrom/nr_in.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index 376b6af431448..37d0bf6cab456 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -954,7 +954,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device = *dev) * G8PZT's Xrouter which is sending packets with command type 7 * as an extension of the protocol. */ - if (sysctl_netrom_reset_circuit && + if (READ_ONCE(sysctl_netrom_reset_circuit) && (frametype !=3D NR_RESET || flags !=3D 0)) nr_transmit_reset(skb, 1); =20 diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c index 2f084b6f69d7e..97944db6b5ac6 100644 --- a/net/netrom/nr_in.c +++ b/net/netrom/nr_in.c @@ -97,7 +97,7 @@ static int nr_state1_machine(struct sock *sk, struct sk_b= uff *skb, break; =20 case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; =20 @@ -128,7 +128,7 @@ static int nr_state2_machine(struct sock *sk, struct sk= _buff *skb, break; =20 case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; =20 @@ -262,7 +262,7 @@ static int nr_state3_machine(struct sock *sk, struct sk= _buff *skb, int frametype break; =20 case NR_RESET: - if (sysctl_netrom_reset_circuit) + if (READ_ONCE(sysctl_netrom_reset_circuit)) nr_disconnect(sk, ECONNRESET); break; =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CD5A143C78; Wed, 13 Mar 2024 16:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348177; cv=none; b=MpeGNIB7ZoMTEXAOBVmfMdxH6sdmmed39XKTUMy04sYLFeqcpFSa5YSu52p/nwbMkbQUrFMIwUReVgAPhq9+wtN8vWeZq7WMRS6KkH91gtl437VqWxxJ0vb5UtmvXHmhe7a8CbB2T2pHmYC8kH6zHouUnNdVK9L1dIcHYkX8frE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348177; c=relaxed/simple; bh=K6uUHDmgjsziI7JWX0ockfdu56Tnoh69HOTfEp2fHaY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lz1nnuQWboqr5MzObVPeTLExibL1e5y8BqURjBb1TZvT74Luqwis/ceRZZHB5axyZttv1PJK0dyKWxBHJzc6Z/c9R4I8s4cWQqJJ2CIPbQOXsEeSV1OgP9gkUI5/sBW6l1njFBoWmJl7hSDPlgSAer5HFHhFww8NJauheitMMAw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fTjRUTqj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fTjRUTqj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FEABC433C7; Wed, 13 Mar 2024 16:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348177; bh=K6uUHDmgjsziI7JWX0ockfdu56Tnoh69HOTfEp2fHaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTjRUTqjVTO9t9vg8+tbMnYTRPfcpfMhaRZtbfGOsFXLI0oI1mow3wY1V7t3rWGO5 bUh9WBDIrC9XjaJUNIYTEFKtyZkAkU60P20iugVsixrKPXX6bGwDucFp+RnyuKA7er AXwB24qBNQ5XNqpdE17ccQqbBQpSjCyYfXrUNHQNH0/dfHoCc3ct1OW/w2Ktorw61E CZDFBg1ivih0FmzmJmlIQWLBhV3nWCbgHzk81LcKKb2Ty++BnfTS3g+5IHEx4SyEW2 CUeOBs5rQoEr66siftDHSyk8MHeXBL6WD95YZRArwiuFBAcvICeZT3d0s9tjtN2bmd 8fAmlrCvyxCWA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 28/76] ALSA: usb-audio: Refcount multiple accesses on the single clock Date: Wed, 13 Mar 2024 12:41:35 -0400 Message-ID: <20240313164223.615640-29-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit c11117b634f4f832c4420d3cf41c44227f140ce1 ] When a clock source is connected to multiple nodes / endpoints, the current USB-audio driver tries to set up at each time one of them is configured. Although it reads the current rate and updates only if it differs, some devices seem unhappy with this behavior and spew the errors when reading/updating the rate unnecessarily. This patch tries to reduce the redundant clock setup by introducing a refcount for each clock source. When the stream is actually running, a clock rate is "locked", and it bypasses the clock and/or refuse to change any longer. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D215934 Link: https://lore.kernel.org/r/20220516104807.16482-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/card.c | 1 + sound/usb/card.h | 3 +- sound/usb/endpoint.c | 90 +++++++++++++++++++++++++++++++++++++++----- sound/usb/usbaudio.h | 1 + 4 files changed, 85 insertions(+), 10 deletions(-) diff --git a/sound/usb/card.c b/sound/usb/card.c index 550c6a72fb5bc..bebd42413fadb 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -643,6 +643,7 @@ static int snd_usb_audio_create(struct usb_interface *i= ntf, INIT_LIST_HEAD(&chip->pcm_list); INIT_LIST_HEAD(&chip->ep_list); INIT_LIST_HEAD(&chip->iface_ref_list); + INIT_LIST_HEAD(&chip->clock_ref_list); INIT_LIST_HEAD(&chip->midi_list); INIT_LIST_HEAD(&chip->mixer_list); =20 diff --git a/sound/usb/card.h b/sound/usb/card.h index 87f042d06ce08..ca75f2206170f 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -44,6 +44,7 @@ struct audioformat { =20 struct snd_usb_substream; struct snd_usb_iface_ref; +struct snd_usb_clock_ref; struct snd_usb_endpoint; struct snd_usb_power_domain; =20 @@ -62,6 +63,7 @@ struct snd_urb_ctx { struct snd_usb_endpoint { struct snd_usb_audio *chip; struct snd_usb_iface_ref *iface_ref; + struct snd_usb_clock_ref *clock_ref; =20 int opened; /* open refcount; protect with chip->mutex */ atomic_t running; /* running status */ @@ -138,7 +140,6 @@ struct snd_usb_endpoint { unsigned int cur_period_frames; unsigned int cur_period_bytes; unsigned int cur_buffer_periods; - unsigned char cur_clock; =20 spinlock_t lock; struct list_head list; diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 6c7d842d04965..803053d4c9dbc 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -35,6 +35,14 @@ struct snd_usb_iface_ref { struct list_head list; }; =20 +/* clock refcounting */ +struct snd_usb_clock_ref { + unsigned char clock; + atomic_t locked; + int rate; + struct list_head list; +}; + /* * snd_usb_endpoint is a model that abstracts everything related to an * USB endpoint and its streaming. @@ -598,6 +606,25 @@ iface_ref_find(struct snd_usb_audio *chip, int iface) return ip; } =20 +/* Similarly, a refcount object for clock */ +static struct snd_usb_clock_ref * +clock_ref_find(struct snd_usb_audio *chip, int clock) +{ + struct snd_usb_clock_ref *ref; + + list_for_each_entry(ref, &chip->clock_ref_list, list) + if (ref->clock =3D=3D clock) + return ref; + + ref =3D kzalloc(sizeof(*ref), GFP_KERNEL); + if (!ref) + return NULL; + ref->clock =3D clock; + atomic_set(&ref->locked, 0); + list_add_tail(&ref->list, &chip->clock_ref_list); + return ref; +} + /* * Get the existing endpoint object corresponding EP * Returns NULL if not present. @@ -775,6 +802,14 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, goto unlock; } =20 + if (fp->protocol !=3D UAC_VERSION_1) { + ep->clock_ref =3D clock_ref_find(chip, fp->clock); + if (!ep->clock_ref) { + ep =3D NULL; + goto unlock; + } + } + ep->cur_audiofmt =3D fp; ep->cur_channels =3D fp->channels; ep->cur_rate =3D params_rate(params); @@ -784,7 +819,6 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, ep->cur_period_frames =3D params_period_size(params); ep->cur_period_bytes =3D ep->cur_period_frames * ep->cur_frame_bytes; ep->cur_buffer_periods =3D params_periods(params); - ep->cur_clock =3D fp->clock; =20 if (ep->type =3D=3D SND_USB_ENDPOINT_TYPE_SYNC) endpoint_set_syncinterval(chip, ep); @@ -902,8 +936,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, ep->altsetting =3D 0; ep->cur_audiofmt =3D NULL; ep->cur_rate =3D 0; - ep->cur_clock =3D 0; ep->iface_ref =3D NULL; + ep->clock_ref =3D NULL; usb_audio_dbg(chip, "EP 0x%x closed\n", ep->ep_num); } mutex_unlock(&chip->mutex); @@ -915,6 +949,8 @@ void snd_usb_endpoint_suspend(struct snd_usb_endpoint *= ep) ep->need_setup =3D true; if (ep->iface_ref) ep->iface_ref->need_setup =3D true; + if (ep->clock_ref) + ep->clock_ref->rate =3D 0; } =20 /* @@ -1321,6 +1357,33 @@ static int snd_usb_endpoint_set_params(struct snd_us= b_audio *chip, return 0; } =20 +static int init_sample_rate(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep) +{ + struct snd_usb_clock_ref *clock =3D ep->clock_ref; + int err; + + if (clock) { + if (atomic_read(&clock->locked)) + return 0; + if (clock->rate =3D=3D ep->cur_rate) + return 0; + if (clock->rate && clock->rate !=3D ep->cur_rate) { + usb_audio_dbg(chip, "Mismatched sample rate %d vs %d for EP 0x%x\n", + clock->rate, ep->cur_rate, ep->ep_num); + return -EINVAL; + } + } + + err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, ep->cur_rate); + if (err < 0) + return err; + + if (clock) + clock->rate =3D ep->cur_rate; + return 0; +} + /* * snd_usb_endpoint_configure: Configure the endpoint * @@ -1350,8 +1413,7 @@ int snd_usb_endpoint_configure(struct snd_usb_audio *= chip, * to update at each EP configuration */ if (ep->cur_audiofmt->protocol =3D=3D UAC_VERSION_1) { - err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, - ep->cur_rate); + err =3D init_sample_rate(chip, ep); if (err < 0) goto unlock; } @@ -1381,7 +1443,7 @@ int snd_usb_endpoint_configure(struct snd_usb_audio *= chip, if (err < 0) goto unlock; =20 - err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, ep->cur_rate); + err =3D init_sample_rate(chip, ep); if (err < 0) goto unlock; =20 @@ -1414,15 +1476,15 @@ int snd_usb_endpoint_configure(struct snd_usb_audio= *chip, /* get the current rate set to the given clock by any endpoint */ int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock) { - struct snd_usb_endpoint *ep; + struct snd_usb_clock_ref *ref; int rate =3D 0; =20 if (!clock) return 0; mutex_lock(&chip->mutex); - list_for_each_entry(ep, &chip->ep_list, list) { - if (ep->cur_clock =3D=3D clock && ep->cur_rate) { - rate =3D ep->cur_rate; + list_for_each_entry(ref, &chip->clock_ref_list, list) { + if (ref->clock =3D=3D clock) { + rate =3D ref->rate; break; } } @@ -1463,6 +1525,9 @@ int snd_usb_endpoint_start(struct snd_usb_endpoint *e= p) if (atomic_inc_return(&ep->running) !=3D 1) return 0; =20 + if (ep->clock_ref) + atomic_inc(&ep->clock_ref->locked); + ep->active_mask =3D 0; ep->unlink_mask =3D 0; ep->phase =3D 0; @@ -1572,6 +1637,9 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *e= p, bool keep_pending) if (ep->sync_source) WRITE_ONCE(ep->sync_source->sync_sink, NULL); stop_urbs(ep, false, keep_pending); + if (ep->clock_ref) + if (!atomic_dec_return(&ep->clock_ref->locked)) + ep->clock_ref->rate =3D 0; } } =20 @@ -1598,12 +1666,16 @@ void snd_usb_endpoint_free_all(struct snd_usb_audio= *chip) { struct snd_usb_endpoint *ep, *en; struct snd_usb_iface_ref *ip, *in; + struct snd_usb_clock_ref *cp, *cn; =20 list_for_each_entry_safe(ep, en, &chip->ep_list, list) kfree(ep); =20 list_for_each_entry_safe(ip, in, &chip->iface_ref_list, list) kfree(ip); + + list_for_each_entry_safe(cp, cn, &chip->clock_ref_list, list) + kfree(ip); } =20 /* diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index ec06f441e890f..e97141ef730ad 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -46,6 +46,7 @@ struct snd_usb_audio { struct list_head pcm_list; /* list of pcm streams */ struct list_head ep_list; /* list of audio-related endpoints */ struct list_head iface_ref_list; /* list of interface refcounts */ + struct list_head clock_ref_list; /* list of clock refcounts */ int pcm_devs; =20 struct list_head midi_list; /* list of midi interfaces */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4ACCD63411; Wed, 13 Mar 2024 16:42:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348178; cv=none; b=AS85gysB+MeGRV2o4xlDi+BlDdaf8CYWUerVv/roiox/e2/92R1DjoVUlY0aqUqk2gKuOl3gt0TbA8Hsw8l0JCo6WyM1n09uTgR+9T1SoVHh/4jSSahCWiHwu6x7YAUnkNuRa8kroNNvA93R/WrAGzzGC1XH1Hk9T9AD/ZpPrP8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348178; c=relaxed/simple; bh=8IImuHKCDLLJHUSZxoAxes0ahPbeQ6kuN9+Djzi8mbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C+mw8t3zld3INY9+2BoGl9iQ7iySk4vI70gi38zPCmzxk/AhQVUY+WQ49NhwyokJlXrPWdQ7i1ZHGsgU+EB2e5AYQTmi0fqT3fyPgmFoHAcyiS9yrVTguxF72kc3JC6z2JMWLVyUrqQ/vvvmK2/IgINVGeyDFJ1xyhrcqh0U2zs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ozhXXXKV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ozhXXXKV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 679CBC43394; Wed, 13 Mar 2024 16:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348178; bh=8IImuHKCDLLJHUSZxoAxes0ahPbeQ6kuN9+Djzi8mbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozhXXXKV1C8BpwXSn0ggOnXbjReceswAeRKPdDvgd+Ciczr1Lz5+pbaw4/BIsN1qL 3IAsFm5NN8t7D4ycnF2zSTcYzdei8y4tN50zzVwwtotd/Iy9qK7Bjt5kKv848UJ4Pa BYskbUntHgbLb3Kpn1lo642RWr9ZjRU/Y2hctx3mgz7W7ZtpOb/JffL8n4dIhHqosk /3ApWoYTVceBmSHRzwn/I/O8EKg2nNIqtFA1yChWrKDBeWzKblhXVVyoV+me6bfBFf nX9rjkevpNROZgPAUTvS5ignH1jwWdFk1+n9oJAxRYYjqPOZBT7ePHypHYcBHEdTcV 9lNqRZibBNygA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , "Jason A . Donenfeld" , Sasha Levin Subject: [PATCH 5.15 29/76] ALSA: usb-audio: Clear fixed clock rate at closing EP Date: Wed, 13 Mar 2024 12:41:36 -0400 Message-ID: <20240313164223.615640-30-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 809f44a0cc5ad4b1209467a6287f8ac0eb49d393 ] The recent commit c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the single clock") tries to manage the clock rate shared by several endpoints. This was intended for avoiding the unmatched rate by a different endpoint, but unfortunately, it introduced a regression for PulseAudio and pipewire, too; those applications try to probe the multiple possible rates (44.1k and 48kHz) and setting up the normal rate fails but only the last rate is applied. The cause is that the last sample rate is still left to the clock reference even after closing the endpoint, and this value is still used at the next open. It happens only when applications set up via PCM prepare but don't start/stop the stream; the rate is reset when the stream is stopped, but it's not cleared at close. This patch addresses the issue above, simply by clearing the rate set in the clock reference at the last close of each endpoint. Fixes: c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the si= ngle clock") Reported-by: Jason A. Donenfeld Tested-by: Jason A. Donenfeld Cc: Link: https://lore.kernel.org/all/YxXIWv8dYmg1tnXP@zx2c4.com/ Link: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2620 Link: https://lore.kernel.org/r/20220907100421.6443-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 803053d4c9dbc..13c0264881499 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -932,6 +932,8 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, endpoint_set_interface(chip, ep, false); =20 if (!--ep->opened) { + if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) + ep->clock_ref->rate =3D 0; ep->iface =3D 0; ep->altsetting =3D 0; ep->cur_audiofmt =3D NULL; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BE721448DE; Wed, 13 Mar 2024 16:42:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348179; cv=none; b=dr4UuazSjPAruBjDUpx6WptH/djx+9uBec188o+6tvym16XBxchpXCSrcbCQutDVRvdKIinZiDAicu6h6c4LqdXt3lZG3zN7MwTGU5GrCJb47yBjBFV8qKukSMoE3DMRwC6roRjG/Tbfyblan7/bWfos3HuYzBBgQOwYkKz9/44= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348179; c=relaxed/simple; bh=fb+uyGrzfDSNzqv09/El8PbxSWNbJhSbA+9LnH4t+bI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O4Ml/p4NYeJCFxQwOMThS/CcrltBcB8dVQ9/aia00XM2i+JPsA0IJFXWUdxJF3Kd6yX+0NNoUuYiDyX9uBUAhZhIapcIGrIW7wMFRciot6X4Zpazqc8beX1lZFg5Kd5NLPAx3lFPhZRBc3AyC6QUHcaO3VGlII+u4gBrZ9cBzI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S+fpdhlJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S+fpdhlJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 813D5C43390; Wed, 13 Mar 2024 16:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348179; bh=fb+uyGrzfDSNzqv09/El8PbxSWNbJhSbA+9LnH4t+bI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S+fpdhlJeldHIt1n2i1OmN+YtNapiHrizrkYpxuyoasJL1tbemIinUBs6Rpya0hI2 waw9H0v35rGUKPK1aucgVLrZMPIIn3tqYCugAzp5im4kA1OIofT/xXwcLAhCHQzZAE Sm+b89uttoGTNzEKqkkNFckTSYJDGma1zKK6wUu7BhWYdwEeIAgFdC8tpP48GA0eaD wsZRaTUA3H0YSpJeotzz+h6NEr1KiR4Xx3aZS80D28RKdH/Ttx2OT0tN2ku5wfeSrO PLmP/RKKJ4ps7k5uyfthyId0G9LEy9/xNYb0ywEwx0FaNQaRUXdy9EPV7jG+WSXDiq iSvmvBi0BgH4w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , chihhao chen , Sasha Levin Subject: [PATCH 5.15 30/76] ALSA: usb-audio: Split endpoint setups for hw_params and prepare (take#2) Date: Wed, 13 Mar 2024 12:41:37 -0400 Message-ID: <20240313164223.615640-31-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 2be79d58645465351af5320eb14c70a94724c5ef ] This is a second attempt to fix the bug appearing on Android with the recent kernel; the first try was ff878b408a03 and reverted at commit 79764ec772bc. The details taken from the v1 patch: One of the former changes for the endpoint management was the more consistent setup of endpoints at hw_params. snd_usb_endpoint_configure() is a single function that does the full setup, and it's called from both PCM hw_params and prepare callbacks. Although the EP setup at the prepare phase is usually skipped (by checking need_setup flag), it may be still effective in some cases like suspend/resume that requires the interface setup again. As it's a full and single setup, the invocation of snd_usb_endpoint_configure() includes not only the USB interface setup but also the buffer release and allocation. OTOH, doing the buffer release and re-allocation at PCM prepare phase is rather superfluous, and better to be done only in the hw_params phase. For those optimizations, this patch splits the endpoint setup to two phases: snd_usb_endpoint_set_params() and snd_usb_endpoint_prepare(), to be called from hw_params and from prepare, respectively. Note that this patch changes the driver operation slightly, effectively moving the USB interface setup again to PCM prepare stage instead of hw_params stage, while the buffer allocation and such initializations are still done at hw_params stage. And, the change of the USB interface setup timing (moving to prepare) gave an interesting "fix", too: it was reported that the recent kernels caused silent output at the beginning on playbacks on some devices on Android, and this change casually fixed the regression. It seems that those devices are picky about the sample rate change (or the interface change?), and don't follow the too immediate rate changes. Meanwhile, Android operates the PCM in the following order: - open, then hw_params with the possibly highest sample rate - close without prepare - re-open, hw_params with the normal sample rate - prepare, and start streaming This procedure ended up the hw_params twice with different rates, and because the recent kernel did set up the sample rate twice one and after, it screwed up the device. OTOH, the earlier kernels didn't set up the USB interface at hw_params, hence this problem didn't appear. Now, with this patch, the USB interface setup is again back to the prepare phase, and it works around the problem automagically. Although we should address the sample rate problem in a more solid way in future, let's keep things working as before for now. *** What's new in the take#2 patch: - The regression caused by the v1 patch (bko#216500) was due to the missing check of need_setup flag at hw_params. Now the check is added, and the snd_usb_endpoint_set_params() call is skipped when the running EP is re-opened. - There was another bug in v1 where the clock reference rate wasn't updated at hw_params phase, which may lead to a lack of the proper hw constraints when an application doesn't issue the prepare but only the hw_params call. This patch fixes it as well by tracking the clock rate change in the prepare callback with a new flag "need_update" for the clock reference object, just like others. - The configure_endpoints() are simplified and folded back into snd_usb_pcm_prepare(). Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management") Fixes: ff878b408a03 ("ALSA: usb-audio: Split endpoint setups for hw_params = and prepare") Reported-by: chihhao chen Link: https://lore.kernel.org/r/87e6d6ae69d68dc588ac9acc8c0f24d6188375c3.ca= mel@mediatek.com Link: https://lore.kernel.org/r/20220901124136.4984-1-tiwai@suse.de Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216500 Link: https://lore.kernel.org/r/20220920181106.4894-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 76 +++++++++++++++++++++++++++----------------- sound/usb/endpoint.h | 6 ++-- sound/usb/pcm.c | 51 ++++++++++++----------------- 3 files changed, 70 insertions(+), 63 deletions(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 13c0264881499..32a9e016665c8 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -40,6 +40,7 @@ struct snd_usb_clock_ref { unsigned char clock; atomic_t locked; int rate; + bool need_setup; struct list_head list; }; =20 @@ -765,7 +766,8 @@ bool snd_usb_endpoint_compatible(struct snd_usb_audio *= chip, * The endpoint needs to be closed via snd_usb_endpoint_close() later. * * Note that this function doesn't configure the endpoint. The substream - * needs to set it up later via snd_usb_endpoint_configure(). + * needs to set it up later via snd_usb_endpoint_set_params() and + * snd_usb_endpoint_prepare(). */ struct snd_usb_endpoint * snd_usb_endpoint_open(struct snd_usb_audio *chip, @@ -1296,15 +1298,39 @@ static int sync_ep_set_params(struct snd_usb_endpoi= nt *ep) return -ENOMEM; } =20 +/* update the rate of the referred clock; return the actual rate */ +static int update_clock_ref_rate(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep) +{ + struct snd_usb_clock_ref *clock =3D ep->clock_ref; + int rate =3D ep->cur_rate; + + if (!clock || clock->rate =3D=3D rate) + return rate; + if (clock->rate) { + if (atomic_read(&clock->locked)) + return clock->rate; + if (clock->rate !=3D rate) { + usb_audio_err(chip, "Mismatched sample rate %d vs %d for EP 0x%x\n", + clock->rate, rate, ep->ep_num); + return clock->rate; + } + } + clock->rate =3D rate; + clock->need_setup =3D true; + return rate; +} + /* * snd_usb_endpoint_set_params: configure an snd_usb_endpoint * + * It's called either from hw_params callback. * Determine the number of URBs to be used on this endpoint. * An endpoint must be configured before it can be started. * An endpoint that is already running can not be reconfigured. */ -static int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, - struct snd_usb_endpoint *ep) +int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep) { const struct audioformat *fmt =3D ep->cur_audiofmt; int err; @@ -1356,49 +1382,46 @@ static int snd_usb_endpoint_set_params(struct snd_u= sb_audio *chip, ep->maxframesize =3D ep->maxpacksize / ep->cur_frame_bytes; ep->curframesize =3D ep->curpacksize / ep->cur_frame_bytes; =20 - return 0; + return update_clock_ref_rate(chip, ep); } =20 static int init_sample_rate(struct snd_usb_audio *chip, struct snd_usb_endpoint *ep) { struct snd_usb_clock_ref *clock =3D ep->clock_ref; - int err; + int rate, err; =20 - if (clock) { - if (atomic_read(&clock->locked)) - return 0; - if (clock->rate =3D=3D ep->cur_rate) - return 0; - if (clock->rate && clock->rate !=3D ep->cur_rate) { - usb_audio_dbg(chip, "Mismatched sample rate %d vs %d for EP 0x%x\n", - clock->rate, ep->cur_rate, ep->ep_num); - return -EINVAL; - } - } + rate =3D update_clock_ref_rate(chip, ep); + if (rate < 0) + return rate; + if (clock && !clock->need_setup) + return 0; =20 - err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, ep->cur_rate); - if (err < 0) + err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, rate); + if (err < 0) { + if (clock) + clock->rate =3D 0; /* reset rate */ return err; + } =20 if (clock) - clock->rate =3D ep->cur_rate; + clock->need_setup =3D false; return 0; } =20 /* - * snd_usb_endpoint_configure: Configure the endpoint + * snd_usb_endpoint_prepare: Prepare the endpoint * * This function sets up the EP to be fully usable state. - * It's called either from hw_params or prepare callback. + * It's called either from prepare callback. * The function checks need_setup flag, and performs nothing unless needed, * so it's safe to call this multiple times. * * This returns zero if unchanged, 1 if the configuration has changed, * or a negative error code. */ -int snd_usb_endpoint_configure(struct snd_usb_audio *chip, - struct snd_usb_endpoint *ep) +int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep) { bool iface_first; int err =3D 0; @@ -1419,9 +1442,6 @@ int snd_usb_endpoint_configure(struct snd_usb_audio *= chip, if (err < 0) goto unlock; } - err =3D snd_usb_endpoint_set_params(chip, ep); - if (err < 0) - goto unlock; goto done; } =20 @@ -1449,10 +1469,6 @@ int snd_usb_endpoint_configure(struct snd_usb_audio = *chip, if (err < 0) goto unlock; =20 - err =3D snd_usb_endpoint_set_params(chip, ep); - if (err < 0) - goto unlock; - err =3D snd_usb_select_mode_quirk(chip, ep->cur_audiofmt); if (err < 0) goto unlock; diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index daa7ba063d858..b972f7899d57e 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h @@ -17,8 +17,10 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, bool is_sync_ep); void snd_usb_endpoint_close(struct snd_usb_audio *chip, struct snd_usb_endpoint *ep); -int snd_usb_endpoint_configure(struct snd_usb_audio *chip, - struct snd_usb_endpoint *ep); +int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep); +int snd_usb_endpoint_prepare(struct snd_usb_audio *chip, + struct snd_usb_endpoint *ep); int snd_usb_endpoint_get_clock_rate(struct snd_usb_audio *chip, int clock); =20 bool snd_usb_endpoint_compatible(struct snd_usb_audio *chip, diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index de0964dbf7a91..7f09191c83d0e 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -433,35 +433,6 @@ static void close_endpoints(struct snd_usb_audio *chip, } } =20 -static int configure_endpoints(struct snd_usb_audio *chip, - struct snd_usb_substream *subs) -{ - int err; - - if (subs->data_endpoint->need_setup) { - /* stop any running stream beforehand */ - if (stop_endpoints(subs, false)) - sync_pending_stops(subs); - if (subs->sync_endpoint) { - err =3D snd_usb_endpoint_configure(chip, subs->sync_endpoint); - if (err < 0) - return err; - } - err =3D snd_usb_endpoint_configure(chip, subs->data_endpoint); - if (err < 0) - return err; - snd_usb_set_format_quirk(subs, subs->cur_audiofmt); - } else { - if (subs->sync_endpoint) { - err =3D snd_usb_endpoint_configure(chip, subs->sync_endpoint); - if (err < 0) - return err; - } - } - - return 0; -} - /* * hw_params callback * @@ -553,7 +524,16 @@ static int snd_usb_hw_params(struct snd_pcm_substream = *substream, subs->cur_audiofmt =3D fmt; mutex_unlock(&chip->mutex); =20 - ret =3D configure_endpoints(chip, subs); + if (!subs->data_endpoint->need_setup) + goto unlock; + + if (subs->sync_endpoint) { + ret =3D snd_usb_endpoint_set_params(chip, subs->sync_endpoint); + if (ret < 0) + goto unlock; + } + + ret =3D snd_usb_endpoint_set_params(chip, subs->data_endpoint); =20 unlock: if (ret < 0) @@ -636,9 +616,18 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substrea= m *substream) goto unlock; } =20 - ret =3D configure_endpoints(chip, subs); + if (subs->sync_endpoint) { + ret =3D snd_usb_endpoint_prepare(chip, subs->sync_endpoint); + if (ret < 0) + goto unlock; + } + + ret =3D snd_usb_endpoint_prepare(chip, subs->data_endpoint); if (ret < 0) goto unlock; + else if (ret > 0) + snd_usb_set_format_quirk(subs, subs->cur_audiofmt); + ret =3D 0; =20 /* reset the pointer */ subs->buffer_bytes =3D frames_to_bytes(runtime, runtime->buffer_size); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D2771448F3; Wed, 13 Mar 2024 16:43:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348180; cv=none; b=fxsoKvGB0WC4SCYo68Uu/3CrUc+yu5PCxWPsT6EnukKVjd2lzIQ6QQNHaHd7HVnCaNHFsHdgUE0BO7shwuDRjyJMN5KJD8UHOL2eeUr5gjCv/6yygRfzmXK72D8o7RW1PKztDc38ljddg0Q3aFVAqAGhF49Tjnh6YH3GueNO82s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348180; c=relaxed/simple; bh=VYkQF9qbqyMDJR8JFKnAreUT2dI30RanQeT2HZkhdO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qT6DXD7Q+wsLmeP9Uh8e1R81vCVqaZAxSedZd5sWlpxbog5LFPluyJdyA2Ps7zb1vGJfC3BXYG7YN6J/45lXCDfYQ/RVEeh9PEGmraFLrXjFxTaq3uBvrRQuYdtUrsu1yKqx5+Vsc3RAgpwfxoL+Vbv6bZ2lh6V3jlpwEBNvpoo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MlV4aIGk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MlV4aIGk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EE40C43394; Wed, 13 Mar 2024 16:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348180; bh=VYkQF9qbqyMDJR8JFKnAreUT2dI30RanQeT2HZkhdO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlV4aIGkUo2pMOveXaiJud9l057e1bwCHwXOzTRkZdTQOiohP6AAsqOPdUJwUpuST IAzQM0ibvTg85rkFDxQpLjrYv5GxL0X5eYfRwpKRQ/pvrN3hj32Wa2ZqEibYMw3C11 UbNRimmRKKiDiu4fsj7S8Vm91wRa5e2C0jQvGLTaXi5X2dPHzAB7zm0RGio8Fwtgs6 wrjlURTcx4uhFynKbgvBC634lmvGLUmP+C+uozk1ETht7r6riPnB0K0x3IoWfLkfIV lOrAZk4TDLVlX7gFoTS4uKBLznEJ0lSPeJumBqou/ISHbqpGxIds5/NrzuHxgDtuSV SRPwKwoqH9uDA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 31/76] ALSA: usb-audio: Properly refcounting clock rate Date: Wed, 13 Mar 2024 12:41:38 -0400 Message-ID: <20240313164223.615640-32-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 9a737e7f8b371e97eb649904276407cee2c9cf30 ] We fixed the bug introduced by the patch for managing the shared clocks at the commit 809f44a0cc5a ("ALSA: usb-audio: Clear fixed clock rate at closing EP"), but it was merely a workaround. By this change, the clock reference rate is cleared at each EP close, hence the still remaining EP may need a re-setup of rate unnecessarily. This patch introduces the proper refcounting for the clock reference object so that the clock setup is done only when needed. Fixes: 809f44a0cc5a ("ALSA: usb-audio: Clear fixed clock rate at closing EP= ") Fixes: c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the si= ngle clock") Link: https://lore.kernel.org/r/20220920181126.4912-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 32a9e016665c8..2d3f814d067b5 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -39,6 +39,7 @@ struct snd_usb_iface_ref { struct snd_usb_clock_ref { unsigned char clock; atomic_t locked; + int opened; int rate; bool need_setup; struct list_head list; @@ -810,6 +811,7 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, ep =3D NULL; goto unlock; } + ep->clock_ref->opened++; } =20 ep->cur_audiofmt =3D fp; @@ -934,8 +936,10 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, endpoint_set_interface(chip, ep, false); =20 if (!--ep->opened) { - if (ep->clock_ref && !atomic_read(&ep->clock_ref->locked)) - ep->clock_ref->rate =3D 0; + if (ep->clock_ref) { + if (!--ep->clock_ref->opened) + ep->clock_ref->rate =3D 0; + } ep->iface =3D 0; ep->altsetting =3D 0; ep->cur_audiofmt =3D NULL; @@ -1656,8 +1660,7 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *e= p, bool keep_pending) WRITE_ONCE(ep->sync_source->sync_sink, NULL); stop_urbs(ep, false, keep_pending); if (ep->clock_ref) - if (!atomic_dec_return(&ep->clock_ref->locked)) - ep->clock_ref->rate =3D 0; + atomic_dec(&ep->clock_ref->locked); } } =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D811145336; Wed, 13 Mar 2024 16:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348181; cv=none; b=IU4tAqM+YbQF3HewNA1L/Usu3FZud8XKok9QXPF1XWbQmHBI5cJFovsCucdtmpDmjtAUnTtFrOxE1JC5D1Cl58gOAvCKO3FFbC+T4w5y1Bc46tneg4z+ODk05WhsZZ/0i7KkOKYQO6+m2q8hWFiviX+gyhYV/4km+boJQsYoik4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348181; c=relaxed/simple; bh=d4bgCm84uOLJ0JEFkn9q+wIIL0g3dWamq5di/Dq6FBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MhjmLbpQiAtkeTFZhzp6ag9cXktoYwSYsx/ycR0QaOmWbYb97A/3ddjWLt1PNuV9C3En4LXkV6vdnRZT4Mu0AInUfuXkrXFrorlEXE1YLVAZCYPMkG5zlHHk4K5KnghUiKG9jse8hHc1O6crUAaXwimUJY/dWx4x3pLMSbr4uQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f1CCMwt3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f1CCMwt3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CB5CC43399; Wed, 13 Mar 2024 16:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348181; bh=d4bgCm84uOLJ0JEFkn9q+wIIL0g3dWamq5di/Dq6FBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1CCMwt36QteyK1CPz6zP6E6UOKYwl5GLO/0u9YxRr/e3i3fdtUhJSIL8yWzpOX/E YrIW4SlozFRYWezYpdBdRRpYOG//XfCTtCkMYzBdNc0lAnZ53JyaveUWl0bY+qJdbA 5AE+CPcdJqDGlhLGgpdupIC3r2v8eDQmGLETFUyLO+BF2BDIYZOTTTMiBotCH/h3eU slFcjN9PW2uLix2HlKtc/qXPKamkqmlv3+Pc6XofK9a0V0ttiALKt1BPtqPlN62Sr6 G34AwJ3ctSzxDOFlM+bS38UpJ4JZNA0n8dGxnY/l4TyiLQYLZSVIH5XsSGliZiDjUY iT2IyTP+bDP6w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 32/76] ALSA: usb-audio: Apply mutex around snd_usb_endpoint_set_params() Date: Wed, 13 Mar 2024 12:41:39 -0400 Message-ID: <20240313164223.615640-33-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit a74f8d0aa902ca494676b79226e0b5a1747b81d4 ] The protection with chip->mutex was lost after splitting snd_usb_endpoint_set_params() and snd_usb_endpoint_prepare(). Apply the same mutex again to the former function. Fixes: 2be79d586454 ("ALSA: usb-audio: Split endpoint setups for hw_params = and prepare (take#2)") Link: https://lore.kernel.org/r/20221009104212.18877-3-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 2d3f814d067b5..486ef6b022552 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -1339,10 +1339,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_audi= o *chip, const struct audioformat *fmt =3D ep->cur_audiofmt; int err; =20 + mutex_lock(&chip->mutex); /* release old buffers, if any */ err =3D release_urbs(ep, false); if (err < 0) - return err; + goto unlock; =20 ep->datainterval =3D fmt->datainterval; ep->maxpacksize =3D fmt->maxpacksize; @@ -1380,13 +1381,16 @@ int snd_usb_endpoint_set_params(struct snd_usb_audi= o *chip, usb_audio_dbg(chip, "Set up %d URBS, ret=3D%d\n", ep->nurbs, err); =20 if (err < 0) - return err; + goto unlock; =20 /* some unit conversions in runtime */ ep->maxframesize =3D ep->maxpacksize / ep->cur_frame_bytes; ep->curframesize =3D ep->curpacksize / ep->cur_frame_bytes; =20 - return update_clock_ref_rate(chip, ep); + err =3D update_clock_ref_rate(chip, ep); + unlock: + mutex_unlock(&chip->mutex); + return err; } =20 static int init_sample_rate(struct snd_usb_audio *chip, --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B5F06341F; Wed, 13 Mar 2024 16:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348182; cv=none; b=T7J4K8FzoT0gvR87UeKKl0UIn4h6XfxuqhdkmDRBD6P3ikLSOZg4pqm1+CEBtPmcyquw1XGiMNmOK0iKajEmPFBGE2tCC7g2rNISn+NUVcyJYy6It2Ko14T6pXdyd2vHYHR3+KT7wRJppTZGh410hu17fN8wqzV85QHRimjIGew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348182; c=relaxed/simple; bh=L3YXKMWNBC7K/C/TGW/wJXP/alvbOQPZAj9zj67+GfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E8kaksA1oKghkqlfijK+z2oJGvasWaWKFiN1j0N/6LuN7ACGIZ0lLHyMsWzRiMY2PDpVr3uAp9n0FX30pxiFg3q4YAzTHD8TaSKeOABUhrb0YTHznheBMca2huTsnCxpkVTG7vV18Bwt+XJ1w3AuQT5FrFdMuhwldPPTA22K4N8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ASNAI3Jc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ASNAI3Jc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BD02C43390; Wed, 13 Mar 2024 16:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348182; bh=L3YXKMWNBC7K/C/TGW/wJXP/alvbOQPZAj9zj67+GfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ASNAI3Jc6WXxpmdEfVrAXFh9JeCZiveMaZFLWcG1k3jsYvvK90j4Lex4lIbLHysMK ll/RLwiGzlvpxOHnlcQICxkCe1E0FWE6xaUFtwNNvRTjoQNEJGwwLQDSL2u9xjGyWJ 8zsogMtq3JrBYaMng5+Gz3UmqP4R54WHo7YQEt2wXin/u1YdoEsANt0h5o9j8eKWG+ mMgicip5CV4DkVtIsEG9KSaKKH+1qO/Bu+/RH2bIKtucvskxg9ypCxivURFJ2WOFB2 qO51QH/BWeopbDw9hTIgTeE78UAnOwJ3uMYkFipjcv+fv2U40yYnGR7VXBUhRBEltw Uwjq8olTMIYEQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 33/76] ALSA: usb-audio: Correct the return code from snd_usb_endpoint_set_params() Date: Wed, 13 Mar 2024 12:41:40 -0400 Message-ID: <20240313164223.615640-34-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 9355b60e401d825590d37f04ea873c58efe9b7bf ] snd_usb_endpoint_set_params() should return zero for a success, but currently it returns the sample rate. Correct it. Fixes: 2be79d586454 ("ALSA: usb-audio: Split endpoint setups for hw_params = and prepare (take#2)") Link: https://lore.kernel.org/r/20221009104212.18877-4-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 486ef6b022552..80ead3db4d1c7 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -1388,6 +1388,8 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio = *chip, ep->curframesize =3D ep->curpacksize / ep->cur_frame_bytes; =20 err =3D update_clock_ref_rate(chip, ep); + if (err >=3D 0) + err =3D 0; unlock: mutex_unlock(&chip->mutex); return err; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3497C145654; Wed, 13 Mar 2024 16:43:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348183; cv=none; b=u0iOWOoc4mPydkSSx9sUyPfxB/VhFpGrO28VDeCCUuZZPvMb9FiKE/klRiCbEspu+Dg7cmg7ZUtstVjrbjL9wRiGlC9BkhpxHfwR6Ug67SC4/1Q66nB4B91lEmrZ1vFk/GrvwGiqC51w8obzD91oiXlOM7unvLpv9ksMyBYt+po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348183; c=relaxed/simple; bh=VZ5yNX8+WYqIibWi5E1WJBgVxjEbmgdMKVjOC7DiaS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PS31BJkK0Px9TktXJiMr6//Va1MWBZg5Kzfn0qa9mlRE6n+L9ifaEqqCkXLkVSVjX8T/LBkWfXDETd2k5csILWq1Zq4VVMxPJOX5nrTwIvBdQcagWB971EihyS4wOJYPhCuwlVvhEdhWyChig8/lCyyVLFN2jCrQAChpFjo1I+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NZPR2Cyw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NZPR2Cyw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77416C43394; Wed, 13 Mar 2024 16:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348183; bh=VZ5yNX8+WYqIibWi5E1WJBgVxjEbmgdMKVjOC7DiaS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NZPR2CywYdEbo5yYNV7lGR4K7I/L5jgiHUTc/DYz7KM3ENYcRCxDQEzOuz/UoIVxF 5l1Ywe1Byk1asq5I1uKqsf7knG83AJzCD/jBHDHGm/mk4a600GWeCSqroyNJh3ZDNP NPM+FfNd+B2Ff6D6osPK+bqi7eUOLZ+ihh89PGwo4zZetSWKK0BSeBDn/WeIAibHaV UQaerb9rfmliF1jQRLOCTY8406n7oQLYx8/a49X463odmeUPoxah8wLVt4V42/P+31 UMl340HOva9PrTMQkS3g0h9qOiWz/FGUG7lDpKi1rq8go/YIkqNXFQ0+YHvetS98Qt rD1YbzZpYsYNg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 34/76] ALSA: usb-audio: Avoid superfluous endpoint setup Date: Wed, 13 Mar 2024 12:41:41 -0400 Message-ID: <20240313164223.615640-35-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 1045f5f1ff0751423aeb65648e5e1abd7a7a8672 ] After splitting to snd_usb_endpoint_set_params() and *_prepare(), the skip of each function should be checked with different flags, while we still use ep->need_setup as the single one. Introduce ep->need_prepare for indicating the need of prepare, and also add the missing check of ep->need_setup at the set_params. Fixes: 2be79d586454 ("ALSA: usb-audio: Split endpoint setups for hw_params = and prepare (take#2)") Link: https://lore.kernel.org/r/20221009104212.18877-5-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/card.h | 3 ++- sound/usb/endpoint.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sound/usb/card.h b/sound/usb/card.h index ca75f2206170f..40061550105ac 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -129,7 +129,8 @@ struct snd_usb_endpoint { in a stream */ bool implicit_fb_sync; /* syncs with implicit feedback */ bool lowlatency_playback; /* low-latency playback mode */ - bool need_setup; /* (re-)need for configure? */ + bool need_setup; /* (re-)need for hw_params? */ + bool need_prepare; /* (re-)need for prepare? */ =20 /* for hw constraints */ const struct audioformat *cur_audiofmt; diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 80ead3db4d1c7..cf48d7ccc496e 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -829,6 +829,7 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, =20 ep->implicit_fb_sync =3D fp->implicit_fb; ep->need_setup =3D true; + ep->need_prepare =3D true; =20 usb_audio_dbg(chip, " channels=3D%d, rate=3D%d, format=3D%s, period_byt= es=3D%d, periods=3D%d, implicit_fb=3D%d\n", ep->cur_channels, ep->cur_rate, @@ -954,7 +955,7 @@ void snd_usb_endpoint_close(struct snd_usb_audio *chip, /* Prepare for suspening EP, called from the main suspend handler */ void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep) { - ep->need_setup =3D true; + ep->need_prepare =3D true; if (ep->iface_ref) ep->iface_ref->need_setup =3D true; if (ep->clock_ref) @@ -1337,9 +1338,12 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio= *chip, struct snd_usb_endpoint *ep) { const struct audioformat *fmt =3D ep->cur_audiofmt; - int err; + int err =3D 0; =20 mutex_lock(&chip->mutex); + if (!ep->need_setup) + goto unlock; + /* release old buffers, if any */ err =3D release_urbs(ep, false); if (err < 0) @@ -1388,8 +1392,11 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio= *chip, ep->curframesize =3D ep->curpacksize / ep->cur_frame_bytes; =20 err =3D update_clock_ref_rate(chip, ep); - if (err >=3D 0) + if (err >=3D 0) { + ep->need_setup =3D false; err =3D 0; + } + unlock: mutex_unlock(&chip->mutex); return err; @@ -1439,7 +1446,7 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *ch= ip, mutex_lock(&chip->mutex); if (WARN_ON(!ep->iface_ref)) goto unlock; - if (!ep->need_setup) + if (!ep->need_prepare) goto unlock; =20 /* If the interface has been already set up, just set EP parameters */ @@ -1493,7 +1500,7 @@ int snd_usb_endpoint_prepare(struct snd_usb_audio *ch= ip, ep->iface_ref->need_setup =3D false; =20 done: - ep->need_setup =3D false; + ep->need_prepare =3D false; err =3D 1; =20 unlock: --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3669714567B; Wed, 13 Mar 2024 16:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348184; cv=none; b=CrtFK9Ycy6uunB9n1OlIF7JVz0PDsevxwdn5qRkDGBOLJsI44eGUUrhWN9X8td1HBRtwhIiwUfevfqawLyXCsZg5VdzqiYL4UOrQHEvWFkF7owTKtVpxYKb9c/mpjjCNnpfAVMSBo09LYdZchsW4Ca76Z3YxhpQsSpkBXoR1biA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348184; c=relaxed/simple; bh=uCdl5rV13o5rx56uT1QCdFQKttQgRBXCDQxEL5xpVck=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ALWzXxMLn1W60STm6MV1Ov/1nHzHZXofarRPmlQY/bRHvJn492zqEDrSvP5pSz3ngKG9Qo4eJI1qnfPF2nwFdf4lcKmSWzIVmAlv5aGWr5W2JIBR84liuphWml54j1hC5+xitx6E0IyF1vLICF5S4okhqiONfZD7+yJj8Hhn6KM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pmk7df2I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pmk7df2I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61C88C43390; Wed, 13 Mar 2024 16:43:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348184; bh=uCdl5rV13o5rx56uT1QCdFQKttQgRBXCDQxEL5xpVck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pmk7df2I6nXxlfm31PUir39w2ZADCG8uFcXs8rRgkHRq3jPA+9LfR5s5Xrny3dtdg QPwsX5HHCAH8cN/QCMTn9nq8kw4g8JfTbg0iHhrVpyPmodV3ZfKMPRNQr96Zf6KZDw gb5KFoOGuLqbt9vF/FCt63FS+RH8nIl9bJ1rd+qZ60mKu6k6hpnSjqDzEN1kp59oDP Mavq3cmhswGQjlKPB02gIuU5jrdLYR8LjWkT25Zbj62OOlUsOFR6PAsMUf6RIeY7zh kP7LOOlWNgtbTN14XOkz18y5aN/4psDerm2nQVtnzsbsmg0+IIY+xCveIV9AqxfWDP S4w5l3VURh4Fw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Keeping , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 35/76] ALSA: usb-audio: Add quirk for Tascam Model 12 Date: Wed, 13 Mar 2024 12:41:42 -0400 Message-ID: <20240313164223.615640-36-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: John Keeping [ Upstream commit 67df411db3f0209e4bb5227d4dd9d41b21368b9d ] Tascam's Model 12 is a mixer which can also operate as a USB audio interface. The audio interface uses explicit feedback but it seems that it does not correctly handle missing isochronous frames. When injecting an xrun (or doing anything else that pauses the playback stream) the feedback rate climbs (for example, at 44,100Hz nominal, I see a stable rate around 44,099 but xrun injection sees this peak at around 44,135 in most cases) and glitches are heard in the audio stream for several seconds - this is significantly worse than the single glitch expected for an underrun. While the stream does normally recover and the feedback rate returns to a stable value, I have seen some occurrences where this does not happen and the rate continues to increase while no audio is heard from the output. I have not found a solid reproduction for this. This misbehaviour can be avoided by totally resetting the stream state by switching the interface to alt 0 and back before restarting the playback stream. Add a new quirk flag which forces the endpoint and interface to be reconfigured whenever the stream is stopped, and use this for the Tascam Model 12. Separate interfaces are used for the playback and capture endpoints, so resetting the playback interface here will not affect the capture stream if it is running. While there are two endpoints on the interface, these are the OUT data endpoint and the IN explicit feedback endpoint corresponding to it and these are always stopped and started together. Signed-off-by: John Keeping Link: https://lore.kernel.org/r/20221129130100.1257904-1-john@metanate.com Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 7 +++++++ sound/usb/quirks.c | 2 ++ sound/usb/usbaudio.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index cf48d7ccc496e..aca9ebfec22c8 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -1674,6 +1674,13 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *= ep, bool keep_pending) stop_urbs(ep, false, keep_pending); if (ep->clock_ref) atomic_dec(&ep->clock_ref->locked); + + if (ep->chip->quirk_flags & QUIRK_FLAG_FORCE_IFACE_RESET && + usb_pipeout(ep->pipe)) { + ep->need_prepare =3D true; + if (ep->iface_ref) + ep->iface_ref->need_setup =3D true; + } } } =20 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 03b6a07a2ea05..b9c0affb79b10 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1786,6 +1786,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { DEVICE_FLG(0x0644, 0x804a, /* TEAC UD-301 */ QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY | QUIRK_FLAG_IFACE_DELAY), + DEVICE_FLG(0x0644, 0x805f, /* TEAC Model 12 */ + QUIRK_FLAG_FORCE_IFACE_RESET), DEVICE_FLG(0x06f8, 0xb000, /* Hercules DJ Console (Windows Edition) */ QUIRK_FLAG_IGNORE_CTL_ERROR), DEVICE_FLG(0x06f8, 0xd002, /* Hercules DJ Console (Macintosh Edition) */ diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index e97141ef730ad..2aba508a48312 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -172,6 +172,9 @@ extern bool snd_usb_skip_validation; * Don't apply implicit feedback sync mode * QUIRK_FLAG_IFACE_SKIP_CLOSE * Don't closed interface during setting sample rate + * QUIRK_FLAG_FORCE_IFACE_RESET + * Force an interface reset whenever stopping & restarting a stream + * (e.g. after xrun) */ =20 #define QUIRK_FLAG_GET_SAMPLE_RATE (1U << 0) @@ -194,5 +197,6 @@ extern bool snd_usb_skip_validation; #define QUIRK_FLAG_GENERIC_IMPLICIT_FB (1U << 17) #define QUIRK_FLAG_SKIP_IMPLICIT_FB (1U << 18) #define QUIRK_FLAG_IFACE_SKIP_CLOSE (1U << 19) +#define QUIRK_FLAG_FORCE_IFACE_RESET (1U << 20) =20 #endif /* __USBAUDIO_H */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40A41634EE; Wed, 13 Mar 2024 16:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348185; cv=none; b=jRZPZB5uzBU47ZsnOsZMkNxOXlr6m9QTQRn6oLsJxIcpMSUK+51uBkUuMyadUMRSSM1N307prPEf+LFf67Aax8K+hEglx88hhpMSG4PQ8TozzzfgpOWzY3nD4wKMtLRAGi+Zn0L5Fhuh1PhKIXPOQONRa5Gie1BaeZPPtYbLNOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348185; c=relaxed/simple; bh=j3deBCIo610qH8lBsnvCzgBaJulvYL6MRE5DGkNll0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xm8F9yRx86bWrb+oqbsVSM8mfWnfBvh1dfVGrfY4bABwWq2F9KR23mm5olF6WNrGm3/OIDU6BKk+T5Bhpp4YOguApwtRVAqN6RaJdroFyJ8ebxQ9YRJqx1EU4mkg6zhDNdLdtXS7+Ab+n8MhcNh9+tChaJHucfyrMmEm4Z44ctM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sWK/7cGh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sWK/7cGh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EFBEC43399; Wed, 13 Mar 2024 16:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348185; bh=j3deBCIo610qH8lBsnvCzgBaJulvYL6MRE5DGkNll0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sWK/7cGhpcfI8vExGLWp5/n2taKnxAIOUpasHSblAJlereVCQufwNmHxN2T1UDfVu EvH2jozZ9cdUkqkNZkwr+J0k73iVLG/9OIx1dTxtwZ8qi4CwmELw+jYzzHfTi/haK7 S9QOTrg0WliBwnOux7jQWvCrJ615aXUuAj3mA560yquSvSf8xivqviAY5QqGTp8+Uj 081y07YAyt207KVsX+013uFk26779vFF5KNS9O+/uKjOiJjpruaPrJUGZuuEI5hlWa Ps3WOEu2I5iXwa7RaRvEAZNI6EOJP/Z1Yil3GsA9Avf4pifvyGObM7MLOIBZpMCf4A B1s3B49+6mirA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jaroslav Kysela , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 36/76] ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless Date: Wed, 13 Mar 2024 12:41:43 -0400 Message-ID: <20240313164223.615640-37-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jaroslav Kysela [ Upstream commit fd28941cff1cd9d8ffa59fe11eb64148e09b6ed6 ] It seems that the firmware is broken and does not accept the UAC_EP_CS_ATTR_SAMPLE_RATE URB. There is only one rate (48000Hz) available in the descriptors for the output endpoint. Create a new quirk QUIRK_FLAG_FIXED_RATE to skip the rate setup when only one rate is available (fixed). BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=3D216798 Signed-off-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20221215153037.1163786-1-perex@perex.cz Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/card.h | 1 + sound/usb/endpoint.c | 16 ++++++++++------ sound/usb/endpoint.h | 3 ++- sound/usb/implicit.c | 6 +++++- sound/usb/implicit.h | 2 +- sound/usb/pcm.c | 36 +++++++++++++++++++++++++++++++++--- sound/usb/pcm.h | 2 ++ sound/usb/quirks.c | 2 ++ sound/usb/usbaudio.h | 4 ++++ 9 files changed, 60 insertions(+), 12 deletions(-) diff --git a/sound/usb/card.h b/sound/usb/card.h index 40061550105ac..6ec95b2edf863 100644 --- a/sound/usb/card.h +++ b/sound/usb/card.h @@ -131,6 +131,7 @@ struct snd_usb_endpoint { bool lowlatency_playback; /* low-latency playback mode */ bool need_setup; /* (re-)need for hw_params? */ bool need_prepare; /* (re-)need for prepare? */ + bool fixed_rate; /* skip rate setup */ =20 /* for hw constraints */ const struct audioformat *cur_audiofmt; diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index aca9ebfec22c8..26af199f3836e 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -774,7 +774,8 @@ struct snd_usb_endpoint * snd_usb_endpoint_open(struct snd_usb_audio *chip, const struct audioformat *fp, const struct snd_pcm_hw_params *params, - bool is_sync_ep) + bool is_sync_ep, + bool fixed_rate) { struct snd_usb_endpoint *ep; int ep_num =3D is_sync_ep ? fp->sync_ep : fp->endpoint; @@ -830,6 +831,7 @@ snd_usb_endpoint_open(struct snd_usb_audio *chip, ep->implicit_fb_sync =3D fp->implicit_fb; ep->need_setup =3D true; ep->need_prepare =3D true; + ep->fixed_rate =3D fixed_rate; =20 usb_audio_dbg(chip, " channels=3D%d, rate=3D%d, format=3D%s, period_byt= es=3D%d, periods=3D%d, implicit_fb=3D%d\n", ep->cur_channels, ep->cur_rate, @@ -1414,11 +1416,13 @@ static int init_sample_rate(struct snd_usb_audio *c= hip, if (clock && !clock->need_setup) return 0; =20 - err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, rate); - if (err < 0) { - if (clock) - clock->rate =3D 0; /* reset rate */ - return err; + if (!ep->fixed_rate) { + err =3D snd_usb_init_sample_rate(chip, ep->cur_audiofmt, rate); + if (err < 0) { + if (clock) + clock->rate =3D 0; /* reset rate */ + return err; + } } =20 if (clock) diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h index b972f7899d57e..c09f68ce08b18 100644 --- a/sound/usb/endpoint.h +++ b/sound/usb/endpoint.h @@ -14,7 +14,8 @@ struct snd_usb_endpoint * snd_usb_endpoint_open(struct snd_usb_audio *chip, const struct audioformat *fp, const struct snd_pcm_hw_params *params, - bool is_sync_ep); + bool is_sync_ep, + bool fixed_rate); void snd_usb_endpoint_close(struct snd_usb_audio *chip, struct snd_usb_endpoint *ep); int snd_usb_endpoint_set_params(struct snd_usb_audio *chip, diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c index f3e8484b3d9cb..41ac7185b42b6 100644 --- a/sound/usb/implicit.c +++ b/sound/usb/implicit.c @@ -15,6 +15,7 @@ #include "usbaudio.h" #include "card.h" #include "helper.h" +#include "pcm.h" #include "implicit.h" =20 enum { @@ -455,7 +456,8 @@ const struct audioformat * snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, const struct audioformat *target, const struct snd_pcm_hw_params *params, - int stream) + int stream, + bool *fixed_rate) { struct snd_usb_substream *subs; const struct audioformat *fp, *sync_fmt =3D NULL; @@ -483,6 +485,8 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_aud= io *chip, } } =20 + if (fixed_rate) + *fixed_rate =3D snd_usb_pcm_has_fixed_rate(subs); return sync_fmt; } =20 diff --git a/sound/usb/implicit.h b/sound/usb/implicit.h index ccb415a0ea860..7f1577b6c4d38 100644 --- a/sound/usb/implicit.h +++ b/sound/usb/implicit.h @@ -9,6 +9,6 @@ const struct audioformat * snd_usb_find_implicit_fb_sync_format(struct snd_usb_audio *chip, const struct audioformat *target, const struct snd_pcm_hw_params *params, - int stream); + int stream, bool *fixed_rate); =20 #endif /* __USBAUDIO_IMPLICIT_H */ diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 7f09191c83d0e..962a6e1bc70c8 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -157,6 +157,31 @@ find_substream_format(struct snd_usb_substream *subs, true, subs); } =20 +bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *subs) +{ + const struct audioformat *fp; + struct snd_usb_audio *chip =3D subs->stream->chip; + int rate =3D -1; + + if (!(chip->quirk_flags & QUIRK_FLAG_FIXED_RATE)) + return false; + list_for_each_entry(fp, &subs->fmt_list, list) { + if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) + return false; + if (fp->nr_rates < 1) + continue; + if (fp->nr_rates > 1) + return false; + if (rate < 0) { + rate =3D fp->rate_table[0]; + continue; + } + if (rate !=3D fp->rate_table[0]) + return false; + } + return true; +} + static int init_pitch_v1(struct snd_usb_audio *chip, int ep) { struct usb_device *dev =3D chip->dev; @@ -450,12 +475,14 @@ static int snd_usb_hw_params(struct snd_pcm_substream= *substream, struct snd_usb_audio *chip =3D subs->stream->chip; const struct audioformat *fmt; const struct audioformat *sync_fmt; + bool fixed_rate, sync_fixed_rate; int ret; =20 ret =3D snd_media_start_pipeline(subs); if (ret) return ret; =20 + fixed_rate =3D snd_usb_pcm_has_fixed_rate(subs); fmt =3D find_substream_format(subs, hw_params); if (!fmt) { usb_audio_dbg(chip, @@ -469,7 +496,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *= substream, if (fmt->implicit_fb) { sync_fmt =3D snd_usb_find_implicit_fb_sync_format(chip, fmt, hw_params, - !substream->stream); + !substream->stream, + &sync_fixed_rate); if (!sync_fmt) { usb_audio_dbg(chip, "cannot find sync format: ep=3D0x%x, iface=3D%d:%d, format=3D%s,= rate=3D%d, channels=3D%d\n", @@ -482,6 +510,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *= substream, } } else { sync_fmt =3D fmt; + sync_fixed_rate =3D fixed_rate; } =20 ret =3D snd_usb_lock_shutdown(chip); @@ -501,7 +530,7 @@ static int snd_usb_hw_params(struct snd_pcm_substream *= substream, close_endpoints(chip, subs); } =20 - subs->data_endpoint =3D snd_usb_endpoint_open(chip, fmt, hw_params, false= ); + subs->data_endpoint =3D snd_usb_endpoint_open(chip, fmt, hw_params, false= , fixed_rate); if (!subs->data_endpoint) { ret =3D -EINVAL; goto unlock; @@ -510,7 +539,8 @@ static int snd_usb_hw_params(struct snd_pcm_substream *= substream, if (fmt->sync_ep) { subs->sync_endpoint =3D snd_usb_endpoint_open(chip, sync_fmt, hw_params, - fmt =3D=3D sync_fmt); + fmt =3D=3D sync_fmt, + sync_fixed_rate); if (!subs->sync_endpoint) { ret =3D -EINVAL; goto unlock; diff --git a/sound/usb/pcm.h b/sound/usb/pcm.h index 493a4e34d78dc..388fe2ba346d6 100644 --- a/sound/usb/pcm.h +++ b/sound/usb/pcm.h @@ -6,6 +6,8 @@ void snd_usb_set_pcm_ops(struct snd_pcm *pcm, int stream); int snd_usb_pcm_suspend(struct snd_usb_stream *as); int snd_usb_pcm_resume(struct snd_usb_stream *as); =20 +bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *as); + int snd_usb_init_pitch(struct snd_usb_audio *chip, const struct audioformat *fmt); void snd_usb_preallocate_buffer(struct snd_usb_substream *subs); diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index b9c0affb79b10..a765da40eb27d 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1896,6 +1896,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_GENERIC_IMPLICIT_FB), DEVICE_FLG(0x0525, 0xa4ad, /* Hamedal C20 usb camero */ QUIRK_FLAG_IFACE_SKIP_CLOSE), + DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */ + QUIRK_FLAG_FIXED_RATE), =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index 2aba508a48312..f5a8dca66457f 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -175,6 +175,9 @@ extern bool snd_usb_skip_validation; * QUIRK_FLAG_FORCE_IFACE_RESET * Force an interface reset whenever stopping & restarting a stream * (e.g. after xrun) + * QUIRK_FLAG_FIXED_RATE + * Do not set PCM rate (frequency) when only one rate is available + * for the given endpoint. */ =20 #define QUIRK_FLAG_GET_SAMPLE_RATE (1U << 0) @@ -198,5 +201,6 @@ extern bool snd_usb_skip_validation; #define QUIRK_FLAG_SKIP_IMPLICIT_FB (1U << 18) #define QUIRK_FLAG_IFACE_SKIP_CLOSE (1U << 19) #define QUIRK_FLAG_FORCE_IFACE_RESET (1U << 20) +#define QUIRK_FLAG_FIXED_RATE (1U << 21) =20 #endif /* __USBAUDIO_H */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 428A8145B34; Wed, 13 Mar 2024 16:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348186; cv=none; b=NLqDX5r51oXR8rmtbNyGljUG5/PQrjXI8+hQVz3VICP7sGxdC2vI5pZPzjy0vOkI8N6nTTMNH2kDfzDDSSZ5o4alDo3BowlcsNBAJpkr39wtrlhAlfxbJFIKYJ1KhxVnlovURRJYXxZsGYKyfVBfvEVMt8DjR0bD2pIFiZ31+M0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348186; c=relaxed/simple; bh=rOcQLc+c5oGpLCDyOwWmMShv+flioNNcrK/cP/qzZAE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oQXqjsZ9f2gcdBzQNKeZlQjN2Gv1j1M2vq8ADoxSbG1T047MhIeoYEt2MFPhfZYaac1rEi9YBCNhIzuqpvArP888wD5E34QXpaZQJ/zrXOrTbQRHlRdkTgMj3xR50T+bevOwk2KsB9Y0TGWjuqE4dc2tjHYmYdRUmzbupfRxPTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HNTLZ8LC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HNTLZ8LC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6115DC43390; Wed, 13 Mar 2024 16:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348186; bh=rOcQLc+c5oGpLCDyOwWmMShv+flioNNcrK/cP/qzZAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HNTLZ8LC1Ir6gmxStyRYU6n0wgJOkToIblA+kduo/sonDsI7Grxh8kx1GlVlVLyhs eGtWlRsJk6ttk0LuaC7OmXV7ax6LiNQg1s8aWTyMAV5qvm2oDMCystmXXz8AWra1JT zIpe9zZsEM2M8Tjlzb02iWh4HNm2RGVV4azIU+2b+3XgSnltouFcnSJCxeR2IK+3UO IltqO9oRylfLrYUkeB4FOUwSZ1HzLIcdHrZf0kIKxeiRd5ZP/2VnLduKajzCajF5yt Tkn5cyIIzpp/1WJtRlygbUXaJSl3qv3b/bpAwEaWLJk5MK2UOfI+IvtUxRAJRLcl3o njA0gCyRBZUUA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christos Skevis , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 37/76] ALSA: usb-audio: Fix microphone sound on Nexigo webcam. Date: Wed, 13 Mar 2024 12:41:44 -0400 Message-ID: <20240313164223.615640-38-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Christos Skevis [ Upstream commit 4a63e68a295187ae3c1cb3fa0c583c96a959714f ] I own an external usb Webcam, model NexiGo N930AF, which had low mic volume= and inconsistent sound quality. Video works as expected. (snip) [ +0.047857] usb 5-1: new high-speed USB device number 2 using xhci_hcd [ +0.003406] usb 5-1: New USB device found, idVendor=3D1bcf, idProduct=3D2= 283, bcdDevice=3D12.17 [ +0.000007] usb 5-1: New USB device strings: Mfr=3D1, Product=3D2, Serial= Number=3D3 [ +0.000004] usb 5-1: Product: NexiGo N930AF FHD Webcam [ +0.000003] usb 5-1: Manufacturer: SHENZHEN AONI ELECTRONIC CO., LTD [ +0.000004] usb 5-1: SerialNumber: 20201217011 [ +0.003900] usb 5-1: Found UVC 1.00 device NexiGo N930AF FHD Webcam (1bcf= :2283) [ +0.025726] usb 5-1: 3:1: cannot get usb sound sample rate freq at ep 0x86 [ +0.071482] usb 5-1: 3:2: cannot get usb sound sample rate freq at ep 0x86 [ +0.004679] usb 5-1: 3:3: cannot get usb sound sample rate freq at ep 0x86 [ +0.051607] usb 5-1: Warning! Unlikely big volume range (=3D4096), cval->= res is probably wrong. [ +0.000005] usb 5-1: [7] FU [Mic Capture Volume] ch =3D 1, val =3D 0/4096= /1 Set up quirk cval->res to 16 for 256 levels, Set GET_SAMPLE_RATE quirk flag to stop trying to get the sample rate. Confirmed that happened anyway later due to the backoff mechanism, after 3 = failures All audio stream on device interfaces share the same values, apart from wMaxPacketSize and tSamFreq : (snip) Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 3 bNumEndpoints 1 bInterfaceClass 1 Audio bInterfaceSubClass 2 Streaming bInterfaceProtocol 0 iInterface 0 AudioStreaming Interface Descriptor: bLength 7 bDescriptorType 36 bDescriptorSubtype 1 (AS_GENERAL) bTerminalLink 8 bDelay 1 frames wFormatTag 0x0001 PCM AudioStreaming Interface Descriptor: bLength 11 bDescriptorType 36 bDescriptorSubtype 2 (FORMAT_TYPE) bFormatType 1 (FORMAT_TYPE_I) bNrChannels 1 bSubframeSize 2 bBitResolution 16 bSamFreqType 1 Discrete tSamFreq[ 0] 44100 Endpoint Descriptor: bLength 9 bDescriptorType 5 bEndpointAddress 0x86 EP 6 IN bmAttributes 5 Transfer Type Isochronous Synch Type Asynchronous Usage Type Data wMaxPacketSize 0x005c 1x 92 bytes bInterval 4 bRefresh 0 bSynchAddress 0 AudioStreaming Endpoint Descriptor: bLength 7 bDescriptorType 37 bDescriptorSubtype 1 (EP_GENERAL) bmAttributes 0x01 Sampling Frequency bLockDelayUnits 0 Undefined wLockDelay 0x0000 (snip) Based on the usb data about manufacturer, SPCA2281B3 is the most likely con= troller IC Manufacturer does not provide link for datasheet nor detailed specs. No way to confirm if the firmware supports any other way of getting the sam= ple rate. Testing patch provides consistent good sound recording quality and volume r= ange. (snip) [ +0.045764] usb 5-1: new high-speed USB device number 2 using xhci_hcd [ +0.106290] usb 5-1: New USB device found, idVendor=3D1bcf, idProduct=3D2= 283, bcdDevice=3D12.17 [ +0.000006] usb 5-1: New USB device strings: Mfr=3D1, Product=3D2, Serial= Number=3D3 [ +0.000004] usb 5-1: Product: NexiGo N930AF FHD Webcam [ +0.000003] usb 5-1: Manufacturer: SHENZHEN AONI ELECTRONIC CO., LTD [ +0.000004] usb 5-1: SerialNumber: 20201217011 [ +0.043700] usb 5-1: set resolution quirk: cval->res =3D 16 [ +0.002585] usb 5-1: Found UVC 1.00 device NexiGo N930AF FHD Webcam (1bcf= :2283) Signed-off-by: Christos Skevis Link: https://lore.kernel.org/r/20231006155330.399393-1-xristos.thes@gmail.= com Signed-off-by: Takashi Iwai Stable-dep-of: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/mixer.c | 7 +++++++ sound/usb/quirks.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 567514832b0df..d818eee53c90a 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1205,6 +1205,13 @@ static void volume_control_quirks(struct usb_mixer_e= lem_info *cval, cval->res =3D 16; } break; + case USB_ID(0x1bcf, 0x2283): /* NexiGo N930AF FHD Webcam */ + if (!strcmp(kctl->id.name, "Mic Capture Volume")) { + usb_audio_info(chip, + "set resolution quirk: cval->res =3D 16\n"); + cval->res =3D 16; + } + break; } } =20 diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index a765da40eb27d..39313db7aed3f 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1898,6 +1898,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_IFACE_SKIP_CLOSE), DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */ QUIRK_FLAG_FIXED_RATE), + DEVICE_FLG(0x1bcf, 0x2283, /* NexiGo N930AF FHD Webcam */ + QUIRK_FLAG_GET_SAMPLE_RATE), =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51FC6145B27; Wed, 13 Mar 2024 16:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348187; cv=none; b=qWEM5oTRSXUncT0QhzvuTvqiflD/qywT20nYI6dsEohbT/6SZhDCsSc7iMbLPZIiFZIO9yHrf0b9zk3NA+/d31TQ85iBVLfgWIzOpw/6VNGOpayu/tZourH+kUQe94HvABsQG0MsgNvGjSFXLK4X/Wj1dc0bkJOFBI4DQAA4uYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348187; c=relaxed/simple; bh=l7C8ExZm8/vajn99EmHxXsg/No9nGsLLD1RgbmkFRlY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rmKYZIv9dvWXQKaha05hJKDpzYRT+sAmb2JjbNh1qxoCJWy2Spm+sYBubOo3muBNzlYG97fWjUq0s4+fS1nzDUX9CDbfWXq0CjMqasbyUdGYcfD3Eg4mERs2aXi9VsFuvsDaWPFn7TuLGF2tNdcSyD5kvpm17W2TQjWhC6TzHRY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LslA6w0V; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LslA6w0V" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ADE9C43394; Wed, 13 Mar 2024 16:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348187; bh=l7C8ExZm8/vajn99EmHxXsg/No9nGsLLD1RgbmkFRlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LslA6w0Vbo+ivLPXQO+zOsIp3VboYVCLBcbZNGmhI5fxQJ9MKUIPSzXeUDhLFaNIU fcMAK40NVMozOOGZyhJFfaZKaaEbHNG+m0Oviv0VrLtaVDPIFeSoBRDisV1JjcZiHR biyWsHg5IAUPeZ9VSYTfWZHKrIw9ThcDfMw74p3n1JqFEJbmCKNqXdtCoBTfUCuhpA nIh2W4Aj0dJqzbNApwfPswBIAYULRDT63lGL/MPrn1MiOtvRjqrZGHS1TuR6o5yxs0 1NFkBHVk1qDU2DuqzgTUL6asgWyw5/09nWGoazNCLhfjD3Ilindy9MIChLQUQwa/1y /oR0r490JLhDg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sean Young , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 38/76] ALSA: usb-audio: add quirk for RODE NT-USB+ Date: Wed, 13 Mar 2024 12:41:45 -0400 Message-ID: <20240313164223.615640-39-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Sean Young [ Upstream commit 7822baa844a87cbb93308c1032c3d47d4079bb8a ] The RODE NT-USB+ is marketed as a professional usb microphone, however the usb audio interface is a mess: [ 1.130977] usb 1-5: new full-speed USB device number 2 using xhci_hcd [ 1.503906] usb 1-5: config 1 has an invalid interface number: 5 but max= is 4 [ 1.503912] usb 1-5: config 1 has no interface number 4 [ 1.519689] usb 1-5: New USB device found, idVendor=3D19f7, idProduct=3D= 0035, bcdDevice=3D 1.09 [ 1.519695] usb 1-5: New USB device strings: Mfr=3D1, Product=3D2, Seria= lNumber=3D3 [ 1.519697] usb 1-5: Product: R=C3=98DE NT-USB+ [ 1.519699] usb 1-5: Manufacturer: R=C3=98DE [ 1.519700] usb 1-5: SerialNumber: 1D773A1A [ 8.327495] usb 1-5: 1:1: cannot get freq at ep 0x82 [ 8.344500] usb 1-5: 1:2: cannot get freq at ep 0x82 [ 8.365499] usb 1-5: 2:1: cannot get freq at ep 0x2 Add QUIRK_FLAG_GET_SAMPLE_RATE to work around the broken sample rate get. I have asked Rode support to fix it, but they show no interest. Signed-off-by: Sean Young Cc: Link: https://lore.kernel.org/r/20240124151524.23314-1-sean@mess.org Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 39313db7aed3f..6cd7f77779159 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1900,6 +1900,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_FIXED_RATE), DEVICE_FLG(0x1bcf, 0x2283, /* NexiGo N930AF FHD Webcam */ QUIRK_FLAG_GET_SAMPLE_RATE), + DEVICE_FLG(0x19f7, 0x0035, /* RODE NT-USB+ */ + QUIRK_FLAG_GET_SAMPLE_RATE), =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6CB114600D; Wed, 13 Mar 2024 16:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348189; cv=none; b=T4zub0F0Uu7TJ0NCfhrFvaMoFSm1B3fIjHnCv1USeOs4xjcXAJpRJtwiVt1oU+su8PgmZbVYHLkH+E2yA5WScUfPZoihnz0qk1skzmxjP7tVogq0fz5b/VqB3JeVjekFSBzYSR3tSr5UCHcxjwU8bXlLZWKr5d9EM7R96t6Sn1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348189; c=relaxed/simple; bh=MmP7YXHxW0FUCck29DRUrd4GsX2NbUzPP9VMeEKAEII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XrPN0Ce+IIfs9G9fpzAOvNUfVdM9zKdKEDZzjjOJbHMTFsTH9Eom0BxQcIidobvsZ/d5UhkDLHgB5+bkGgLFti/6vTvwI1OktGFEeOeO8ZYqKr51qHflsohn0Cp6f5s309/SBjmzsFMKQEHQ/gVOeDSeMFtAtkmufMpzbl5hTWU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LAYePT2F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LAYePT2F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73421C433C7; Wed, 13 Mar 2024 16:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348188; bh=MmP7YXHxW0FUCck29DRUrd4GsX2NbUzPP9VMeEKAEII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LAYePT2Fd37oNGIJDTX+YeRWFYv8j1W4QFdpN283FbtiWEWzU3D59kmVOyP+5+KN2 xVvkuSSD+aH1NEhK3j6pHKCx8nAEieUaNoVaSKjBUxl8PptmFCkiDpIQZd0PnVwQRT NU56wtkvOlDW6b4YgB7shSmu/DleiSQe8grCnw5UKyrVT6tr7alAcfkRXUZeQ33s0O pmTsKQF0UuG61AMUwQLkBPzif1RCIA1ua2+fIxOd6Zq8TJNc7umZuj10i1Ute0o0wF hbIOSSVBI39Sq9FSDeLEg9IxWwfdR105gYKkbL7t5q+u2WjJsyKCZ780LX9gUUrqtC 3BJNkJdVwtIrg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Jerry Zuo , Jun Lei , Wayne Lin , Aurabindo Pillai , Rodrigo Siqueira , Hamza Mahfooz , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 39/76] drm/amd/display: Fix uninitialized variable usage in core_link_ 'read_dpcd() & write_dpcd()' functions Date: Wed, 13 Mar 2024 12:41:46 -0400 Message-ID: <20240313164223.615640-40-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Srinivasan Shanmugam [ Upstream commit a58371d632ebab9ea63f10893a6b6731196b6f8d ] The 'status' variable in 'core_link_read_dpcd()' & 'core_link_write_dpcd()' was uninitialized. Thus, initializing 'status' variable to 'DC_ERROR_UNEXPECTED' by default. Fixes the below: drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_dpcd.c:226 cor= e_link_read_dpcd() error: uninitialized symbol 'status'. drivers/gpu/drm/amd/amdgpu/../display/dc/link/protocols/link_dpcd.c:248 cor= e_link_write_dpcd() error: uninitialized symbol 'status'. Cc: stable@vger.kernel.org Cc: Jerry Zuo Cc: Jun Lei Cc: Wayne Lin Cc: Aurabindo Pillai Cc: Rodrigo Siqueira Cc: Hamza Mahfooz Signed-off-by: Srinivasan Shanmugam Reviewed-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c b/drivers/g= pu/drm/amd/display/dc/core/dc_link_dpcd.c index 72970e49800a6..3978cd5ea08a7 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c @@ -199,7 +199,7 @@ enum dc_status core_link_read_dpcd( uint32_t extended_size; /* size of the remaining partitioned address space */ uint32_t size_left_to_read; - enum dc_status status; + enum dc_status status =3D DC_ERROR_UNEXPECTED; /* size of the next partition to be read from */ uint32_t partition_size; uint32_t data_index =3D 0; @@ -228,7 +228,7 @@ enum dc_status core_link_write_dpcd( { uint32_t partition_size; uint32_t data_index =3D 0; - enum dc_status status; + enum dc_status status =3D DC_ERROR_UNEXPECTED; =20 while (size) { partition_size =3D dpcd_get_next_partition_size(address, size); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7913A146011; Wed, 13 Mar 2024 16:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348190; cv=none; b=aboBqitirQf+rRiw7YvkhC3n7FEKDOcCU7Jn9uoY7aFpbR0w2cBV20vyIKwGRr0vr7lvo5PhS2zzwdVfdmWPzV6HlYJZzqueOIuDu5DcS93Kqb1DDNexIbZpQgBRjB4TNHdXukvQikksbi7ivRckZAfJY1WekHkht8y9VXSWeKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348190; c=relaxed/simple; bh=wNNfFzItL9kIY7N3FpnuegyxHy1IDH6KujAVM8vnIvs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XdgXWzMbkksv28Rjr7kOACCDBTiLs9JHbLGFvzIErB4QwWB01f5suvqV20cEs8IaRW9OAf5Z9bAefKX9mqDTcru+L0wXOAFYfipHjxh1ufA2or+taYwdOPwDUttuiaCUlDteRlDGttiCRT3qa2o4chtw5uvGgrzNK7gmzrs89Sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HNIo4XsD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HNIo4XsD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F0C7C433B1; Wed, 13 Mar 2024 16:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348190; bh=wNNfFzItL9kIY7N3FpnuegyxHy1IDH6KujAVM8vnIvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HNIo4XsDySRzI+LsI0q4M4SORLi9Ie75SwelZ3/t/9ZQC8FKrnvsycGjGQ/7bZMX+ GDVnpGlShS9PdhZM3ZKZW45Q20paQhflvZOe+7/R41dceUA/Lr1xUdC4E7DSiF5xo7 sRpvdDwoydeY+BxG5RfdUnjXxjPMGxUS2HWnNv9OePwisG2y1GNvmnKXsg+nga4f2l v53jj58mTqRS1PPWQ+JMrr6bMa07g2pVEwfcGV51ywqD/DcYEIsnlmXskTItHqm083 VDQYZau8YUimy6d0+COWLk2x1x70Z2myuK+FCviyI95CdcO2QhIXaKeVJ5CpsxmW92 WAvszQcu818gg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wentao Jia , Simon Horman , Louis Peens , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 40/76] nfp: flower: add goto_chain_index for ct entry Date: Wed, 13 Mar 2024 12:41:47 -0400 Message-ID: <20240313164223.615640-41-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Wentao Jia [ Upstream commit 3e44d19934b92398785b3ffc2353b9eba264140e ] The chain_index has different means in pre ct entry and post ct entry. In pre ct entry, it means chain index, but in post ct entry, it means goto chain index, it is confused. chain_index and goto_chain_index may be present in one flow rule, It cannot be distinguished by one field chain_index, both chain_index and goto_chain_index are required in the follow-up patch to support multiple ct zones Another field goto_chain_index is added to record the goto chain index. If no goto action in post ct entry, goto_chain_index is 0. Signed-off-by: Wentao Jia Acked-by: Simon Horman Signed-off-by: Louis Peens Signed-off-by: Jakub Kicinski Stable-dep-of: cefa98e806fd ("nfp: flower: add hardware offload check for p= ost ct entry") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/ethernet/netronome/nfp/flower/conntrack.c | 8 ++++++-- drivers/net/ethernet/netronome/nfp/flower/conntrack.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/driver= s/net/ethernet/netronome/nfp/flower/conntrack.c index fc17e9b11d19d..0a5592b12e2d1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -1004,7 +1004,7 @@ static int nfp_ct_do_tc_merge(struct nfp_fl_ct_zone_e= ntry *zt, /* Checks that the chain_index of the filter matches the * chain_index of the GOTO action. */ - if (post_ct_entry->chain_index !=3D pre_ct_entry->chain_index) + if (post_ct_entry->chain_index !=3D pre_ct_entry->goto_chain_index) return -EINVAL; =20 err =3D nfp_ct_merge_check(post_ct_entry, pre_ct_entry); @@ -1450,7 +1450,8 @@ int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *p= riv, if (IS_ERR(ct_entry)) return PTR_ERR(ct_entry); ct_entry->type =3D CT_TYPE_PRE_CT; - ct_entry->chain_index =3D ct_goto->chain_index; + ct_entry->chain_index =3D flow->common.chain_index; + ct_entry->goto_chain_index =3D ct_goto->chain_index; list_add(&ct_entry->list_node, &zt->pre_ct_list); zt->pre_ct_count++; =20 @@ -1473,6 +1474,7 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *= priv, struct nfp_fl_ct_zone_entry *zt; bool wildcarded =3D false; struct flow_match_ct ct; + struct flow_action_entry *ct_goto; =20 flow_rule_match_ct(rule, &ct); if (!ct.mask->ct_zone) { @@ -1497,6 +1499,8 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *= priv, =20 ct_entry->type =3D CT_TYPE_POST_CT; ct_entry->chain_index =3D flow->common.chain_index; + ct_goto =3D get_flow_act(flow->rule, FLOW_ACTION_GOTO); + ct_entry->goto_chain_index =3D ct_goto ? ct_goto->chain_index : 0; list_add(&ct_entry->list_node, &zt->post_ct_list); zt->post_ct_count++; =20 diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h b/driver= s/net/ethernet/netronome/nfp/flower/conntrack.h index beb6cceff9d8e..47607cd8a716d 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.h +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.h @@ -108,6 +108,7 @@ enum nfp_nfp_layer_name { * @cookie: Flow cookie, same as original TC flow, used as key * @list_node: Used by the list * @chain_index: Chain index of the original flow + * @goto_chain_index: goto chain index of the flow * @netdev: netdev structure. * @type: Type of pre-entry from enum ct_entry_type * @zt: Reference to the zone table this belongs to @@ -120,6 +121,7 @@ struct nfp_fl_ct_flow_entry { unsigned long cookie; struct list_head list_node; u32 chain_index; + u32 goto_chain_index; enum ct_entry_type type; struct net_device *netdev; struct nfp_fl_ct_zone_entry *zt; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3DD8146E9C; Wed, 13 Mar 2024 16:43:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348191; cv=none; b=EFsWVYTLXWpgRvKJ8VrMLUB2AnE3qriNC16x9YR0VxWF4EKXP2cEcz1wH4nlno7XELYsmzLNwkgS05+cPJZqVUG7ovwhM1u83WcNXiEHDoDgySOjz29XHOchKRvN7SUN432RPmpaIWcnhFT0azFAzdG6+NdLWs4EJ9nCusrOFGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348191; c=relaxed/simple; bh=ognCZaFS6GdMBlOCUFY4jl2BZglCYU4E6QLhPCdkh8Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s5p6E7Fw5L+gyTmAz0Bwdm3wVmzTBApXqVoGBHCxtK5VSeqkFL8jh3w+sD00zK32O4kJwx8Li3HUo4yboL+EKowl1nB2mVgMo/S7YpWsEH2NBkvijCGADDdKHtql3HibUZEH5eNGhFe6+3uCcmhK6J2Qmy3rMFE3yQJDkT1FiSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZF6Ude33; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZF6Ude33" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CF63C43609; Wed, 13 Mar 2024 16:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348191; bh=ognCZaFS6GdMBlOCUFY4jl2BZglCYU4E6QLhPCdkh8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZF6Ude339PnGDq7O0XpMkn2SIXW9yth6sOYrNZW/84AHiomvuJS40t2cxI9S/gsCA 88lobIs4+6io/m3uChaXuoaeJO3Xxee54GNiBmNIJ+GRgkq0GZF9srFJwuvM6+KPrO Y4MpjIL+zmMfhBI5H54fo4JJgc32tqMQb1RoOxQusCZHNi9L+lUUgZQLFRN/xaIAZ5 U4+u7yBbwt7guc041KqmeiEfaulUkjNPpQ0oIWdy57NAdC7SDREBAG3ubgA/gvImdq t4d1UjJy1I5VWGYiRqGakd6mzKFEdhG7465Un3gL6hOl+3b9xOAkNW8nV8WrzRfENH cBQaTn/IHooVg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hui Zhou , Louis Peens , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 41/76] nfp: flower: add hardware offload check for post ct entry Date: Wed, 13 Mar 2024 12:41:48 -0400 Message-ID: <20240313164223.615640-42-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hui Zhou [ Upstream commit cefa98e806fd4e2a5e2047457a11ae5f17b8f621 ] The nfp offload flow pay will not allocate a mask id when the out port is openvswitch internal port. This is because these flows are used to configure the pre_tun table and are never actually send to the firmware as an add-flow message. When a tc rule which action contains ct and the post ct entry's out port is openvswitch internal port, the merge offload flow pay with the wrong mask id of 0 will be send to the firmware. Actually, the nfp can not support hardware offload for this situation, so return EOPNOTSUPP. Fixes: bd0fe7f96a3c ("nfp: flower-ct: add zone table entry when handling pr= e/post_ct flows") CC: stable@vger.kernel.org # 5.14+ Signed-off-by: Hui Zhou Signed-off-by: Louis Peens Link: https://lore.kernel.org/r/20240124151909.31603-2-louis.peens@corigine= .com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- .../ethernet/netronome/nfp/flower/conntrack.c | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c b/driver= s/net/ethernet/netronome/nfp/flower/conntrack.c index 0a5592b12e2d1..03a2dbcfbe566 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/conntrack.c +++ b/drivers/net/ethernet/netronome/nfp/flower/conntrack.c @@ -1471,10 +1471,30 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv= *priv, { struct flow_rule *rule =3D flow_cls_offload_flow_rule(flow); struct nfp_fl_ct_flow_entry *ct_entry; + struct flow_action_entry *ct_goto; struct nfp_fl_ct_zone_entry *zt; + struct flow_action_entry *act; bool wildcarded =3D false; struct flow_match_ct ct; - struct flow_action_entry *ct_goto; + int i; + + flow_action_for_each(i, act, &rule->action) { + switch (act->id) { + case FLOW_ACTION_REDIRECT: + case FLOW_ACTION_REDIRECT_INGRESS: + case FLOW_ACTION_MIRRED: + case FLOW_ACTION_MIRRED_INGRESS: + if (act->dev->rtnl_link_ops && + !strcmp(act->dev->rtnl_link_ops->kind, "openvswitch")) { + NL_SET_ERR_MSG_MOD(extack, + "unsupported offload: out port is openvswitch internal port"); + return -EOPNOTSUPP; + } + break; + default: + break; + } + } =20 flow_rule_match_ct(rule, &ct); if (!ct.mask->ct_zone) { --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E41441474B5; Wed, 13 Mar 2024 16:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348193; cv=none; b=rz+U95dVfoDrc9IiQat8RKBzzAwoTEnXqq2NWvwEUZ9avc/Qi+Gxjk06dOwqFu8hU8hkhBqWssOd/uzpMbt5CrbKfD4k7lnNWi7F+TI2it1QjstisuXqIAGRDsGBrabHbW232A/7pDKRe+/cBqsWUsAeXC5U/BBa6ENson/VbK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348193; c=relaxed/simple; bh=LxXgNAae7E20TE67ywM3grU9vzZlJD5fGIwAgR5pvE8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VKDq0NFzg2BEG5OfH1nkxXcCBKnr3tH5WyDRzuDc5Ocnj1OD4mlHjMmYp1LU+NnQzhBSrmB3nCg4ZKQrQS05QP+FmKm4LdZhqzHeQkE09qBXV71q8WSdXkvTGGvIQ0afhsb9evalNOnK9uQBUtIcsGtNvuZ3Xxxamq7qcyEJH4I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BPCF5RZW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BPCF5RZW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CF0DC433F1; Wed, 13 Mar 2024 16:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348192; bh=LxXgNAae7E20TE67ywM3grU9vzZlJD5fGIwAgR5pvE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPCF5RZW2Hxelib63FpQp2W+0kycu9K6rDklIRiz7D4FSU6WiQW5zHxeLAA4oHy7S szDXFk+J6EBC4XI/2lVWtFBbWv2SLQOJ6bv37QrOCC2zBYnQmovUBQMntkKaiuUDrK QdvLBcEv0o2J5V6qRUeDhmzrpImw59fOCaBz9ahybtQhn4KMJ2mCxwc9oURMVgEuK3 Vv/4LEsIg58IkwxeqIPN2WCY3U256VD1QBu/JZPcysl+ygjoOliT6m2jUnDPJDe7Hq t7/BvMSPGz4MfvzVO3oCLwiHhkX1Kb+u/+FRlTZAxdCM/yXy7b72CvuWUONMvVqjHc 8cNLV7CwOQnAg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Muhammad Usama Anjum , Shuah Khan , David Laight , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 42/76] selftests/mm: switch to bash from sh Date: Wed, 13 Mar 2024 12:41:49 -0400 Message-ID: <20240313164223.615640-43-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Muhammad Usama Anjum [ Upstream commit bc29036e1da1cf66e5f8312649aeec2d51ea3d86 ] Running charge_reserved_hugetlb.sh generates errors if sh is set to dash: ./charge_reserved_hugetlb.sh: 9: [[: not found ./charge_reserved_hugetlb.sh: 19: [[: not found ./charge_reserved_hugetlb.sh: 27: [[: not found ./charge_reserved_hugetlb.sh: 37: [[: not found ./charge_reserved_hugetlb.sh: 45: Syntax error: "(" unexpected Switch to using /bin/bash instead of /bin/sh. Make the switch for write_hugetlb_memory.sh as well which is called from charge_reserved_hugetlb.sh. Link: https://lkml.kernel.org/r/20240116090455.3407378-1-usama.anjum@collab= ora.com Signed-off-by: Muhammad Usama Anjum Cc: Muhammad Usama Anjum Cc: Shuah Khan Cc: David Laight Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- tools/testing/selftests/vm/charge_reserved_hugetlb.sh | 2 +- tools/testing/selftests/vm/write_hugetlb_memory.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh b/tools/= testing/selftests/vm/charge_reserved_hugetlb.sh index 0899019a7fcb4..e14bdd4455f2d 100644 --- a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh +++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 =20 # Kselftest framework requirement - SKIP code is 4. diff --git a/tools/testing/selftests/vm/write_hugetlb_memory.sh b/tools/tes= ting/selftests/vm/write_hugetlb_memory.sh index 70a02301f4c27..3d2d2eb9d6fff 100644 --- a/tools/testing/selftests/vm/write_hugetlb_memory.sh +++ b/tools/testing/selftests/vm/write_hugetlb_memory.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 =20 set -e --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 567011474D6; Wed, 13 Mar 2024 16:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348194; cv=none; b=LljcWItLxqO+P1sgLQR+SfjOruvRmOwpHHRMOkUA43cGGO3qu8Rcx0O+uUAYCvtcC5FkSy1c5cKUI9n4fObniMF7vafX08zFJOwgQeixbQJNPSc74VAF7QaP86JEPaSjT5Bq3JPbvPst+KriX+XVGolY3MPJSeciNaAByahpy2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348194; c=relaxed/simple; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OAwDq9SfKcSMHqef/67AXiSCHV0xzN6hiKUUzlZy0JBKAnhRudfdaTiO21sCwNhTxpb1gkheavGNeL+0Oh92KBwSGD1VlgjKO3lrdzkp++wEyFLLFOkCgZx5oUo/mV9AV+SHBw2VQ3NVOwNdTrzftfLag0WHxT5Kb/b5+N8sOJU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iQ5ifE9a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iQ5ifE9a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A847BC433C7; Wed, 13 Mar 2024 16:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348193; bh=LyeZc5QveyggAQYPY/hrck83W9yX91L3yriLGxrzjlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iQ5ifE9aia5Mbincn25yXaMxvSa/5/wJmwqgxBI4kw75OiY8UXZckWRCbyHcsXQYQ 9JElXJLhtWWh622jthwcZlJfKCTKPflhG4EbTv032mTyodaVKV1yryGo16Xh5YQy+y /mofkCNak+QqQVZbTyczapK6hlbtY6NCCV4Hx2ssDFx1RwJOCHkzLv03puT0tP/wul chYgGKuYFmNgkf+k4fzIs4dW175rxtsaUi0MKGcp2P8DdCF6RceqC1ImIF4W5/thOP 3BUsHvuA5WJhLtR+RCoSFTdCjb8ZHur21KS3/KWyo4DxZkUP9jSi+mL8Oevn/gcwge QNT0Csay7LQSA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nico Pache , Donet Tom , Shuah Khan , Christophe Leroy , Michael Ellerman , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 43/76] selftests: mm: fix map_hugetlb failure on 64K page size systems Date: Wed, 13 Mar 2024 12:41:50 -0400 Message-ID: <20240313164223.615640-44-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nico Pache [ Upstream commit 91b80cc5b39f00399e8e2d17527cad2c7fa535e2 ] On systems with 64k page size and 512M huge page sizes, the allocation and test succeeds but errors out at the munmap. As the comment states, munmap will failure if its not HUGEPAGE aligned. This is due to the length of the mapping being 1/2 the size of the hugepage causing the munmap to not be hugepage aligned. Fix this by making the mapping length the full hugepage if the hugepage is larger than the length of the mapping. Link: https://lkml.kernel.org/r/20240119131429.172448-1-npache@redhat.com Signed-off-by: Nico Pache Cc: Donet Tom Cc: Shuah Khan Cc: Christophe Leroy Cc: Michael Ellerman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- tools/testing/selftests/vm/map_hugetlb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/vm/map_hugetlb.c b/tools/testing/selft= ests/vm/map_hugetlb.c index 312889edb84ab..c65c55b7a789f 100644 --- a/tools/testing/selftests/vm/map_hugetlb.c +++ b/tools/testing/selftests/vm/map_hugetlb.c @@ -15,6 +15,7 @@ #include #include #include +#include "vm_util.h" =20 #define LENGTH (256UL*1024*1024) #define PROTECTION (PROT_READ | PROT_WRITE) @@ -70,10 +71,16 @@ int main(int argc, char **argv) { void *addr; int ret; + size_t hugepage_size; size_t length =3D LENGTH; int flags =3D FLAGS; int shift =3D 0; =20 + hugepage_size =3D default_huge_page_size(); + /* munmap with fail if the length is not page aligned */ + if (hugepage_size > length) + length =3D hugepage_size; + if (argc > 1) length =3D atol(argv[1]) << 20; if (argc > 2) { --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 986E71482F2; Wed, 13 Mar 2024 16:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348195; cv=none; b=ibC9rNL2VwMQ8Y5XF3bKQFsjjUzk203ck6LI0UoBxbhxlV7LYJ0Uv78E+8XFtpx1Vkpa5Pfnfz90ibH0eXHnclbNOdmV0bwKKEFV5wkcLub+E/G1DET55prgGGtnm8m8pb0vWk1lPnHigQfeS796lM7Th2ecExa4e9Y/tT4PSmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348195; c=relaxed/simple; bh=5SDctwHu9DHMh2gBhoRuCV0/5gTefGQIPVLdm95wCeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVEAMpqq5FMw2nra7OcD3WAPM7o88jlw6ZzPcAcIRb+baQcfFx1vT1K6OVm9i+XPC0OjnsMrvIt5iqRzosESF/n7HX2QnGmR9vFmfK2aryo9jx9wcY/0PizVrNfwTXckimsMuJY3b8+E5XW7/5cyZWKn0zS0MaAF8h9t36CgaoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pl0wegWJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pl0wegWJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C067C43399; Wed, 13 Mar 2024 16:43:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348195; bh=5SDctwHu9DHMh2gBhoRuCV0/5gTefGQIPVLdm95wCeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pl0wegWJGhM9R5yMgcfGsKU8FfD1w4HNXugbNBKOTtYVNI+h+zHEOC5tz8bgnbgjz He0Tc9LRsFTeLstCvBFzMXbD9okTnrzNI/JtR5RUgb6+uox77oT2f8bvVR009ze0rV Q8DyGZf+JnNo7MPjIHSD2DE1XXjk/yfqSIjsD22lcKksYv+T9/egtwnRXIOI5RQCKW R4jPTzW8b6gIvcu/iDJJrQ2rJBzoybSFW9mN8mpuIQFRGtoq85FKAOLKdVqiraLKWc FWNNfQg6hb9KBDyAXKQ2hN3HJwPwGi537Sppi9Smm2w7XQpz2SeL2I4PCT8h+KFfhu hXMSzQ2ksYusg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Vincent Donnefort , Alexander Lobakin , Sami Tolvanen , Masahiro Yamada , Sasha Levin Subject: [PATCH 5.15 44/76] modpost: Include '.text.*' in TEXT_SECTIONS Date: Wed, 13 Mar 2024 12:41:51 -0400 Message-ID: <20240313164223.615640-45-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nathan Chancellor [ Upstream commit 19331e84c3873256537d446afec1f6c507f8c4ef ] Commit 6c730bfc894f ("modpost: handle -ffunction-sections") added ".text.*" to the OTHER_TEXT_SECTIONS macro to fix certain section mismatch warnings. Unfortunately, this makes it impossible for modpost to warn about section mismatches with LTO, which implies '-ffunction-sections', as all functions are put in their own '.text.' sections, which may still reference functions in sections they are not supposed to, such as __init. Fix this by moving ".text.*" into TEXT_SECTIONS, so that configurations with '-ffunction-sections' will see warnings about mismatched sections. Link: https://lore.kernel.org/Y39kI3MOtVI5BAnV@google.com/ Reported-by: Vincent Donnefort Reviewed-and-tested-by: Alexander Lobakin Reviewed-by: Sami Tolvanen Tested-by: Vincent Donnefort Signed-off-by: Nathan Chancellor Signed-off-by: Masahiro Yamada Stable-dep-of: 397586506c3d ("modpost: Add '.ltext' and '.ltext.*' to TEXT_= SECTIONS") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index c6e655e0ed988..43bacdee5cc5d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -936,10 +936,10 @@ static void check_section(const char *modname, struct= elf_info *elf, #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS =20 #define DATA_SECTIONS ".data", ".data.rel" -#define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ +#define TEXT_SECTIONS ".text", ".text.*", ".sched.text", \ ".kprobes.text", ".cpuidle.text", ".noinstr.text" #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ - ".fixup", ".entry.text", ".exception.text", ".text.*", \ + ".fixup", ".entry.text", ".exception.text", \ ".coldtext", ".softirqentry.text" =20 #define INIT_SECTIONS ".init.*" --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A434C14830A; Wed, 13 Mar 2024 16:43:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348196; cv=none; b=dKv4K81XLt/l0nsSgRT6Ysl/tgTIS37VoDtiPYKYic0HBoIxNOrQz5Uc8HNhmclYk4hqy648O+JiJt7fztOX1meWTVuggvfOpLUhafsM0zJ7Ftr+MpG7VXW+ka/RTYmHosJPYPbAVeoiBRbhX361PnQwfveyMV3RP31A+QpKNdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348196; c=relaxed/simple; bh=/JqcOwDy3vmYnzIP4SeFWDetGnNlE3xy9azSvyjg9+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AGqlalbaRZQu/2sVYB2hbCTP+bmO8pfYeCBqs95mvOndQh1413urBJruYRk8VSCdWfb3a3dSlF6VRRC1lzX4JBKxpTGxiTLcoMwgIYuUYL/ujyxWxhCBqHZPahDW2foGdh+z53E9wIi7gcRnOtah7V9oa7HOVyC2kBrJmkGyk24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UO2OIWqY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UO2OIWqY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82B3AC433A6; Wed, 13 Mar 2024 16:43:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348196; bh=/JqcOwDy3vmYnzIP4SeFWDetGnNlE3xy9azSvyjg9+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UO2OIWqYhmUR/xxgQC5tcJMBHttExJx/+osOFHTWiveWmdc2DO937j2ga4pu/Cmec RAtbH5kO1uDx9a3qUEdWwKxX1MVyYBxkFpMKYj7RUPgqYVz9NozMleGRghvZOtyFZ/ qGcCvPyjCBngqJbazmzs0j7WjE8PpdpS+HzHEZNLsuMPowG/AeIYrEkhQYULqUvEQ1 XI/YYFOqqW0flAcYa3TWopBgKHGdKdVCKyOMSu4WIWRxjA61gFJ3dr1+x2AqBdUzIp FQbGz83wvRMgu2/3o9zMcu2aF6XSAYqqSzNy8gtC0T8kXRdK2gj+RONTrAEbeBdnAN WvHkmIkweG8dQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Masahiro Yamada , Sasha Levin Subject: [PATCH 5.15 45/76] modpost: Add '.ltext' and '.ltext.*' to TEXT_SECTIONS Date: Wed, 13 Mar 2024 12:41:52 -0400 Message-ID: <20240313164223.615640-46-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nathan Chancellor [ Upstream commit 397586506c3da005b9333ce5947ad01e8018a3be ] After the linked LLVM change, building ARCH=3Dum defconfig results in a segmentation fault in modpost. Prior to commit a23e7584ecf3 ("modpost: unify 'sym' and 'to' in default_mismatch_handler()"), there was a warning: WARNING: modpost: vmlinux.o(__ex_table+0x88): Section mismatch in referen= ce to the .ltext:(unknown) WARNING: modpost: The relocation at __ex_table+0x88 references section ".ltext" which is not in the list of authorized sections. If you're adding a new section and/or if this reference is valid, add ".ltext" to the list of authorized sections to jump to on fault. This can be achieved by adding ".ltext" to OTHER_TEXT_SECTIONS in scripts/mod/modpost.c. The linked LLVM change moves global objects to the '.ltext' (and '.ltext.*' with '-ffunction-sections') sections with '-mcmodel=3Dlarge', which ARCH=3Dum uses. These sections should be handled just as '.text' and '.text.*' are, so add them to TEXT_SECTIONS. Cc: stable@vger.kernel.org Closes: https://github.com/ClangBuiltLinux/linux/issues/1981 Link: https://github.com/llvm/llvm-project/commit/4bf8a688956a759b7b6b8d94f= 42d25c13c7af130 Signed-off-by: Nathan Chancellor Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 43bacdee5cc5d..201ac1bf5030d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -937,7 +937,8 @@ static void check_section(const char *modname, struct e= lf_info *elf, =20 #define DATA_SECTIONS ".data", ".data.rel" #define TEXT_SECTIONS ".text", ".text.*", ".sched.text", \ - ".kprobes.text", ".cpuidle.text", ".noinstr.text" + ".kprobes.text", ".cpuidle.text", ".noinstr.text", \ + ".ltext", ".ltext.*" #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ ".fixup", ".entry.text", ".exception.text", \ ".coldtext", ".softirqentry.text" --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D97F96351D; Wed, 13 Mar 2024 16:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348197; cv=none; b=jThpK7Wzhb+R1JEzKTarI1d4Cc+LydsG5HSbyRfaz3/DOwoZOZm2dNfTR0MyuWm8tA0M800AXiLeJvOn6gE3WXJB5JXq3uke2W55wLFyLqh8rT454qRgKcq2dZraXR5pJY8svWFNupqgv3WkBUuKj8dz1rz6PwX5xTE7bt8IvzY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348197; c=relaxed/simple; bh=5rpHXRhcPl6lbXJLB6ylw3YrCJhJxnN/XB+6g1t3MRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b14mfp1Oz+hcc9DUt4VdCjgKmpb7fixaqnv+fNzzwYuI57YUJogDjUB8N1ku7rKuffAU3wnyWKDoFrdHdtu3Lpb/R406TbM0nxfpO1iupX3QmBWmiudgg21/kXZkOKPciGKVVDw3LRiT4ycILn2bS5FD9HazRWJjELIQMMrXvTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LArpGSzY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LArpGSzY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82989C43601; Wed, 13 Mar 2024 16:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348197; bh=5rpHXRhcPl6lbXJLB6ylw3YrCJhJxnN/XB+6g1t3MRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LArpGSzYfLVg/2vSW4S1lZLDjCE/a2EXRbI5boHWqqAW5THZv8AGLftN8OzlSXk/X qhzBljndpZtEjUAWzyjyYPiMhYvfdJmZ1JVhHxCxfaLko2qcT8rSvcpjFgcyRXRtIt FsXSrsAzTM80qxYw3Wuyz1PxlnzYK0srJgBjs25ZtZO25u/MfxuPPrkg+E2XInycqy j/AHz+Tje6QyLOh0DUxya2IfS7cMTuiRAEOidmRCNCXMeBuM8Z4E611Q/pwD2mi2gE AoBNTZ8DrI/JcTnDaO19IoAvj3UfySv4IrMciha60vOrJuZi7HIzgJsb/q5NSSkLs9 XL72IwgLLne9Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mathias Nyman , =?UTF-8?q?Micha=C5=82=20Pecio?= , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 46/76] xhci: process isoc TD properly when there was a transaction error mid TD. Date: Wed, 13 Mar 2024 12:41:53 -0400 Message-ID: <20240313164223.615640-47-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Mathias Nyman [ Upstream commit 5372c65e1311a16351ef03dd096ff576e6477674 ] The last TRB of a isoc TD might not trigger an event if there was an error event for a TRB mid TD. This is seen on a NEC Corporation uPD720200 USB 3.0 Host After an error mid a multi-TRB TD the xHC should according to xhci 4.9.1 generate events for passed TRBs with IOC flag set if it proceeds to the next TD. This event is either a copy of the original error, or a "success" transfer event. If that event is missing then the driver and xHC host get out of sync as the driver is still expecting a transfer event for that first TD, while xHC host is already sending events for the next TD in the list. This leads to "Transfer event TRB DMA ptr not part of current TD" messages. As a solution we tag the isoc TDs that get error events mid TD. If an event doesn't match the first TD, then check if the tag is set, and event points to the next TD. In that case give back the fist TD and process the next TD normally Make sure TD status and transferred length stay valid in both cases with and without final TD completion event. Reported-by: Micha=C5=82 Pecio Closes: https://lore.kernel.org/linux-usb/20240112235205.1259f60c@foxbook/ Tested-by: Micha=C5=82 Pecio Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240125152737.2983959-4-mathias.nyman@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/usb/host/xhci-ring.c | 74 +++++++++++++++++++++++++++++------- drivers/usb/host/xhci.h | 1 + 2 files changed, 61 insertions(+), 14 deletions(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index aa12da0796d2d..7e88b65b694ad 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2428,6 +2428,9 @@ static int process_isoc_td(struct xhci_hcd *xhci, str= uct xhci_virt_ep *ep, /* handle completion code */ switch (trb_comp_code) { case COMP_SUCCESS: + /* Don't overwrite status if TD had an error, see xHCI 4.9.1 */ + if (td->error_mid_td) + break; if (remaining) { frame->status =3D short_framestatus; if (xhci->quirks & XHCI_TRUST_TX_LENGTH) @@ -2453,8 +2456,9 @@ static int process_isoc_td(struct xhci_hcd *xhci, str= uct xhci_virt_ep *ep, break; case COMP_USB_TRANSACTION_ERROR: frame->status =3D -EPROTO; + sum_trbs_for_length =3D true; if (ep_trb !=3D td->last_trb) - return 0; + td->error_mid_td =3D true; break; case COMP_STOPPED: sum_trbs_for_length =3D true; @@ -2474,6 +2478,9 @@ static int process_isoc_td(struct xhci_hcd *xhci, str= uct xhci_virt_ep *ep, break; } =20 + if (td->urb_length_set) + goto finish_td; + if (sum_trbs_for_length) frame->actual_length =3D sum_trb_lengths(xhci, ep->ring, ep_trb) + ep_trb_len - remaining; @@ -2482,6 +2489,14 @@ static int process_isoc_td(struct xhci_hcd *xhci, st= ruct xhci_virt_ep *ep, =20 td->urb->actual_length +=3D frame->actual_length; =20 +finish_td: + /* Don't give back TD yet if we encountered an error mid TD */ + if (td->error_mid_td && ep_trb !=3D td->last_trb) { + xhci_dbg(xhci, "Error mid isoc TD, wait for final completion event\n"); + td->urb_length_set =3D true; + return 0; + } + return finish_td(xhci, ep, ep_ring, td, trb_comp_code); } =20 @@ -2866,17 +2881,51 @@ static int handle_tx_event(struct xhci_hcd *xhci, } =20 if (!ep_seg) { - if (!ep->skip || - !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { - /* Some host controllers give a spurious - * successful event after a short transfer. - * Ignore it. - */ - if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) && - ep_ring->last_td_was_short) { - ep_ring->last_td_was_short =3D false; - goto cleanup; + + if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) { + skip_isoc_td(xhci, td, ep, status); + goto cleanup; + } + + /* + * Some hosts give a spurious success event after a short + * transfer. Ignore it. + */ + if ((xhci->quirks & XHCI_SPURIOUS_SUCCESS) && + ep_ring->last_td_was_short) { + ep_ring->last_td_was_short =3D false; + goto cleanup; + } + + /* + * xhci 4.10.2 states isoc endpoints should continue + * processing the next TD if there was an error mid TD. + * So host like NEC don't generate an event for the last + * isoc TRB even if the IOC flag is set. + * xhci 4.9.1 states that if there are errors in mult-TRB + * TDs xHC should generate an error for that TRB, and if xHC + * proceeds to the next TD it should genete an event for + * any TRB with IOC flag on the way. Other host follow this. + * So this event might be for the next TD. + */ + if (td->error_mid_td && + !list_is_last(&td->td_list, &ep_ring->td_list)) { + struct xhci_td *td_next =3D list_next_entry(td, td_list); + + ep_seg =3D trb_in_td(xhci, td_next->start_seg, td_next->first_trb, + td_next->last_trb, ep_trb_dma, false); + if (ep_seg) { + /* give back previous TD, start handling new */ + xhci_dbg(xhci, "Missing TD completion event after mid TD error\n"); + ep_ring->dequeue =3D td->last_trb; + ep_ring->deq_seg =3D td->last_trb_seg; + inc_deq(xhci, ep_ring); + xhci_td_cleanup(xhci, td, ep_ring, td->status); + td =3D td_next; } + } + + if (!ep_seg) { /* HC is busted, give up! */ xhci_err(xhci, "ERROR Transfer event TRB DMA ptr not " @@ -2888,9 +2937,6 @@ static int handle_tx_event(struct xhci_hcd *xhci, ep_trb_dma, true); return -ESHUTDOWN; } - - skip_isoc_td(xhci, td, ep, status); - goto cleanup; } if (trb_comp_code =3D=3D COMP_SHORT_PACKET) ep_ring->last_td_was_short =3D true; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 8ae33db1e4bcc..0e46b9e45c20c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1572,6 +1572,7 @@ struct xhci_td { struct xhci_segment *bounce_seg; /* actual_length of the URB has already been set */ bool urb_length_set; + bool error_mid_td; unsigned int num_trbs; }; =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F17D21487E1; Wed, 13 Mar 2024 16:43:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348199; cv=none; b=sCJbz6ZKCAc+TuloSJXAiZejEuyTwMqdUP1DhMV44Z1X788OdJJAnO/t5MjAP7cQfYvSu3DZ0e1gZjOmxUNtwG7Pp0J++AnsJwWW0Si4PbGtYk9l7e2DXTVWmB/B2tCZjxHLen8bLbfnunf1UA8kCIncnvTXXITqCkO54jnVY04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348199; c=relaxed/simple; bh=H/BEk14QfxxwzVTPYhHlI6B6JlzJZBjZ/A9OkanOfRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VuCM7MpCo2r9RA9hs7Xhxf3aYByWAiR6xFOsX4iDSVY7yME6bNwr7Cyvh9l23PkzfQ4HYkqNYyrAmt0zTwireveQotraRhkusATyeIC3UMV8Kfq736HMNdG+IdQ8CXApJOCDyJZdgzD5zkYbbDOEzPqjnnDtr8fwMNjgNnxt/Ok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N3yKTJJ+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N3yKTJJ+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CD9CC43399; Wed, 13 Mar 2024 16:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348198; bh=H/BEk14QfxxwzVTPYhHlI6B6JlzJZBjZ/A9OkanOfRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N3yKTJJ+ERKYk3btlyzFfdPIuCR84FbEuFP/iB3NhZp53HwyqnhNflhUmsKj/6FK1 QrtsaPupj8Rd9l9Jnw4BEsKNzcD5vO8wq8QOqYMJ9N+M/zKuRXXyJGnv0x0Oh6s45Z 64sRvyOeqEdfA89Q/owUy6Bfdv4+vbwBL+BCC8UqOEidxHtOzWqk/0iNC5jAUk6PDc qU8iMswFUGw/MpbIRr3ua77Gy7h+D3xPrGZ4OVgSKM0jdOD6gITpEtMxwhvcjmepjL kTVWA3KFtIVu26cX5FCAkDnCUfyA88WA7LANKqdi0wUiUBIXbZK4m6hYOrRk98bwYN Z5LDnUJkCCWPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michal Pecio , Mathias Nyman , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 47/76] xhci: handle isoc Babble and Buffer Overrun events properly Date: Wed, 13 Mar 2024 12:41:54 -0400 Message-ID: <20240313164223.615640-48-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Michal Pecio [ Upstream commit 7c4650ded49e5b88929ecbbb631efb8b0838e811 ] xHCI 4.9 explicitly forbids assuming that the xHC has released its ownership of a multi-TRB TD when it reports an error on one of the early TRBs. Yet the driver makes such assumption and releases the TD, allowing the remaining TRBs to be freed or overwritten by new TDs. The xHC should also report completion of the final TRB due to its IOC flag being set by us, regardless of prior errors. This event cannot be recognized if the TD has already been freed earlier, resulting in "Transfer event TRB DMA ptr not part of current TD" error message. Fix this by reusing the logic for processing isoc Transaction Errors. This also handles hosts which fail to report the final completion. Fix transfer length reporting on Babble errors. They may be caused by device malfunction, no guarantee that the buffer has been filled. Signed-off-by: Michal Pecio Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20240125152737.2983959-5-mathias.nyman@linu= x.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/usb/host/xhci-ring.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 7e88b65b694ad..31d355613933f 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -2446,9 +2446,13 @@ static int process_isoc_td(struct xhci_hcd *xhci, st= ruct xhci_virt_ep *ep, case COMP_BANDWIDTH_OVERRUN_ERROR: frame->status =3D -ECOMM; break; - case COMP_ISOCH_BUFFER_OVERRUN: case COMP_BABBLE_DETECTED_ERROR: + sum_trbs_for_length =3D true; + fallthrough; + case COMP_ISOCH_BUFFER_OVERRUN: frame->status =3D -EOVERFLOW; + if (ep_trb !=3D td->last_trb) + td->error_mid_td =3D true; break; case COMP_INCOMPATIBLE_DEVICE_ERROR: case COMP_STALL_ERROR: --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD64663CAE; Wed, 13 Mar 2024 16:43:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348199; cv=none; b=SY2QC78cpk+xHvILoMCfcxGG8G+2JQUpm5clwMAu419n5/z6kRayQSHQio82qGn57sAxjH0fsaCDdMxBwwHbCdp4bgeohcAEF7cDRytWxFVOMfI74tmr9+EhznSYWnBbwYAZB99Kz4rLbEixujGw7WhC2pCFe46qPf0phOFNP4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348199; c=relaxed/simple; bh=uL4wRVagRog8IuUH9Dd2Z/ogV6B19zOQMfGMFLV9ap8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbCQst7jX6/EGoqMf1STi9jY7YUkr7L9vVukXQYSzm3skp2D6WZs+UzX4Y3LJy0l0oAOc3AzNTyrz6MZxDIE2/uvJS+LWfKFTY2E77arYo3msiIC0Ie993UzacV+OC9AKIoOfvFI60wQzYf28NZaBTlMl37LB/N/fRrT5yBxkiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZV80LE8k; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZV80LE8k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8803C43394; Wed, 13 Mar 2024 16:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348199; bh=uL4wRVagRog8IuUH9Dd2Z/ogV6B19zOQMfGMFLV9ap8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZV80LE8k9WFTWly+QxQNB0AL8FvO1286bBTDDoTB3SHMG3UvpPBN9M2rBSGrs+57t W23G6MQPpahLI6hTKKqdWiyk8Eam8lesUoMaxk8NtAsV8b1zwy8t4IiodC8lEUVuVH oQtZcAWJq7DHSxBCvoDxnjC9EG1kYD0NpStTW3xQKcI4uUE3pD3z/6ybhqbEaZQRer l0s+LGDJ7Bzs9UnbXuGgX13k0m0lHUBkt7jMTV1aGz8wIt7VoBNHTaKIRYDPhnrUoe D+DrfDPv3AMU9dyO7Q0P6ur2cMWZeCjwkfNVz3QW3HtCY5zhv7hYrcEl4p9zqxv2Xb MRrqtsOZMyHvQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cosmin Tanislav , Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 48/76] serial: max310x: use regmap methods for SPI batch operations Date: Wed, 13 Mar 2024 12:41:55 -0400 Message-ID: <20240313164223.615640-49-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cosmin Tanislav [ Upstream commit 285e76fc049c4d32c772eea9460a7ef28a193802 ] The SPI batch read/write operations can be implemented as simple regmap raw read and write, which will also try to do a gather write just as it is done here. Use the regmap raw read and write methods. Reviewed-by: Andy Shevchenko Signed-off-by: Cosmin Tanislav Link: https://lore.kernel.org/r/20220605144659.4169853-2-demonsingur@gmail.= com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: b35f8dbbce81 ("serial: max310x: prevent infinite while() loo= p in port startup") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/tty/serial/max310x.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 5dd73d1da1ecc..c9032e300a586 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -263,8 +263,6 @@ struct max310x_one { struct work_struct md_work; struct work_struct rs_work; =20 - u8 wr_header; - u8 rd_header; u8 rx_buf[MAX310X_FIFO_SIZE]; }; #define to_max310x_port(_port) \ @@ -635,32 +633,18 @@ static s32 max310x_set_ref_clk(struct device *dev, st= ruct max310x_port *s, =20 static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigne= d int len) { - struct max310x_one *one =3D to_max310x_port(port); - struct spi_transfer xfer[] =3D { - { - .tx_buf =3D &one->wr_header, - .len =3D sizeof(one->wr_header), - }, { - .tx_buf =3D txbuf, - .len =3D len, - } - }; - spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer)); + struct max310x_port *s =3D dev_get_drvdata(port->dev); + u8 reg =3D port->iobase + MAX310X_THR_REG; + + regmap_raw_write(s->regmap, reg, txbuf, len); } =20 static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned= int len) { - struct max310x_one *one =3D to_max310x_port(port); - struct spi_transfer xfer[] =3D { - { - .tx_buf =3D &one->rd_header, - .len =3D sizeof(one->rd_header), - }, { - .rx_buf =3D rxbuf, - .len =3D len, - } - }; - spi_sync_transfer(to_spi_device(port->dev), xfer, ARRAY_SIZE(xfer)); + struct max310x_port *s =3D dev_get_drvdata(port->dev); + u8 reg =3D port->iobase + MAX310X_RHR_REG; + + regmap_raw_read(s->regmap, reg, rxbuf, len); } =20 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) @@ -1386,10 +1370,6 @@ static int max310x_probe(struct device *dev, const s= truct max310x_devtype *devty INIT_WORK(&s->p[i].md_work, max310x_md_proc); /* Initialize queue for changing RS485 mode */ INIT_WORK(&s->p[i].rs_work, max310x_rs_proc); - /* Initialize SPI-transfer buffers */ - s->p[i].wr_header =3D (s->p[i].port.iobase + MAX310X_THR_REG) | - MAX310X_WRITE_BIT; - s->p[i].rd_header =3D (s->p[i].port.iobase + MAX310X_RHR_REG); =20 /* Register port */ ret =3D uart_add_one_port(&max310x_uart, &s->p[i].port); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE457148FF6; Wed, 13 Mar 2024 16:43:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348200; cv=none; b=ZKKHwnNw7JN/7ebIbzjRFAoExAsAq7lC1ySa8P1rwoH97lplPfmECPRGi9rbkGeNo6cb3ozO2On/jQk7IwxrNVqJBHypAbmk9Fu/9i/4Bz+ORaGRdmqDLVH/fJvGnjZ1QWEitr/RKz6AKyhhS7p5qQhO8iZrQ0Tqmi5mSEWJVtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348200; c=relaxed/simple; bh=tUKeK3rvwuNybJHsTZfWYGg+fGIv/4In9a6RGBZKds4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WYPzl9nX11cvKOgreWGrpVBrmsAYQxOCPxaRjEHkXSHfSugEcgiIGk2sQmBZZtsgaP5zqBkmDcgCaICGZ/nndlfM6raJJTfj1nAB60CiFSBSarN1maMP5MG70h/d7ZVuJbdt7jcoEYE2nEqhIZ995Ste/0LtOuQhDDzQvjg6Mvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AUlYfEby; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AUlYfEby" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2714C433C7; Wed, 13 Mar 2024 16:43:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348200; bh=tUKeK3rvwuNybJHsTZfWYGg+fGIv/4In9a6RGBZKds4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AUlYfEbyE7BPZHvjo7hdUFAqh6CZrG1OaY54pkNsogPWMrQrSgJAu6W3nnAXzp3oB 7XYWLWrUERPfbgK7HfHlZfMFGfmqfyMOV7S2tA4UHqvGv4i/gTTwm0OMyj53QVjvjY RlwhcKeyXm9nz/dX+UtWCGEpzewFa2g7jx7QKsmGK4g9SU1653ZoK4OEnz6aBdmYOQ galNhQCgXfn9qDbRl4NA1EjbYtD64gOgUwyFCt3Uyi6FYm3oRIrQQSk1WxJOpX2vAs IuEvaCQ45SXvJ8gmJThaNXDku+8AaA8stYnaPM1JDy5RUrLexMtXAJmfscm5wgRvvP u7Jc2r1iodMYg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cosmin Tanislav , Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 49/76] serial: max310x: use a separate regmap for each port Date: Wed, 13 Mar 2024 12:41:56 -0400 Message-ID: <20240313164223.615640-50-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cosmin Tanislav [ Upstream commit 6ef281daf020592c219fa91780abc381c6c20db5 ] The driver currently does manual register manipulation in multiple places to talk to a specific UART port. In order to talk to a specific UART port over SPI, the bits U1 and U0 of the register address can be set, as explained in the Command byte configuration section of the datasheet. Make this more elegant by creating regmaps for each UART port and setting the read_flag_mask and write_flag_mask accordingly. All communcations regarding global registers are done on UART port 0, so replace the global regmap entirely with the port 0 regmap. Also, remove the 0x1f masks from reg_writeable(), reg_volatile() and reg_precious() methods, since setting the U1 and U0 bits of the register address happens inside the regmap core now. Reviewed-by: Andy Shevchenko Signed-off-by: Cosmin Tanislav Link: https://lore.kernel.org/r/20220605144659.4169853-3-demonsingur@gmail.= com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: b35f8dbbce81 ("serial: max310x: prevent infinite while() loo= p in port startup") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/tty/serial/max310x.c | 68 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index c9032e300a586..d61e8a6bc99dd 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -262,6 +262,7 @@ struct max310x_one { struct work_struct tx_work; struct work_struct md_work; struct work_struct rs_work; + struct regmap *regmap; =20 u8 rx_buf[MAX310X_FIFO_SIZE]; }; @@ -291,26 +292,26 @@ static DECLARE_BITMAP(max310x_lines, MAX310X_UART_NRM= AX); =20 static u8 max310x_port_read(struct uart_port *port, u8 reg) { - struct max310x_port *s =3D dev_get_drvdata(port->dev); + struct max310x_one *one =3D to_max310x_port(port); unsigned int val =3D 0; =20 - regmap_read(s->regmap, port->iobase + reg, &val); + regmap_read(one->regmap, reg, &val); =20 return val; } =20 static void max310x_port_write(struct uart_port *port, u8 reg, u8 val) { - struct max310x_port *s =3D dev_get_drvdata(port->dev); + struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_write(s->regmap, port->iobase + reg, val); + regmap_write(one->regmap, reg, val); } =20 static void max310x_port_update(struct uart_port *port, u8 reg, u8 mask, u= 8 val) { - struct max310x_port *s =3D dev_get_drvdata(port->dev); + struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_update_bits(s->regmap, port->iobase + reg, mask, val); + regmap_update_bits(one->regmap, reg, mask, val); } =20 static int max3107_detect(struct device *dev) @@ -449,7 +450,7 @@ static const struct max310x_devtype max14830_devtype = =3D { =20 static bool max310x_reg_writeable(struct device *dev, unsigned int reg) { - switch (reg & 0x1f) { + switch (reg) { case MAX310X_IRQSTS_REG: case MAX310X_LSR_IRQSTS_REG: case MAX310X_SPCHR_IRQSTS_REG: @@ -466,7 +467,7 @@ static bool max310x_reg_writeable(struct device *dev, u= nsigned int reg) =20 static bool max310x_reg_volatile(struct device *dev, unsigned int reg) { - switch (reg & 0x1f) { + switch (reg) { case MAX310X_RHR_REG: case MAX310X_IRQSTS_REG: case MAX310X_LSR_IRQSTS_REG: @@ -488,7 +489,7 @@ static bool max310x_reg_volatile(struct device *dev, un= signed int reg) =20 static bool max310x_reg_precious(struct device *dev, unsigned int reg) { - switch (reg & 0x1f) { + switch (reg) { case MAX310X_RHR_REG: case MAX310X_IRQSTS_REG: case MAX310X_SPCHR_IRQSTS_REG: @@ -633,18 +634,16 @@ static s32 max310x_set_ref_clk(struct device *dev, st= ruct max310x_port *s, =20 static void max310x_batch_write(struct uart_port *port, u8 *txbuf, unsigne= d int len) { - struct max310x_port *s =3D dev_get_drvdata(port->dev); - u8 reg =3D port->iobase + MAX310X_THR_REG; + struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_raw_write(s->regmap, reg, txbuf, len); + regmap_raw_write(one->regmap, MAX310X_THR_REG, txbuf, len); } =20 static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned= int len) { - struct max310x_port *s =3D dev_get_drvdata(port->dev); - u8 reg =3D port->iobase + MAX310X_RHR_REG; + struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_raw_read(s->regmap, reg, rxbuf, len); + regmap_raw_read(one->regmap, MAX310X_RHR_REG, rxbuf, len); } =20 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) @@ -1247,15 +1246,16 @@ static int max310x_gpio_set_config(struct gpio_chip= *chip, unsigned int offset, #endif =20 static int max310x_probe(struct device *dev, const struct max310x_devtype = *devtype, - struct regmap *regmap, int irq) + struct regmap *regmaps[], int irq) { int i, ret, fmin, fmax, freq; struct max310x_port *s; s32 uartclk =3D 0; bool xtal; =20 - if (IS_ERR(regmap)) - return PTR_ERR(regmap); + for (i =3D 0; i < devtype->nr; i++) + if (IS_ERR(regmaps[i])) + return PTR_ERR(regmaps[i]); =20 /* Alloc port structure */ s =3D devm_kzalloc(dev, struct_size(s, p, devtype->nr), GFP_KERNEL); @@ -1302,7 +1302,7 @@ static int max310x_probe(struct device *dev, const st= ruct max310x_devtype *devty goto out_clk; } =20 - s->regmap =3D regmap; + s->regmap =3D regmaps[0]; s->devtype =3D devtype; dev_set_drvdata(dev, s); =20 @@ -1312,22 +1312,18 @@ static int max310x_probe(struct device *dev, const = struct max310x_devtype *devty goto out_clk; =20 for (i =3D 0; i < devtype->nr; i++) { - unsigned int offs =3D i << 5; - /* Reset port */ - regmap_write(s->regmap, MAX310X_MODE2_REG + offs, + regmap_write(regmaps[i], MAX310X_MODE2_REG, MAX310X_MODE2_RST_BIT); /* Clear port reset */ - regmap_write(s->regmap, MAX310X_MODE2_REG + offs, 0); + regmap_write(regmaps[i], MAX310X_MODE2_REG, 0); =20 /* Wait for port startup */ do { - regmap_read(s->regmap, - MAX310X_BRGDIVLSB_REG + offs, &ret); + regmap_read(regmaps[i], MAX310X_BRGDIVLSB_REG, &ret); } while (ret !=3D 0x01); =20 - regmap_write(s->regmap, MAX310X_MODE1_REG + offs, - devtype->mode1); + regmap_write(regmaps[i], MAX310X_MODE1_REG, devtype->mode1); } =20 uartclk =3D max310x_set_ref_clk(dev, s, freq, xtal); @@ -1355,11 +1351,13 @@ static int max310x_probe(struct device *dev, const = struct max310x_devtype *devty s->p[i].port.fifosize =3D MAX310X_FIFO_SIZE; s->p[i].port.flags =3D UPF_FIXED_TYPE | UPF_LOW_LATENCY; s->p[i].port.iotype =3D UPIO_PORT; - s->p[i].port.iobase =3D i * 0x20; + s->p[i].port.iobase =3D i; s->p[i].port.membase =3D (void __iomem *)~0; s->p[i].port.uartclk =3D uartclk; s->p[i].port.rs485_config =3D max310x_rs485_config; s->p[i].port.ops =3D &max310x_ops; + s->p[i].regmap =3D regmaps[i]; + /* Disable all interrupts */ max310x_port_write(&s->p[i].port, MAX310X_IRQEN_REG, 0); /* Clear IRQ status register */ @@ -1456,6 +1454,7 @@ static struct regmap_config regcfg =3D { .val_bits =3D 8, .write_flag_mask =3D MAX310X_WRITE_BIT, .cache_type =3D REGCACHE_RBTREE, + .max_register =3D MAX310X_REG_1F, .writeable_reg =3D max310x_reg_writeable, .volatile_reg =3D max310x_reg_volatile, .precious_reg =3D max310x_reg_precious, @@ -1465,7 +1464,8 @@ static struct regmap_config regcfg =3D { static int max310x_spi_probe(struct spi_device *spi) { const struct max310x_devtype *devtype; - struct regmap *regmap; + struct regmap *regmaps[4]; + unsigned int i; int ret; =20 /* Setup SPI bus */ @@ -1480,10 +1480,14 @@ static int max310x_spi_probe(struct spi_device *spi) if (!devtype) devtype =3D (struct max310x_devtype *)spi_get_device_id(spi)->driver_dat= a; =20 - regcfg.max_register =3D devtype->nr * 0x20 - 1; - regmap =3D devm_regmap_init_spi(spi, ®cfg); + for (i =3D 0; i < devtype->nr; i++) { + u8 port_mask =3D i * 0x20; + regcfg.read_flag_mask =3D port_mask; + regcfg.write_flag_mask =3D port_mask | MAX310X_WRITE_BIT; + regmaps[i] =3D devm_regmap_init_spi(spi, ®cfg); + } =20 - return max310x_probe(&spi->dev, devtype, regmap, spi->irq); + return max310x_probe(&spi->dev, devtype, regmaps, spi->irq); } =20 static int max310x_spi_remove(struct spi_device *spi) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6344149019; Wed, 13 Mar 2024 16:43:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348201; cv=none; b=r6VAkfG8KpZvUNP4xCdEzzfM9Vx/1rc7QDBR/E6b81AVUYxyHyeX8P+hbyjMF9ppZbtN15EXw5X1GznqN4Ml3iKTpb+Ec4j/2v3JAnIO/E9RFx6BXdw36Gdw47Qfl4CV49GOv8UPi3vCOil8771sDalQMP9NhlFyLYAzRwthvR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348201; c=relaxed/simple; bh=E+O2824pnAebbyG8An1Pn9KJS1r4lPV+GKukQp0+tR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qzo6Go7FwAKUNCvtAoH/+9y86KAr+jq6T7oQB8mofHwIuZadhir/5Gb118ZCbe4UN0V5XxP5IQKajomRPHSmOwpDVUo0K+infoLSDWpDPvaRdWTyDDheqkwsa5nk1uM0xh/nfXfBxQMLYUjicfFx4ZyEFCMtXfoEqRSP686ZRLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RfQX2Qdo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RfQX2Qdo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07CF4C433F1; Wed, 13 Mar 2024 16:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348201; bh=E+O2824pnAebbyG8An1Pn9KJS1r4lPV+GKukQp0+tR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RfQX2Qdor89Ccr7z4rO+ILZB74KkMWL2jzSgQ9tuyphUDng4EsGjOiapl8C8qoA8k /JaObncRMoXf1FADuXKWwhqDa4ELbcfgt1lHxtXX78dYf+ACleuvBeW/Nct/KfmXMq 4SPu+9LLgV61n3vXqA4Z20cobKg5DkMN/r0D6Sben5yigC0juf5yleKCXTL6ckmAsc mbMzNOTkqHrErG9kbf+RHmETbPBkwtdUhMvjv8w45nwoajjvXqcsxTe8/LHT+dh7xZ f3TOKuCaMtBntNItZNvYFuRgz8sM3PoHHIwQw3gXZ7hyGEBiEaYKvQCE8KLnMfLcwy 2Klz3aqWSXd4g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hugo Villeneuve , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 50/76] serial: max310x: prevent infinite while() loop in port startup Date: Wed, 13 Mar 2024 12:41:57 -0400 Message-ID: <20240313164223.615640-51-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Hugo Villeneuve [ Upstream commit b35f8dbbce818b02c730dc85133dc7754266e084 ] If there is a problem after resetting a port, the do/while() loop that checks the default value of DIVLSB register may run forever and spam the I2C bus. Add a delay before each read of DIVLSB, and a maximum number of tries to prevent that situation from happening. Also fail probe if port reset is unsuccessful. Fixes: 10d8b34a4217 ("serial: max310x: Driver rework") Cc: stable@vger.kernel.org Signed-off-by: Hugo Villeneuve Link: https://lore.kernel.org/r/20240116213001.3691629-5-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/tty/serial/max310x.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index d61e8a6bc99dd..41251fdf7c845 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -235,6 +235,10 @@ #define MAX310x_REV_MASK (0xf8) #define MAX310X_WRITE_BIT 0x80 =20 +/* Port startup definitions */ +#define MAX310X_PORT_STARTUP_WAIT_RETRIES 20 /* Number of retries */ +#define MAX310X_PORT_STARTUP_WAIT_DELAY_MS 10 /* Delay between retries */ + /* Crystal-related definitions */ #define MAX310X_XTAL_WAIT_RETRIES 20 /* Number of retries */ #define MAX310X_XTAL_WAIT_DELAY_MS 10 /* Delay between retries */ @@ -1312,6 +1316,9 @@ static int max310x_probe(struct device *dev, const st= ruct max310x_devtype *devty goto out_clk; =20 for (i =3D 0; i < devtype->nr; i++) { + bool started =3D false; + unsigned int try =3D 0, val =3D 0; + /* Reset port */ regmap_write(regmaps[i], MAX310X_MODE2_REG, MAX310X_MODE2_RST_BIT); @@ -1320,8 +1327,17 @@ static int max310x_probe(struct device *dev, const s= truct max310x_devtype *devty =20 /* Wait for port startup */ do { - regmap_read(regmaps[i], MAX310X_BRGDIVLSB_REG, &ret); - } while (ret !=3D 0x01); + msleep(MAX310X_PORT_STARTUP_WAIT_DELAY_MS); + regmap_read(regmaps[i], MAX310X_BRGDIVLSB_REG, &val); + + if (val =3D=3D 0x01) + started =3D true; + } while (!started && (++try < MAX310X_PORT_STARTUP_WAIT_RETRIES)); + + if (!started) { + ret =3D dev_err_probe(dev, -EAGAIN, "port reset failed\n"); + goto out_uart; + } =20 regmap_write(regmaps[i], MAX310X_MODE1_REG, devtype->mode1); } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0405814939D; Wed, 13 Mar 2024 16:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348203; cv=none; b=GC8pII98eQFABCMrA8FxrR67+gaaU4IqStBylPAT45ArTOQ6WToAmMHGD4RATSYwnMJZuax2CGzb6LbN9VQZA3TKsOLMblMHNt/1tREPED9hRew0Cf2zxqfxlPOW6AB5BwuDRn6vfyeXh6suetuN7R/UtZZ2lXPNmvFrh5lzF20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348203; c=relaxed/simple; bh=OkoS5TTcRGYuMZ6dkOhiY+0lat7Zn4j2ojDEj8rTdt8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z32vpEzDPrl0b/m4naoWWVXlh4lTaTbhJU8lair2Q2Q5bu8hSaOFL2le1Ed9F+EoX/eQRTqWAWLBaJYyXAtQQi2KPEhGPjHJR6SKY6J6ncyCCBkFqNOP2c/A3yTnFLe0oB+7Cswd1wLZ2jcwinHpqLT7uqZnQjHeTKFbI6Dj5sk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jf2FfqM7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jf2FfqM7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DA49C433C7; Wed, 13 Mar 2024 16:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348202; bh=OkoS5TTcRGYuMZ6dkOhiY+0lat7Zn4j2ojDEj8rTdt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jf2FfqM7K19faHdtwg38p+9g+asEvN5tWv9xWh5G0Y/iBqk5xWCgMTFxpFfJQd1s8 NXGdIDCUJPEnaeTMxI10377oh3BNMRIFgINlmaWQ+wNoNxnpJ0+34q8g0k57rLzj5X aPTx+feYjD2pB+3nPMFZbBlAjYcSr6MaAv2hX7Cn5FmjWbtlejWfUaviBt0g/ca3B+ X3WMd02YxFzl0o4FLgJXGx5/NM0eA4R6z5Ymr6hv07a4DQHX6JX3I+e9LsmunTzKSv Qouz3lZPrANODGritMpY0aSA6dX6d2yKKlHnyUDG/3+Lce+UYA+Ajmw92cNQK61vrI qlM/TJPbGY9uw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evan Quan , Lijo Lazar , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 51/76] drm/amd/pm: do not expose the API used internally only in kv_dpm.c Date: Wed, 13 Mar 2024 12:41:58 -0400 Message-ID: <20240313164223.615640-52-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Evan Quan [ Upstream commit 28a31774b050261371953401e8072ae15200c91e ] Move it to kv_dpm.c instead. Signed-off-by: Evan Quan Reviewed-by: Lijo Lazar Signed-off-by: Alex Deucher Stable-dep-of: 733025626866 ("drm/amdgpu: Reset IH OVERFLOW_CLEAR bit") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 23 --------------------- drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 -- drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c | 25 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/a= mdgpu_dpm.c index a68496b3f9296..197ea6e263878 100644 --- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c +++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c @@ -188,29 +188,6 @@ u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev) return vrefresh; } =20 -bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor) -{ - switch (sensor) { - case THERMAL_TYPE_RV6XX: - case THERMAL_TYPE_RV770: - case THERMAL_TYPE_EVERGREEN: - case THERMAL_TYPE_SUMO: - case THERMAL_TYPE_NI: - case THERMAL_TYPE_SI: - case THERMAL_TYPE_CI: - case THERMAL_TYPE_KV: - return true; - case THERMAL_TYPE_ADT7473_WITH_INTERNAL: - case THERMAL_TYPE_EMC2103_WITH_INTERNAL: - return false; /* need special handling */ - case THERMAL_TYPE_NONE: - case THERMAL_TYPE_EXTERNAL: - case THERMAL_TYPE_EXTERNAL_GPIO: - default: - return false; - } -} - union power_info { struct _ATOM_POWERPLAY_INFO info; struct _ATOM_POWERPLAY_INFO_V2 info_2; diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h b/drivers/gpu/drm/amd/= pm/inc/amdgpu_dpm.h index 16e3f72d31b9f..a3f6caaec88c7 100644 --- a/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h @@ -501,8 +501,6 @@ void amdgpu_dpm_get_active_displays(struct amdgpu_devic= e *adev); int amdgpu_dpm_read_sensor(struct amdgpu_device *adev, enum amd_pp_sensors= sensor, void *data, uint32_t *size); =20 -bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor= ); - int amdgpu_get_platform_caps(struct amdgpu_device *adev); =20 int amdgpu_parse_extended_power_table(struct amdgpu_device *adev); diff --git a/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c b/drivers/gpu/drm/am= d/pm/powerplay/kv_dpm.c index 309c9f0b8f83a..b56854c03ead6 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c +++ b/drivers/gpu/drm/amd/pm/powerplay/kv_dpm.c @@ -1256,6 +1256,29 @@ static void kv_dpm_enable_bapm(void *handle, bool en= able) } } =20 +static bool kv_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sen= sor) +{ + switch (sensor) { + case THERMAL_TYPE_RV6XX: + case THERMAL_TYPE_RV770: + case THERMAL_TYPE_EVERGREEN: + case THERMAL_TYPE_SUMO: + case THERMAL_TYPE_NI: + case THERMAL_TYPE_SI: + case THERMAL_TYPE_CI: + case THERMAL_TYPE_KV: + return true; + case THERMAL_TYPE_ADT7473_WITH_INTERNAL: + case THERMAL_TYPE_EMC2103_WITH_INTERNAL: + return false; /* need special handling */ + case THERMAL_TYPE_NONE: + case THERMAL_TYPE_EXTERNAL: + case THERMAL_TYPE_EXTERNAL_GPIO: + default: + return false; + } +} + static int kv_dpm_enable(struct amdgpu_device *adev) { struct kv_power_info *pi =3D kv_get_pi(adev); @@ -1352,7 +1375,7 @@ static int kv_dpm_enable(struct amdgpu_device *adev) } =20 if (adev->irq.installed && - amdgpu_is_internal_thermal_sensor(adev->pm.int_thermal_type)) { + kv_is_internal_thermal_sensor(adev->pm.int_thermal_type)) { ret =3D kv_set_thermal_temperature_range(adev, KV_TEMP_RANGE_MIN, KV_TEM= P_RANGE_MAX); if (ret) { DRM_ERROR("kv_set_thermal_temperature_range failed\n"); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B24114830A; Wed, 13 Mar 2024 16:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348204; cv=none; b=fk1WpR8o6TFkcgQOc44/uNQWc9dJ9sFoJjMghzDXWyuid3iyZr+kYi3mdkxA/Lih9A8GPo9EYEVjifnfOS0S4SHkB8s4b1SwCGBrru5bGKrLHIdZmx4ZpF3PwIYgrtblqVcDSuR3LtUpDmPHUYkQMAqvhAYUBMiNaR4oDqUGj2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348204; c=relaxed/simple; bh=Mm/tr00ywrJzhhYpiiRpjB+gKwsvwESEe46uyqLgqCs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y5Sxk8C/JnNTGrM586DQfxTLAoHY0kpm3ft6OVkcVxloY4Knnklu34MadTM7aKfgx4d1BJfUdVff4ArdcME6dUGOsJX45NuSUemlyleVhhWml/su52ZBx6u8ZjGAsoWHPRrN8FNjzaOkDqjdm/WB7M6xocDST4UivSCSgubjL+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SIhkfjTs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SIhkfjTs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3018FC43390; Wed, 13 Mar 2024 16:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348204; bh=Mm/tr00ywrJzhhYpiiRpjB+gKwsvwESEe46uyqLgqCs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIhkfjTsUrr+WuPBRj/AL/9m6NkDcp6JSo2Sg1RRtlJvewzlQ028RKt1wRH/y99qK wlgt6ffa/3THLx27sGjGr0Be5kO2tnDBX9JkWnjxVR1Mp8B7XtVQh2Wp6LL24VN1u7 WzCdHSJbC/raLfrXqHYd4ru/K1mtpypHxY5BPWTDVjyg5SdfoqfL3QvCbdsEjdow9X n+2BKjzxMhbKmfX+XBGGQHsLMtZmCH+SifDaOdAPin6201xIfwkz5r7ugTnXLKlMCD AVxR6SKeLfY5pVxbAMkKdFgaF2k+Cd+YYi7G/mprRv33dUiK7ZFf0JdJz+9CWTpu91 1JRY7USPuqhlw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Friedrich Vock , Joshua Ashton , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , Sasha Levin Subject: [PATCH 5.15 52/76] drm/amdgpu: Reset IH OVERFLOW_CLEAR bit Date: Wed, 13 Mar 2024 12:41:59 -0400 Message-ID: <20240313164223.615640-53-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Friedrich Vock [ Upstream commit 7330256268664ea0a7dd5b07a3fed363093477dd ] Allows us to detect subsequent IH ring buffer overflows as well. Cc: Joshua Ashton Cc: Alex Deucher Cc: Christian K=C3=B6nig Cc: stable@vger.kernel.org Signed-off-by: Friedrich Vock Reviewed-by: Christian K=C3=B6nig Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/amdgpu/cik_ih.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/cz_ih.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/si_ih.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/tonga_ih.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 6 ++++++ 8 files changed, 46 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/cik_ih.c b/drivers/gpu/drm/amd/amdg= pu/cik_ih.c index df385ffc97683..6578ca1b90afa 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/cik_ih.c @@ -204,6 +204,12 @@ static u32 cik_ih_get_wptr(struct amdgpu_device *adev, tmp =3D RREG32(mmIH_RB_CNTL); tmp |=3D IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; WREG32(mmIH_RB_CNTL, tmp); + + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp &=3D ~IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; + WREG32(mmIH_RB_CNTL, tmp); } return (wptr & ih->ptr_mask); } diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgp= u/cz_ih.c index b8c47e0cf37ad..c19681492efa7 100644 --- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c @@ -216,6 +216,11 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev, tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32(mmIH_RB_CNTL, tmp); =20 + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32(mmIH_RB_CNTL, tmp); =20 out: return (wptr & ih->ptr_mask); diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/= amdgpu/iceland_ih.c index ddfe4eaeea05e..77aacc242d439 100644 --- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c @@ -215,6 +215,11 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *a= dev, tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32(mmIH_RB_CNTL, tmp); =20 + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32(mmIH_RB_CNTL, tmp); =20 out: return (wptr & ih->ptr_mask); diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c b/drivers/gpu/drm/amd/a= mdgpu/navi10_ih.c index 5300116228013..6aa1884147c4c 100644 --- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c @@ -447,6 +447,12 @@ static u32 navi10_ih_get_wptr(struct amdgpu_device *ad= ev, tmp =3D RREG32_NO_KIQ(ih_regs->ih_rb_cntl); tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); + + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); out: return (wptr & ih->ptr_mask); } diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgp= u/si_ih.c index 9a24f17a57502..cada9f300a7f5 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c @@ -119,6 +119,12 @@ static u32 si_ih_get_wptr(struct amdgpu_device *adev, tmp =3D RREG32(IH_RB_CNTL); tmp |=3D IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; WREG32(IH_RB_CNTL, tmp); + + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp &=3D ~IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK; + WREG32(IH_RB_CNTL, tmp); } return (wptr & ih->ptr_mask); } diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/am= dgpu/tonga_ih.c index b08905d1c00f0..07a5d95be07f5 100644 --- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c @@ -219,6 +219,12 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *ade= v, tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32(mmIH_RB_CNTL, tmp); =20 + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32(mmIH_RB_CNTL, tmp); + out: return (wptr & ih->ptr_mask); } diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c b/drivers/gpu/drm/amd/a= mdgpu/vega10_ih.c index 73728fa859970..e0524197f1b3d 100644 --- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c @@ -371,6 +371,12 @@ static u32 vega10_ih_get_wptr(struct amdgpu_device *ad= ev, tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); =20 + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); + out: return (wptr & ih->ptr_mask); } diff --git a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c b/drivers/gpu/drm/amd/a= mdgpu/vega20_ih.c index ac34af4cb178c..87edd1908e8b9 100644 --- a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c +++ b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c @@ -422,6 +422,12 @@ static u32 vega20_ih_get_wptr(struct amdgpu_device *ad= ev, tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); =20 + /* Unset the CLEAR_OVERFLOW bit immediately so new overflows + * can be detected. + */ + tmp =3D REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 0); + WREG32_NO_KIQ(ih_regs->ih_rb_cntl, tmp); + out: return (wptr & ih->ptr_mask); } --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4FB6149DFD; Wed, 13 Mar 2024 16:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348205; cv=none; b=nGMoli7aC98ddX2s+2wXeiP8/ZZSkeDABbYpUmjidPnrdwCop925GNAk3b2NmPblXDCWbPo4ppG7rQOuj8MBggyczh5QD9cQakdtTaia/ngGYRCvuT+wNatuKwsQqlPxE6cNpBY75BroAToA/mWFOf5+yPEpzaLrMOjykAIUpCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348205; c=relaxed/simple; bh=otcY7mfhal37SsnDZ5/grTWidMrFmetWGelHWtWZv1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZxA8Wc8YU8mkX7TxAf9e3EbUlZnvwYIgLgqGTP2jeymGMcW76JextRRT6PsOa/5simQ0sPxNcVQpuFIB+dG8iWUhjvPcTEMiUszoV4vEamssDppEYbnd45QrYfJI2/nPeZzKKoj0cbksp6Q9wViAVm157WsJbmR/5ku2H/rPA30= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OCAUmSCu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OCAUmSCu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6403EC433A6; Wed, 13 Mar 2024 16:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348205; bh=otcY7mfhal37SsnDZ5/grTWidMrFmetWGelHWtWZv1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OCAUmSCu6qD7oYa1PiUFpJfekgwj/DF2RD40CeaDU+NkHG7smayN/BxYAEFZ7YN2a 4fNdsl+qlt/CLZ7ApMVfqjyzs/CXtMFjCW3uf4TNs1yg9uaCYRKlnmLjht02CJX3cH /xs43wne5GdZAwMSiQsT2NVZpGcJapCpL5NysWZpnnDQmRN8MAdo2NXuP2ZzfxPSis Z3RL+V8cwWJOnrKcUI47FMefLOx39+vRMnGPbJVY40dCyKJDzwa9XCGQ66GG1YPLH6 2MzzCNUCgqh0HZJ/c8Ts2ap/8Brrqm0vxOSOLkg1UVZgeRD+JCuG1fWoZcy13HwLaB Dflqx1RANLqbQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Matthieu Baerts (NGI0)" , Paolo Abeni , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 53/76] selftests: mptcp: decrease BW in simult flows Date: Wed, 13 Mar 2024 12:42:00 -0400 Message-ID: <20240313164223.615640-54-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Matthieu Baerts (NGI0)" [ Upstream commit 5e2f3c65af47e527ccac54060cf909e3306652ff ] When running the simult_flow selftest in slow environments -- e.g. QEmu without KVM support --, the results can be unstable. This selftest checks if the aggregated bandwidth is (almost) fully used as expected. To help improving the stability while still keeping the same validation in place, the BW and the delay are reduced to lower the pressure on the CPU. Fixes: 1a418cb8e888 ("mptcp: simult flow self-tests") Fixes: 219d04992b68 ("mptcp: push pending frames when subflow has free spac= e") Cc: stable@vger.kernel.org Suggested-by: Paolo Abeni Signed-off-by: Matthieu Baerts (NGI0) Link: https://lore.kernel.org/r/20240131-upstream-net-20240131-mptcp-ci-iss= ues-v1-6-4c1c11e571ff@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- tools/testing/selftests/net/mptcp/simult_flows.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/test= ing/selftests/net/mptcp/simult_flows.sh index 752cef1688040..99deb3abb169f 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -289,10 +289,10 @@ done =20 setup run_test 10 10 0 0 "balanced bwidth" -run_test 10 10 1 50 "balanced bwidth with unbalanced delay" +run_test 10 10 1 25 "balanced bwidth with unbalanced delay" =20 # we still need some additional infrastructure to pass the following test-= cases -run_test 30 10 0 0 "unbalanced bwidth" -run_test 30 10 1 50 "unbalanced bwidth with unbalanced delay" -run_test 30 10 50 1 "unbalanced bwidth with opposed, unbalanced delay" +run_test 10 3 0 0 "unbalanced bwidth" +run_test 10 3 1 25 "unbalanced bwidth with unbalanced delay" +run_test 10 3 25 1 "unbalanced bwidth with opposed, unbalanced delay" exit $ret --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD1D614939D; Wed, 13 Mar 2024 16:43:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348206; cv=none; b=uQbcMOtDphg/HUXiRCweZEYwvg7Devi7q2Aqygd/6NGxX/q2JLagDMHpJZJ9qXcQZsXT+B7+khRwceEMkccAoFxrK/w1uZxnyGD0kPYcSZdbA+2KYj8f1k69/N2ABu+Y4FWviN/S9IWO5Ncd2RlqxFifk4cRiKgo66cpVz+W3u4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348206; c=relaxed/simple; bh=OjueRW/qxdue+0tSTD6SIsf+rLllHpSewjOCIhIb3wo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EN0bhnuN6OX8ASTHLvIqr8NA/ENJsiROyGMctjESkK+55xlpx2O/jw1DGB5ouTQqQxu9xdZ95wVrlyHoP08JRe644YJGHs2I1niZgkubXUa9s87acNTgos/NY8FEZz8LuLxfTGDcdJEusFv7bILPjyzXJ7Ud4+N8Sez1wUKXchw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UjNRm4gq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UjNRm4gq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B784C43390; Wed, 13 Mar 2024 16:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348206; bh=OjueRW/qxdue+0tSTD6SIsf+rLllHpSewjOCIhIb3wo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjNRm4gqwNbdC1tsoXR7q+nBqE4Fwe0TqRPx8QM8sjxpdVnK8k9NQeg+/SkDbKcet qy7bZQWkyRyvTCc2xwCpFdp/iJcU1PyJBfVnqrLv9ZeA1Fbg0QLD9lDkmsdkR65Fjo FfDxHvH+L2wzg74BqRyWz77wI28rA32HDPbshY+HvczXO4JREVK3E/JBQrMZyiVVgV 99ojejf3tuOx1C8DuutFUGcRzONEo7v9a0+aCSxpNW7grVwEP4cdrBJ7LvKad1eHpu pf7Xl9xwWmrSyF62W5TjEdh2vRV/7B/pqXxDQfcnDriXbOP+H9Do1J7rX3GhTKvxTB 5F+1QNVBU9QvA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Juhee Kang , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 54/76] hv_netvsc: use netif_is_bond_master() instead of open code Date: Wed, 13 Mar 2024 12:42:01 -0400 Message-ID: <20240313164223.615640-55-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Juhee Kang [ Upstream commit c60882a4566a0a62dc3a40c85131103aad83dcb3 ] Use netif_is_bond_master() function instead of open code, which is ((event_dev->priv_flags & IFF_BONDING) && (event_dev->flags & IFF_MASTER)). This patch doesn't change logic. Signed-off-by: Juhee Kang Signed-off-by: David S. Miller Stable-dep-of: 9cae43da9867 ("hv_netvsc: Register VF in netvsc_probe if NET= _DEVICE_REGISTER missed") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/hyperv/netvsc_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_dr= v.c index 25b65450cbb99..a7d1304466880 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2784,8 +2784,7 @@ static int netvsc_netdev_event(struct notifier_block = *this, return NOTIFY_DONE; =20 /* Avoid Bonding master dev with same MAC registering as VF */ - if ((event_dev->priv_flags & IFF_BONDING) && - (event_dev->flags & IFF_MASTER)) + if (netif_is_bond_master(event_dev)) return NOTIFY_DONE; =20 switch (event) { --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B205514A088; Wed, 13 Mar 2024 16:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348207; cv=none; b=QvHmdkUIdwdYFbffQ+iybO8bhDThBntvlVOWvOy2we5U4vLH/W7gMqFaokmOuwRUxtmg5Rri6G6R1Ls+SBpCdVOvoHbdPnSLMiei4CJPmIerjFljzUy+t73KPWgxK/CYpgOXIgE443/eh1U3Zl0CSQE/cZOfZtpsOOqSJfs+Wo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348207; c=relaxed/simple; bh=OMRKw+JfNCMJGVklikilPsgcB18UH1vcqNvrL8kA3uc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P652mck84vDCE/pBljwUPONXZByRg1ppC0lsLe/gW8eXdx7U+n6iX1gGP12zUSYQAZJIYK6SBQuE/1w+kyBOzgNP3aEJHrySvVvwbsmOBohHkdvklVAlTqj5liHfRYgTO3f40+QvbuwgDAm+20AsjLPxzBcNV/LM35ruVg4iaac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RtVgTFMU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RtVgTFMU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98D12C433C7; Wed, 13 Mar 2024 16:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348207; bh=OMRKw+JfNCMJGVklikilPsgcB18UH1vcqNvrL8kA3uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtVgTFMU9BvHRG3tbMrrecW52x6kohQ7657bTDU/w2NELEptTVsYdGVBiDZFX9wdn 9Oo63dwBViaf+Vxnz9NgLVEymDKkd99W6A6Lczjcp9Vemco8lOE5hmS7QXtb8WGtVN 1FhSZ8obGjnhD0Sz1SW3bPDVhqwEzUr9Ml19xXqPN1oxhcbxU+hJTnunuaGpAKxqm9 0oPTrWjfvMkq3RBPW25rkBL6RqCHVXZshyspJlCD4vkI+NtoZKsb+cZY0VBb3XJA0N xvuRgMtxUGbUyqUQF8zpq3k4bEwiOaG7aW+yswbFOkFTsRcv6jBHSpubMyME7ThTtI 1MmQThKXIjwwA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shradha Gupta , Dexuan Cui , Haiyang Zhang , "David S . Miller" , Sasha Levin Subject: [PATCH 5.15 55/76] hv_netvsc: Register VF in netvsc_probe if NET_DEVICE_REGISTER missed Date: Wed, 13 Mar 2024 12:42:02 -0400 Message-ID: <20240313164223.615640-56-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shradha Gupta [ Upstream commit 9cae43da9867412f8bd09aee5c8a8dc5e8dc3dc2 ] If hv_netvsc driver is unloaded and reloaded, the NET_DEVICE_REGISTER handler cannot perform VF register successfully as the register call is received before netvsc_probe is finished. This is because we register register_netdevice_notifier() very early( even before vmbus_driver_register()). To fix this, we try to register each such matching VF( if it is visible as a netdevice) at the end of netvsc_probe. Cc: stable@vger.kernel.org Fixes: 85520856466e ("hv_netvsc: Fix race of register_netdevice_notifier an= d VF register") Suggested-by: Dexuan Cui Signed-off-by: Shradha Gupta Reviewed-by: Haiyang Zhang Reviewed-by: Dexuan Cui Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/net/hyperv/netvsc_drv.c | 82 +++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_dr= v.c index a7d1304466880..804c11cbccff6 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -42,6 +42,10 @@ #define LINKCHANGE_INT (2 * HZ) #define VF_TAKEOVER_INT (HZ / 10) =20 +/* Macros to define the context of vf registration */ +#define VF_REG_IN_PROBE 1 +#define VF_REG_IN_NOTIFIER 2 + static unsigned int ring_size __ro_after_init =3D 128; module_param(ring_size, uint, 0444); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of 4K pages)"); @@ -2204,7 +2208,7 @@ static rx_handler_result_t netvsc_vf_handle_frame(str= uct sk_buff **pskb) } =20 static int netvsc_vf_join(struct net_device *vf_netdev, - struct net_device *ndev) + struct net_device *ndev, int context) { struct net_device_context *ndev_ctx =3D netdev_priv(ndev); int ret; @@ -2227,7 +2231,11 @@ static int netvsc_vf_join(struct net_device *vf_netd= ev, goto upper_link_failed; } =20 - schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT); + /* If this registration is called from probe context vf_takeover + * is taken care of later in probe itself. + */ + if (context =3D=3D VF_REG_IN_NOTIFIER) + schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT); =20 call_netdevice_notifiers(NETDEV_JOIN, vf_netdev); =20 @@ -2365,7 +2373,7 @@ static int netvsc_prepare_bonding(struct net_device *= vf_netdev) return NOTIFY_DONE; } =20 -static int netvsc_register_vf(struct net_device *vf_netdev) +static int netvsc_register_vf(struct net_device *vf_netdev, int context) { struct net_device_context *net_device_ctx; struct netvsc_device *netvsc_dev; @@ -2405,7 +2413,7 @@ static int netvsc_register_vf(struct net_device *vf_n= etdev) =20 netdev_info(ndev, "VF registering: %s\n", vf_netdev->name); =20 - if (netvsc_vf_join(vf_netdev, ndev) !=3D 0) + if (netvsc_vf_join(vf_netdev, ndev, context) !=3D 0) return NOTIFY_DONE; =20 dev_hold(vf_netdev); @@ -2503,10 +2511,31 @@ static int netvsc_unregister_vf(struct net_device *= vf_netdev) return NOTIFY_OK; } =20 +static int check_dev_is_matching_vf(struct net_device *event_ndev) +{ + /* Skip NetVSC interfaces */ + if (event_ndev->netdev_ops =3D=3D &device_ops) + return -ENODEV; + + /* Avoid non-Ethernet type devices */ + if (event_ndev->type !=3D ARPHRD_ETHER) + return -ENODEV; + + /* Avoid Vlan dev with same MAC registering as VF */ + if (is_vlan_dev(event_ndev)) + return -ENODEV; + + /* Avoid Bonding master dev with same MAC registering as VF */ + if (netif_is_bond_master(event_ndev)) + return -ENODEV; + + return 0; +} + static int netvsc_probe(struct hv_device *dev, const struct hv_vmbus_device_id *dev_id) { - struct net_device *net =3D NULL; + struct net_device *net =3D NULL, *vf_netdev; struct net_device_context *net_device_ctx; struct netvsc_device_info *device_info =3D NULL; struct netvsc_device *nvdev; @@ -2614,6 +2643,30 @@ static int netvsc_probe(struct hv_device *dev, } =20 list_add(&net_device_ctx->list, &netvsc_dev_list); + + /* When the hv_netvsc driver is unloaded and reloaded, the + * NET_DEVICE_REGISTER for the vf device is replayed before probe + * is complete. This is because register_netdevice_notifier() gets + * registered before vmbus_driver_register() so that callback func + * is set before probe and we don't miss events like NETDEV_POST_INIT + * So, in this section we try to register the matching vf device that + * is present as a netdevice, knowing that its register call is not + * processed in the netvsc_netdev_notifier(as probing is progress and + * get_netvsc_byslot fails). + */ + for_each_netdev(dev_net(net), vf_netdev) { + ret =3D check_dev_is_matching_vf(vf_netdev); + if (ret !=3D 0) + continue; + + if (net !=3D get_netvsc_byslot(vf_netdev)) + continue; + + netvsc_prepare_bonding(vf_netdev); + netvsc_register_vf(vf_netdev, VF_REG_IN_PROBE); + __netvsc_vf_setup(net, vf_netdev); + break; + } rtnl_unlock(); =20 netvsc_devinfo_put(device_info); @@ -2770,28 +2823,17 @@ static int netvsc_netdev_event(struct notifier_bloc= k *this, unsigned long event, void *ptr) { struct net_device *event_dev =3D netdev_notifier_info_to_dev(ptr); + int ret =3D 0; =20 - /* Skip our own events */ - if (event_dev->netdev_ops =3D=3D &device_ops) - return NOTIFY_DONE; - - /* Avoid non-Ethernet type devices */ - if (event_dev->type !=3D ARPHRD_ETHER) - return NOTIFY_DONE; - - /* Avoid Vlan dev with same MAC registering as VF */ - if (is_vlan_dev(event_dev)) - return NOTIFY_DONE; - - /* Avoid Bonding master dev with same MAC registering as VF */ - if (netif_is_bond_master(event_dev)) + ret =3D check_dev_is_matching_vf(event_dev); + if (ret !=3D 0) return NOTIFY_DONE; =20 switch (event) { case NETDEV_POST_INIT: return netvsc_prepare_bonding(event_dev); case NETDEV_REGISTER: - return netvsc_register_vf(event_dev); + return netvsc_register_vf(event_dev, VF_REG_IN_NOTIFIER); case NETDEV_UNREGISTER: return netvsc_unregister_vf(event_dev); case NETDEV_UP: --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9ADB14A0B6; Wed, 13 Mar 2024 16:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348209; cv=none; b=SOSmZCZQ3BKshTIaWwwOwZ6d2h2MiMkdzcAwG5Us+QkrIndMxXqRUJwMzJKfqD60Bw6PaP68dKZv8ar+8o/KJ72cNYxJQT9ZMwdVBIrrhoQxeYcrt5HG52faELYa6WgBEgSclLMf4u4mD0RWafGgRkOxjqoQeXrbCL41exNU9bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348209; c=relaxed/simple; bh=Fd4BmX0q2dviXv8ZBe0IndRZBVtCPxqAMvzM1rbIf+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=di8ff25M9bLZC6conCUzk9e4PnqPf2VI7AZp4lbG/SsuvX0iFJqeWDty4bW4G6S4raKLpXpsgeYImOPJj7Hx9h3vfNGoIXo5tzWQJpQ6H5zHt4BLfPWSj0K2lfY3Hkf1DE1G67/wYao2Ag6mwFFVm6zyGiBfhsq3L0F7nxmNpJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AKZv2gZH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AKZv2gZH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEC52C43390; Wed, 13 Mar 2024 16:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348208; bh=Fd4BmX0q2dviXv8ZBe0IndRZBVtCPxqAMvzM1rbIf+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AKZv2gZHAfQDcBItrinvlIU3M3f0oNH2Onwdpn4W4KzhUb2iINBuCZigIiQ/JerId QJq4VUeY721XkonVqFVd8el9Dm0bOUw2seN5p4F/zM4R85zf+h1wFxVGkwcBNXKJe4 NsB3fo1dnUhKInyBEZB+UvI32VVbEIWQLLSKBAzE6ozOS6+MsF8K1MR+h10plFL4Ww 69FwM4UYdQO5whUSiwHuSVKuAnlLZqCmZ7zfw97Z0gt96Zo3mGRsVogG+pOBgQPBdV 1F19rAa+ZocGoh81DKsEc6esgGK5U7qghsdwL6A6fGg+EVnp8CGA9ZF0EJL2uc3ddh JoSzQZ+oQArEA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Qingqing Zhuo , Rodrigo Siqueira , Solomon Chiu , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 56/76] drm/amd/display: Re-arrange FPU code structure for dcn2x Date: Wed, 13 Mar 2024 12:42:03 -0400 Message-ID: <20240313164223.615640-57-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Qingqing Zhuo [ Upstream commit ee37341199c61558b73113659695c90bf4736eb2 ] [Why] Current FPU code for DCN2x is located under dml/dcn2x. This is not aligned with DC's general source tree structure. [How] Move FPU code for DCN2x to dml/dcn20. Reviewed-by: Rodrigo Siqueira Acked-by: Solomon Chiu Signed-off-by: Qingqing Zhuo Signed-off-by: Alex Deucher Stable-dep-of: e63e35f0164c ("drm/amd/display: Increase frame-larger-than f= or all display_mode_vba files") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +- drivers/gpu/drm/amd/display/dc/dml/Makefile | 4 ++-- .../amd/display/dc/dml/{dcn2x/dcn2x.c =3D> dcn20/dcn20_fpu.c} | 2 +- .../amd/display/dc/dml/{dcn2x/dcn2x.h =3D> dcn20/dcn20_fpu.h} | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) rename drivers/gpu/drm/amd/display/dc/dml/{dcn2x/dcn2x.c =3D> dcn20/dcn20_= fpu.c} (99%) rename drivers/gpu/drm/amd/display/dc/dml/{dcn2x/dcn2x.h =3D> dcn20/dcn20_= fpu.h} (94%) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c b/drivers/gpu/d= rm/amd/display/amdgpu_dm/dc_fpu.c index b1bf80da3a55f..ab0c6d1910382 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c @@ -52,7 +52,7 @@ static DEFINE_PER_CPU(int, fpu_recursion_depth); * This function tells if the code is already under FPU protection or not.= A * function that works as an API for a set of FPU operations can use this * function for checking if the caller invoked it after DC_FP_START(). For - * example, take a look at dcn2x.c file. + * example, take a look at dcn20_fpu.c file. */ inline void dc_assert_fp_enabled(void) { diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c index ede11eb120d4f..04b370e7e732e 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c @@ -35,7 +35,7 @@ #include "include/irq_service_interface.h" #include "dcn20/dcn20_resource.h" =20 -#include "dml/dcn2x/dcn2x.h" +#include "dml/dcn20/dcn20_fpu.h" =20 #include "dcn10/dcn10_hubp.h" #include "dcn10/dcn10_ipp.h" diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/driver= s/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c index 5b8274b8c3845..7c5c1414b7a1c 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c @@ -35,7 +35,7 @@ #include "include/irq_service_interface.h" #include "dcn20/dcn20_resource.h" =20 -#include "dml/dcn2x/dcn2x.h" +#include "dml/dcn20/dcn20_fpu.h" =20 #include "clk_mgr.h" #include "dcn10/dcn10_hubp.h" diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index 9009b92490f34..e7bb69ec99b66 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -58,7 +58,7 @@ CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml= _ccflags) =20 ifdef CONFIG_DRM_AMD_DC_DCN CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_ccflags) -CFLAGS_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o :=3D $(dml_ccfl= ags) @@ -95,8 +95,8 @@ CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers= .o :=3D $(dml_rcflags) DML =3D display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_ca= lc.o \ =20 ifdef CONFIG_DRM_AMD_DC_DCN +DML +=3D dcn20/dcn20_fpu.o DML +=3D display_mode_vba.o dcn20/display_rq_dlg_calc_20.o dcn20/display_m= ode_vba_20.o -DML +=3D dcn2x/dcn2x.o DML +=3D dcn20/display_rq_dlg_calc_20v2.o dcn20/display_mode_vba_20v2.o DML +=3D dcn21/display_rq_dlg_calc_21.o dcn21/display_mode_vba_21.o DML +=3D dcn30/display_mode_vba_30.o dcn30/display_rq_dlg_calc_30.o diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.c b/drivers/gpu= /drm/amd/display/dc/dml/dcn20/dcn20_fpu.c similarity index 99% rename from drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.c rename to drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c index c58522436291a..d590dc9173637 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c @@ -26,7 +26,7 @@ =20 #include "resource.h" =20 -#include "dcn2x.h" +#include "dcn20_fpu.h" =20 /** * DOC: DCN2x FPU manipulation Overview diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.h b/drivers/gpu= /drm/amd/display/dc/dml/dcn20/dcn20_fpu.h similarity index 94% rename from drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.h rename to drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.h index 331547ba07132..36f26126d574b 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn2x/dcn2x.h +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.h @@ -24,11 +24,11 @@ * */ =20 -#ifndef __DCN2X_H__ -#define __DCN2X_H__ +#ifndef __DCN20_FPU_H__ +#define __DCN20_FPU_H__ =20 void dcn20_populate_dml_writeback_from_context(struct dc *dc, struct resource_context *res_ctx, display_e2e_pipe_params_st *pipes); =20 -#endif /* __DCN2X_H__ */ +#endif /* __DCN20_FPU_H__ */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9FA14A4E1; Wed, 13 Mar 2024 16:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348210; cv=none; b=CKkJAy0A7OczjkSYVlSDEjQpPA8rLyk4eK2aiWEAz9y6GrqMOUFT38p7hEqhJM5Ro+Dg32pl7z2RlpsHgw57jTWb9gXrvXgwwbAEUeUZId45JWVUPgyApk7DDq9uWeyvjP0oeLXUG3NbmLI6B/po4xd8fCLkh96WqUDIH3h3KQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348210; c=relaxed/simple; bh=83vlgMjnqg6tqbJqt+QGuUIjPsYAVxfIo9ttAP0BEtk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UxaIHlCWOD/hi1T5PIfmRutbZTFWiw3Lnxe2Dc7rJSgzzfu0rzWEe66U+sgORmxD0fu57bjemu2H26uXJuMOHza4npds2nk4Wmrz0QNhS8j52UYW814YZHbopfBmEDibWNMYfeXIVhjHSKcHey4P0UbDVLWueu58XY1n6muqrHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fV5hAjE+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fV5hAjE+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20117C433F1; Wed, 13 Mar 2024 16:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348209; bh=83vlgMjnqg6tqbJqt+QGuUIjPsYAVxfIo9ttAP0BEtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fV5hAjE+tONfKljMLrw8OFh3F2jlgLUY3qVqiNutO1ga2KOmRj+c6+ivAJlc/vtRO VR0mnoboujmvKfM2zCuWE3pmiZ/PSbXDryhYoIUnskYejH8GIwNCHShy6Iv9N2zqwX YorYip1E1KZbrDyWxqRuVeKkhZSefA/xeKpbl1t4SY4Us+zHwCzM7WTr7HNwpUT7th uKgxFWDfjQWFq9XeyNsT3Ikgl4Mh9r9l3osgK3B4LgUSYBrGVwpWQBJVaCX0jxqUOw iNMjbNrHVU+ZoXAb1m9ypwy9sAZ5LNkEvly5rpW/bAATjr2Ny5WFcQBeij+uEKpqgs 4KLsTdoHhbUsA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Isabella Basso , Rodrigo Siqueira , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 57/76] drm/amd/display: move calcs folder into DML Date: Wed, 13 Mar 2024 12:42:04 -0400 Message-ID: <20240313164223.615640-58-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Isabella Basso [ Upstream commit 552b7cb0eed12c184b3bdfcc262e96a954a2bc86 ] The calcs folder has FPU code on it, which should be isolated inside the DML folder as per https://patchwork.freedesktop.org/series/93042/. This commit aims single-handedly to correct the location of such FPU code and does not refactor any functions. Changes since v2: - Corrected problems to compile when DCN was disabled. Reviewed-by: Rodrigo Siqueira Signed-off-by: Isabella Basso Signed-off-by: Alex Deucher Stable-dep-of: e63e35f0164c ("drm/amd/display: Increase frame-larger-than f= or all display_mode_vba files") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/display/dc/Makefile | 4 +- drivers/gpu/drm/amd/display/dc/calcs/Makefile | 68 ------------------- drivers/gpu/drm/amd/display/dc/dml/Makefile | 10 ++- .../amd/display/dc/{ =3D> dml}/calcs/bw_fixed.c | 0 .../display/dc/{ =3D> dml}/calcs/calcs_logger.h | 0 .../display/dc/{ =3D> dml}/calcs/custom_float.c | 0 .../display/dc/{ =3D> dml}/calcs/dce_calcs.c | 0 .../dc/{ =3D> dml}/calcs/dcn_calc_auto.c | 0 .../dc/{ =3D> dml}/calcs/dcn_calc_auto.h | 0 .../dc/{ =3D> dml}/calcs/dcn_calc_math.c | 0 .../display/dc/{ =3D> dml}/calcs/dcn_calcs.c | 0 11 files changed, 11 insertions(+), 71 deletions(-) delete mode 100644 drivers/gpu/drm/amd/display/dc/calcs/Makefile rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/bw_fixed.c (100%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/calcs_logger.h (10= 0%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/custom_float.c (10= 0%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/dce_calcs.c (100%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/dcn_calc_auto.c (1= 00%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/dcn_calc_auto.h (1= 00%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/dcn_calc_math.c (1= 00%) rename drivers/gpu/drm/amd/display/dc/{ =3D> dml}/calcs/dcn_calcs.c (100%) diff --git a/drivers/gpu/drm/amd/display/dc/Makefile b/drivers/gpu/drm/amd/= display/dc/Makefile index 943fcb164876c..d82574f379119 100644 --- a/drivers/gpu/drm/amd/display/dc/Makefile +++ b/drivers/gpu/drm/amd/display/dc/Makefile @@ -23,12 +23,12 @@ # Makefile for Display Core (dc) component. # =20 -DC_LIBS =3D basics bios calcs clk_mgr dce gpio irq virtual +DC_LIBS =3D basics bios clk_mgr dce dml gpio irq virtual =20 ifdef CONFIG_DRM_AMD_DC_DCN DC_LIBS +=3D dcn20 DC_LIBS +=3D dsc -DC_LIBS +=3D dcn10 dml +DC_LIBS +=3D dcn10 DC_LIBS +=3D dcn21 DC_LIBS +=3D dcn30 DC_LIBS +=3D dcn301 diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/dr= m/amd/display/dc/calcs/Makefile deleted file mode 100644 index f3c00f479e1cb..0000000000000 --- a/drivers/gpu/drm/amd/display/dc/calcs/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright 2017 Advanced Micro Devices, Inc. -# Copyright 2019 Raptor Engineering, LLC -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"= ), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included = in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS = OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -# -# -# Makefile for the 'calcs' sub-component of DAL. -# It calculates Bandwidth and Watermarks values for HW programming -# - -ifdef CONFIG_X86 -calcs_ccflags :=3D -mhard-float -msse -endif - -ifdef CONFIG_PPC64 -calcs_ccflags :=3D -mhard-float -maltivec -endif - -ifdef CONFIG_CC_IS_GCC -ifeq ($(call cc-ifversion, -lt, 0701, y), y) -IS_OLD_GCC =3D 1 -endif -endif - -ifdef CONFIG_X86 -ifdef IS_OLD_GCC -# Stack alignment mismatch, proceed with caution. -# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-bound= ary=3D3 -# (8B stack alignment). -calcs_ccflags +=3D -mpreferred-stack-boundary=3D4 -else -calcs_ccflags +=3D -msse2 -endif -endif - -CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calcs.o :=3D $(calcs_ccflags) -CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o :=3D $(calcs_ccflags) -CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o :=3D $(calcs_ccflags) -Wno-t= autological-compare -CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calcs.o :=3D $(calcs_rcflags) -CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o :=3D $(calcs_rcflags) -CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o :=3D $(calcs_rcflags) - -BW_CALCS =3D dce_calcs.o bw_fixed.o custom_float.o - -ifdef CONFIG_DRM_AMD_DC_DCN -BW_CALCS +=3D dcn_calcs.o dcn_calc_math.o dcn_calc_auto.o -endif - -AMD_DAL_BW_CALCS =3D $(addprefix $(AMDDALPATH)/dc/calcs/,$(BW_CALCS)) - -AMD_DISPLAY_FILES +=3D $(AMD_DAL_BW_CALCS) diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index e7bb69ec99b66..c97fdfc36d0fd 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -72,6 +72,9 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o := =3D $(dml_ccflags) $(fram CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o :=3D $(dml_ccflags) -Wno= -tautological-compare CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o :=3D $(dml_rcflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_= rcflags) @@ -91,10 +94,14 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o = :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o :=3D $(dml_ccflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o :=3D $(dml_r= cflags) CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o :=3D $(dml_rcf= lags) +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o :=3D $(dml_rcflags) +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o :=3D $(dml_rcflag= s) +CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o :=3D $(dml_rcflag= s) =20 -DML =3D display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_ca= lc.o \ +DML =3D calcs/dce_calcs.o calcs/custom_float.o calcs/bw_fixed.o =20 ifdef CONFIG_DRM_AMD_DC_DCN +DML +=3D display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_c= alc.o DML +=3D dcn20/dcn20_fpu.o DML +=3D display_mode_vba.o dcn20/display_rq_dlg_calc_20.o dcn20/display_m= ode_vba_20.o DML +=3D dcn20/display_rq_dlg_calc_20v2.o dcn20/display_mode_vba_20v2.o @@ -102,6 +109,7 @@ DML +=3D dcn21/display_rq_dlg_calc_21.o dcn21/display_m= ode_vba_21.o DML +=3D dcn30/display_mode_vba_30.o dcn30/display_rq_dlg_calc_30.o DML +=3D dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o DML +=3D dsc/rc_calc_fpu.o +DML +=3D calcs/dcn_calcs.o calcs/dcn_calc_math.o calcs/dcn_calc_auto.o endif =20 AMD_DAL_DML =3D $(addprefix $(AMDDALPATH)/dc/dml/,$(DML)) diff --git a/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c b/drivers/gpu/= drm/amd/display/dc/dml/calcs/bw_fixed.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c diff --git a/drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h b/drivers/= gpu/drm/amd/display/dc/dml/calcs/calcs_logger.h similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h rename to drivers/gpu/drm/amd/display/dc/dml/calcs/calcs_logger.h diff --git a/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c b/drivers/= gpu/drm/amd/display/dc/dml/calcs/custom_float.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/custom_float.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu= /drm/amd/display/dc/dml/calcs/dce_calcs.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c b/drivers= /gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.c diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h b/drivers= /gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.h similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h rename to drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.h diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c b/drivers= /gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu= /drm/amd/display/dc/dml/calcs/dcn_calcs.c similarity index 100% rename from drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c rename to drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFE9E14AD0E; Wed, 13 Mar 2024 16:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348211; cv=none; b=EIdT+IbhVtox6Xy86EakXqovf/iIaAMgM/80cbaPEKVRJJF9YQVAIREIJxtWfKdF/RgeOwKv6pROAR44MS/hoxSCbAtQQWgw/jFI0KnD+8SUN0BcgcT4bK9lKfGH0NvF1aZ1pYUgZ7LGncczy0Kw+igTIgQ3Dxv+TnKQ9QXShmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348211; c=relaxed/simple; bh=XcA4zsHiHN6Jv8wny1OCHvfAqepR6uN0UFEN1AfWYN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cg6TdS/aUSGM4HrUxqvA6Ft4ADEGelxOzK37NIsShA/2ny2dSXl4w7Vk3heBx7kfmJ+pIRSrS9+HdKlxEQS2Jy99YCfLirJLH9NcH8jgnx4bRlCgnKrii0dgeTAywv31ZvNzrn9fs6vpLFLE94NaRzAac+ig+QoAJnn/8lCQYnM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EM6OT3mD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EM6OT3mD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35F0FC433C7; Wed, 13 Mar 2024 16:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348211; bh=XcA4zsHiHN6Jv8wny1OCHvfAqepR6uN0UFEN1AfWYN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EM6OT3mDiD/PKKs54seaYwcOjZx2yYGi3Y4+yvlWnAmv7wCleyk9ls4fBFiD/UpKc JG4RwNZz6JPGVpmOJj8aXjORcXlmFmfwny5rGNkJh5RtPa6NZQlYDtCV2y1FhQV/a9 YcFowPsLoeSZkvcyCBSOAyQOvE1X1wYzU1ZhG0gcYnd4rwIAuoPSYQJHiSdAnndKN4 CUqBEKpRlXaa35OvG5YIbpeW614b/r9j80rVXG/xQzbZXZFwb7N3dmuXOoFVPKpjWv 5B39rytLI077LqSpd4d3bltZfOlQ57HxD0zVG9dcV89R1VfG4kr5HeeGzMNcA+wSoP tEystkGAz6h4w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Magali Lemes , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Harry Wentland , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 58/76] drm/amd/display: remove DML Makefile duplicate lines Date: Wed, 13 Mar 2024 12:42:05 -0400 Message-ID: <20240313164223.615640-59-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Magali Lemes [ Upstream commit 41ead3e0cdc03d64b7da2dcb1fd70ebb7164228b ] There are two identical CFLAGS entries for "display_mode_vba_20.o", so remove one of them. Also, as there's already an entry for "display_mode_lib.o" CFLAGS, regardless of CONFIG_DRM_AMD_DC_DCN being defined or not, remove the one entry between CONFIG_DRM_AMD_DC_DCN ifdef guards. Signed-off-by: Magali Lemes Reviewed-by: Andr=C3=A9 Almeida Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher Stable-dep-of: e63e35f0164c ("drm/amd/display: Increase frame-larger-than f= or all display_mode_vba files") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/display/dc/dml/Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index c97fdfc36d0fd..93cc3086783fa 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -60,7 +60,6 @@ ifdef CONFIG_DRM_AMD_DC_DCN CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags) -CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o :=3D $(dml_ccfla= gs) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20v2.o :=3D $(dml_cc= flags) @@ -71,7 +70,6 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.= o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o :=3D $(dml_ccflags) -CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o :=3D $(dml_ccflags) -Wno= -tautological-compare --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A599814AD3F; Wed, 13 Mar 2024 16:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348213; cv=none; b=PD22/Bxi1/pZopX+hlZMXlM4i2bhXwTXx9a5KpNnP5HTtIvsdFV+psyA+yFmi4YBbtuMygDO6nfTIt7/KRrn8IZHKszwTSzMEoYpHAJsSX3QqnN+XWnoJbnDBvJY8jdr65fHm5KdzcoEBAy3pRvVM5IncUo52rqZ6kqqzLdkQIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348213; c=relaxed/simple; bh=xWXNefaQZBQdWGtaZwmaLJIxt24HwXX91agyZD8u11Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NshoR0LX6sE239jYs90G58dpYi3G+ZFNWlBN+/JyhLwatBnyKVDAeI6poaH4cPBEMlsYlFVbzbS4VtcD1wIKPWJdHEUPlcvj5tg9OvvjFxp0bx+FOZH+7GBG8Em7fyhXOxIZCt4eGJkEtzkfGYjz5XzvdKLlTRnAR9H0siRs4lI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b2F7ZTtG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b2F7ZTtG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68672C433F1; Wed, 13 Mar 2024 16:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348212; bh=xWXNefaQZBQdWGtaZwmaLJIxt24HwXX91agyZD8u11Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2F7ZTtGXi1HXtMmTOeSQt0s8qJBdKMM2ygvyFkrDCDZccgClqFjImR91PBv5IFcT iaB6t4CkYUNl9Ywnu0AwkUJkD/AWnrlvmy2DGWKlu4Q3YgoiDW37HzxoTRdDw2c05G I7gH75RiCDKDYIICubIAyYDVTKHal0wnph0+FY9rxJcNqa//BhGQDoHIgbCWIkcokX oAro/1yxG5p/rcSURHeaSA/URpINx7h6kMWGoNamh/k+I2YmDjJBaY6346oBNfGJbx 8QFegkD1tHZHkc0/OPVEWLW1EJIIv+IR++i4i5FiFKiuIAGBmJiO5h4eCG1Jbc4ren vLbSddt8uyTkA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Alex Deucher , Sasha Levin Subject: [PATCH 5.15 59/76] drm/amd/display: Increase frame-larger-than for all display_mode_vba files Date: Wed, 13 Mar 2024 12:42:06 -0400 Message-ID: <20240313164223.615640-60-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nathan Chancellor [ Upstream commit e63e35f0164c43fbc1adb481d6604f253b9f9667 ] After a recent change in LLVM, allmodconfig (which has CONFIG_KCSAN=3Dy and CONFIG_WERROR=3Dy enabled) has a few new instances of -Wframe-larger-than for the mode support and system configuration functions: drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn20/display_mode_vba_20v2.= c:3393:6: error: stack frame size (2144) exceeds limit (2048) in 'dml20v2_M= odeSupportAndSystemConfigurationFull' [-Werror,-Wframe-larger-than] 3393 | void dml20v2_ModeSupportAndSystemConfigurationFull(struct display= _mode_lib *mode_lib) | ^ 1 error generated. drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn21/display_mode_vba_21.c:= 3520:6: error: stack frame size (2192) exceeds limit (2048) in 'dml21_ModeS= upportAndSystemConfigurationFull' [-Werror,-Wframe-larger-than] 3520 | void dml21_ModeSupportAndSystemConfigurationFull(struct display_m= ode_lib *mode_lib) | ^ 1 error generated. drivers/gpu/drm/amd/amdgpu/../display/dc/dml/dcn20/display_mode_vba_20.c:= 3286:6: error: stack frame size (2128) exceeds limit (2048) in 'dml20_ModeS= upportAndSystemConfigurationFull' [-Werror,-Wframe-larger-than] 3286 | void dml20_ModeSupportAndSystemConfigurationFull(struct display_m= ode_lib *mode_lib) | ^ 1 error generated. Without the sanitizers enabled, there are no warnings. This was the catalyst for commit 6740ec97bcdb ("drm/amd/display: Increase frame warning limit with KASAN or KCSAN in dml2") and that same change was made to dml in commit 5b750b22530f ("drm/amd/display: Increase frame warning limit with KASAN or KCSAN in dml") but the frame_warn_flag variable was not applied to all files. Do so now to clear up the warnings and make all these files consistent. Cc: stable@vger.kernel.org Closes: https://github.com/ClangBuiltLinux/linux/issue/1990 Signed-off-by: Nathan Chancellor Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/gpu/drm/amd/display/dc/dml/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile b/drivers/gpu/drm/= amd/display/dc/dml/Makefile index 93cc3086783fa..96e70832c7423 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile @@ -59,11 +59,11 @@ CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o :=3D $(d= ml_ccflags) ifdef CONFIG_DRM_AMD_DC_DCN CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_vba.o :=3D $(dml_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/dcn20_fpu.o :=3D $(dml_ccflags) -CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20.o :=3D $(dml_ccfl= ags) -CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o :=3D $(dml_ccfla= gs) +CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20v2.o :=3D $(dml_ccfla= gs) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn20/display_rq_dlg_calc_20v2.o :=3D $(dml_cc= flags) -CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_mode_vba_21.o :=3D $(dml_ccflags) +CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_mode_vba_21.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn21/display_rq_dlg_calc_21.o :=3D $(dml_ccfl= ags) CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_mode_vba_30.o :=3D $(dml_ccflags= ) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o :=3D $(dml_ccfl= ags) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C6CD14AD26; Wed, 13 Mar 2024 16:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348213; cv=none; b=UNulbj5dA5GA37soWpkWIcCWrNvruZU/q6xtItRnucMps8fqj35kR56YC3Nai0I+zKfhMrn+TU+KWSnvbhqJArNLDmwUoCvSdeVotakPictbbI01dPMit9WspHs5dr9Epooew0DciweWwbDYHFSKUS9hwvw+oPfZIqDCvoxcOz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348213; c=relaxed/simple; bh=t8JjLrSBnpcqofryRsssp6nAlEA9Bh5ZWeeJ3QS4LoM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kr2ha2BWZwuhGxc0u/xpceJgEfRvblviDgDkV8gR0CKhnWpvcMFqvHBivMz3dHzNywxxAgJuRkK3xP/BjsI/HwOHQBImAAHZDy7lO8tQ5xqq/H5//gx6XkyskPFoFEXhODL1UgXtZiax0LsdsYwdk3EX5rn2lJ/Ob4TbE5jZr9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XHGWpggE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XHGWpggE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DD8DC433A6; Wed, 13 Mar 2024 16:43:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348213; bh=t8JjLrSBnpcqofryRsssp6nAlEA9Bh5ZWeeJ3QS4LoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XHGWpggEpUION2Otf+l+LJajRnpS+2Aku/OdjhmVxhEHm5lgeopWEIU9XU20VVsqb EFtUqKn/5xl284OAHHVRpT6OJhS37iA8NAFzcpjchk9Uf/c4B1FDZ8wkvu46WTbV52 UeDUMJEHBXtcBoImLOpbguMIx3ZFJx9efDRwr6S1NjQeRU14ZLm/VNKAKuVh0eOuqO sgkK9KzZbnl4YHeaRBzbVPB/r0Lk452sTKf/8e8npsSUphB9qfhrBMzZWTvzD9pKSg nlFRVw5O49b0672/VsDZwpK4Cj51g5AycS07L3H17lZ6DyFo0l/hd8VRKIIXLe222s WsJfUxqLRdpAw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 60/76] getrusage: add the "signal_struct *sig" local variable Date: Wed, 13 Mar 2024 12:42:07 -0400 Message-ID: <20240313164223.615640-61-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit c7ac8231ace9b07306d0299969e42073b189c70a ] No functional changes, cleanup/preparation. Link: https://lkml.kernel.org/r/20230909172554.GA20441@redhat.com Signed-off-by: Oleg Nesterov Cc: Eric W. Biederman Signed-off-by: Andrew Morton Stable-dep-of: daa694e41375 ("getrusage: move thread_group_cputime_adjusted= () outside of lock_task_sighand()") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/sys.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index 2efab44746356..0298992c1eb9b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1764,6 +1764,7 @@ void getrusage(struct task_struct *p, int who, struct= rusage *r) unsigned long flags; u64 tgutime, tgstime, utime, stime; unsigned long maxrss =3D 0; + struct signal_struct *sig =3D p->signal; =20 memset((char *)r, 0, sizeof (*r)); utime =3D stime =3D 0; @@ -1771,7 +1772,7 @@ void getrusage(struct task_struct *p, int who, struct= rusage *r) if (who =3D=3D RUSAGE_THREAD) { task_cputime_adjusted(current, &utime, &stime); accumulate_thread_rusage(p, r); - maxrss =3D p->signal->maxrss; + maxrss =3D sig->maxrss; goto out; } =20 @@ -1781,15 +1782,15 @@ void getrusage(struct task_struct *p, int who, stru= ct rusage *r) switch (who) { case RUSAGE_BOTH: case RUSAGE_CHILDREN: - utime =3D p->signal->cutime; - stime =3D p->signal->cstime; - r->ru_nvcsw =3D p->signal->cnvcsw; - r->ru_nivcsw =3D p->signal->cnivcsw; - r->ru_minflt =3D p->signal->cmin_flt; - r->ru_majflt =3D p->signal->cmaj_flt; - r->ru_inblock =3D p->signal->cinblock; - r->ru_oublock =3D p->signal->coublock; - maxrss =3D p->signal->cmaxrss; + utime =3D sig->cutime; + stime =3D sig->cstime; + r->ru_nvcsw =3D sig->cnvcsw; + r->ru_nivcsw =3D sig->cnivcsw; + r->ru_minflt =3D sig->cmin_flt; + r->ru_majflt =3D sig->cmaj_flt; + r->ru_inblock =3D sig->cinblock; + r->ru_oublock =3D sig->coublock; + maxrss =3D sig->cmaxrss; =20 if (who =3D=3D RUSAGE_CHILDREN) break; @@ -1799,14 +1800,14 @@ void getrusage(struct task_struct *p, int who, stru= ct rusage *r) thread_group_cputime_adjusted(p, &tgutime, &tgstime); utime +=3D tgutime; stime +=3D tgstime; - r->ru_nvcsw +=3D p->signal->nvcsw; - r->ru_nivcsw +=3D p->signal->nivcsw; - r->ru_minflt +=3D p->signal->min_flt; - r->ru_majflt +=3D p->signal->maj_flt; - r->ru_inblock +=3D p->signal->inblock; - r->ru_oublock +=3D p->signal->oublock; - if (maxrss < p->signal->maxrss) - maxrss =3D p->signal->maxrss; + r->ru_nvcsw +=3D sig->nvcsw; + r->ru_nivcsw +=3D sig->nivcsw; + r->ru_minflt +=3D sig->min_flt; + r->ru_majflt +=3D sig->maj_flt; + r->ru_inblock +=3D sig->inblock; + r->ru_oublock +=3D sig->oublock; + if (maxrss < sig->maxrss) + maxrss =3D sig->maxrss; t =3D p; do { accumulate_thread_rusage(t, r); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9186C14BD5C; Wed, 13 Mar 2024 16:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348214; cv=none; b=TS/1xh0EqtsM9l7oRVyk+wWmym9HuqY37wJvqc2/Sk11iFdaPb++KZTLz8XpmeHC0pj3R7ISK91TW8lYsL3OVsrEdxdZYM7mddgKf5ewIHyLLYrB6NolqDEc79e7JwsNeCdL+SCnc1U2FKmmc9VH2k0gqvXvj+J6qq8Z1YT14HU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348214; c=relaxed/simple; bh=dBX5SGMYIABZbhEPwSAvjJkH193cy6hXRvYEI6b9Mqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ASuyNKu3IErx3y6lwYYKbu4j1F2BZWNIQnObkdl+YoXWaAGYN+i+yjdGMIwVMlwXJ2iPZNwuZc19GI97yg3KY4opj3wYrTUM9OQP0hmeivBW1PbMKgu4+pOQhn5ll1tgxBy4aPaSOlAbUof68yVgH1TQZf252TollbMeOecrFh0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r4bOOFP2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r4bOOFP2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8629CC43390; Wed, 13 Mar 2024 16:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348214; bh=dBX5SGMYIABZbhEPwSAvjJkH193cy6hXRvYEI6b9Mqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4bOOFP2owrkwu6tkcPpfxQkEwLaKajdVfFGG8hXZLbucDQ9cgG26ixfhJMWdWb8P GhA+mfxJcohK2pFrbjb+XaIkZo60HeX+MTAzjYrTKFmGfe+B1Nt++mD/9GTQSxmVdH 19HV8F4wu0ZpCJGE5Ieh1LnNMNrAI1m2BzZdPuTm6+oXjkTjHDjo2MLfJoxQr+J04r DmN2MsOVKP20/2zI5/ciXa+IiM/NGqYO/4ZfK/0kvtT2YsP9rYir07g1OCxMravTqe 3bLegTAX/OSgZr66skeEZpX6n3E4IGHWd/nl3MuWqW29rDtDc/lLmncCiXDZ24S9Uw S8bVdpx4i2XuA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , Dylan Hatch , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 61/76] getrusage: move thread_group_cputime_adjusted() outside of lock_task_sighand() Date: Wed, 13 Mar 2024 12:42:08 -0400 Message-ID: <20240313164223.615640-62-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit daa694e4137571b4ebec330f9a9b4d54aa8b8089 ] Patch series "getrusage: use sig->stats_lock", v2. This patch (of 2): thread_group_cputime() does its own locking, we can safely shift thread_group_cputime_adjusted() which does another for_each_thread loop outside of ->siglock protected section. This is also preparation for the next patch which changes getrusage() to use stats_lock instead of siglock, thread_group_cputime() takes the same lock. With the current implementation recursive read_seqbegin_or_lock() is fine, thread_group_cputime() can't enter the slow mode if the caller holds stats_lock, yet this looks more safe and better performance-wise. Link: https://lkml.kernel.org/r/20240122155023.GA26169@redhat.com Link: https://lkml.kernel.org/r/20240122155050.GA26205@redhat.com Signed-off-by: Oleg Nesterov Reported-by: Dylan Hatch Tested-by: Dylan Hatch Cc: Eric W. Biederman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/sys.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index 0298992c1eb9b..25f0c0697356b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1763,17 +1763,19 @@ void getrusage(struct task_struct *p, int who, stru= ct rusage *r) struct task_struct *t; unsigned long flags; u64 tgutime, tgstime, utime, stime; - unsigned long maxrss =3D 0; + unsigned long maxrss; + struct mm_struct *mm; struct signal_struct *sig =3D p->signal; =20 - memset((char *)r, 0, sizeof (*r)); + memset(r, 0, sizeof(*r)); utime =3D stime =3D 0; + maxrss =3D 0; =20 if (who =3D=3D RUSAGE_THREAD) { task_cputime_adjusted(current, &utime, &stime); accumulate_thread_rusage(p, r); maxrss =3D sig->maxrss; - goto out; + goto out_thread; } =20 if (!lock_task_sighand(p, &flags)) @@ -1797,9 +1799,6 @@ void getrusage(struct task_struct *p, int who, struct= rusage *r) fallthrough; =20 case RUSAGE_SELF: - thread_group_cputime_adjusted(p, &tgutime, &tgstime); - utime +=3D tgutime; - stime +=3D tgstime; r->ru_nvcsw +=3D sig->nvcsw; r->ru_nivcsw +=3D sig->nivcsw; r->ru_minflt +=3D sig->min_flt; @@ -1819,19 +1818,24 @@ void getrusage(struct task_struct *p, int who, stru= ct rusage *r) } unlock_task_sighand(p, &flags); =20 -out: - r->ru_utime =3D ns_to_kernel_old_timeval(utime); - r->ru_stime =3D ns_to_kernel_old_timeval(stime); + if (who =3D=3D RUSAGE_CHILDREN) + goto out_children; =20 - if (who !=3D RUSAGE_CHILDREN) { - struct mm_struct *mm =3D get_task_mm(p); + thread_group_cputime_adjusted(p, &tgutime, &tgstime); + utime +=3D tgutime; + stime +=3D tgstime; =20 - if (mm) { - setmax_mm_hiwater_rss(&maxrss, mm); - mmput(mm); - } +out_thread: + mm =3D get_task_mm(p); + if (mm) { + setmax_mm_hiwater_rss(&maxrss, mm); + mmput(mm); } + +out_children: r->ru_maxrss =3D maxrss * (PAGE_SIZE / 1024); /* convert pages to KBs */ + r->ru_utime =3D ns_to_kernel_old_timeval(utime); + r->ru_stime =3D ns_to_kernel_old_timeval(stime); } =20 SYSCALL_DEFINE2(getrusage, int, who, struct rusage __user *, ru) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC23F14BF20; Wed, 13 Mar 2024 16:43:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348215; cv=none; b=LyZnI2P8zCH2mNbl1I7aaTMxPiFP3KoEVrFpe806XWycUrV9Ie3bpOcz0u53xyRejpxCe7ZzxyX79Gr78oBZTw3hv78yui6n7p3wXzSfPKHmkpPy0SzsJw1YJrd9ExqMZ1rwOdrl+bkvz+pNKcyhZX37IPBcigLgFyb4ZyG8vy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348215; c=relaxed/simple; bh=Ua5zIpkGM0VdF4IOpoP+bs2DZ9wApB/huugP8qfRO6Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pqjsAuJFInBI4VA6sKdKg3U6z6btmxz/oDHQHQzvpmJZHav5wLgovCoTNJAc6O2bcXmUE0s9VGCVxOdQBJmMMMr4GObhjK/xXtRRieWVjCW8G6JBQd7yJkfHZsle62xhJ5JV1Fw+vpRDJKjidqo/U8fHm90l3gLhTuZZAQ/724Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t2jnWM0b; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t2jnWM0b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB6C6C43399; Wed, 13 Mar 2024 16:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348215; bh=Ua5zIpkGM0VdF4IOpoP+bs2DZ9wApB/huugP8qfRO6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2jnWM0b1frbqK2QpEXLkLtdCrZSS8glgypjmiMP2IK3bVBCqhkyv1NHCqNhD9a7T bkSWK6Oxt/Eyq/acBPIQBw6WbNxbvT7M34gwhAHTat7dGEStawWk0uCg9hhlgqn1vY TIw5UxmYHJT6u97Qz/r9CThK1bqvRnXhljGOeF6gdGedPGHDgrdIaVta/z/50g2Hhg ewETABWvehbTl9m+ozCu6/3+DaL3wal3Ir5mc/P/no7KIWhSIOUtL9TUqsh11EuLcQ sMGjmX8/68BhZ1/LDQWr8H3RCcV/GTx1H6cwoOOSpS841jooOJOLF7ql1l1tlv+qz/ bwlCiLsHSnr1A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 62/76] getrusage: use __for_each_thread() Date: Wed, 13 Mar 2024 12:42:09 -0400 Message-ID: <20240313164223.615640-63-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit 13b7bc60b5353371460a203df6c38ccd38ad7a3a ] do/while_each_thread should be avoided when possible. Plus this change allows to avoid lock_task_sighand(), we can use rcu and/or sig->stats_lock instead. Link: https://lkml.kernel.org/r/20230909172629.GA20454@redhat.com Signed-off-by: Oleg Nesterov Cc: Eric W. Biederman Signed-off-by: Andrew Morton Stable-dep-of: f7ec1cd5cc7e ("getrusage: use sig->stats_lock rather than lo= ck_task_sighand()") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/sys.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index 25f0c0697356b..85f358a5d5eb5 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1807,10 +1807,8 @@ void getrusage(struct task_struct *p, int who, struc= t rusage *r) r->ru_oublock +=3D sig->oublock; if (maxrss < sig->maxrss) maxrss =3D sig->maxrss; - t =3D p; - do { + __for_each_thread(sig, t) accumulate_thread_rusage(t, r); - } while_each_thread(p, t); break; =20 default: --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8C6914BF4B; Wed, 13 Mar 2024 16:43:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348217; cv=none; b=C2XQKC8wsEy5MXVGP1lDxoKA/JzI1HwRZEqGuuIo6YPkvMGFJuO59U+VHHNsBHlHk+kUDR/harG/E83LFy3cSy4oDjdSpOuuKjZfF0BlgsFio3RxuykbecLdmmL5kwD8yUz4/0wyzHJODLhiNmD7XtsKY8P4Gey30LBQaawNKxY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348217; c=relaxed/simple; bh=qhKKir9adXpVC5ZKe/JXK2kRFSMDfnJPV9kOB+uQ8ng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bXpOJjMisPZNRJp5eGCGklHOJ3+OyfEofHZibn8QolyeBWjruP8cyDKM582PpixOkdoJhmw9M49wc69wBWDokZQYFHXKS2p4TOpexbMqu+Kry6pKT3g/53ANxoF9UCplrYHXSvmJm/5iY4pixKilWixK8/l5ZHYZTB1eAqxseQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TxBlwI3/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TxBlwI3/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6AA7C433C7; Wed, 13 Mar 2024 16:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348216; bh=qhKKir9adXpVC5ZKe/JXK2kRFSMDfnJPV9kOB+uQ8ng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TxBlwI3/nkayaPKS9q/ciYO8osQh0le6LPUyUizkWnm67atsPSkkSxFZ4qzGaiZ5u 9vJ0PtdAT5yjBv88S5yJkzSMGfJQ75gqjtixro9i7U4oriMPCUMXZaJK9qu8uzBWT6 XAZmXpWdC3DMiUekswZ0TOq9V3Q8Ee9I7YddK7OVGVDEEPOfDruvivIjhFyXuRC5EV gezNK/ceLiq680pIHguIVHY376C7572YED0VnhvN+hmPkKI7aO2oii456TS2Hb1QKM uqxZDnWDriviX2yKshWZosA/TQsG9H4WytT/G3oNr4HezHMgZeQBRBAC5weDkgXvst DlkSsj2PFZUwg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , Dylan Hatch , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 63/76] getrusage: use sig->stats_lock rather than lock_task_sighand() Date: Wed, 13 Mar 2024 12:42:10 -0400 Message-ID: <20240313164223.615640-64-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit f7ec1cd5cc7ef3ad964b677ba82b8b77f1c93009 ] lock_task_sighand() can trigger a hard lockup. If NR_CPUS threads call getrusage() at the same time and the process has NR_THREADS, spin_lock_irq will spin with irqs disabled O(NR_CPUS * NR_THREADS) time. Change getrusage() to use sig->stats_lock, it was specifically designed for this type of use. This way it runs lockless in the likely case. TODO: - Change do_task_stat() to use sig->stats_lock too, then we can remove spin_lock_irq(siglock) in wait_task_zombie(). - Turn sig->stats_lock into seqcount_rwlock_t, this way the readers in the slow mode won't exclude each other. See https://lore.kernel.org/all/20230913154907.GA26210@redhat.com/ - stats_lock has to disable irqs because ->siglock can be taken in irq context, it would be very nice to change __exit_signal() to avoid the siglock->stats_lock dependency. Link: https://lkml.kernel.org/r/20240122155053.GA26214@redhat.com Signed-off-by: Oleg Nesterov Reported-by: Dylan Hatch Tested-by: Dylan Hatch Cc: Eric W. Biederman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/sys.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index 85f358a5d5eb5..2cfb829864c63 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1766,7 +1766,9 @@ void getrusage(struct task_struct *p, int who, struct= rusage *r) unsigned long maxrss; struct mm_struct *mm; struct signal_struct *sig =3D p->signal; + unsigned int seq =3D 0; =20 +retry: memset(r, 0, sizeof(*r)); utime =3D stime =3D 0; maxrss =3D 0; @@ -1778,8 +1780,7 @@ void getrusage(struct task_struct *p, int who, struct= rusage *r) goto out_thread; } =20 - if (!lock_task_sighand(p, &flags)) - return; + flags =3D read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq); =20 switch (who) { case RUSAGE_BOTH: @@ -1807,14 +1808,23 @@ void getrusage(struct task_struct *p, int who, stru= ct rusage *r) r->ru_oublock +=3D sig->oublock; if (maxrss < sig->maxrss) maxrss =3D sig->maxrss; + + rcu_read_lock(); __for_each_thread(sig, t) accumulate_thread_rusage(t, r); + rcu_read_unlock(); + break; =20 default: BUG(); } - unlock_task_sighand(p, &flags); + + if (need_seqretry(&sig->stats_lock, seq)) { + seq =3D 1; + goto retry; + } + done_seqretry_irqrestore(&sig->stats_lock, seq, flags); =20 if (who =3D=3D RUSAGE_CHILDREN) goto out_children; --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6268E64CDC; Wed, 13 Mar 2024 16:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348218; cv=none; b=UGaMzLDm09AH38fo56a9s0VqhSaK14RHGd6fQxWwrCojOGPd653Sio1gOXdp8IdTY2vUHf1eqbY1nTvrbcmnlhMEyO4msHQ1Lo3zcA9yCD54vI8RWeBm/jPB8sRALxw4ccdXi+GozYIbOtdgt/B3OsK1ykUokB85lxS65s0gJTU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348218; c=relaxed/simple; bh=0rNqNmlVXTX/11HQ0XAMJYZPgzeF+GgYg85DZhweKCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cUGSie4Wy/s7jOObi0pT88uGwNgJD20unuYzemz0Do43bIb0NBHuw174SsJCsveeNfeLnEbpxxSykTy1cUVTLHK+yHJ/o6xeZ4UI3TxxBeo7kaOjeDDLASTKUZJH9+Xz3WjVeHaliQnPF1tdf6EgxD/MqfUI9N+ThQOTp5pAk3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bZWMt/64; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bZWMt/64" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2138EC43399; Wed, 13 Mar 2024 16:43:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348217; bh=0rNqNmlVXTX/11HQ0XAMJYZPgzeF+GgYg85DZhweKCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bZWMt/6437nPh+VHuEI38fkI24S/Fv9GizfeL1EbCRGZGFTihVS4wtdE0Gws1qL5Z 6bpaMgYN9QbbsBMnPstAclVqBqljLR2wdMuXXjHjbTYLKom7i8XB7jUhT5qGUotdsm vGaiNnORwjWsrRbTLUHhLUYeoqpG4I+88zDSSvYDVrpJAD5O7GbDmZo1Or73y9aC42 +kKUkax9Hfsc5N7V5N/oLPwVRynZg4Kwzmg32/gU2hd6fdvtlOyv8nCmx1IsDVh6mr /0oszIjM28bRBwdHqr3lDYALui2TOSwqXSa2SNg1yV4i74IkZXlDYkUM0XA3Auai1/ bAxCOMNweyGDg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kees Cook , Peter Zijlstra , Sasha Levin Subject: [PATCH 5.15 64/76] proc: Use task_is_running() for wchan in /proc/$pid/stat Date: Wed, 13 Mar 2024 12:42:11 -0400 Message-ID: <20240313164223.615640-65-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Kees Cook [ Upstream commit 4e046156792c26bef8a4e30be711777fc8578257 ] The implementations of get_wchan() can be expensive. The only information imparted here is whether or not a process is currently blocked in the scheduler (and even this doesn't need to be exact). Avoid doing the heavy lifting of stack walking and just report that information by using task_is_running(). Signed-off-by: Kees Cook Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20211008111626.211281780@infradead.org Stable-dep-of: 60f92acb60a9 ("fs/proc: do_task_stat: move thread_group_cput= ime_adjusted() outside of lock_task_sighand()") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- fs/proc/array.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 49be8c8ef555e..77cf4187adecc 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -541,7 +541,7 @@ static int do_task_stat(struct seq_file *m, struct pid_= namespace *ns, } =20 if (permitted && (!whole || num_threads < 2)) - wchan =3D get_wchan(task); + wchan =3D !task_is_running(task); if (!whole) { min_flt =3D task->min_flt; maj_flt =3D task->maj_flt; @@ -606,10 +606,7 @@ static int do_task_stat(struct seq_file *m, struct pid= _namespace *ns, * * This works with older implementations of procps as well. */ - if (wchan) - seq_puts(m, " 1"); - else - seq_puts(m, " 0"); + seq_put_decimal_ull(m, " ", wchan); =20 seq_put_decimal_ull(m, " ", 0); seq_put_decimal_ull(m, " ", 0); --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3692414C5A2; Wed, 13 Mar 2024 16:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348219; cv=none; b=YBlNJfdsSRwG9hv8onLbivk3t6y+CrtzM0MhUs4RrKDYSWdcLwf7zWilWCXSN0NG76oI6+d6K8EvK9Neq8mxDCyIfgLUkGvyTdPHMxxbgzz2j6LtyO4e7MCFREvucpf5ZthJbKLv9aS0y4Wq7/kDIqSBM1stz5RnfcvHzTUPWEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348219; c=relaxed/simple; bh=PgNbsfSnge8biy8YM3pVL9sIVanFruRxDzQvse34EW0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAiItjvibRo78oVSXQ9XYsw615j2on+4I3poMC0zPSQBMeuiDRWsa3BDQh/be6FzTTj1cxEJHYUHV3lR9nM8cbyoyKUWHizjmaU9H8ZiXH3y409xZLruEwzGd5mBJxdwqMaHBWT+b8H5Qt+s5/uWz2Ytzn9sh3iI1WmXBlSSqNY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B+dH4tin; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B+dH4tin" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27F99C433F1; Wed, 13 Mar 2024 16:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348219; bh=PgNbsfSnge8biy8YM3pVL9sIVanFruRxDzQvse34EW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B+dH4tin/pdpzY+vUX2/goLoeKAoqY/vRLrW00xkwTLpGg+QSd1yt7QPbLbU41m28 rycGsxtwfhLt2VJVp27ytE6KBulMR/eKzktJkVuYJSq3XAEgfi7WfMP8I/L6/j0T3c ghPA1ctDRLQQPUrX2YHjMlMmH2gncyzQWMS3cayBh78J6ukXNZ58UV0GH0tFTe5kul wEolxGGvg/qjWZEZQV9HKkvm4HbdFkb71yBkO+sOgiIkeAEFHyST3HH20ZQEhIyEzm L88WO0ykAuoDmekXGEfvMK5iO90F41efku7UAbPADYLhHdqFa7ZT5BmTllt/p/YMe5 CSAo+/V0ikxFg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , Dylan Hatch , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 65/76] fs/proc: do_task_stat: move thread_group_cputime_adjusted() outside of lock_task_sighand() Date: Wed, 13 Mar 2024 12:42:12 -0400 Message-ID: <20240313164223.615640-66-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit 60f92acb60a989b14e4b744501a0df0f82ef30a3 ] Patch series "fs/proc: do_task_stat: use sig->stats_". do_task_stat() has the same problem as getrusage() had before "getrusage: use sig->stats_lock rather than lock_task_sighand()": a hard lockup. If NR_CPUS threads call lock_task_sighand() at the same time and the process has NR_THREADS, spin_lock_irq will spin with irqs disabled O(NR_CPUS * NR_THREADS) time. This patch (of 3): thread_group_cputime() does its own locking, we can safely shift thread_group_cputime_adjusted() which does another for_each_thread loop outside of ->siglock protected section. Not only this removes for_each_thread() from the critical section with irqs disabled, this removes another case when stats_lock is taken with siglock held. We want to remove this dependency, then we can change the users of stats_lock to not disable irqs. Link: https://lkml.kernel.org/r/20240123153313.GA21832@redhat.com Link: https://lkml.kernel.org/r/20240123153355.GA21854@redhat.com Signed-off-by: Oleg Nesterov Signed-off-by: Dylan Hatch Cc: Eric W. Biederman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- fs/proc/array.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 77cf4187adecc..c925287a4dc4b 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -495,7 +495,7 @@ static int do_task_stat(struct seq_file *m, struct pid_= namespace *ns, =20 sigemptyset(&sigign); sigemptyset(&sigcatch); - cutime =3D cstime =3D utime =3D stime =3D 0; + cutime =3D cstime =3D 0; cgtime =3D gtime =3D 0; =20 if (lock_task_sighand(task, &flags)) { @@ -529,7 +529,6 @@ static int do_task_stat(struct seq_file *m, struct pid_= namespace *ns, =20 min_flt +=3D sig->min_flt; maj_flt +=3D sig->maj_flt; - thread_group_cputime_adjusted(task, &utime, &stime); gtime +=3D sig->gtime; } =20 @@ -542,10 +541,13 @@ static int do_task_stat(struct seq_file *m, struct pi= d_namespace *ns, =20 if (permitted && (!whole || num_threads < 2)) wchan =3D !task_is_running(task); - if (!whole) { + + if (whole) { + thread_group_cputime_adjusted(task, &utime, &stime); + } else { + task_cputime_adjusted(task, &utime, &stime); min_flt =3D task->min_flt; maj_flt =3D task->maj_flt; - task_cputime_adjusted(task, &utime, &stime); gtime =3D task_gtime(task); } =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2582A14C5BF; Wed, 13 Mar 2024 16:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348220; cv=none; b=eQo/axbjsA9dkaggHjEZYh31wLOsevP5Eo8oxErov2YJ5ddDcxJY7pexpK8+L78GrLgm28Bx/ufkgQKP7fxG7/IWWoT6JMp6YyNSrs+Z2bxWUGueKgLjDr7WQcaEdD3QOqJUml5fXvfQZOM3DFR22JnFlI+smdLvw0oIh+qsO4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348220; c=relaxed/simple; bh=P9DP6IqgYN3+tqfLxffosppibCXgUTe6UqRwTE+IcKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nQ2XXWl2hpCrnrXSJHZyGlnaBmMn8x8AFywXQHXcKgRnPAQrYgf0tciQkI8UmvKEKYk8aW6odxObyvC+kFdYAmSgfsEWWoMB5d99r47Bclqsi48O+VBYuzOa916dWAiV3NY+jGml7/t4KNvd5drsam0Y80XCG8Ok+wdpt5MNxmo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i4GI888W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i4GI888W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62016C433C7; Wed, 13 Mar 2024 16:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348220; bh=P9DP6IqgYN3+tqfLxffosppibCXgUTe6UqRwTE+IcKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4GI888WF0so4/myq8YRGYKiCk+RM9ybcZLPUPVB/Tu55SwxE5UyqzJZkBhx47Onm ktSeiY4FWJJrcXmya9ZbmyTxt1dhTs1JHN7YUJjty9RZ46VONKms9fvaITnmgwVGKf uHJIOdu6a6Pole3s4kn7MIpUUsdhAMaMLqRue+l2uUrStV+Dtx/zXquoyLIoeK34Ix ijmK1gARkf3LXpgzLNxwxfjDCie6ZhXtrFxv/tV+yUD2AJTbs7gl2geZ6FBlf9+vrn uwWu1olffNe/AMm5C8+7j+DRse+/WVQzBEpvj2uBlfCvYg39buljgL/9fz6MtB+yKp qD+3TBDYztBrg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ingo Molnar , Sasha Levin Subject: [PATCH 5.15 66/76] exit: Fix typo in comment: s/sub-theads/sub-threads Date: Wed, 13 Mar 2024 12:42:13 -0400 Message-ID: <20240313164223.615640-67-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ingo Molnar [ Upstream commit dcca34754a3f5290406403b8066e3b15dda9f4bf ] Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar Stable-dep-of: c1be35a16b2f ("exit: wait_task_zombie: kill the no longer ne= cessary spin_lock_irq(siglock)") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/exit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/exit.c b/kernel/exit.c index 80efdfda6662b..e982111c489a9 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1119,7 +1119,7 @@ static int wait_task_zombie(struct wait_opts *wo, str= uct task_struct *p) * p->signal fields because the whole thread group is dead * and nobody can change them. * - * psig->stats_lock also protects us from our sub-theads + * psig->stats_lock also protects us from our sub-threads * which can reap other children at the same time. Until * we change k_getrusage()-like users to rely on this lock * we have to take ->siglock as well. --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AC6D64CEF; Wed, 13 Mar 2024 16:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348221; cv=none; b=NE+lHSxefdICLwsgvWNnx12z6ET0HxUQSLEcX7eeTHOBSqqeG/4oTLSLy5pZnmP94AFgeIj1cLYMw5V6VihSoBSf4OAhc+oD8QkWIkXKbtz87+pgaps1w7kS3mwa35MasG9niZcOTwp22CC2jeODeP9S7bYtCFcb8ZTB0Y2YSxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348221; c=relaxed/simple; bh=WAUj8o87Jtl9FY8pDymI7DWVAEqnJiixd48oKquu4iI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SeyYb92Hyq0eW9gsdfE3xx0sQBIIRwFS/aIH4Q+1WNpL/bVTqK8yYC/y10y5GsXLFDWO07hVZP1HOtk0eLgoOUiWq3Jh/2QQXT+GinBTITL61qRB5DMcPc77EqlqRb9+OlLOfHGLY/NwQH4qpSsYPScny3NiKyiyxXlGOIe9BSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o7TY/Ia2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o7TY/Ia2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F1D7C433C7; Wed, 13 Mar 2024 16:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348221; bh=WAUj8o87Jtl9FY8pDymI7DWVAEqnJiixd48oKquu4iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7TY/Ia2kdis+532dlECAIEuQdXX6Oj/lZoreuoVRvGf0a9AhK0ra/IR3EMdewWHe msy4j4uXbo2mCzFS0USbOury7NGEu6AYwWrO3Pi1CM7W2TBDPU7BKyJ6vgjJYQeFLX vyDovPuRQji7/4DhbqzpUcDJlxztGR5qDSa5O711JsnwXEkTaVMjnOpAf/jukj5pcm RlOOxe1djo70tVsWox/2JvVkaWMEup04LxJF/C+uwOyWedYoYPYq/fp7p2WqrRaTFJ aPmp5vGTOsdmJId5ia6WDKnRgs6LdQBpdgUxxGXbYv4udrYCK2dXTodxPhfGgyNtmc njiet83lDu1zQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oleg Nesterov , Dylan Hatch , "Eric W . Biederman" , Andrew Morton , Sasha Levin Subject: [PATCH 5.15 67/76] exit: wait_task_zombie: kill the no longer necessary spin_lock_irq(siglock) Date: Wed, 13 Mar 2024 12:42:14 -0400 Message-ID: <20240313164223.615640-68-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Oleg Nesterov [ Upstream commit c1be35a16b2f1fe21f4f26f9de030ad6eaaf6a25 ] After the recent changes nobody use siglock to read the values protected by stats_lock, we can kill spin_lock_irq(¤t->sighand->siglock) and update the comment. With this patch only __exit_signal() and thread_group_start_cputime() take stats_lock under siglock. Link: https://lkml.kernel.org/r/20240123153359.GA21866@redhat.com Signed-off-by: Oleg Nesterov Signed-off-by: Dylan Hatch Cc: Eric W. Biederman Cc: Signed-off-by: Andrew Morton Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- kernel/exit.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index e982111c489a9..85baaa31b2997 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -1120,17 +1120,14 @@ static int wait_task_zombie(struct wait_opts *wo, s= truct task_struct *p) * and nobody can change them. * * psig->stats_lock also protects us from our sub-threads - * which can reap other children at the same time. Until - * we change k_getrusage()-like users to rely on this lock - * we have to take ->siglock as well. + * which can reap other children at the same time. * * We use thread_group_cputime_adjusted() to get times for * the thread group, which consolidates times for all threads * in the group including the group leader. */ thread_group_cputime_adjusted(p, &tgutime, &tgstime); - spin_lock_irq(¤t->sighand->siglock); - write_seqlock(&psig->stats_lock); + write_seqlock_irq(&psig->stats_lock); psig->cutime +=3D tgutime + sig->cutime; psig->cstime +=3D tgstime + sig->cstime; psig->cgtime +=3D task_gtime(p) + sig->gtime + sig->cgtime; @@ -1153,8 +1150,7 @@ static int wait_task_zombie(struct wait_opts *wo, str= uct task_struct *p) psig->cmaxrss =3D maxrss; task_io_accounting_add(&psig->ioac, &p->ioac); task_io_accounting_add(&psig->ioac, &sig->ioac); - write_sequnlock(&psig->stats_lock); - spin_unlock_irq(¤t->sighand->siglock); + write_sequnlock_irq(&psig->stats_lock); } =20 if (wo->wo_rusage) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B773F14CADE; Wed, 13 Mar 2024 16:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348222; cv=none; b=d9YEQIfUHNfk/pPxYRxOcoxs6VJjLSk7tTvmUqZDsGRqSumZSLZ5X7idTrZtvW+FHaUC9arZBZCqiqUq1n6CQoeLBKyzz+dnnnFX6opfJswnY0N4qH5Ce3NKO06yS+YyfTIltRi17PFHsIAxz8gxZM7z17jWIeEGuI6GAyA9HJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348222; c=relaxed/simple; bh=6dxmNiCCcPORI/dA+Z0VsqZXbOzR01ZPsdvJA7HTG90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mo/aR2mZjy57lWLmlaVYWUd9Yn0kmZEUNtml90AEJXYiZQNiZFzS/dAbAjkIV8dmjmeM60oNWh+vuBOjAZ5WTTCIHDe38lUlWplM0wL4AL3vIrOB3rcb6IPKvcfE+d3jwkU3cMz/SH8l8VMgtN7jX1qNSO02jwwpCNKtrNhek4g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vEjDxbOk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vEjDxbOk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87382C433F1; Wed, 13 Mar 2024 16:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348222; bh=6dxmNiCCcPORI/dA+Z0VsqZXbOzR01ZPsdvJA7HTG90=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vEjDxbOk4ASmaihi2yzCB60hXT5KNYcUWen59yS+PI2ff2IFp6Q2PxKjCDb025VBc kTbUYnFZnBLAh8YRBovwC3ACQaTEzjIqkPe52sIE/gQJwpKj7/hJvBdZpsQN6zpUi2 jjwM5Mp1xctFeScwM67WTjTlu0AEXHMWL4Taa6Joi5ouKL2DzAdv/+BgCzv1F/M3vN a4iI+AzFy1p2uiXnDy9eWqQH/0PjhWZ5HRr2/v/pKkmKvOvu+/cta4Ze1B2AZ9HRQ5 5B0wrZhcZL83+fQrryy+kFK0Nkz7GOHNJU7G8rqFwTsSff3DnOAQMKFljVBlYTGtsp psmvuy9TSPIWg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wan Jiabing , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 68/76] ALSA: usb-audio: Fix wrong kfree issue in snd_usb_endpoint_free_all Date: Wed, 13 Mar 2024 12:42:15 -0400 Message-ID: <20240313164223.615640-69-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Wan Jiabing [ Upstream commit 03a8b0df757f1beb21ba1626e23ca7412e48b525 ] Fix following coccicheck error: ./sound/usb/endpoint.c:1671:8-10: ERROR: reference preceded by free on line= 1671. Here should be 'cp' rather than 'ip'. Fixes: c11117b634f4 ("ALSA: usb-audio: Refcount multiple accesses on the si= ngle clock") Signed-off-by: Wan Jiabing Link: https://lore.kernel.org/r/20220518021617.10114-1-wanjiabing@vivo.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/endpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 26af199f3836e..8188113ca83f2 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -1720,7 +1720,7 @@ void snd_usb_endpoint_free_all(struct snd_usb_audio *= chip) kfree(ip); =20 list_for_each_entry_safe(cp, cn, &chip->clock_ref_list, list) - kfree(ip); + kfree(cp); } =20 /* --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8B5A14D444; Wed, 13 Mar 2024 16:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348224; cv=none; b=i1bwl8rQ+xL/NyawDqB7BmRfUVGfP/MeYclsYtsA8jA94hMLZeD6tim21EoyUafPWMCTWhBMj4sXM71E+IlIEgKZUNVjCcCcYkNzDHJSsQPgYm3BXcnQ/he25XPXE/f5ekDBQCuOyPv91/GLGGkytfI7qO2htN5Q5lE+tcZPJtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348224; c=relaxed/simple; bh=s8SnMuojUTopw8S4/MfbR5xT0i36Z9rfYwSR7D7R1wQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OJVCcQX7vF58WPczAyWLPnSaczW2WGmobHO8BSp0SRqO4r+3aQ+b9+lshMW0LeREN8fnMwGxSyF7XO9D8GbMLNP2dUbmzIIIRh/RAD2FcV/sRKKhPpCYTh3Y1rXcdqC14Cnzb6sh1efRxE9ZMbQawJ3Pb9pGBoSt9ik228B3mtA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EPt16zyY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EPt16zyY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90B2FC43390; Wed, 13 Mar 2024 16:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348223; bh=s8SnMuojUTopw8S4/MfbR5xT0i36Z9rfYwSR7D7R1wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EPt16zyY9P3F5r+J/f5LStTkzPfGqXmqxcl/XtMlqdyza3F/waI+D3vm02Yu1WUwR 21KZHb/TQx39szIm64bYBK9u8wIDzY2USsUyInm9nXmFVSBDsTRoMiA7dCL7ajJHPo dfHMCg+qMHI/yDlL6uvDuIsl7mxqpdzrOvc4pfjm9pQ6fBm6LNPNcA72JVp6D/B5Kw PI1GHisl53cWpc5nYdLHaWeRi2Pvcb9CFTG1m0KTT7BfaRp+BtMwvR9svhFAS4+Wla bTX4Zl9aSk07ERwAXSBy54F2uK/7UP80yaRWvzJhQXWsG2MSKSClltpVPb7T7Y+dBL TR4Ut6ZYbT6+A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jaroslav Kysela , Dan Carpenter , Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 69/76] ALSA: usb-audio: Always initialize fixed_rate in snd_usb_find_implicit_fb_sync_format() Date: Wed, 13 Mar 2024 12:42:16 -0400 Message-ID: <20240313164223.615640-70-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jaroslav Kysela [ Upstream commit 291e9da91403e0e628d7692b5ed505100e7b7706 ] Handle the fallback code path, too. Fixes: fd28941cff1c ("ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Qua= ntum810 Wireless") BugLink: https://lore.kernel.org/alsa-devel/Y7frf3N%2FxzvESEsN@kili/ Reported-by: Dan Carpenter Cc: Signed-off-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20230109141133.335543-1-perex@perex.cz Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/implicit.c | 3 ++- sound/usb/pcm.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c index 41ac7185b42b6..4727043fd7458 100644 --- a/sound/usb/implicit.c +++ b/sound/usb/implicit.c @@ -471,7 +471,7 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_aud= io *chip, subs =3D find_matching_substream(chip, stream, target->sync_ep, target->fmt_type); if (!subs) - return sync_fmt; + goto end; =20 high_score =3D 0; list_for_each_entry(fp, &subs->fmt_list, list) { @@ -485,6 +485,7 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_aud= io *chip, } } =20 + end: if (fixed_rate) *fixed_rate =3D snd_usb_pcm_has_fixed_rate(subs); return sync_fmt; diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 962a6e1bc70c8..580e2649641e4 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -163,6 +163,8 @@ bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substrea= m *subs) struct snd_usb_audio *chip =3D subs->stream->chip; int rate =3D -1; =20 + if (!subs) + return false; if (!(chip->quirk_flags & QUIRK_FLAG_FIXED_RATE)) return false; list_for_each_entry(fp, &subs->fmt_list, list) { --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84C0914D452; Wed, 13 Mar 2024 16:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348224; cv=none; b=OLk0Zgs2P+VcYOj0q1vXDNakfDaIBAV456IuXn9XjS99fdB+qyGANBntrVitcvnFynKPerD+Lj+xLxXbmLjD1XXTR/v+dDchKKMqXH/h/IvezTqxF5jN32MbiH1G6oaAl4AMAc/sE7Y4DQhkqbSHF47ck7hNL12DNtjH/q11N3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348224; c=relaxed/simple; bh=9HIXSwzU4M5cUYpKlNYWQPtrx4F5qK1+uj3SlIT4wDI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rIoYCP9vDYoJhAldGlLuHJK0uGEd+IcXZzSMqf7/w1h40gKhZ65fuFusjOWzP0Z3irUbWgiZQMdXRCJKqhLtz+pKOKveTVBMCWddqu2c/Woj589ataPfTTlnLnqPKmwxFlVjdFAdzd7W/L6SuLHXH/DxLJKfF7nrDKYubjU/0zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pQXZDyKX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pQXZDyKX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B20E6C43394; Wed, 13 Mar 2024 16:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348224; bh=9HIXSwzU4M5cUYpKlNYWQPtrx4F5qK1+uj3SlIT4wDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pQXZDyKXJ+mGNYDJpLfi8enj0gO0Z7cbOjwiSeLJRtKsXl8VHUc9YqF/N4GzQuGt1 038qLWwD++tcdvX54L5cb77/+9v84bFEwMRgF1R4T3J0ThusclxyZfKoe18/OzbICf wp6MwYiVW0TaaDUv4oe4DwHKJX3Dy1xmnB3P/l22MUfoKe+M06U7+V8O49pLDb7GKa YHYzOg4qANVBUs65iOX8Sh6y5lQ0EHypdmaNqblQt6F6xWZkzl1OLCNCtXf5MOghD9 xa1bQUWmFpCr01WxtivyYMp0l7XSjdzWfKnTm63eEMzffjFxR27i5X425TfbkGbdly /qGIh8Zwn6s3Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 70/76] ALSA: usb-audio: Add FIXED_RATE quirk for JBL Quantum610 Wireless Date: Wed, 13 Mar 2024 12:42:17 -0400 Message-ID: <20240313164223.615640-71-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit dfd5fe19db7dc7006642f8109ee8965e5d031897 ] JBL Quantum610 Wireless (0ecb:205c) requires the same workaround that was used for JBL Quantum810 for limiting the sample rate. Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D216798 Link: https://lore.kernel.org/r/20230118165947.22317-1-tiwai@suse.de Signed-off-by: Takashi Iwai Stable-dep-of: 668abe6dc7b6 ("ALSA: usb-audio: Sort quirk table entries") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 6cd7f77779159..3073570beb3e2 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1896,6 +1896,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_GENERIC_IMPLICIT_FB), DEVICE_FLG(0x0525, 0xa4ad, /* Hamedal C20 usb camero */ QUIRK_FLAG_IFACE_SKIP_CLOSE), + DEVICE_FLG(0x0ecb, 0x205c, /* JBL Quantum610 Wireless */ + QUIRK_FLAG_FIXED_RATE), DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */ QUIRK_FLAG_FIXED_RATE), DEVICE_FLG(0x1bcf, 0x2283, /* NexiGo N930AF FHD Webcam */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91C3914E2C9; Wed, 13 Mar 2024 16:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348225; cv=none; b=i479BvO+If8XGU15UdRDbToOMUY3TrqxoOMRj1SJZOdy/3brUQbQsRlLpfalZfTNEoUuOHYEBBsmL1gZ+BAWWM4CFjjuoRSPdSJ4D5oBzQf7zT0BpId8DBBalf/JOOGLHV5IFzBgro3OHvbpMXjEhXyoAnF/h9Ne2ggeSUFjub0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348225; c=relaxed/simple; bh=LUfg0XTepmWmbWbCCa61wEGCuowP79X8chJrlyHlpsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SHzQUCWWhl4YazXdmk8UrH25cLdR0yABQ8/tXXRnQBw7XKiF0xcO1+++UA9PJwJZ5HVCwtgDHBEq/zJexmbw+7WVr8KNAf6J5VfgclNNm9i1pQndYiDLuIYVLIiKvbfk9C7mbeln0akmPbSYyDT1eD8m3gsGWdrUhtBlrwzXiW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XxeZgdjf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XxeZgdjf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 976C7C43390; Wed, 13 Mar 2024 16:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348225; bh=LUfg0XTepmWmbWbCCa61wEGCuowP79X8chJrlyHlpsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XxeZgdjft12zwKxMyBx45Arl3mKMr9yag7qQQAb2thIVu0F4/TNLSNw79gzmTxtZE EY/vUicWnQ4eo9LBVuORzqqq3o9hL4hoVHOt2otfmAK5UvGXpv3ABUJ52hJxkuWcAS NfkIQcj3jI7jLAFW2dh8Gx2OmuyUrfxoaZ/5++0XQIZQe6voqA0lrMmWNFqbg4o8Jz Hj12vRFR46+i3Tlv7msZdk/CsQuzzoGLWpKVAvjr62YNFyGla8ymTpM7gHPbXJwyDH AstV0oBudDHgwZTrTRHJq6cZRghzLVLhQjMxTaY4W58CGb4fZn+/q+cgyw0ecf6fxN jyohBb1E5yyvQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , Sasha Levin Subject: [PATCH 5.15 71/76] ALSA: usb-audio: Sort quirk table entries Date: Wed, 13 Mar 2024 12:42:18 -0400 Message-ID: <20240313164223.615640-72-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Takashi Iwai [ Upstream commit 668abe6dc7b61941fa5c724c06797efb0b87f070 ] The quirk table entries should be put in the USB ID order, but some entries have been put in random places. Re-sort them. Fixes: bf990c102319 ("ALSA: usb-audio: add quirk to fix Hamedal C20 disconn= ect issue") Fixes: fd28941cff1c ("ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Qua= ntum810 Wireless") Fixes: dfd5fe19db7d ("ALSA: usb-audio: Add FIXED_RATE quirk for JBL Quantum= 610 Wireless") Fixes: 4a63e68a2951 ("ALSA: usb-audio: Fix microphone sound on Nexigo webca= m.") Fixes: 7822baa844a8 ("ALSA: usb-audio: add quirk for RODE NT-USB+") Fixes: 4fb7c24f69c4 ("ALSA: usb-audio: Add quirk for Fiero SC-01") Fixes: 2307a0e1ca0b ("ALSA: usb-audio: Add quirk for Fiero SC-01 (fw v1.0.0= )") Link: https://lore.kernel.org/r/20240124155307.16996-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- sound/usb/quirks.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c index 3073570beb3e2..1226ce5d5a304 100644 --- a/sound/usb/quirks.c +++ b/sound/usb/quirks.c @@ -1765,6 +1765,8 @@ static const struct usb_audio_quirk_flags_table quirk= _flags_table[] =3D { QUIRK_FLAG_GET_SAMPLE_RATE), DEVICE_FLG(0x04e8, 0xa051, /* Samsung USBC Headset (AKG) */ QUIRK_FLAG_SKIP_CLOCK_SELECTOR | QUIRK_FLAG_CTL_MSG_DELAY_5M), + DEVICE_FLG(0x0525, 0xa4ad, /* Hamedal C20 usb camero */ + QUIRK_FLAG_IFACE_SKIP_CLOSE), DEVICE_FLG(0x054c, 0x0b8c, /* Sony WALKMAN NW-A45 DAC */ QUIRK_FLAG_SET_IFACE_FIRST), DEVICE_FLG(0x0556, 0x0014, /* Phoenix Audio TMX320VC */ @@ -1808,8 +1810,14 @@ static const struct usb_audio_quirk_flags_table quir= k_flags_table[] =3D { QUIRK_FLAG_CTL_MSG_DELAY_1M), DEVICE_FLG(0x0b0e, 0x0349, /* Jabra 550a */ QUIRK_FLAG_CTL_MSG_DELAY_1M), + DEVICE_FLG(0x0ecb, 0x205c, /* JBL Quantum610 Wireless */ + QUIRK_FLAG_FIXED_RATE), + DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */ + QUIRK_FLAG_FIXED_RATE), DEVICE_FLG(0x0fd9, 0x0008, /* Hauppauge HVR-950Q */ QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), + DEVICE_FLG(0x1224, 0x2a25, /* Jieli Technology USB PHY 2.0 */ + QUIRK_FLAG_GET_SAMPLE_RATE), DEVICE_FLG(0x1395, 0x740a, /* Sennheiser DECT */ QUIRK_FLAG_GET_SAMPLE_RATE), DEVICE_FLG(0x1397, 0x0507, /* Behringer UMC202HD */ @@ -1840,6 +1848,10 @@ static const struct usb_audio_quirk_flags_table quir= k_flags_table[] =3D { QUIRK_FLAG_ITF_USB_DSD_DAC | QUIRK_FLAG_CTL_MSG_DELAY), DEVICE_FLG(0x1901, 0x0191, /* GE B850V3 CP2114 audio interface */ QUIRK_FLAG_GET_SAMPLE_RATE), + DEVICE_FLG(0x19f7, 0x0035, /* RODE NT-USB+ */ + QUIRK_FLAG_GET_SAMPLE_RATE), + DEVICE_FLG(0x1bcf, 0x2283, /* NexiGo N930AF FHD Webcam */ + QUIRK_FLAG_GET_SAMPLE_RATE), DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */ QUIRK_FLAG_SHARE_MEDIA_DEVICE | QUIRK_FLAG_ALIGN_TRANSFER), DEVICE_FLG(0x2040, 0x7201, /* Hauppauge HVR-950Q-MXL */ @@ -1878,6 +1890,12 @@ static const struct usb_audio_quirk_flags_table quir= k_flags_table[] =3D { QUIRK_FLAG_IGNORE_CTL_ERROR), DEVICE_FLG(0x2912, 0x30c8, /* Audioengine D1 */ QUIRK_FLAG_GET_SAMPLE_RATE), + DEVICE_FLG(0x2b53, 0x0023, /* Fiero SC-01 (firmware v1.0.0 @ 48 kHz) */ + QUIRK_FLAG_GENERIC_IMPLICIT_FB), + DEVICE_FLG(0x2b53, 0x0024, /* Fiero SC-01 (firmware v1.0.0 @ 96 kHz) */ + QUIRK_FLAG_GENERIC_IMPLICIT_FB), + DEVICE_FLG(0x2b53, 0x0031, /* Fiero SC-01 (firmware v1.1.0) */ + QUIRK_FLAG_GENERIC_IMPLICIT_FB), DEVICE_FLG(0x30be, 0x0101, /* Schiit Hel */ QUIRK_FLAG_IGNORE_CTL_ERROR), DEVICE_FLG(0x413c, 0xa506, /* Dell AE515 sound bar */ @@ -1886,24 +1904,6 @@ static const struct usb_audio_quirk_flags_table quir= k_flags_table[] =3D { QUIRK_FLAG_ALIGN_TRANSFER), DEVICE_FLG(0x534d, 0x2109, /* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER), - DEVICE_FLG(0x1224, 0x2a25, /* Jieli Technology USB PHY 2.0 */ - QUIRK_FLAG_GET_SAMPLE_RATE), - DEVICE_FLG(0x2b53, 0x0023, /* Fiero SC-01 (firmware v1.0.0 @ 48 kHz) */ - QUIRK_FLAG_GENERIC_IMPLICIT_FB), - DEVICE_FLG(0x2b53, 0x0024, /* Fiero SC-01 (firmware v1.0.0 @ 96 kHz) */ - QUIRK_FLAG_GENERIC_IMPLICIT_FB), - DEVICE_FLG(0x2b53, 0x0031, /* Fiero SC-01 (firmware v1.1.0) */ - QUIRK_FLAG_GENERIC_IMPLICIT_FB), - DEVICE_FLG(0x0525, 0xa4ad, /* Hamedal C20 usb camero */ - QUIRK_FLAG_IFACE_SKIP_CLOSE), - DEVICE_FLG(0x0ecb, 0x205c, /* JBL Quantum610 Wireless */ - QUIRK_FLAG_FIXED_RATE), - DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */ - QUIRK_FLAG_FIXED_RATE), - DEVICE_FLG(0x1bcf, 0x2283, /* NexiGo N930AF FHD Webcam */ - QUIRK_FLAG_GET_SAMPLE_RATE), - DEVICE_FLG(0x19f7, 0x0035, /* RODE NT-USB+ */ - QUIRK_FLAG_GET_SAMPLE_RATE), =20 /* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */ --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A2C514E2EA; Wed, 13 Mar 2024 16:43:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348226; cv=none; b=dYffSQ9MqNvZEiE2fY96cPYPfyCEJjp09Qphzk3BsXWuZ+fr62SQM5qo3yjc28n35hkRGvJs7/2oddKxySmBXyzyaO/ChksAITyGyXkt2W0x011wLaBXNZ28UG+1x1eMUS1Nzdfxt6ax02q8l17VOHxm9ulgA/niqaeD3Fl+F58= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348226; c=relaxed/simple; bh=18U3/jqedjbpaw8g2u8F62gwbxSW7wd9fOj3ASax9Zg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lRhsNs8+rcl0fTUHD+roJ4PJkG0kbW8U87q3pnAgAzl4z5wloB5yOiqOouvLmn8t5chjZ3XYm8w3S0oljs5Z7+Bb+BSACRNxoJAkDtiMmoD+v9eMaU154wCGOSUbOu+2m/alWbcKBR4odJRKVS86xZ9/XayFUOK4J8p1maez7Js= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sldq3OI/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sldq3OI/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79794C43399; Wed, 13 Mar 2024 16:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348226; bh=18U3/jqedjbpaw8g2u8F62gwbxSW7wd9fOj3ASax9Zg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sldq3OI/FKSMaFQBlRHDZLOWGk/GtliIdpQnrxcZtfXJ+WDLLgtub8gubx3Hvim5J eXM5gUsPUdeaSpDlKUnxzdrohMK3z7a0TGX9MjdMiCXMpnfdpozcYF7zU58+4fX7wx nZDkdGKGkwBYkmhtw0JdZk7TKHyW6TlV+zCP+RJIZiadSUAzFKWYmsv1PeHlY03QIt thpwCbWwfMGvEYCX7x3fpiEPYUHJ+jMm2OmBgZor6cDHbNXp1WJ1fFPMYnouv8hFnl slCpdKFo8sbdtcHTXkLFan5ji/fJNYRZG5zPqeZkUiGMfEodzGITTC/TEsTIK46Q5g VYu7M3KdhpqPQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ansuel Smith , Mark Brown , Sasha Levin Subject: [PATCH 5.15 72/76] regmap: allow to define reg_update_bits for no bus configuration Date: Wed, 13 Mar 2024 12:42:19 -0400 Message-ID: <20240313164223.615640-73-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ansuel Smith [ Upstream commit 02d6fdecb9c38de19065f6bed8d5214556fd061d ] Some device requires a special handling for reg_update_bits and can't use the normal regmap read write logic. An example is when locking is handled by the device and rmw operations requires to do atomic operations. Allow to declare a dedicated function in regmap_config for reg_update_bits in no bus configuration. Signed-off-by: Ansuel Smith Link: https://lore.kernel.org/r/20211104150040.1260-1-ansuelsmth@gmail.com Signed-off-by: Mark Brown Stable-dep-of: 3f42b142ea11 ("serial: max310x: fix IO data corruption in ba= tched operations") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/base/regmap/regmap.c | 1 + include/linux/regmap.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 7621b54975b57..ab924127e0aef 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -877,6 +877,7 @@ struct regmap *__regmap_init(struct device *dev, if (!bus) { map->reg_read =3D config->reg_read; map->reg_write =3D config->reg_write; + map->reg_update_bits =3D config->reg_update_bits; =20 map->defer_caching =3D false; goto skip_format_initialization; diff --git a/include/linux/regmap.h b/include/linux/regmap.h index e3c9a25a853a8..22652e5fbc380 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -290,6 +290,11 @@ typedef void (*regmap_unlock)(void *); * read operation on a bus such as SPI, I2C, etc. Most of the * devices do not need this. * @reg_write: Same as above for writing. + * @reg_update_bits: Optional callback that if filled will be used to perf= orm + * all the update_bits(rmw) operation. Should only be provided + * if the function require special handling with lock and reg + * handling and the operation cannot be represented as a simple + * update_bits operation on a bus such as SPI, I2C, etc. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex * to perform locking. This field is ignored if custom lock/unlock * functions are used (see fields lock/unlock of struct regmap_con= fig). @@ -372,6 +377,8 @@ struct regmap_config { =20 int (*reg_read)(void *context, unsigned int reg, unsigned int *val); int (*reg_write)(void *context, unsigned int reg, unsigned int val); + int (*reg_update_bits)(void *context, unsigned int reg, + unsigned int mask, unsigned int val); =20 bool fast_io; =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEC5714EA31; Wed, 13 Mar 2024 16:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348228; cv=none; b=lQVziIiEON+Kr0KQJy+oTKEooW00JYRuna9beJgoHCJE9Z9UllMX9jQUGg0Wt3T/0ABrAGBwXqPPDP+B+tygI4MBvaxA+vqpEAaXR5jP9sUUxZKK36KR0QYz8ufG7j2LGg77xIyt1ioYnK0CeqqQAvzIj6X/jxPgWKt4Ngt79Pk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348228; c=relaxed/simple; bh=51XAzNGg8gzGapu9s6Ag8EJfxhvD/5hMAB4MTW0nNPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sdZTZ2pJeZlgcAOZcCdY20HsRIFcystaFc0iLuEzLSTTsFHsOVk0A2uKlzSczGo8mzAfP5spKPVHL8FDycr5iI7sfTZL49lXDbm59pTRCAEifUSo+CfpqYydvS5AmnVkQI3cvledIfDBkDQul8SX1YhN2URh6cQiKm9s9vzCz+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bjwnR2cS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bjwnR2cS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8045BC43394; Wed, 13 Mar 2024 16:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348227; bh=51XAzNGg8gzGapu9s6Ag8EJfxhvD/5hMAB4MTW0nNPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bjwnR2cSgpShXjh+pSVCwUpakzgaVvI+J/i8vaxWoq9Im9DpbQbnW6S8RKbAgOf6s Ta3LM7ZZvTcqdjPLjgZDILBp+DnVQ7loE2IOjC8p5SAsLRE4h54L5u8mUM96L9Y+ub /zYdY1eY1993+LWPIBb+oV2ekWkDcdnH+WJEzRcu/QyIDXp8I5JLsmKtcETkVemGgs EshLP4ufqo1CZZow3ZeM0/TjMRa+ZcdZTrLR64zBhRp2Zm4zAVSi/64SprRvn/Dj9X Vng3td0G0BNDyHOjTZbu2CYUBEjl+AhT4DV0908YKAyNU/lcmtDN6w5ip2h7wkNNMl jXCpqh1yRdawA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marek Vasut , Jagan Teki , Mark Brown , Maxime Ripard , Robert Foss , Sam Ravnborg , Thomas Zimmermann , Sasha Levin Subject: [PATCH 5.15 73/76] regmap: Add bulk read/write callbacks into regmap_config Date: Wed, 13 Mar 2024 12:42:20 -0400 Message-ID: <20240313164223.615640-74-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Marek Vasut [ Upstream commit d77e745613680c54708470402e2b623dcd769681 ] Currently the regmap_config structure only allows the user to implement single element register read/write using .reg_read/.reg_write callbacks. The regmap_bus already implements bulk counterparts of both, and is being misused as a workaround for the missing bulk read/write callbacks in regmap_config by a couple of drivers. To stop this misuse, add the bulk read/write callbacks to regmap_config and call them from the regmap core code. Signed-off-by: Marek Vasut Cc: Jagan Teki Cc: Mark Brown Cc: Maxime Ripard Cc: Robert Foss Cc: Sam Ravnborg Cc: Thomas Zimmermann To: dri-devel@lists.freedesktop.org Link: https://lore.kernel.org/r/20220430025145.640305-1-marex@denx.de Signed-off-by: Mark Brown Stable-dep-of: 3f42b142ea11 ("serial: max310x: fix IO data corruption in ba= tched operations") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/base/regmap/internal.h | 4 ++ drivers/base/regmap/regmap.c | 76 ++++++++++++++++++---------------- include/linux/regmap.h | 12 ++++++ 3 files changed, 56 insertions(+), 36 deletions(-) diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index b1905916f7af8..93e028445dade 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h @@ -108,6 +108,10 @@ struct regmap { int (*reg_write)(void *context, unsigned int reg, unsigned int val); int (*reg_update_bits)(void *context, unsigned int reg, unsigned int mask, unsigned int val); + /* Bulk read/write */ + int (*read)(void *context, const void *reg_buf, size_t reg_size, + void *val_buf, size_t val_size); + int (*write)(void *context, const void *data, size_t count); =20 bool defer_caching; =20 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index ab924127e0aef..6adb345866610 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -835,12 +835,15 @@ struct regmap *__regmap_init(struct device *dev, map->reg_stride_order =3D ilog2(map->reg_stride); else map->reg_stride_order =3D -1; - map->use_single_read =3D config->use_single_read || !bus || !bus->read; - map->use_single_write =3D config->use_single_write || !bus || !bus->write; - map->can_multi_write =3D config->can_multi_write && bus && bus->write; + map->use_single_read =3D config->use_single_read || !(config->read || (bu= s && bus->read)); + map->use_single_write =3D config->use_single_write || !(config->write || = (bus && bus->write)); + map->can_multi_write =3D config->can_multi_write && (config->write || (bu= s && bus->write)); if (bus) { map->max_raw_read =3D bus->max_raw_read; map->max_raw_write =3D bus->max_raw_write; + } else if (config->max_raw_read && config->max_raw_write) { + map->max_raw_read =3D config->max_raw_read; + map->max_raw_write =3D config->max_raw_write; } map->dev =3D dev; map->bus =3D bus; @@ -874,7 +877,16 @@ struct regmap *__regmap_init(struct device *dev, map->read_flag_mask =3D bus->read_flag_mask; } =20 - if (!bus) { + if (config && config->read && config->write) { + map->reg_read =3D _regmap_bus_read; + + /* Bulk read/write */ + map->read =3D config->read; + map->write =3D config->write; + + reg_endian =3D REGMAP_ENDIAN_NATIVE; + val_endian =3D REGMAP_ENDIAN_NATIVE; + } else if (!bus) { map->reg_read =3D config->reg_read; map->reg_write =3D config->reg_write; map->reg_update_bits =3D config->reg_update_bits; @@ -891,10 +903,13 @@ struct regmap *__regmap_init(struct device *dev, } else { map->reg_read =3D _regmap_bus_read; map->reg_update_bits =3D bus->reg_update_bits; - } + /* Bulk read/write */ + map->read =3D bus->read; + map->write =3D bus->write; =20 - reg_endian =3D regmap_get_reg_endian(bus, config); - val_endian =3D regmap_get_val_endian(dev, bus, config); + reg_endian =3D regmap_get_reg_endian(bus, config); + val_endian =3D regmap_get_val_endian(dev, bus, config); + } =20 switch (config->reg_bits + map->reg_shift) { case 2: @@ -1668,8 +1683,6 @@ static int _regmap_raw_write_impl(struct regmap *map,= unsigned int reg, size_t len; int i; =20 - WARN_ON(!map->bus); - /* Check for unwritable or noinc registers in range * before we start */ @@ -1751,7 +1764,7 @@ static int _regmap_raw_write_impl(struct regmap *map,= unsigned int reg, val =3D work_val; } =20 - if (map->async && map->bus->async_write) { + if (map->async && map->bus && map->bus->async_write) { struct regmap_async *async; =20 trace_regmap_async_write_start(map, reg, val_len); @@ -1819,10 +1832,10 @@ static int _regmap_raw_write_impl(struct regmap *ma= p, unsigned int reg, * write. */ if (val =3D=3D work_val) - ret =3D map->bus->write(map->bus_context, map->work_buf, - map->format.reg_bytes + - map->format.pad_bytes + - val_len); + ret =3D map->write(map->bus_context, map->work_buf, + map->format.reg_bytes + + map->format.pad_bytes + + val_len); else if (map->bus->gather_write) ret =3D map->bus->gather_write(map->bus_context, map->work_buf, map->format.reg_bytes + @@ -1841,7 +1854,7 @@ static int _regmap_raw_write_impl(struct regmap *map,= unsigned int reg, memcpy(buf, map->work_buf, map->format.reg_bytes); memcpy(buf + map->format.reg_bytes + map->format.pad_bytes, val, val_len); - ret =3D map->bus->write(map->bus_context, buf, len); + ret =3D map->write(map->bus_context, buf, len); =20 kfree(buf); } else if (ret !=3D 0 && !map->cache_bypass && map->format.parse_val) { @@ -1898,7 +1911,7 @@ static int _regmap_bus_formatted_write(void *context,= unsigned int reg, struct regmap_range_node *range; struct regmap *map =3D context; =20 - WARN_ON(!map->bus || !map->format.format_write); + WARN_ON(!map->format.format_write); =20 range =3D _regmap_range_lookup(map, reg); if (range) { @@ -1911,8 +1924,7 @@ static int _regmap_bus_formatted_write(void *context,= unsigned int reg, =20 trace_regmap_hw_write_start(map, reg, 1); =20 - ret =3D map->bus->write(map->bus_context, map->work_buf, - map->format.buf_size); + ret =3D map->write(map->bus_context, map->work_buf, map->format.buf_size); =20 trace_regmap_hw_write_done(map, reg, 1); =20 @@ -1932,7 +1944,7 @@ static int _regmap_bus_raw_write(void *context, unsig= ned int reg, { struct regmap *map =3D context; =20 - WARN_ON(!map->bus || !map->format.format_val); + WARN_ON(!map->format.format_val); =20 map->format.format_val(map->work_buf + map->format.reg_bytes + map->format.pad_bytes, val, 0); @@ -1946,7 +1958,7 @@ static int _regmap_bus_raw_write(void *context, unsig= ned int reg, =20 static inline void *_regmap_map_get_context(struct regmap *map) { - return (map->bus) ? map : map->bus_context; + return (map->bus || (!map->bus && map->read)) ? map : map->bus_context; } =20 int _regmap_write(struct regmap *map, unsigned int reg, @@ -2356,7 +2368,7 @@ static int _regmap_raw_multi_reg_write(struct regmap = *map, u8 =3D buf; *u8 |=3D map->write_flag_mask; =20 - ret =3D map->bus->write(map->bus_context, buf, len); + ret =3D map->write(map->bus_context, buf, len); =20 kfree(buf); =20 @@ -2662,9 +2674,7 @@ static int _regmap_raw_read(struct regmap *map, unsig= ned int reg, void *val, struct regmap_range_node *range; int ret; =20 - WARN_ON(!map->bus); - - if (!map->bus || !map->bus->read) + if (!map->read) return -EINVAL; =20 range =3D _regmap_range_lookup(map, reg); @@ -2680,9 +2690,9 @@ static int _regmap_raw_read(struct regmap *map, unsig= ned int reg, void *val, map->read_flag_mask); trace_regmap_hw_read_start(map, reg, val_len / map->format.val_bytes); =20 - ret =3D map->bus->read(map->bus_context, map->work_buf, - map->format.reg_bytes + map->format.pad_bytes, - val, val_len); + ret =3D map->read(map->bus_context, map->work_buf, + map->format.reg_bytes + map->format.pad_bytes, + val, val_len); =20 trace_regmap_hw_read_done(map, reg, val_len / map->format.val_bytes); =20 @@ -2793,8 +2803,6 @@ int regmap_raw_read(struct regmap *map, unsigned int = reg, void *val, unsigned int v; int ret, i; =20 - if (!map->bus) - return -EINVAL; if (val_len % map->format.val_bytes) return -EINVAL; if (!IS_ALIGNED(reg, map->reg_stride)) @@ -2809,7 +2817,7 @@ int regmap_raw_read(struct regmap *map, unsigned int = reg, void *val, size_t chunk_count, chunk_bytes; size_t chunk_regs =3D val_count; =20 - if (!map->bus->read) { + if (!map->read) { ret =3D -ENOTSUPP; goto out; } @@ -2869,7 +2877,7 @@ EXPORT_SYMBOL_GPL(regmap_raw_read); * @val: Pointer to data buffer * @val_len: Length of output buffer in bytes. * - * The regmap API usually assumes that bulk bus read operations will read a + * The regmap API usually assumes that bulk read operations will read a * range of registers. Some devices have certain registers for which a read * operation read will read from an internal FIFO. * @@ -2887,10 +2895,6 @@ int regmap_noinc_read(struct regmap *map, unsigned i= nt reg, size_t read_len; int ret; =20 - if (!map->bus) - return -EINVAL; - if (!map->bus->read) - return -ENOTSUPP; if (val_len % map->format.val_bytes) return -EINVAL; if (!IS_ALIGNED(reg, map->reg_stride)) @@ -3004,7 +3008,7 @@ int regmap_bulk_read(struct regmap *map, unsigned int= reg, void *val, if (val_count =3D=3D 0) return -EINVAL; =20 - if (map->bus && map->format.parse_inplace && (vol || map->cache_type =3D= =3D REGCACHE_NONE)) { + if (map->format.parse_inplace && (vol || map->cache_type =3D=3D REGCACHE_= NONE)) { ret =3D regmap_raw_read(map, reg, val, val_bytes * val_count); if (ret !=3D 0) return ret; diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 22652e5fbc380..f74e543fadc07 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -295,6 +295,12 @@ typedef void (*regmap_unlock)(void *); * if the function require special handling with lock and reg * handling and the operation cannot be represented as a simple * update_bits operation on a bus such as SPI, I2C, etc. + * @read: Optional callback that if filled will be used to perform all the + * bulk reads from the registers. Data is returned in the buffer us= ed + * to transmit data. + * @write: Same as above for writing. + * @max_raw_read: Max raw read size that can be used on the device. + * @max_raw_write: Max raw write size that can be used on the device. * @fast_io: Register IO is fast. Use a spinlock instead of a mutex * to perform locking. This field is ignored if custom lock/unlock * functions are used (see fields lock/unlock of struct regmap_con= fig). @@ -379,6 +385,12 @@ struct regmap_config { int (*reg_write)(void *context, unsigned int reg, unsigned int val); int (*reg_update_bits)(void *context, unsigned int reg, unsigned int mask, unsigned int val); + /* Bulk read/write */ + int (*read)(void *context, const void *reg_buf, size_t reg_size, + void *val_buf, size_t val_size); + int (*write)(void *context, const void *data, size_t count); + size_t max_raw_read; + size_t max_raw_write; =20 bool fast_io; =20 --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F369564CF5; Wed, 13 Mar 2024 16:43:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348229; cv=none; b=hmDBDSYqYgOBrBv0GRH5mIclWInDxGp7cVm36yDeNUU78GfQnMnikvs6XJd+m1tPmYgJ3g+dhR4kEHOLkjAhY2FeeitJT8YosNyVKAu+BUq/V9zwjKQttImvfV8+Owi7xx0TyWFNDKywfLjqyt73J6Ka1DRGBSpA676NPnwrNk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348229; c=relaxed/simple; bh=FlAnfQi6O4H9BoJpowWiJxTJFnaB688i8rTR2c3Ha+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YCxdngG/RseYK8BYLJHwe1AzHgwSVBj/+OlvAa64ceVBk8R/9fBQRFGxUzquOsOr3lmu5vv+LlACqaP3h8Tfq1fW+AI41XdCuo1gD+xyU6ntc+vPRNTjZgSApD7hjCYCboJ7z/9q+UH5EWzXdxRZ6cx9cSNqTINUv1wxXF0XMzE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VBsxCuWp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VBsxCuWp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E540C43399; Wed, 13 Mar 2024 16:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348228; bh=FlAnfQi6O4H9BoJpowWiJxTJFnaB688i8rTR2c3Ha+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VBsxCuWpBdeV0hlRU+z9YbbgEZ3NaW9kv0w1EoYQqC5e0BeKxRONRSyIsnJ8fWUO4 KdRRbg9uFbUKNSyZfof5uFj69FvoAk/dVRKUKy/c8JJydFpFuRdzxiyDZTRPZr4g0K C0icF9yiu6aKXc7Ai2nZmW4QOnweKLjm7L2MSlmshy5PrSPypd76vPpagybvfMpYaF GNFBEcOh/PnpQF6pZJxnsRPBI8KMyiagKd4X6WToEHg3OWId9+bMMexEq61k0tb48b kq9wUf3STKl/ixSHhNRSPgx4NgwNGsHLDqVZoivY++t0EiH+YFniR0RYCmW20aMN/O DkCySvYjmtyqA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Cosmin Tanislav , Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 74/76] serial: max310x: make accessing revision id interface-agnostic Date: Wed, 13 Mar 2024 12:42:21 -0400 Message-ID: <20240313164223.615640-75-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cosmin Tanislav [ Upstream commit b3883ab5e95713e479f774ea68be275413e8e5b2 ] SPI can only use 5 address bits, since one bit is reserved for specifying R/W and 2 bits are used to specify the UART port. To access registers that have addresses past 0x1F, an extended register space can be enabled by writing to the GlobalCommand register (address 0x1F). I2C uses 8 address bits. The R/W bit is placed in the slave address, and so is the UART port. Because of this, registers that have addresses higher than 0x1F can be accessed normally. To access the RevID register, on SPI, 0xCE must be written to the 0x1F address to enable the extended register space, after which the RevID register is accessible at address 0x5. 0xCD must be written to the 0x1F address to disable the extended register space. On I2C, the RevID register is accessible at address 0x25. Create an interface config struct, and add a method for toggling the extended register space and a member for the RevId register address. Implement these for SPI. Reviewed-by: Andy Shevchenko Signed-off-by: Cosmin Tanislav Link: https://lore.kernel.org/r/20220605144659.4169853-4-demonsingur@gmail.= com Signed-off-by: Greg Kroah-Hartman Stable-dep-of: 3f42b142ea11 ("serial: max310x: fix IO data corruption in ba= tched operations") Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/tty/serial/max310x.c | 40 +++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 41251fdf7c845..4299211183a74 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -72,7 +72,7 @@ #define MAX310X_GLOBALCMD_REG MAX310X_REG_1F /* Global Command (WO) */ =20 /* Extended registers */ -#define MAX310X_REVID_EXTREG MAX310X_REG_05 /* Revision ID */ +#define MAX310X_SPI_REVID_EXTREG MAX310X_REG_05 /* Revision ID */ =20 /* IRQ register bits */ #define MAX310X_IRQ_LSR_BIT (1 << 0) /* LSR interrupt */ @@ -253,6 +253,12 @@ #define MAX14830_BRGCFG_CLKDIS_BIT (1 << 6) /* Clock Disable */ #define MAX14830_REV_ID (0xb0) =20 +struct max310x_if_cfg { + int (*extended_reg_enable)(struct device *dev, bool enable); + + unsigned int rev_id_reg; +}; + struct max310x_devtype { char name[9]; int nr; @@ -275,6 +281,7 @@ struct max310x_one { =20 struct max310x_port { const struct max310x_devtype *devtype; + const struct max310x_if_cfg *if_cfg; struct regmap *regmap; struct clk *clk; #ifdef CONFIG_GPIOLIB @@ -364,13 +371,12 @@ static int max3109_detect(struct device *dev) unsigned int val =3D 0; int ret; =20 - ret =3D regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, - MAX310X_EXTREG_ENBL); + ret =3D s->if_cfg->extended_reg_enable(dev, true); if (ret) return ret; =20 - regmap_read(s->regmap, MAX310X_REVID_EXTREG, &val); - regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, MAX310X_EXTREG_DSBL); + regmap_read(s->regmap, s->if_cfg->rev_id_reg, &val); + s->if_cfg->extended_reg_enable(dev, false); if (((val & MAX310x_REV_MASK) !=3D MAX3109_REV_ID)) { dev_err(dev, "%s ID 0x%02x does not match\n", s->devtype->name, val); @@ -395,13 +401,12 @@ static int max14830_detect(struct device *dev) unsigned int val =3D 0; int ret; =20 - ret =3D regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, - MAX310X_EXTREG_ENBL); + ret =3D s->if_cfg->extended_reg_enable(dev, true); if (ret) return ret; =09 - regmap_read(s->regmap, MAX310X_REVID_EXTREG, &val); - regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, MAX310X_EXTREG_DSBL); + regmap_read(s->regmap, s->if_cfg->rev_id_reg, &val); + s->if_cfg->extended_reg_enable(dev, false); if (((val & MAX310x_REV_MASK) !=3D MAX14830_REV_ID)) { dev_err(dev, "%s ID 0x%02x does not match\n", s->devtype->name, val); @@ -1250,6 +1255,7 @@ static int max310x_gpio_set_config(struct gpio_chip *= chip, unsigned int offset, #endif =20 static int max310x_probe(struct device *dev, const struct max310x_devtype = *devtype, + const struct max310x_if_cfg *if_cfg, struct regmap *regmaps[], int irq) { int i, ret, fmin, fmax, freq; @@ -1308,6 +1314,7 @@ static int max310x_probe(struct device *dev, const st= ruct max310x_devtype *devty =20 s->regmap =3D regmaps[0]; s->devtype =3D devtype; + s->if_cfg =3D if_cfg; dev_set_drvdata(dev, s); =20 /* Check device to ensure we are talking to what we expect */ @@ -1477,6 +1484,19 @@ static struct regmap_config regcfg =3D { }; =20 #ifdef CONFIG_SPI_MASTER +static int max310x_spi_extended_reg_enable(struct device *dev, bool enable) +{ + struct max310x_port *s =3D dev_get_drvdata(dev); + + return regmap_write(s->regmap, MAX310X_GLOBALCMD_REG, + enable ? MAX310X_EXTREG_ENBL : MAX310X_EXTREG_DSBL); +} + +static const struct max310x_if_cfg __maybe_unused max310x_spi_if_cfg =3D { + .extended_reg_enable =3D max310x_spi_extended_reg_enable, + .rev_id_reg =3D MAX310X_SPI_REVID_EXTREG, +}; + static int max310x_spi_probe(struct spi_device *spi) { const struct max310x_devtype *devtype; @@ -1503,7 +1523,7 @@ static int max310x_spi_probe(struct spi_device *spi) regmaps[i] =3D devm_regmap_init_spi(spi, ®cfg); } =20 - return max310x_probe(&spi->dev, devtype, regmaps, spi->irq); + return max310x_probe(&spi->dev, devtype, &max310x_spi_if_cfg, regmaps, sp= i->irq); } =20 static int max310x_spi_remove(struct spi_device *spi) --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2583764CF7; Wed, 13 Mar 2024 16:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348230; cv=none; b=dEnwYEUX2aF53olW4s9D2UdUtzczeDZOK+Ki4+K+wCXbBYLsPNpHdQTAfa+GcWxYNfGUWc0ytijjW5sfyMcQVwsjBDK3vNnDSJHO2b60AcAIVZyoeho2NAjk5kVvRKsUeuRWJuC7I1hHLLCng/DSscWE08hq+vl5ZnfSJXDtG6k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348230; c=relaxed/simple; bh=j+1HcfbnqtQLFCt/+wgkCnxHewRTQth12vYb5SjsB1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sZSNn+VcahcspCtkqXaWSsmUs12Vx4lLplZQAWB+NUPBqMCx/LCWPUFwJq+i78nvNtXrUC/nDGzofUnYDEABj8yXinmw/QnHlrhQOYza7TtYreXzTremphqwsKpeQFWVIjG/ArTmKmMwHbCFtCori3gj2/Tc+dl66WNu1YA+GrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T3dVMaiR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T3dVMaiR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29CE8C433F1; Wed, 13 Mar 2024 16:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348230; bh=j+1HcfbnqtQLFCt/+wgkCnxHewRTQth12vYb5SjsB1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3dVMaiR6FfSP+z9i0LUXLirzqx3QiyCNF5pkMH4w8sMwy1uSWY/ixL4DqKLMdjya iyaiNZOTKikqaSq2BVl5B43OzooTsbJeL+iFfRNWtP9QnKuuJtA3XKV6jdJtiFMeRf zGc4oZJS61o4QfAzUAAGpU5JYuVxfIdTfeQAGB/VZ83cpRuLfbJOi5jy8Yl5RHLl6q e0lvG5+o8Mr5/a/yfZHiDZPn0oHmtSlGAxDB56t896kaVHmBL2V11JqQyWV5NU9ItF LsWSstvsp1BuSjpPg7OOjiOpahhfIu076tVAQh0uu3PEZ79sfOkTfYAAiKuCTIcblb /KC417gWb7v8g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Jan=20Kundr=C3=A1t?= , Andy Shevchenko , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH 5.15 75/76] serial: max310x: fix IO data corruption in batched operations Date: Wed, 13 Mar 2024 12:42:22 -0400 Message-ID: <20240313164223.615640-76-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable From: Jan Kundr=C3=A1t [ Upstream commit 3f42b142ea1171967e40e10e4b0241c0d6d28d41 ] After upgrading from 5.16 to 6.1, our board with a MAX14830 started producing lots of garbage data over UART. Bisection pointed out commit 285e76fc049c as the culprit. That patch tried to replace hand-written code which I added in 2b4bac48c1084 ("serial: max310x: Use batched reads when reasonably safe") with the generic regmap infrastructure for batched operations. Unfortunately, the `regmap_raw_read` and `regmap_raw_write` which were used are actually functions which perform IO over *multiple* registers. That's not what is needed for accessing these Tx/Rx FIFOs; the appropriate functions are the `_noinc_` versions, not the `_raw_` ones. Fix this regression by using `regmap_noinc_read()` and `regmap_noinc_write()` along with the necessary `regmap_config` setup; with this patch in place, our board communicates happily again. Since our board uses SPI for talking to this chip, the I2C part is completely untested. Fixes: 285e76fc049c ("serial: max310x: use regmap methods for SPI batch ope= rations") Cc: stable@vger.kernel.org Reviewed-by: Andy Shevchenko Signed-off-by: Jan Kundr=C3=A1t Link: https://lore.kernel.org/r/79db8e82aadb0e174bc82b9996423c3503c8fb37.16= 80732084.git.jan.kundrat@cesnet.cz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- drivers/tty/serial/max310x.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index 4299211183a74..c122e7e90fc89 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -511,6 +511,11 @@ static bool max310x_reg_precious(struct device *dev, u= nsigned int reg) return false; } =20 +static bool max310x_reg_noinc(struct device *dev, unsigned int reg) +{ + return reg =3D=3D MAX310X_RHR_REG; +} + static int max310x_set_baud(struct uart_port *port, int baud) { unsigned int mode =3D 0, div =3D 0, frac =3D 0, c =3D 0, F =3D 0; @@ -645,14 +650,14 @@ static void max310x_batch_write(struct uart_port *por= t, u8 *txbuf, unsigned int { struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_raw_write(one->regmap, MAX310X_THR_REG, txbuf, len); + regmap_noinc_write(one->regmap, MAX310X_THR_REG, txbuf, len); } =20 static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned= int len) { struct max310x_one *one =3D to_max310x_port(port); =20 - regmap_raw_read(one->regmap, MAX310X_RHR_REG, rxbuf, len); + regmap_noinc_read(one->regmap, MAX310X_RHR_REG, rxbuf, len); } =20 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) @@ -1481,6 +1486,10 @@ static struct regmap_config regcfg =3D { .writeable_reg =3D max310x_reg_writeable, .volatile_reg =3D max310x_reg_volatile, .precious_reg =3D max310x_reg_precious, + .writeable_noinc_reg =3D max310x_reg_noinc, + .readable_noinc_reg =3D max310x_reg_noinc, + .max_raw_read =3D MAX310X_FIFO_SIZE, + .max_raw_write =3D MAX310X_FIFO_SIZE, }; =20 #ifdef CONFIG_SPI_MASTER --=20 2.43.0 From nobody Fri Dec 19 20:33:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43C5814EFDB; Wed, 13 Mar 2024 16:43:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348231; cv=none; b=BjL9ljSNRCf869FC6rT8b+j3+0S2Pgk1T4DAPf39jspDgoniBqU4Y/KtCPGqOpKasLOig17KV3Oh3Yeuh5HXdOENQ1SUVsoXNlLCIiGIXkhbd/NQyTL/U4P3ctHJ4dsrVPrZESphSgD0Q2KrVCIYFqkEgUafxFlVeSANCTo/meg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348231; c=relaxed/simple; bh=XRFMJqIjV3rtLAD3YwO2M67wwOFBpj3sqQC4IfSTEAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PAOEFy2JCRqsiYvhFvl5DaiVCkq53YS0rKftd9xTBoMJcuA6MChzMSqe6ZT2ICE7V7NWBqCq3U6S5LxxHKjyFkXyL3xclGMn3j/Wv3U4JQt+5LzwPRT0zRtppAT7Dw9bi40zJd41rh3iBe5ObBQK3Hf4GgL6sfopLv9l45GGTuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z9hzHWNQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z9hzHWNQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A306C433C7; Wed, 13 Mar 2024 16:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710348230; bh=XRFMJqIjV3rtLAD3YwO2M67wwOFBpj3sqQC4IfSTEAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z9hzHWNQHP6G6CoWkYaYDOoSZTnj91+mMG4qz3dHLdRbBbgj8XY0eSIPqQjGAVL33 rgCk7HU2CpgdW2yG+mIEaj/YC1J7Lur4qF47BqFE7m77t3ZSopGhOYRpuAztO58U8L +NfMWWY1un6hG6VAmhlnhv1Gl7XK11RTh1tbU8J0zjj7SIkhMwgL9y3MfRCZp6dNtw s9i9qRWGQc4O2v+5jRAecDgHv48lXRa3Vmu3yC1nbsDbhTOkI9l0gEZgMyKvX+kX19 gWEPDI5bl3+fo9ISmJlTccmo3XyC+W8Svg/6EmCJy8I1nqkmGTVwqdBS/Q6R+qUmvN NWZGW1i3D+zpg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin Subject: [PATCH 5.15 76/76] Linux 5.15.152-rc1 Date: Wed, 13 Mar 2024 12:42:23 -0400 Message-ID: <20240313164223.615640-77-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240313164223.615640-1-sashal@kernel.org> References: <20240313164223.615640-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.152-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.15.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.15.152-rc1 X-KernelTest-Deadline: 2024-03-15T16:42+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Sasha Levin Reported-by: Linux Kernel Functional Testing Tested-by: Florian Fainelli Tested-by: Harshit Mogalapalli Tested-by: SeongJae Park Tested-by: kernelci.org bot --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bb73dba0e5052..34a2aba46cebf 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 VERSION =3D 5 PATCHLEVEL =3D 15 -SUBLEVEL =3D 151 -EXTRAVERSION =3D +SUBLEVEL =3D 152 +EXTRAVERSION =3D -rc1 NAME =3D Trick or Treat =20 # *DOCUMENTATION* --=20 2.43.0