Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1201004pxb; Thu, 15 Apr 2021 17:13:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI1LEK8oLXazfMDAHwVcMlSyU40GZD7AsQZLgCJRv1f7c1ZSElDFrRy7MA8y5iSr5Y2z6c X-Received: by 2002:a62:824c:0:b029:21b:66f5:c813 with SMTP id w73-20020a62824c0000b029021b66f5c813mr5269407pfd.32.1618532035934; Thu, 15 Apr 2021 17:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618532035; cv=none; d=google.com; s=arc-20160816; b=a66WcoRsQ6/R9KuwYacXnz4S/5EZPLoGYjs66XR2TE0jPTGolQhkF4/0m2iiL1dSte DQEQ5ez8ZvY0KIkt7mZOwHX3rwAlBgbF3JculwJAduOtM6xhBpE1iGXHjBSRFbvR7qXy bVNWCnLH6EJjmQO6Z2q/3Tddld/n4WywfKjWWJfxuiRX0RnCvY3zEbqsL9dIgkwZB7YM Lhsj3pvJtzvZYcRUAczYzLc8IrCCqns9lzk5WTvzLsvwBoRz5BNvibpEvifzQAfkdVvJ dkz4btz+KMzadhZpsW0tiUsR/DuRBtH1uItui2lTA8269eW61pz54bL2nNQDgTIxCGyv J5Dg== 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=tvGPmIbqutnusjh4FsMND1Vxqzr2fi82WOvaEOiCik4=; b=cAU2txaAM/3Fmnl9kugae7fisfCA8wj3nyEJQ58KRFue8ZWihG0ews94kLaR3vL8ba 4uzkMF0oFzg4zmTu/aQdsQZGhWJMLWyvGzLuvbmY/zhhDp9+z1gC8bFdy4BZhmAKDkkF 4vMvA6PlUJiXMs/I44uJV1nqblDJHlyBG6KHd68H28KUImsttEA0Mkf+KaXYHQxxeY3+ av8P9+AVD4Wgj103RZXqTNKRWwjwg6LOXQseWjA3ECqzW2bGBtzOmsmcDgvJHcwXcIvo nJVSjcua/kdyYu1cUh/5RzHLzYMzoqpARWGloVAYooecby6+9yGb+X0UaSirnAbcF3Oy fUhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="kp/yEgNb"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si5450622pfi.107.2021.04.15.17.13.43; Thu, 15 Apr 2021 17:13:55 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="kp/yEgNb"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235087AbhDPADy (ORCPT + 99 others); Thu, 15 Apr 2021 20:03:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234874AbhDPADy (ORCPT ); Thu, 15 Apr 2021 20:03:54 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48458C061756 for ; Thu, 15 Apr 2021 17:03:30 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id r9so39473756ejj.3 for ; Thu, 15 Apr 2021 17:03:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tvGPmIbqutnusjh4FsMND1Vxqzr2fi82WOvaEOiCik4=; b=kp/yEgNbhtvLhPkmPxZllv8Zg8yJ+M0NjIlsAeKihyNN7qnoclEF1dSfs/Vt8xKAP5 zRjM0UKpIGjBebusV7raClB7cJq4S8LpcQo8i856lmIz4iOWp4GYkiqgbtZ6CHexuduR RvYoKuGIdR12FnkIoc7EihzvyAypqBN8qbgcemzYVjENxPkWkieaYyV2I9wt1q/8i7jf 7ce2C05GywnIvF9iJt7/evk5xLxQlVIrMQCMCIT1KS7tnzH6SEYHgaxbY9Ju5mOMumMK gleq9yVvqDjDrip9ZpSADYay1A6xkQ0iXApx+dX+j+tHk6xk7SThEpzOviArp0ipKPef Hzig== 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=tvGPmIbqutnusjh4FsMND1Vxqzr2fi82WOvaEOiCik4=; b=L/kan/I+9FDTzOHuGUGGDTnmmlX5KIJeLDQ7iEO2TGfU4P9YfGuqcI2QSFDR+Fb/ss qZNH80AA0p8Mc5e8cVmSAyNC42OxsBHLHela63RAaWq2XZCHy2HlxKF2Q+D9dDbK7uxf UyjT2S0DSfZjJOHbLyb1LSi/oz3tIP7Db20olJvilWRSb025y+UJdqPggGl7LeV2We1e o5Hvg8CJHbyaCVs/BR24rAJR5XcJ9X+m4X94m+NQAB5KGqLIA9N1UqZRldmpeBUqDqbt 9zbiVVhkNkFj6LQe47f2Of3ip973v07yXPeO/7bNPE2AXTt5Rvv0yl/8qQQ7Kwm46aMd ndCQ== X-Gm-Message-State: AOAM532BSHLiZyW4Rib/Uj4HEPWow5if6IrtBr4/zRKyfzhSvoLEO1aZ JTr0pl6a2AwWFg8MPplWehLQpWoWEG0S2I38ry5hnA== X-Received: by 2002:a17:906:ef2:: with SMTP id x18mr6035043eji.323.1618531408722; Thu, 15 Apr 2021 17:03:28 -0700 (PDT) MIME-Version: 1.0 References: <20210415232610.603273-1-ben.widawsky@intel.com> In-Reply-To: <20210415232610.603273-1-ben.widawsky@intel.com> From: Dan Williams Date: Thu, 15 Apr 2021 17:03:17 -0700 Message-ID: Subject: Re: [PATCH 1/3] cxl/mem: Fix register block offset calculation To: Ben Widawsky Cc: linux-cxl@vger.kernel.org, Linux PCI , Linux ACPI , "Weiny, Ira" , Vishal L Verma , "Schofield, Alison" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 4:26 PM Ben Widawsky wrote: > > The offset for the register block should be a 64K aligned value, and > therefore FIELD_GET (which will shift) is not correct for the > calculation. > > From 8.1.9.1 of the CXL 2.0 spec: > A[31:16] of offset from the address contained by one of the Function's > Base Address Registers to point to the base of the Register Block. > Register Block Offset is 64K aligned. Hence A[15:0] is zero > > Fix this by simply using a mask. The above reads slightly funny to me, is this any clearer? The "Register Offset Low" register of a "DVSEC Register Locator" contains the 64K aligned offset for the registers along with the BAR indicator and an id. The implementation was treating the "Register Block Offset Low" field a value rather than as a pre-aligned component of the 64-bit offset. So, just mask, don't mask and shift (FIELD_GET). > > This wasn't found earlier because the primary development done in the > QEMU environment only uses 0 offsets > > Fixes: 8adaf747c9f0b ("cxl/mem: Find device capabilities") As I've learned, linux-next will flag this as the wrong format. Fixes: 8adaf747c9f0 ("cxl/mem: Find device capabilities") ...i.e. looks like your core.abbrev setting is 13 rather than 12 per Documentation/process/submitting-patches.rst Other than that, fix looks good to me. > Reported-by: Vishal Verma > Signed-off-by: Ben Widawsky > --- > drivers/cxl/mem.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c > index e3003f49b329..1b5078311f7d 100644 > --- a/drivers/cxl/mem.c > +++ b/drivers/cxl/mem.c > @@ -998,7 +998,7 @@ static struct cxl_mem *cxl_mem_create(struct pci_dev *pdev, u32 reg_lo, > return NULL; > } > > - offset = ((u64)reg_hi << 32) | FIELD_GET(CXL_REGLOC_ADDR_MASK, reg_lo); > + offset = ((u64)reg_hi << 32) | (reg_lo & CXL_REGLOC_ADDR_MASK); > bar = FIELD_GET(CXL_REGLOC_BIR_MASK, reg_lo); > > /* Basic sanity check that BAR is big enough */ > -- > 2.31.1