From nobody Sat Nov 30 00:38:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=chromium.org ARC-Seal: i=1; a=rsa-sha256; t=1620640332; cv=none; d=zohomail.com; s=zohoarc; b=LBQFkJtUq3QpZHgttbtosOyheBwcS93IS5Sy89H9RRFsjLgQ45ROabW9ki0DMpQzRxoHxGk2LHMbDUk41IczvZSqh3PREeW4bowCFbms1okxz0Hty9rFgMNNCAHIZTb6fDvW5VU/W4lid2JY+7ZhmDbb/7AzJKx2nfFaCt3yrMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620640332; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pTHCFxssIveqpuArSgW3Qj3cZNx2ZZwG3aJYd2ZEd8Y=; b=ePYaDT9hxy4zCu80svyuEKHI6Dz8C0yc/W52RXTSITA4gwTPMXJ+OtP/jsdOlxrvMt9JHUlCLZEPaqGgkbmo0jwAUyP+bHVmoK2e2wfKCWeSjsAblA7Cd5ZfgRbe6ly3/FHYB4QVklW4PW6FgFpVrqH5PODNZUg2E5YGeHc91so= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1620640332600966.979473968253; Mon, 10 May 2021 02:52:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.125077.235510 (Exim 4.92) (envelope-from ) id 1lg2Zz-0002p3-Ue; Mon, 10 May 2021 09:51:59 +0000 Received: by outflank-mailman (output) from mailman id 125077.235510; Mon, 10 May 2021 09:51:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg2Zz-0002ou-Pn; Mon, 10 May 2021 09:51:59 +0000 Received: by outflank-mailman (input) for mailman id 125077; Mon, 10 May 2021 09:51:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lg2Zz-0002B1-9W for xen-devel@lists.xenproject.org; Mon, 10 May 2021 09:51:59 +0000 Received: from mail-pj1-x102f.google.com (unknown [2607:f8b0:4864:20::102f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e7ead912-fb0f-4b56-ab79-c6d660e4883d; Mon, 10 May 2021 09:51:58 +0000 (UTC) Received: by mail-pj1-x102f.google.com with SMTP id g24so9442873pji.4 for ; Mon, 10 May 2021 02:51:58 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:a524:abe8:94e3:5601]) by smtp.gmail.com with UTF8SMTPSA id l127sm10665077pfd.128.2021.05.10.02.51.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 02:51:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: e7ead912-fb0f-4b56-ab79-c6d660e4883d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pTHCFxssIveqpuArSgW3Qj3cZNx2ZZwG3aJYd2ZEd8Y=; b=SU2CBBmY8DtSQd0TNZ7943oJOHoK8+TBS5VGCwhcrloaivVlt1fQYEyAF2Dc62+eQt UT9wdd13n+8GJAVW0U5UJTACdpxx/KKTBexY7stqKf1PPvqGXsqREXZG7XFlnC1R91bt 2OsKvp8oZwX6m5c1ltX1+1ihIJktkKBoMRuaA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pTHCFxssIveqpuArSgW3Qj3cZNx2ZZwG3aJYd2ZEd8Y=; b=UHk08k8hga5nmNJ7NvCSyxdwRIB4l/ur7WivvI3zK314GUv6DSyxGmY6xaECbAb0FI vLmNfvLcIDuI1UxC88WX3Z9dfIFq00bFoZoNx4UdPg6ZApBYQcLli36OprLL2I+aF5qH JgsQ7nTOhwhGmI+qWGYu/un58uJRyG2BSj9Z4dmpgelyU1r3isYasbDj23AGwfqmFdWh EBvibmlil5Hb96WI0oLgULfUSAt9rYqiO9t0szU5hnz3W1026YFjhzG6tKOgKhEWJATb /K47XK+Eq05kEJZG5VFQua1w7x8eXtjc65LAHwWa/4isixQb6xNMc6QwnvqPdBVSSbm6 YpQw== X-Gm-Message-State: AOAM533LRHhzgjrfpZBQ4janeAyzqtk0PATFT02pwSQ7GgA6ggFO6aNT jJh1QOe2oBni+Ywz50XuIhg93Q== X-Google-Smtp-Source: ABdhPJyDFzChlNem0OEVDyj1b5MdL1myWQlCxWzTZ5O8kSwg2MCCOlZ4L1D63xzDiO05ddNXDCzncQ== X-Received: by 2002:a17:90a:d78c:: with SMTP id z12mr39367495pju.106.1620640317770; Mon, 10 May 2021 02:51:57 -0700 (PDT) From: Claire Chang To: Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Will Deacon , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Christoph Hellwig , Marek Szyprowski Cc: benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , sstabellini@kernel.org, Robin Murphy , grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , tfiga@chromium.org, bskeggs@redhat.com, bhelgaas@google.com, chris@chris-wilson.co.uk, tientzu@chromium.org, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, jxgao@google.com, joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, nouveau@lists.freedesktop.org, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Subject: [PATCH v6 09/15] swiotlb: Move alloc_size to find_slots Date: Mon, 10 May 2021 17:50:20 +0800 Message-Id: <20210510095026.3477496-10-tientzu@chromium.org> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog In-Reply-To: <20210510095026.3477496-1-tientzu@chromium.org> References: <20210510095026.3477496-1-tientzu@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @chromium.org) Content-Type: text/plain; charset="utf-8" Move the maintenance of alloc_size to find_slots for better code reusability later. Signed-off-by: Claire Chang --- 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 3f1ad080a4bc..ef04d8f7708f 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -482,8 +482,11 @@ static int find_slots(struct device *dev, phys_addr_t = orig_addr, return -1; =20 found: - for (i =3D index; i < index + nslots; i++) + for (i =3D index; i < index + nslots; i++) { mem->slots[i].list =3D 0; + mem->slots[i].alloc_size =3D + alloc_size - ((i - index) << IO_TLB_SHIFT); + } for (i =3D index - 1; io_tlb_offset(i) !=3D IO_TLB_SEGSIZE - 1 && mem->slots[i].list; i--) @@ -538,11 +541,8 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev,= phys_addr_t orig_addr, * This is needed when we sync the memory. Then we sync the buffer if * needed. */ - for (i =3D 0; i < nr_slots(alloc_size + offset); i++) { + for (i =3D 0; i < nr_slots(alloc_size + offset); i++) mem->slots[index + i].orig_addr =3D slot_addr(orig_addr, i); - mem->slots[index + i].alloc_size =3D - alloc_size - (i << IO_TLB_SHIFT); - } tlb_addr =3D slot_addr(mem->start, index) + offset; if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) && (dir =3D=3D DMA_TO_DEVICE || dir =3D=3D DMA_BIDIRECTIONAL)) --=20 2.31.1.607.g51e8a6a459-goog