Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2395946pxj; Mon, 10 May 2021 01:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwjsu2LHaDKTnOcsvpQ0jIUuflFeUBp3JXc+S9ItohioQIvlLOsSa6iYYfrtsaBq8WOfNr X-Received: by 2002:a05:6638:37a6:: with SMTP id w38mr20173106jal.106.1620636305259; Mon, 10 May 2021 01:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620636305; cv=none; d=google.com; s=arc-20160816; b=y/pfHJ44a+D8QGbBREG1CwTJzFDLH98lPy5263DU+yR1qsBPfy/zsXiaUY4kMpUhFa Z8LM15bz7NJkM341Mr/g94G3u2axLd8gPFOWfE4IBJVJIGe+IxdvhxK3goV0JtFQBf+7 feViXvWY5oTUEIBJxneAHwFkIE7Iy072HIl4F3HXrBF9XduqHuuSw0YU/rGHMaxNv104 qqr9H/BLBOwy9Syl+IkLjfF3zHIJnDqzuDwD0bV7N2QYbJAiPtU7att3Nh2dzhcAgxhR rItj0o9jM11YAOS10N0QvEvy362147KLq1S9RWtSFMjPCkl5C0ApjLozL9K/P7PxMWnk vUQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=/sDuxV3HPlleJ0ldDmNn2ZdGsaBVqUoS+U1ZJSgYXR0=; b=t+zT7yhpD1qlJQ2lvhL8dn0+v+N5HC+UTc32dvpmm5FXhrCsWjJj81X8jtThdhoCrj DBuRon+ylKFpZs9VHA70ARVoSNM9zrFmJ4wiO3/TFW576/vFbE7PalNl1XZDq5wVKK5j KOnZZ8ZE94puZ1M66IYjwVdajuXUgnlyq8uSq+sqTrJSAjoja6+GCRW+ptSLz5CzIh0i e8nJoToTc6AlHt1WPswUexB1Ha9G0cqweG25D/2sWV+x3TOAlwKns0Xra/BPR1GsCavO X95WqABbyd5PLm8/L9nUKgRT2FX6/qu5XNgJUTzSTEQEBLB8NpLrdXpWz9x+Xbim0CQ1 pU+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si14971963iob.72.2021.05.10.01.44.52; Mon, 10 May 2021 01:45:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbhEJIpN (ORCPT + 99 others); Mon, 10 May 2021 04:45:13 -0400 Received: from verein.lst.de ([213.95.11.211]:57663 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbhEJIpM (ORCPT ); Mon, 10 May 2021 04:45:12 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 446F667373; Mon, 10 May 2021 10:44:06 +0200 (CEST) Date: Mon, 10 May 2021 10:44:06 +0200 From: Christoph Hellwig To: Chanho Park Cc: Konrad Rzeszutek Wilk , Christoph Hellwig , Marek Szyprowski , Robin Murphy , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Bumyong Lee Subject: Re: [PATCH] swiotlb: manipulate orig_addr when tlb_addr has offset Message-ID: <20210510084406.GA1093@lst.de> References: <20210510083057.46476-1-chanho61.park@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210510083057.46476-1-chanho61.park@samsung.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 05:30:57PM +0900, Chanho Park wrote: > +static unsigned int swiotlb_align_offset(struct device *dev, u64 addr); Please just move swiotlb_align_offset up to avoid the forward declaration. > /* > * Bounce: copy the swiotlb buffer from or back to the original dma location > */ > @@ -346,10 +347,17 @@ static void swiotlb_bounce(struct device *dev, phys_addr_t tlb_addr, size_t size > size_t alloc_size = mem->slots[index].alloc_size; > unsigned long pfn = PFN_DOWN(orig_addr); > unsigned char *vaddr = phys_to_virt(tlb_addr); > + unsigned int tlb_offset; > > if (orig_addr == INVALID_PHYS_ADDR) > return; > > + tlb_offset = (unsigned int)tlb_addr & (IO_TLB_SIZE - 1); > + tlb_offset -= swiotlb_align_offset(dev, orig_addr); Nit: I'd write this as: tlb_offset = (tlb_addr & (IO_TLB_SIZE - 1)) - swiotlb_align_offset(dev, orig_addr); as there is no need for the cast, and just having a single assignment is easier to follow.