Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5263362ybi; Tue, 4 Jun 2019 04:04:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQcbKOVj/oJ5HQ5NnXmHl19E3dpRF99oJJ7+QyG8an1R4bUelB7uEEUXSeHu1/ViuZrheq X-Received: by 2002:a63:6647:: with SMTP id a68mr8672494pgc.414.1559646289944; Tue, 04 Jun 2019 04:04:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559646289; cv=none; d=google.com; s=arc-20160816; b=kZpH7k+jILsk5cHE1e1G2HtYs2glDXY/zaDThpNES2LHVBL0pcUucf+mCLVbqfmGIJ HnxXHel3c8yVJfhyRaVcTjNTXqQDyxS4n3fxpUndddhdfSHf0BG6L4/MgvTMkSE/4su2 z5PRv8tZhu7lM/b4yOuq3rjNPMdIgxutFBiX6tJHbxBgS7xkomqVgdl7kjtSxjPKpHju jzIiWqkK6z6TX4EFGME1DGSDZvOMt53g6rSeCePgm+B7WKFcYrKxODNX6inqJeZ5eL6N P4woOzKgGE9ScnG/Z9QeyDLm56eFWhCg3mHCKfQFaQbQhC4r+nTnR8wzgnlRDHT5o13C c1wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WDbPSKeCZ8oAwUO/gbQAYonHxio/dp9v0ZS3lSUVGiI=; b=yX/J3bV6tw2kSdkonWk00pRQzq+F4mGg3H9zxGiax0Mi2GwlhEQO+Zi3nc7taz93OL YyBWPB3JJaMyvL5LcjJ8EY8KRw04Y56hkjFDEoETCnmyNUN+aZnpMBIJDhWS5GLyelzf jW+3cXmmR9FHnimsMG0N4fFDF118F5pSatQdPx/oYh5xbGifRXOu58d5tTk5NlRWSd0l X+FMh2s8PNYT48tJyLGWkv9FAf06Yb2XC/ofL2fA1VVDBpPpxOgoua0Xqzo3aJgshSCI bGdqgMzY60+vZ1eQLB5Gi63ndstvNxprLsJDxwScqyZhN24WeO5GMxSGS5ueQKALQ7k6 v8aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UFTBxFiF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id k24si22159971pfk.195.2019.06.04.04.04.31; Tue, 04 Jun 2019 04:04:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UFTBxFiF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727568AbfFDLBW (ORCPT + 99 others); Tue, 4 Jun 2019 07:01:22 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:39647 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbfFDLBW (ORCPT ); Tue, 4 Jun 2019 07:01:22 -0400 Received: by mail-vs1-f66.google.com with SMTP id n2so4821746vso.6 for ; Tue, 04 Jun 2019 04:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WDbPSKeCZ8oAwUO/gbQAYonHxio/dp9v0ZS3lSUVGiI=; b=UFTBxFiFaQAgtc8pGRfpgJK9845bc1+wNN3Ljkixb6j9f/C6DpMOv6EeY1wjgMedGS 1z4TxRJ2Uf/dl5OTSZcqew7Xw4uMG1N6xKcAYtI9vvSz5VV6ha9bJ6dwVDgORMX6bCrS GKKBfElTwlYNDrFuxzHjOXxJO6rYrJrbGaQXjfeLJeUS265m2BZDLz+0UiFBDv5iTzMl boiJTv5mPyyDY4mFXGSlJHkj/5xIHajEhH5HZ4Z/W1oa4DXBWGMvGkt3T+D217UFzvrQ 0Dz/jFifyp/r98ljW5sCi7WcYFQeRupstHnMuRZ2fA1sCe331hW4CUxOKRdtxd2LJkZq SACQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WDbPSKeCZ8oAwUO/gbQAYonHxio/dp9v0ZS3lSUVGiI=; b=LDg8HiICD7TkLEXMofzwcSMA1OcO89EJycpiT7sulYfCmE2qsrybpnaRyl0xueo0le Qm0S6vDKwiUIU4oMnLZsBQv3AC9qLZVZcnPTEYMaT8fMeXP36Yde+kNrkCofGf6sYaLH qU8qxtpC11ii6o9KIWw5Oo3NpVXecIJzsQvZxNieNpI4nQjltRSxyOGNVydjz/7RyL5l HE64xSSmmWAFOKVfoyscRXqjKTrV0N+vrYWKU5X6Yj+cN9CQiYz/ilevQIK/oaO5/iK3 S1pKe/80K1+NASzeJ4k5DHvgz5uR45uf4W6xFlOcbDxfoD3Vz1a2JpTxwXGyXxZ/gI5m H+/A== X-Gm-Message-State: APjAAAVp52TN3acPqufyVzaGb0z8lhPCZ+EUmZzWsohp8DZpt+/3zRej P2R6BYDSuPLikHIPbsb2cVMOHiN1sOjgpOjuDq5YBw== X-Received: by 2002:a67:e3d5:: with SMTP id k21mr765014vsm.172.1559646080843; Tue, 04 Jun 2019 04:01:20 -0700 (PDT) MIME-Version: 1.0 References: <20190603112453.20097-1-ttayar@habana.ai> In-Reply-To: <20190603112453.20097-1-ttayar@habana.ai> From: Oded Gabbay Date: Tue, 4 Jun 2019 14:00:54 +0300 Message-ID: Subject: Re: [PATCH] habanalabs: Fix virtual address access via debugfs for 2MB pages To: Tomer Tayar Cc: "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 3, 2019 at 2:25 PM Tomer Tayar wrote: > > The debugfs interface for accessing DRAM virtual addresses currently > uses the 12 LSBs of a virtual address as an offset. > However, it should use the 20 LSBs in case the device MMU page size is > 2MB instead of 4KB. > This patch fixes the offset calculation to be based on the page size. > > Signed-off-by: Tomer Tayar > --- > drivers/misc/habanalabs/debugfs.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/misc/habanalabs/debugfs.c b/drivers/misc/habanalabs/debugfs.c > index 0ce5621c1324..ba418aaa404c 100644 > --- a/drivers/misc/habanalabs/debugfs.c > +++ b/drivers/misc/habanalabs/debugfs.c > @@ -500,6 +500,7 @@ static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr, > { > struct hl_ctx *ctx = hdev->user_ctx; > u64 hop_addr, hop_pte_addr, hop_pte; > + u64 offset_mask = HOP4_MASK | OFFSET_MASK; > int rc = 0; > > if (!ctx) { > @@ -542,12 +543,14 @@ static int device_va_to_pa(struct hl_device *hdev, u64 virt_addr, > goto not_mapped; > hop_pte_addr = get_hop4_pte_addr(ctx, hop_addr, virt_addr); > hop_pte = hdev->asic_funcs->read_pte(hdev, hop_pte_addr); > + > + offset_mask = OFFSET_MASK; > } > > if (!(hop_pte & PAGE_PRESENT_MASK)) > goto not_mapped; > > - *phys_addr = (hop_pte & PTE_PHYS_ADDR_MASK) | (virt_addr & OFFSET_MASK); > + *phys_addr = (hop_pte & ~offset_mask) | (virt_addr & offset_mask); > > goto out; > > -- > 2.17.1 > This patch is: Reviewed-by: Oded Gabbay applied to -fixes