From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7A5BC433B4 for ; Mon, 10 May 2021 08:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D873610CD for ; Mon, 10 May 2021 08:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbhEJIpO (ORCPT ); Mon, 10 May 2021 04:45:14 -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.