Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp466449rwb; Thu, 12 Jan 2023 08:16:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXvSXoi9id9o3fdfxQdAaeycolXI0kQ38U1/P3bLHrLmX27eoyfzwYBxU7mEGEAGaatDuVwd X-Received: by 2002:a17:902:b414:b0:186:748e:9383 with SMTP id x20-20020a170902b41400b00186748e9383mr70641104plr.46.1673540203436; Thu, 12 Jan 2023 08:16:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673540203; cv=none; d=google.com; s=arc-20160816; b=xI1y16Vz63iQtdIOlhK+tD/uQLlwIzhSyHaQFSuTrFSjJZX/THrBgvAV92pbcjXlXm mxaAd5RUwyoji2VCd1UMFpVwa5A6Ja0xXvikUZhChPearhhLafK26ieSVpTlJ18zUIKR 7nwRJNXXvyr+wIQQgv4FmEmKFSvguOiUGXKqTZ96R1turvfGVg5o9Ro+bF3P68dKCiJV yPhm3clwaOTPSDicpTuIqqvznzV0jg68hTUPe4ofo0dUvvBgrkL+PAAmox0d3U5ihLlq uPWcmAmNQaefEIOZ2QQSQWLqkwP/g9iPwY6ygPKt9lGxx2cA/yPxLcKXKOmfpY04EkrW l6Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=zytAJdJh/6XJBUPJgQ0V8nNu1nJK2hByo8mS16d98+U=; b=BCwjN8BqdRBK2Sd5vfhHTn87GS7ACwO6A9L3P8hoDbd+cMVjfj8mXf5mX2p1fXb8ZM bYTjPaKwXm1XCQrLTsTEk6u9UiCbc7hOTWr/ilh62danBluQ9YvK1ZY+G/HPrrWY6ZOP PW5FGDv6SXUMUtKEoHexkLznAM5XqYH2FtOimHXms8iJ8HUQpbUT/OwGouLN6rZzxItN I1VESAAyx0uKkOELP2eZ+oMD+zS4T/DXT1m7sA9TH6UrMf3Y3Kb0naFRo/X56xbdyaIP 0hszJQQ1riiyayBgs3qi5fka/WLobg3eu7NEQ3PNbxvvDvf/Eyj/V5MVx7zMv28fDVS7 QuBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k3iy8YuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902ea0900b00189d12c0dd9si19094334plg.555.2023.01.12.08.16.36; Thu, 12 Jan 2023 08:16:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k3iy8YuM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240484AbjALPke (ORCPT + 50 others); Thu, 12 Jan 2023 10:40:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240554AbjALPjo (ORCPT ); Thu, 12 Jan 2023 10:39:44 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E62A48CD4; Thu, 12 Jan 2023 07:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673537432; x=1705073432; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=0ritdKUn0cRU7l3A1Ps2Js7vFq3raQ8V5MfOb3WntQg=; b=k3iy8YuMV4//PXat6nX0NbgVotHUkqsi97AFxsXfINhXIN7GcrK7iFvl rzl7N2yyN0aQdpPEswhFSVoVb2TUg5oZkCxBvQ1MY83p44LLeeWa64Otc AxYI+Xp4eFT3hIO4I9JdCjysmLzOfgLb3non8tn7czMDEYx7qGuAKX3w1 9wDe1RJaPB7OnK109XyMIUm/NR1LJsNoTTbP53mqxYZZikLG9ykE5Ok+y RUviUtOIb+yki9n/X97yldU1Z80JLz+f3D70QNHpWRaMd8J8w0yMg8140 tlHV9DCNli5GD/6pVJSOmdcf5QfvyQKQHtltdFXOr79/Lm+wsVl93S5Xh g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="350958895" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="350958895" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 07:30:24 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="659820546" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="659820546" Received: from rhweight-wrk1.ra.intel.com ([137.102.106.43]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 07:30:23 -0800 Date: Thu, 12 Jan 2023 07:30:54 -0800 (PST) From: matthew.gerlach@linux.intel.com X-X-Sender: mgerlach@rhweight-WRK1 To: Xu Yilun cc: Andy Shevchenko , hao.wu@intel.com, russell.h.weight@intel.com, basheer.ahmed.muddebihal@intel.com, trix@redhat.com, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tianfei.zhang@intel.com, corbet@lwn.net, gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, jirislaby@kernel.org, geert+renesas@glider.be, niklas.soderlund+renesas@ragnatech.se, macro@orcam.me.uk, johan@kernel.org, lukas@wunner.de, ilpo.jarvinen@linux.intel.com, marpagan@redhat.com, bagasdotme@gmail.com Subject: Re: [PATCH v10 3/4] fpga: dfl: add basic support for DFHv1 In-Reply-To: Message-ID: References: <20230110003029.806022-1-matthew.gerlach@linux.intel.com> <20230110003029.806022-4-matthew.gerlach@linux.intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Jan 2023, Xu Yilun wrote: > On 2023-01-10 at 14:07:16 -0800, matthew.gerlach@linux.intel.com wrote: >> >> >> On Tue, 10 Jan 2023, Andy Shevchenko wrote: >> >>> On Mon, Jan 09, 2023 at 04:30:28PM -0800, matthew.gerlach@linux.intel.com wrote: >>>> From: Matthew Gerlach >>>> >>>> Version 1 of the Device Feature Header (DFH) definition adds >>>> functionality to the Device Feature List (DFL) bus. >>>> >>>> A DFHv1 header may have one or more parameter blocks that >>>> further describes the HW to SW. Add support to the DFL bus >>>> to parse the MSI-X parameter. >>>> >>>> The location of a feature's register set is explicitly >>>> described in DFHv1 and can be relative to the base of the DFHv1 >>>> or an absolute address. Parse the location and pass the information >>>> to DFL driver. >>> >>> ... >>> >>>> v10: change dfh_find_param to return size of parameter data in bytes >>> >>> The problem that might occur with this approach is byte ordering. >>> When we have u64 items, we know that they all are placed in CPU >>> ordering by the bottom layer. What's the contract now? Can it be >>> a problematic? Please double check this (always keep in mind BE32 >>> as most interesting case for u64/unsigned long representation and >>> other possible byte ordering outcomes). >> >> A number of u64 items certainly states explicit alignment of the memory, but >> I think byte ordering is a different issue. >> >> The bottom layer, by design, is still enforcing a number u64 items under the >> hood. So the contract has not changed. Changing units of size from u64s to >> bytes was suggested to match the general practice of size of memory being in >> bytes. I think the suggestion was made because the return type for >> dfh_find_param() changed from u64* to void* in version 9, when indirectly >> returning the size of the parameter data was introduced. So a void * with a >> size in bytes makes sense. On the other hand, returning a u64 * is a more >> precise reflection of the data alignment. I think the API should be as > > I prefer (void *) + bytes. The properties in the parameter block are not > guarateed to be u64 for each, e.g. the REG_LAYOUT, so (void *) could better > indicate it is not. It is just a block of data unknown to DFL core and to > be parsed by drivers. OK, (void *) + size in bytes is fine. > > And why users/drivers need to care about the alignment of the parameter > block? Consumers of the parameter block data might try access data that is unaligned for a particular CPU. The good news is that the definition of the parameter blocks ensures the data is u64 aligned. Thanks, Matthew Gerlach > > Thanks, > Yilun > > >> follows: >> >> /** >> * dfh_find_param() - find parameter block for the given parameter id >> * @dfl_dev: dfl device >> * @param_id: id of dfl parameter >> * @pcount: destination to store size of parameter data in u64 bit words >> * >> * Return: pointer to start of parameter data, PTR_ERR otherwise. >> */ >> u64 *dfh_find_param(struct dfl_device *dfl_dev, int param_id, size_t >> *pcount) >> >> Regarding byte ordering, Documentation/fpga/dfl.rst does not currently >> mention endianness. All current HW implementations of DFL are little-endian. >> I should add a statement in Documentation/fpga/dfl.rst that fields in the >> Device Feature Header are little-endian. >> >> Thanks for the feedback, >> Matthew Gerlach >> >>> >>> -- >>> With Best Regards, >>> Andy Shevchenko >>> >>> >>> >