Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37742736rwd; Tue, 11 Jul 2023 19:54:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlEqsDMRw1IzAYnamizPjDGBBYdtGfyyKAO/HQxLMoXvD182b4qwesjhs9eXD05ZoDheasXU X-Received: by 2002:a17:903:22c7:b0:1b8:a894:407c with SMTP id y7-20020a17090322c700b001b8a894407cmr807450plg.22.1689130446605; Tue, 11 Jul 2023 19:54:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689130446; cv=none; d=google.com; s=arc-20160816; b=TNCDuP9sn4/AEdu7V2C+7D3Eeitr9OSw5UT77OD97nkeM2f5Gp1UYTzFuYqqWsUgm5 RoITh+8JjFQp9Tqx/OUdeA6KUpotf7ytjStko/XLZv8drg4i3CTFH+Gex5SMq11chipM BpSuYkziKSjIG0bjGroiPNMX1oRQX0/yUtwItIVQ+laenBlu/XiDBTjmhn82QaItzkkx k8lETGMGLyE7u8R9CgZijKFZx1qB/F5KZSvXvLEt8Myfd32Exw5uBoxiIMkCaQPPRu+X 4+s0XLcny8NiY9vMtt8v46TEw7DHbMYHGalDPZh4S0/3V55NwHQIcvM7Tf26Gxisbfhg h7WA== 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=FOidN1EStgcRPqZ23/g58tC0CuKDCjclWBVFhUZxkBc=; fh=niI/0ppPrrlcQE/PCWSM4wsS4M0dx/JiCVWo7ADVoQI=; b=NXhf0GncPuFMi4HDTWuCqcCIvf84Sd1dq95DFNqjeDkSDD0z5bky5kPO0Ki8RM2Xcj HXzF+45cTHPKx8IOVkcv7Br7rGsrW0oyIxmiTN2WTRXrWW46HgM58gHsellkg54cpWsn 0mRu8tCrDYcw58cx3qA+IuKduqsU0uqSnonnMsBGKKSUquOxTXZzums+M1R6SNwgCQqS ZhBizH2KcbT5d2TwR27/mwdWm5WKx7yHLBI7ZJh8bR/yP7fnyP05f9qu+gtDSu9zuq3f 4soSV+vZkY1oqBP+1T6MRjbpvfafQ2tLNynA20zRVsghGXEpSiRD3VjVWuQPFL12NXhJ 1W6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Mci8O9yO; 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 l187-20020a6391c4000000b00544c0bf5ffesi2390992pge.606.2023.07.11.19.53.54; Tue, 11 Jul 2023 19:54:06 -0700 (PDT) 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=Mci8O9yO; 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 S231608AbjGLCBu (ORCPT + 99 others); Tue, 11 Jul 2023 22:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjGLCBt (ORCPT ); Tue, 11 Jul 2023 22:01:49 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9E8BE7E; Tue, 11 Jul 2023 19:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689127308; x=1720663308; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=tnDgXuyxN6TFU9q9l7GfKXwskzKHJdUAYGiVK1N0+ME=; b=Mci8O9yO6zoJ8HYJiaGncfaTQ9Uj2jZwQAOHPjIL6GgvZwdNg8KiYf6o c/KvkUZUJmNcPK4b+QW0X0Uh7lsiYA5gL8ppR4Amp7/twICWbejFQexxe 3FeIdK4BuE7JK9GmleY1Y8MXH+U1fm/vfrZ95kHLzhXDtkNkHcWioDK5B /cpNQU/FTbaZxYSD+neC+Zxp0v94/djdLizrUxWyX6LfR8CaMzHHpYRuv oBFeD/OQW8ZGo1mPrI60LrH7q0vWv6jRHXzi0qzshQv9iP+SZsWUU4mlt 6pupn/4/hHIFSMP1hvBr9NfOwg6qMo4CQMucRzN31HjfQIBPfK2uGKm7o A==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="362247653" X-IronPort-AV: E=Sophos;i="6.01,198,1684825200"; d="scan'208";a="362247653" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2023 19:01:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="786858030" X-IronPort-AV: E=Sophos;i="6.01,198,1684825200"; d="scan'208";a="786858030" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga008.fm.intel.com with ESMTP; 11 Jul 2023 19:01:46 -0700 Date: Wed, 12 Jul 2023 10:00:16 +0800 From: Xu Yilun To: Marco Pagani Cc: Moritz Fischer , Wu Hao , Tom Rix , linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org Subject: Re: [PATCH v8 1/4] fpga: add an initial KUnit suite for the FPGA Manager Message-ID: References: <20230630152507.30219-1-marpagan@redhat.com> <20230630152507.30219-2-marpagan@redhat.com> <1d03a695-d603-a4d5-b726-4b0ff6bc33f8@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1d03a695-d603-a4d5-b726-4b0ff6bc33f8@redhat.com> 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,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-07-11 at 16:02:44 +0200, Marco Pagani wrote: > > > On 2023-07-10 06:44, Xu Yilun wrote: > > On 2023-06-30 at 17:25:04 +0200, Marco Pagani wrote: > >> The suite tests the basic behaviors of the FPGA Manager including > >> programming using a single contiguous buffer and a scatter gather table. > >> > >> Signed-off-by: Marco Pagani > >> --- > >> drivers/fpga/tests/fpga-mgr-test.c | 311 +++++++++++++++++++++++++++++ > >> 1 file changed, 311 insertions(+) > >> create mode 100644 drivers/fpga/tests/fpga-mgr-test.c > >> > >> diff --git a/drivers/fpga/tests/fpga-mgr-test.c b/drivers/fpga/tests/fpga-mgr-test.c > >> new file mode 100644 > >> index 000000000000..6fd2e235f195 > >> --- /dev/null > >> +++ b/drivers/fpga/tests/fpga-mgr-test.c > >> @@ -0,0 +1,311 @@ > >> +// SPDX-License-Identifier: GPL-2.0 > >> +/* > >> + * KUnit test for the FPGA Manager > >> + * > >> + * Copyright (C) 2023 Red Hat, Inc. > >> + * > >> + * Author: Marco Pagani > >> + */ > >> + > > [...] > > >> +static int op_write(struct fpga_manager *mgr, const char *buf, size_t count) > >> +{ > >> + struct mgr_stats *stats = mgr->priv; > >> + size_t i; > >> + > >> + /* Check the image */ > >> + stats->image_match = true; > >> + for (i = 0; i < count; i++) > >> + if (buf[i] != IMAGE_FILL) > >> + stats->image_match = false; > >> + > >> + stats->op_write_state = mgr->state; > >> + stats->op_write_seq = stats->seq_num++; > >> + > >> + return 0; > >> +} > >> + > >> +static int op_write_sg(struct fpga_manager *mgr, struct sg_table *sgt) > >> +{ > >> + struct mgr_stats *stats = mgr->priv; > >> + struct sg_mapping_iter miter; > >> + char *img; > >> + size_t i; > >> + > >> + /* > >> + * Check the image, but first skip the header since write_sg will get > >> + * the whole image in sg_table. > >> + */ > >> + stats->image_match = true; > >> + sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG); > >> + > >> + if (!sg_miter_skip(&miter, HEADER_SIZE)) > >> + stats->image_match = false; > > > > If this fails, should we continue? > > Would it be okay to set the image_match flag to false and then > return 0 if sg_miter_skip() fails? That's good to me. > > I think returning an error code to the FPGA manager would not > be beneficial in this case since if an op fails, it is a failure > of the FPGA manager itself, not the low-level driver that tests > the FPGA manager. So the idea is we never return error code in any fake driver ops? That's OK. Please add some comments in code for it and the reason. Thanks, Yilun > > > > > >> + > >> + while (sg_miter_next(&miter)) { > >> + img = miter.addr; > >> + for (i = 0; i < miter.length; i++) { > >> + if (img[i] != IMAGE_FILL) > >> + stats->image_match = false; > >> + } > >> + } > >> + > >> + sg_miter_stop(&miter); > >> + > >> + stats->op_write_sg_state = mgr->state; > >> + stats->op_write_sg_seq = stats->seq_num++; > >> + > >> + return 0; > >> +} > > >