From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795952894; b=ZxKSwwtNenAa3xsC6xn8dm9kthSc6O6MFBCl+LdJjU1PsaW5V7F/fHebC7r29m+yT9HZ mGgUtYB9g0BwBra3qoXcReuPGCd2X5q49Yn0B0LVsNVnyGMCfMLWkM8v8h33lCoRxgg9Y vOXFudU0KMmvKuBURrgEPbPYbNedoSiP5qCYncX8s8AYlVCrSGRKDqggQtSt87SAVRDge NWhGUoohTbF41wsCmPJBd30PUhfGAFWX1wqiUJdGTWQWV/+haUDlB5X+3C9d1GtBy6Ipx a/Hj4Bn1yO7blvYPOLqljmyjJfFuBlOulw11wHeMP+iEpLgXij7pb+7BoOLkjo6VfNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795952894; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jhPYe/u/XCF2alszaoZJ2HvhFtS1iHooA+6ZpIJsG50=; b=LwfU+7dgnViaDV0Cu5y1DLQKLnjUtDWqxjfbIW92+sywtcwve28oDoNb6iolAR9mE1BC fSSHYfF49ef6fc8wTJ5qGQ/0cNJswx8AbYPafbRKhbBCdfJBCgN3VvGODAO2O1C0FokVu niIHGBc0AFmTCk0ogaqspi4G8Y4n1xqJ0MqUbHEKhvEmV4MOgqE9f+S25SLjG5/jf4BLl QKpgJ90B5GNtioL/ZPv3MmayAi92+M3C/9da0J4QyR/n7mQbTobR22Utj2KtXKekYUdBl L9tsCOw3VbERtn6kXCGz7+3PId5MSjEXYjfhXMpr4Dx2GJuQQJA1KXWNtrs4/iwIN5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZdKhVnrj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E615606A69A for ; Sun, 29 Nov 2026 11:48:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZdKhVnrj Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDB5E1F00896; Sun, 29 Nov 2026 11:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795952894; bh=jhPYe/u/XCF2alszaoZJ2HvhFtS1iHooA+6ZpIJsG50=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ZdKhVnrjkwJfIvGRAppZib6hp1mZC+z3V3BbW+Zr+Nrde/ZDs82Vcbfrr/pxreg2f 1/sxOUVWt8NUF9NAfNERqxykm1iMNvbV/zIe1QID3QTvmeq2Ajgo9TSXnSOogZ0KJY +tIkd148uC9KqRwL+yApI5W4tbeHBSukY/tGTCBX+WYuhZplSwRqsg9Yqgx1oedWRQ v/lIdtIZzO9qv6eAQWn4q8lyXwr5D7fEafE2KfF9B3Bwu73pF/B6hhZsCg6KOz4tJC K9J/2fYEEHyS9M9A2UeICNpSAGq3rI1pRZFovF3dKQ3JVZCpeU5j8RyF0NGGq6Y+Vb qbPMcbZlRpqjw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 07/14] accel/thames: Add support for submitting DMA operations Reply-To: sashiko-reviews@lists.linux.dev To: "Tomeu Vizoso" Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, robh@kernel.org, conor+dt@kernel.org, media-ci@linuxtv.org In-Reply-To: <20261129-thames-v4-7-003b1e3365bf@tomeuvizoso.net> References: <20261129-thames-v4-0-003b1e3365bf@tomeuvizoso.net> <20261129-thames-v4-7-003b1e3365bf@tomeuvizoso.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 29 Nov 2026 11:48:13 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] accel/thames: out-of-bounds IPC write in thames_transfers_alloc_table() - [Medium] accel/thames: missing wmb() after WC IPC writes in thames_transfers_write_table() -- commit b506c4c5faf43e8de930635840dc32e5769eb0c2 Author: Tomeu Vizoso accel/thames: Add support for submitting DMA operations This commit adds validation, address translation, and IPC transfer table pool management for C7x DRU DMA transfer records. > diff --git a/drivers/accel/thames/thames_transfers.c b/drivers/accel/tham= es/thames_transfers.c > new file mode 100644 > index 0000000000000..113f0b73875cc > --- /dev/null > +++ b/drivers/accel/thames/thames_transfers.c [ ... ] > +static void thames_transfers_write_table(struct thames_core *core, > + const struct thames_transfer_table *table) > +{ > + static const unsigned int addr_word[2] =3D { TR_ADDR_LO, TR_DADDR_LO }; > + const struct thames_transfer *records =3D table->records; > + const u16 *group_counts =3D table->group_counts; > + void *base =3D core->ipc->transfer_table_pool + table->offset; > + struct thames_dru_record *out =3D base; > + u8 *channels =3D base + THAMES_TRANSFER_TABLE_CHANNELS_OFFSET(table->co= unt); > + u32 i, s; > + > + for (i =3D 0; i < table->count; i++) { > + struct thames_dru_record record =3D records[i].record; > + > + for (s =3D 0; s < 2; s++) { > + u32 *lo =3D &record.words[addr_word[s]]; > + u64 addr; > + > + if (records[i].side[s] =3D=3D THAMES_TRANSFER_SIDE_DDR) > + continue; > + > + addr =3D ((u64)lo[1] << 32 | lo[0]) + > + thames_core_window(core, records[i].side[s])->start; > + lo[0] =3D lower_32_bits(addr); > + lo[1] =3D upper_32_bits(addr); > + } > + > + memcpy(&out[i], &record, sizeof(record)); > + channels[i] =3D records[i].channel; > + } > + > + memcpy(base + THAMES_TRANSFER_TABLE_GROUPS_OFFSET(table->count), group_= counts, > + table->group_count * sizeof(u16)); > +} > + > +/* Same offsets, so the Ring entries of the Jobs still queued stay valid= . */ > +void thames_transfers_rewrite(struct thames_core *core) > +{ > + struct thames_device *tdev =3D core->tdev; > + struct thames_transfer_table *table; > + > + guard(mutex)(&tdev->transfer_table_pool_lock); > + > + list_for_each_entry(table, &tdev->transfer_tables, node) > + thames_transfers_write_table(core, table); > +} > + > +static int thames_transfers_alloc_table(struct thames_device *tdev, > + struct thames_transfer_table *table) > +{ > + const unsigned long lines =3D tdev->caps.transfer_table_pool_size / THA= MES_ABI_LINE_SIZE; > + unsigned long start, nr =3D table->size / THAMES_ABI_LINE_SIZE; > + u32 i; > + > + guard(mutex)(&tdev->transfer_table_pool_lock); > + > + start =3D bitmap_find_next_zero_area(tdev->transfer_table_pool_map, lin= es, 0, nr, 0); > + if (start + nr > lines) > + return -ENOSPC; > + > + bitmap_set(tdev->transfer_table_pool_map, start, nr); > + table->offset =3D start * THAMES_ABI_LINE_SIZE; > + > + for (i =3D 0; i < tdev->num_cores; i++) > + thames_transfers_write_table(&tdev->cores[i], table); > + > + list_add_tail(&table->node, &tdev->transfer_tables); > + return 0; > +} [Severity: Medium] Does thames_transfers_write_table() need a trailing wmb() after writing to core->ipc->transfer_table_pool? core->ipc is mapped with MEMREMAP_WC, and unlike thames_context_bump_generation(), neither thames_transfers_alloc_table() nor thames_transfers_rewrite() issues a wmb() before releasing transfer_table_pool_lock. If a job is created on one CPU and submitted to the ring by a scheduler worker on another CPU (or if a core comes online after thames_transfers_rewrite()), the DSP can observe stale or partially written DRU transfer records in the write-combined IPC pool. [Severity: Medium] Can thames_transfers_alloc_table() write past the end of core->ipc when cores have different ipc_size values or a core has not attached? thames_platform_probe() sizes the bitmap from the largest core->ipc_size using max() and keeps offline or failed-attach cores in tdev->cores[0 .. tdev->num_cores - 1]. When the first core attaches, thames_core_read_caps() checks caps->transfer_table_pool_size only against that core's ipc_size: drivers/accel/thames/thames_core.c:thames_core_read_caps() { ... if (!caps->transfer_table_pool_size || !IS_ALIGNED(caps->transfer_table_pool_size, THAMES_ABI_LINE_SIZE) || pool_offset + caps->transfer_table_pool_size > core->ipc_size) { ... } Because thames_transfers_alloc_table() writes at table->offset into every core in tdev->cores[], any other core whose ipc_size is smaller than pool_offset + table->offset + table->size will suffer an out-of-bounds write past its memremap()ed core->ipc mapping. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-thames-v4-= 0-003b1e3365bf@tomeuvizoso.net?part=3D7