From nobody Mon Feb 9 06:59:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5583C001E0 for ; Wed, 2 Aug 2023 16:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbjHBQbM (ORCPT ); Wed, 2 Aug 2023 12:31:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbjHBQbI (ORCPT ); Wed, 2 Aug 2023 12:31:08 -0400 Received: from frasgout11.his.huawei.com (ecs-14-137-139-23.compute.hwclouds-dns.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC26210D for ; Wed, 2 Aug 2023 09:31:06 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4RGHHV3NbMz9xGgV for ; Thu, 3 Aug 2023 00:19:34 +0800 (CST) Received: from A2101119013HW2.china.huawei.com (unknown [10.81.207.228]) by APP1 (Coremail) with SMTP id LxC2BwD3qbmxhMpkI9QsAA--.44769S2; Wed, 02 Aug 2023 17:30:48 +0100 (CET) From: Petr Tesarik To: Christoph Hellwig , Marek Szyprowski , Robin Murphy , Jianxiong Gao , Konrad Rzeszutek Wilk , iommu@lists.linux.dev (open list:DMA MAPPING HELPERS), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz Subject: [PATCH v1] swiotlb: move slot allocation explanation comment where it belongs Date: Wed, 2 Aug 2023 18:30:34 +0200 Message-Id: <20230802163034.1410-1-petrtesarik@huaweicloud.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: LxC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r4UJbIYCTnIWIevJa73UjIFyTuYvjfU0UUUUUUUU X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Petr Tesarik Move the comment down in front of the loop that actually sets the list member of struct io_tlb_slot to zero. Fixes: 26a7e094783d ("swiotlb: refactor swiotlb_tbl_map_single") Signed-off-by: Petr Tesarik --- kernel/dma/swiotlb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index d7eac84f975b..50a0e9c45c39 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -1018,11 +1018,6 @@ static int swiotlb_area_find_slots(struct device *de= v, struct io_tlb_pool *pool, continue; } =20 - /* - * If we find a slot that indicates we have 'nslots' number of - * contiguous buffers, we allocate the buffers from that slot - * and mark the entries as '0' indicating unavailable. - */ if (!iommu_is_span_boundary(slot_index, nslots, nr_slots(tbl_dma_addr), max_slots)) { @@ -1038,6 +1033,11 @@ static int swiotlb_area_find_slots(struct device *de= v, struct io_tlb_pool *pool, return -1; =20 found: + /* + * If we find a slot that indicates we have 'nslots' number of + * contiguous buffers, we allocate the buffers from that slot onwards + * and set the list of free entries to '0' indicating unavailable. + */ for (i =3D slot_index; i < slot_index + nslots; i++) { pool->slots[i].list =3D 0; pool->slots[i].alloc_size =3D alloc_size - (offset + --=20 2.25.1