From nobody Tue Feb 10 02:49:50 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559120733; cv=none; d=zoho.com; s=zohoarc; b=GQoV5CP+s2ibzG8jgN6Vw1Bnmn6+XTD0qq0K41tWdicqzk/C6Kc+2oCu3XZ6/XsIqVaCVkPmHupo2YFvb6NJQUWrwg8a9JIp7BTVqjvYZ5CYPatAhQ6oOVS/GB+Rj+NLRdCkk5qtXupIhElRlNcNuMI9N2ey+wMUjvvoSPOqBgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559120733; h=Content-Type: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:ARC-Authentication-Results; bh=qoJf6me4qgi5WWfa1+qKT3w2L6/WLuvdlkXQbMEeSPc=; b=aUwP7jEp+3SdyWMtwvzw9jxGNslyvXIz3lWKoKWmo7viosDlx/zYBBKEBCZ9Rl0dqdESdKKDFEFhRHJtL2kDFi5KftGCYHtRfA+R66R1dX2lvoudPkD6pfWBFZlJDCj3hLC+06SuMiEpV4Tp0JfVvZl1ULq+q6V1OHwYMfaKfqA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559120733613369.3003605857971; Wed, 29 May 2019 02:05:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVuVL-0005VY-HQ; Wed, 29 May 2019 09:04:15 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hVuVK-0005VC-Af for xen-devel@lists.xenproject.org; Wed, 29 May 2019 09:04:14 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id b935d389-81f0-11e9-8980-bc764e045a96; Wed, 29 May 2019 09:04:11 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6A11AE56; Wed, 29 May 2019 09:04:10 +0000 (UTC) X-Inumbo-ID: b935d389-81f0-11e9-8980-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Date: Wed, 29 May 2019 11:04:06 +0200 Message-Id: <20190529090407.1225-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190529090407.1225-1-jgross@suse.com> References: <20190529090407.1225-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v2 2/3] xen/swiotlb: simplify range_straddles_page_boundary() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , xen-devel@lists.xenproject.org, Boris Ostrovsky , Stefano Stabellini , Konrad Rzeszutek Wilk MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" range_straddles_page_boundary() is open coding several macros from include/xen/page.h. Use those instead. Additionally there is no need to have check_pages_physically_contiguous() as a separate function as it is used only once, so merge it into range_straddles_page_boundary(). Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky --- drivers/xen/swiotlb-xen.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index 1caadca124b3..aba5247b9145 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -92,34 +92,18 @@ static inline dma_addr_t xen_virt_to_bus(void *address) return xen_phys_to_bus(virt_to_phys(address)); } =20 -static int check_pages_physically_contiguous(unsigned long xen_pfn, - unsigned int offset, - size_t length) +static inline int range_straddles_page_boundary(phys_addr_t p, size_t size) { - unsigned long next_bfn; - int i; - int nr_pages; + unsigned long next_bfn, xen_pfn =3D XEN_PFN_DOWN(p); + unsigned int i, nr_pages =3D XEN_PFN_UP(xen_offset_in_page(p) + size); =20 next_bfn =3D pfn_to_bfn(xen_pfn); - nr_pages =3D (offset + length + XEN_PAGE_SIZE-1) >> XEN_PAGE_SHIFT; =20 - for (i =3D 1; i < nr_pages; i++) { + for (i =3D 1; i < nr_pages; i++) if (pfn_to_bfn(++xen_pfn) !=3D ++next_bfn) - return 0; - } - return 1; -} + return 1; =20 -static inline int range_straddles_page_boundary(phys_addr_t p, size_t size) -{ - unsigned long xen_pfn =3D XEN_PFN_DOWN(p); - unsigned int offset =3D p & ~XEN_PAGE_MASK; - - if (offset + size <=3D XEN_PAGE_SIZE) - return 0; - if (check_pages_physically_contiguous(xen_pfn, offset, size)) - return 0; - return 1; + return 0; } =20 static int is_xen_swiotlb_buffer(dma_addr_t dma_addr) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel