Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2462852pxb; Fri, 17 Sep 2021 10:15:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygNomvhD23+vOAuCYX4xrbFTnZoRoH7i7LqWEfAC3hvXHY4+gPA40mDNs2DJOFEBy7jq7W X-Received: by 2002:a17:906:1945:: with SMTP id b5mr13104180eje.347.1631898956013; Fri, 17 Sep 2021 10:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631898956; cv=none; d=google.com; s=arc-20160816; b=xkA2kUslceVbctlX2z/NWkEpVYR+CO27b/yKueAie/9wx2LArqSFILCkCqaXOU839N 1TuHamrMAFhIx95JGLrJmU5Vshf/jyI7JilCSlN834wVSnLgrJ5tiMfFH6zsGXGLoJ+d NZKmWdlL83a2hA6/xSwS5EgwBlMM+BSM0F5nUp4ah7DKECntw9tSdhoGpey1Uh1M7fkL zGc/u0Pad4UdxyTAO89cjMqkkNO4GmsKovwdTQpFS6UC2o0CUSLVcfdN2qAIKhg80SFJ vD39x6C5iuCMDUqQPmsAn3fEyuqOYmc+kUzPyIJyIKfn4MVB/sjP84h3jEP5RehQ3GSR K9LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Qm38hcFwUX9FW/ci+/zYJ0a1d/k4aBvN8whvlAXgqA4=; b=IiKPLW+YdNzFQSiQEYIdLXDivLapArXlNZSEjHsfh3vnNBpNIiErzqO+o2ImZgbJUl GFSkofnARrw/eVMoI2+D0fGZk2ySfxsGAHy/Grd0mLuDMdsuzH0NSL6legZzIeIOqqvj xulPX5n3383um69PmjZlZoAjLdU9g4Z92sl9ChobmNLyAVWZBN8Hu5eWPaokf76Lio0n BoWBMNk5KL2xAE9DR849WvzOV0a4jCD5RaOmT52db1Qf/WSqd7OOkns+9B6PGnj8J+nT /4HCCU4gDXw7AgB30S9TKj3Dl6MFUYgk7H3D7wG3FYF9vL1nHYxQnzYoqof6R6f1CJDe cpLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ASNg2Vs1; 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 t26si7277237eds.588.2021.09.17.10.15.32; Fri, 17 Sep 2021 10:15:56 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ASNg2Vs1; 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 S232357AbhIQGS4 (ORCPT + 99 others); Fri, 17 Sep 2021 02:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231197AbhIQGS4 (ORCPT ); Fri, 17 Sep 2021 02:18:56 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA20C061574; Thu, 16 Sep 2021 23:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Qm38hcFwUX9FW/ci+/zYJ0a1d/k4aBvN8whvlAXgqA4=; b=ASNg2Vs1c3CalDy2e42QIziEkF 5sDgcumGnphwcntt1heh39lu989AF5R9Cja18mQOJ2YiXRLRi9REvLu4kHMxSPriysAYGzuuLWNn8 iUq/wb7SfMV/ActM7LlgkZRWV/+iAS7/vrQdIy8a85fxDJkPiurYqqbGTTXPRbwrmBJ5W7qutr3ED 8QLXQmu0wAJ/UeJEgPPsxP3dkWPsnTeT75CqwJU8laf0RzjVAvETXqpqUJVdPdD1L0EGvAgg2fw+M bGoflxb6CwGgBuS/0IjsXVb3oZjkOKo+V/j7p+AObiLJ/27ScbrobnlSardfUuZII+2orTtrERw+T VjKo04GA==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mR79k-00HZ0j-6R; Fri, 17 Sep 2021 06:15:37 +0000 Date: Fri, 17 Sep 2021 07:15:28 +0100 From: Christoph Hellwig To: Huacai Chen Cc: Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , Yanteng Si , Huacai Chen , Jiaxun Yang Subject: Re: [PATCH V3 21/22] LoongArch: Add Non-Uniform Memory Access (NUMA) support Message-ID: References: <20210917035736.3934017-1-chenhuacai@loongson.cn> <20210917035736.3934017-22-chenhuacai@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210917035736.3934017-22-chenhuacai@loongson.cn> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* > + * We extract 4bit node id (bit 44~47) from Loongson-3's > + * 48bit physical address space and embed it into 40bit. > + */ > + > +static int node_id_offset; > + > +static dma_addr_t loongson_phys_to_dma(struct device *dev, phys_addr_t paddr) > +{ > + long nid = (paddr >> 44) & 0xf; > + > + return ((nid << 44) ^ paddr) | (nid << node_id_offset); > +} > + > +static phys_addr_t loongson_dma_to_phys(struct device *dev, dma_addr_t daddr) > +{ > + long nid = (daddr >> node_id_offset) & 0xf; > + > + return ((nid << node_id_offset) ^ daddr) | (nid << 44); > +} > + > +static struct loongson_addr_xlate_ops { > + dma_addr_t (*phys_to_dma)(struct device *dev, phys_addr_t paddr); > + phys_addr_t (*dma_to_phys)(struct device *dev, dma_addr_t daddr); > +} xlate_ops; > + > +dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) > +{ > + return xlate_ops.phys_to_dma(dev, paddr); > +} > + > +phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) > +{ > + return xlate_ops.dma_to_phys(dev, daddr); > +} Please don't add unused indirections. Also please just use the generic translations