Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp235161rwb; Thu, 12 Jan 2023 19:04:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXt8n+zbOjN3Z8zvF06YDl8EKGBMLnK41+P4L+nKHRqYxE9qlJ0G9Y9AILxZW4fzNCA++ia6 X-Received: by 2002:a17:906:eb94:b0:841:df6e:a325 with SMTP id mh20-20020a170906eb9400b00841df6ea325mr65708396ejb.9.1673579077705; Thu, 12 Jan 2023 19:04:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673579077; cv=none; d=google.com; s=arc-20160816; b=dNBBro2RHtK179Z3bu+GSPPFdfeaNOKCWjuMvyOHx+MDhOHcSvOcJrghGiwr0pSQ+Y QYDGseqk3IZU/9ObrciioL5mnEFCIAZCyJkpVEQg7sH4F/pYm7ojv+4wBQQ9pu5CB7s9 ON4pChpaY0YC9sEgMCgub1a2bjluF0jZiSg8ENVjNtAmhSIbI8cnLDPF93kYOIEVblSL uissfAAjNJQfpdzEIWt8Yf3oMopQOgse1ykehkibyO7yG/miijkdNZeOEiIbyrHCA3RN S2UBspX8VVrH75o+HFrJ1YMgrCSyxG4yYvNP5XNkB4wmmATQGwvlF8eVx8lRDL40l/Rg 4P0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BGJ5p4olkOacRFaZgkkzImrhwGjvrPdVraohX9O30cQ=; b=gQfTKl0IdrUVTJspgDoH/T3xVNT2FQ5wjBCQS0vI3peE5U16J0scdP76YEntH6x4gT tJrQG2gv5ytl+jbVb+1QsWNwg82OWzTdpFHzP4RnO1Y/k8a5US1pCalsimpEIsmk92Mv mXvBeKDiv+P7GyQg2m9p1YcqjzVlP/LcS4/QUL8RG+BvedkJqNMF9DaYs3Il395kJRZ4 Re7h2lmFRUOK+lXf4ZiNw12Gpbqzy//61mL+MxN9TC6ZXRDAIccaUweHuCltB62XxqU3 GduvYVwb2h/3aGvrbyBOYg/dQ6wDRLvnYbAGGNB7oeqsqFFawoDp8rMKo1Gp7u1SoydY JtWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V8QFgrh1; 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 i7-20020a1709064fc700b0084d34979424si20185224ejw.334.2023.01.12.19.04.25; Thu, 12 Jan 2023 19:04:37 -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=V8QFgrh1; 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 S238228AbjAMCej (ORCPT + 50 others); Thu, 12 Jan 2023 21:34:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbjAMCef (ORCPT ); Thu, 12 Jan 2023 21:34:35 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD745E086; Thu, 12 Jan 2023 18:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673577274; x=1705113274; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=1Fhn7RBHP5K/zgQ40UOi83c/4i6gFct3E7arxwKP9fg=; b=V8QFgrh1GffE1olnkg/Qco6Ew3WI8sbjza0JHpphZCDHDBauIilDSEFH 6S0wxzLUastKjJGIVx8n2FLILqr3bL+L8bI8RX5e+b8nCnrPyslAVgIHS oYfQj/haE3Au3J7CBJ60mkmAHRd06Qk7GmcJOtmOupoS1sdyNJgTixBjO oOXd6fR0V7LqruZfBfLmWKSfH5Q5m5YuEv2qgdea08V63l0Cu7TXGJ5Xg gJTw4/92+baT8/ZKMG37gm9N8ytUIt/nQDy9XdkSzuDgzNcB8Ra68V3r8 pN06+wJ7Ree8vuNO7BI5Hp0hKiv7zMOXJ5WRem1yiyhf8wLOWGTVhcPyG g==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="325953181" X-IronPort-AV: E=Sophos;i="5.97,212,1669104000"; d="scan'208";a="325953181" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 18:33:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="903436020" X-IronPort-AV: E=Sophos;i="5.97,212,1669104000"; d="scan'208";a="903436020" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga006.fm.intel.com with ESMTP; 12 Jan 2023 18:32:59 -0800 Date: Fri, 13 Jan 2023 10:22:39 +0800 From: Xu Yilun To: matthew.gerlach@linux.intel.com 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 Message-ID: References: <20230110003029.806022-1-matthew.gerlach@linux.intel.com> <20230110003029.806022-4-matthew.gerlach@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 2023-01-12 at 07:36:29 -0800, matthew.gerlach@linux.intel.com wrote: > > > On Thu, 12 Jan 2023, Andy Shevchenko wrote: > > > On Wed, Jan 11, 2023 at 10:13:31AM +0800, 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 > > > > ... > > > > > > > > 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. > > > > If the hardware / protocol is capable of communicating the arbitrary lengths > > of parameters, then yes, bytes make sense. But this should be clear what byte > > ordering is there if the items can be words / dwords / qwords. > > The hardware does communicate the arbitrary lengths of the parameter data; > so bytes make sense. I will update Documentation/fpga/dfl.rst to explicitly > say that multi-byte quantities are little-endian. > > > > > TL;DR: The Q is: Is the parameter block a byte stream? If yes, then your > > proposal is okay. If no, no void * should be used. In the latter it should > > be union of possible items or a like as defined by a protocol. > > The parameter block is not a byte stream; so void * should be used. Mm.. I think Andy's idea is, if the parameter block is not a byte stream, void * should NOT be used. My understanding is, The parameter block is not a byte stream in HW, it is some items (or properties) of various lengths. They are compacted in the parameter block. But the layout is not generally defined, each parameter block could have its own layout. The definition and layout of the parameter block is specific to each device, that is, people design the parameter block for the device when they design the device. So DFL core doesn't try to generalize all the layouts, they are unlimited. DFL core just see it as a block of untouched data to be parsed by each driver. So from DFL core's perspective, it is a byte stream. Thanks, Yilun > > Thanks, > Matthew Gerlach > > > > > > > And why users/drivers need to care about the alignment of the parameter > > > block? > > > > > > > follows: > > > > -- > > With Best Regards, > > Andy Shevchenko > > > > > >