From nobody Sat Nov 30 00:46:20 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=1623763922; cv=none; d=zohomail.com; s=zohoarc; b=Rzb1PHEy1IVzUFtzVuoSEXrG9L8wwwjBQG2Qp7hLQldWvEERScMxb71xrYD9ZyqgJOn9hY7ADg9Ukk8dKQNv/6447VXfLTXPZiNjGk3VUZeNOz6KXG+4Zlg77fOq/jvQXVIHjFQ/oTuybqTkJufhbOt1T6u8YezUmbc3entrTMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623763922; 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=G2K/m+Zr/C3L9kjElXXnw2MqplvvJistlV9RBDCxxbA=; b=AZNLJtouM4ZmTJruRdhKRiQ15gDvEEhg0PnxIWNuq1ZJF63LeEk3lzPB6SEOu9LwmJ1IfwghDcvu6fyOyA3KuR5taTmsIbM6Bvjg7vqNUqU2mon+ojn3EXPwu9Z/n+q+lECq1YBheuQ8wJNzh2NZFcdVMJYmP7TkaoMFfmNylV4= 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) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1623763922551188.46962697355798; Tue, 15 Jun 2021 06:32:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.142070.262291 (Exim 4.92) (envelope-from ) id 1lt9AU-0004Lv-DQ; Tue, 15 Jun 2021 13:31:50 +0000 Received: by outflank-mailman (output) from mailman id 142070.262291; Tue, 15 Jun 2021 13:31:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lt9AU-0004K6-6f; Tue, 15 Jun 2021 13:31:50 +0000 Received: by outflank-mailman (input) for mailman id 142070; Tue, 15 Jun 2021 13:31:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lt97f-0000bS-NV for xen-devel@lists.xenproject.org; Tue, 15 Jun 2021 13:28:55 +0000 Received: from mail-pj1-x102e.google.com (unknown [2607:f8b0:4864:20::102e]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e168b282-b877-436d-99ba-e8f4e047ac20; Tue, 15 Jun 2021 13:28:25 +0000 (UTC) Received: by mail-pj1-x102e.google.com with SMTP id s17-20020a17090a8811b029016e89654f93so1813180pjn.1 for ; Tue, 15 Jun 2021 06:28:25 -0700 (PDT) Received: from localhost ([2401:fa00:95:205:1846:5274:e444:139e]) by smtp.gmail.com with UTF8SMTPSA id b6sm15444521pfv.16.2021.06.15.06.28.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Jun 2021 06:28:23 -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: e168b282-b877-436d-99ba-e8f4e047ac20 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=G2K/m+Zr/C3L9kjElXXnw2MqplvvJistlV9RBDCxxbA=; b=S+0WgFWRpS+XVuyOr6ge+m8GeoamDCl8MImPmxPownLMaRnPddIW/4jWtOzq7baMS4 2cYnPw3kqWnOh0beyRy8sCyEGJJQnDgQZsawvLBFKtk8G7k3bIkUl48o16Ce4bkzeIE8 42Td6UN7L2/FOv7HufjRoYmlw39AIEDY4BEEo= 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=G2K/m+Zr/C3L9kjElXXnw2MqplvvJistlV9RBDCxxbA=; b=luJygGixtfdeDh93lhTDWSjgs6YHIykYAx28LYiXM6z48fJT5+ytbiwYZ8KyG3r8Bd y2b6UOcRna0ZEiGjRdRDlDNOq3m26jKDtUsVrrr+u6d8yZfth/6W5wb2RfrZbV5jaXy3 9eXqsnWAlfgFupZlVRMyiTRKcArWRA49hC/F7+4HB49MVSLX6Kpfzg+PHZxvMlshuCKp lfzCfXjKM0ydSV+BIzBybthBAn7DeOmufwtIY7PZ9BsHTZKwejedSEifA1aiJbtya3QX He5EK8SIw+PmvItMTHw2o1qXCZO60pRcwCy6OrXeeCcd6mqzAgu1vTXJaI27sXP7+gSu VBKQ== X-Gm-Message-State: AOAM5337WjV4RYD2/upgQLgsUrJaDvpFVQgICYC+4VS78rZT4N0O/B18 UFPaG0fWSNhsOXWUnbDvtbvgag== X-Google-Smtp-Source: ABdhPJzZB1FWHQkznzmBmSBFzh8JRoY7MD6aobVhux7mtkc928qojTPDdCJJ8YwZ2pCQlZ/ERmu5LQ== X-Received: by 2002:a17:90a:5b07:: with SMTP id o7mr10771533pji.35.1623763704484; Tue, 15 Jun 2021 06:28:24 -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, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Subject: [PATCH v10 07/12] swiotlb: Move alloc_size to swiotlb_find_slots Date: Tue, 15 Jun 2021 21:27:06 +0800 Message-Id: <20210615132711.553451-8-tientzu@chromium.org> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog In-Reply-To: <20210615132711.553451-1-tientzu@chromium.org> References: <20210615132711.553451-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" Rename find_slots to swiotlb_find_slots and move the maintenance of alloc_size to it for better code reusability later. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig --- kernel/dma/swiotlb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 5af47a8f68b8..e498f11e150e 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -422,8 +422,8 @@ static unsigned int wrap_index(struct io_tlb_mem *mem, = unsigned int index) * Find a suitable number of IO TLB entries size that will fit this reques= t and * allocate a buffer from that IO TLB pool. */ -static int find_slots(struct device *dev, phys_addr_t orig_addr, - size_t alloc_size) +static int swiotlb_find_slots(struct device *dev, phys_addr_t orig_addr, + size_t alloc_size) { struct io_tlb_mem *mem =3D dev->dma_io_tlb_mem; unsigned long boundary_mask =3D dma_get_seg_boundary(dev); @@ -478,8 +478,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--) @@ -520,7 +523,7 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, = phys_addr_t orig_addr, return (phys_addr_t)DMA_MAPPING_ERROR; } =20 - index =3D find_slots(dev, orig_addr, alloc_size + offset); + index =3D swiotlb_find_slots(dev, orig_addr, alloc_size + offset); if (index =3D=3D -1) { if (!(attrs & DMA_ATTR_NO_WARN)) dev_warn_ratelimited(dev, @@ -534,11 +537,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.32.0.272.g935e593368-goog