Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2428170pxb; Fri, 17 Sep 2021 09:31:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzICrTWpSjJVa6vs/TFtOQu9D3N+s35hM4qVzwjVh7PAn7atNWrajWzhXoNmcD4WBZWcuVw X-Received: by 2002:a17:907:1de0:: with SMTP id og32mr13336025ejc.348.1631896292854; Fri, 17 Sep 2021 09:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631896292; cv=none; d=google.com; s=arc-20160816; b=Lk0u0pAJ2pDidCVTbcmnqzxiWdFA0LoIZ2ilBUxk4+6JKVk4QseUh+H2+Vi1i/kMNi lueNxX0Wx2Blfq9f7gRdnzV5nW29TBK3OUnn02KbNLZxPl3TNgJljIa6ayhOC6lJomUE Kr14LQeW8QnQzcAbePPFz+6muk5A3H9AhiBU36GQAUMsSXdKs8XPpuiwTb3vHab/2Zfw HqO1ogaa2u/DXo6wd36FlYZjRZiwufBBE3zcpxmfnFFHyHGNI4RM6Feol9pLEa0/1Mna ETUxuM17oUEp4oqlO02jy8yWwcMZgpiI3/2AbaDiN/H9ms8wgPtPL9roruquwOOdPSmb Aelg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fVx8Txip/StjPOD2jLvVsMLUrbAlebmeTfy3904j/s8=; b=Nu6eZUUyI8a0xdbV4Nb/YUfklVpfCvAlfwV+bW2cJSWSNu4GwDytDaaxR42ecaQGMs 1qn59HbUK478IWuCRYdCAvvjCSNqVTCkpFTqM5TYh66BKd/cr22yftQt8reK22i1Ugnr yzt2teiloX1bmXRD7lPJqhlsqs8+pusS7FLUyy+q+imNwCZIMb/0L7StYYTCLJ/z9hFD QcjU7UdDieagzj+m7w5SZjl+IQfxI6WA/JXGGOIsgilV4926lLdIFXQZcA4AHLq4lwVA mUJltiMMsN8RjxjYkLJaZmEb6TuWR6i9Q94NYF+o5lTAmu9t/nl4VkcUGZnXIVdtERRp ziXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=B42cV+Vk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si779570edi.133.2021.09.17.09.30.56; Fri, 17 Sep 2021 09:31:32 -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=@gmail.com header.s=20210112 header.b=B42cV+Vk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236946AbhIQGmQ (ORCPT + 99 others); Fri, 17 Sep 2021 02:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236487AbhIQGmM (ORCPT ); Fri, 17 Sep 2021 02:42:12 -0400 Received: from mail-vk1-xa36.google.com (mail-vk1-xa36.google.com [IPv6:2607:f8b0:4864:20::a36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17DDC061768; Thu, 16 Sep 2021 23:40:50 -0700 (PDT) Received: by mail-vk1-xa36.google.com with SMTP id t186so3334512vkd.3; Thu, 16 Sep 2021 23:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fVx8Txip/StjPOD2jLvVsMLUrbAlebmeTfy3904j/s8=; b=B42cV+Vk58LaOagsuwBpCCU3JGFLZwsVCvetR0q+GuE7Lnj8xEjm5RzGjvEBUayfUS NGi1QlcFSUz2uUph9PEzQKAcKrve1w2DzP6k0rLOradZHoW5nquakeCNJuGchVfvf0jv exFivBYcVLsfPn6WYja8UMBY2h0x2dppbEcygJi9WiYjryuOMuJCIFp5JphkrwOfc1x9 XfHVpIgP7HarQXSCXDiwxG55RaPpqR0HxxWM3Sgr/6vF0K6GxzxeYmpHM3XfqVEjUJSA PoGtDi2jSkUTeQE2w9cmxU1eDZ7mRCRFo50Wi2xXXGiYulMYckrGJZNLPk78nyUNCXoa s+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fVx8Txip/StjPOD2jLvVsMLUrbAlebmeTfy3904j/s8=; b=QxgppivCfXdeXY+T6XscK58Ki6oLYH/PZMR8qj6k7Au+XTIUyUCCqJ3vNMJInoDgGk 4RJs6Jz3M0d5FvPFo7KX5HZtO22VUxIOFUYKunkQSt27YHakDulwmEmx6yZGu+ft/PTl fvh/NF12OJQ9in8cIKhEmBgkEniN+X+6HJ5L57LaM5NZF0AlntIbEH0sOw+9QyjGOD7k /mGVoZB5RtdQBRvTuA5nmhHtoklbN4w6peYy7Fss6Nit06BALVDotNbdXVU3rbtxjLz7 SZsHFT8bpe8sQ/tLVEkb9xB7DQ53qEcjaLzx7q1TH5z3etcMvyi1GIYGNgR7JRzCqdFB Q/Ew== X-Gm-Message-State: AOAM530KgTMSw+xh+WNJCQpfCYYJv4HjjNO5xeFT+EaPylgEcvEHXzlA Kx8U2KJOlp7PTSWOu/VOmE2Jw4ImnTYWRx+3FIc= X-Received: by 2002:a1f:9781:: with SMTP id z123mr6691649vkd.25.1631860849907; Thu, 16 Sep 2021 23:40:49 -0700 (PDT) MIME-Version: 1.0 References: <20210917035736.3934017-1-chenhuacai@loongson.cn> <20210917035736.3934017-22-chenhuacai@loongson.cn> In-Reply-To: From: Huacai Chen Date: Fri, 17 Sep 2021 14:40:38 +0800 Message-ID: Subject: Re: [PATCH V3 21/22] LoongArch: Add Non-Uniform Memory Access (NUMA) support To: Christoph Hellwig Cc: Huacai Chen , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch , linux-doc@vger.kernel.org, LKML , Xuefeng Li , Yanteng Si , Jiaxun Yang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Christoph, On Fri, Sep 17, 2021 at 2:17 PM Christoph Hellwig wrote: > > > +/* > > + * 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 OK, I will simplify thi by removing indirections. Huacai >