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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86305C43334 for ; Thu, 9 Jun 2022 08:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229441AbiFII1q (ORCPT ); Thu, 9 Jun 2022 04:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbiFII1p (ORCPT ); Thu, 9 Jun 2022 04:27:45 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 594BF14D7AD; Thu, 9 Jun 2022 01:27:43 -0700 (PDT) Received: from fraeml740-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4LJcXs124Jz6892X; Thu, 9 Jun 2022 16:22:53 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml740-chm.china.huawei.com (10.206.15.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 10:27:40 +0200 Received: from localhost (10.81.202.195) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 9 Jun 2022 09:27:39 +0100 Date: Thu, 9 Jun 2022 09:27:38 +0100 From: Jonathan Cameron To: Ira Weiny CC: Ben Widawsky , Dan Williams , Bjorn Helgaas , "Alison Schofield" , Vishal Verma , Dave Jiang , , , Subject: Re: [PATCH V10 6/9] cxl/port: Read CDAT table Message-ID: <20220609092738.00007553@Huawei.com> In-Reply-To: References: <20220605005049.2155874-1-ira.weiny@intel.com> <20220605005049.2155874-7-ira.weiny@intel.com> <20220606181541.ysb3zqdpe5cuk4e6@bwidawsk-mobl5> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.81.202.195] X-ClientProxiedBy: lhreml731-chm.china.huawei.com (10.201.108.82) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org On Wed, 8 Jun 2022 14:27:14 -0700 Ira Weiny wrote: > On Mon, Jun 06, 2022 at 11:15:41AM -0700, Ben Widawsky wrote: > > On 22-06-04 17:50:46, ira.weiny@intel.com wrote: > > > From: Jonathan Cameron > > > > [snip] > > > > > + > > > + entry = cdat_response_pl + 1; > > > + entry_dw = task.rv / sizeof(u32); > > > + /* Skip Header */ > > > + entry_dw -= 1; > > > + entry_dw = min(length / 4, entry_dw); > > > + memcpy(data, entry, entry_dw * sizeof(u32)); > > > + length -= entry_dw * sizeof(u32); > > > + data += entry_dw; > > > + entry_handle = FIELD_GET(CXL_DOE_TABLE_ACCESS_ENTRY_HANDLE, cdat_response_pl[0]); > > > > [0] looks suspicious... > > Actually I have to claim ignorance on this one. I've carried this from > Jonathan's original patches. I'm not as worried about the [0] as that is just > the first dword. But I'm confused as to this entry handle now. > > Jonathan? Help? Looks right to me. The entryhandle is a field in the upper 16 bits of the first dword defined in Read Entry Response table in the CXL spec and also used in the request of the next entry (which is more or less a CDAT structure) Two magic values. 0 - CDAT header (request only - can't be returned) 0xFFFF - No more entries. As we are reading the whole table, we write 0 to first request and from there on use the value returned in the response for the next request until we see 0xFFFF and stop. Note IIRC the meaning of entry handle was clarified in a CXL 2.0 errata as was a bit ambiguous in the original spec (we had two QEMU implementations briefly and they did different things :) Jonathan > > > > > > + > > > + } while (entry_handle != 0xFFFF); > > > + > > > + return rc; > > > +} > > > +