Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3301733lfo; Mon, 23 May 2022 01:07:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNFYtg+u5KYYt7EIaS+hk16B9ZeWK19CVA80A1/dNFKcwW07S51qBkQS4S8YXyc6PRnKWD X-Received: by 2002:a17:903:41c1:b0:161:d0d8:d1c7 with SMTP id u1-20020a17090341c100b00161d0d8d1c7mr21944631ple.148.1653293259660; Mon, 23 May 2022 01:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653293259; cv=none; d=google.com; s=arc-20160816; b=Pd9EZnktB1NR1CjohJJKItfGP6kOh+rH86l1iKN7diA1SpG5quCGyn1y/jgtDSYyp4 CWtz1iUzF0CWo5/ENR24cyZIzHGVb7Rd3y59oXpOkOCgvqbeGov+g7lHVSfHz2NzJkC0 y+SKevyQuRKm5KIQ0+cQL15850fM2ppVmRj1hrfm/QXnLSLEfJsZsE72IGaEa5etm9cc Uwm+PjK0daDyg2XxlecOcdGwhvhsqgFSMMKKwejbnxfjgVPGT/H85juG3ytlpqsNCt3U GcY8Tjbm33RNOLDJ57a+G0ebJdm8IkzaWlqAdebFI4s9b/Fjxos5Ihnn+0Um+gjfN1Es H6IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RdfJrHZOQ1NyS95uJKaLrnqYZCyhOhIpQ9DqO/4pn9A=; b=lS7khZVJnH74KuqS7OFAU/Nm6uHxJaluMjTnjpT69Q4kD4Kx17QUwra/yYGZ5KkNnW +xbmvuPtSdwUIODjy26/yiK7gcfIaCo+7AQ6Ud8YEKH9G+WfLlEY2DOMnh1m3rfmli/B uFguqdnPsLov213jGC9mU5f/yBlofTqCuqZR3BnpnWwGk4xr94e75PJJub6PLcNZYZWQ I4sx9uW+rtFJNZoKSZL0FbrROEzkIkeNm4dgVEMLHWL3ioX/W3Rdhv+zitchDkYdJUqo dWZSURM2x6jyKSywHhWrL+WioX82widO+TW8EyDiYeUzE4dBjqNAr3TbxyCWkprRmBCg /EIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dT8iAA//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 4-20020a630004000000b003f64dce1105si9884804pga.766.2022.05.23.01.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dT8iAA//"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CBE5DB64; Mon, 23 May 2022 00:03:30 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344376AbiETBbk (ORCPT + 99 others); Thu, 19 May 2022 21:31:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344086AbiETBbf (ORCPT ); Thu, 19 May 2022 21:31:35 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90AC895A08; Thu, 19 May 2022 18:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653010293; x=1684546293; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kyp3JRERShg4eTuUYYWrAsJejoTn+bDOBMBL5rwGgCI=; b=dT8iAA//YoHwWdRowTKHH8WHp8WGDVOwLghm+geUmHqffKNjTKV4P3F+ Nhxxz0sSEvO5lNg4eWj/EhnJn1/Fm5jA3oJYxM5bD4We3r00QDhS7q7W3 tvMwU+sVRgM9uujUvA1Fnq6b9YxHPU8UZ7XK/E7aoL9PJeP0j9mXBleWF nMIV4+UmT87bWuac8cPGoNlpFkvtLBWoR69mJQY7BM9aIclJ85e2s6Tio /c6PhC0TnVr+2PE2zLxyUof7QaW64KeypY+vMENlZUG7xaLV+S7z6XNTs gWjLSdFukn6CZ9ThKGwE2pPR3PE0Ws1dqvy19K4GhI1E0u+2tPRR3Bnr7 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10352"; a="333067384" X-IronPort-AV: E=Sophos;i="5.91,238,1647327600"; d="scan'208";a="333067384" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2022 18:31:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,238,1647327600"; d="scan'208";a="524396205" Received: from unknown (HELO localhost.localdomain) ([10.226.216.90]) by orsmga003.jf.intel.com with ESMTP; 19 May 2022 18:31:24 -0700 From: tien.sung.ang@intel.com To: christophe.jaillet@wanadoo.fr Cc: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Ang Tien Sung Subject: [PATCH v2] fpga: altera-cvp: Truncated bitstream error support Date: Fri, 20 May 2022 09:30:40 +0800 Message-Id: <20220520013040.2920835-1-tien.sung.ang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <6939d35f-36a0-568e-bfec-4dd2e3a48604@wanadoo.fr> References: <6939d35f-36a0-568e-bfec-4dd2e3a48604@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Ang Tien Sung To support the error handling of a truncated bitstream sent. The current AIB CvP firmware is not capable of handling a data stream smaller than 4096bytes. The firmware's limitation causes a hung-up as it's DMA engine waits forever for the completion of the instructed 4096bytes. To resolve this design limitation, both firmware and CvP driver made several changes. At the CvP driver, we just have to ensure that anything lesser than 4096bytes are padded with extra bytes. The CvP will then, initiate the tear-down by clearing the START_XFER and CVP_CONFIG bits. We should also check for CVP_ERROR during the CvP completion. A send_buf which is always 4096bytes is used to copy the data during every transaction. Signed-off-by: Ang Tien Sung --- changelog v2: * Alignment fix parameter 'conf' altera_cvp_send_block --- drivers/fpga/altera-cvp.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c index 4ffb9da537d8..5169f9bcd726 100644 --- a/drivers/fpga/altera-cvp.c +++ b/drivers/fpga/altera-cvp.c @@ -81,6 +81,7 @@ struct altera_cvp_conf { u8 numclks; u32 sent_packets; u32 vsec_offset; + u8 *send_buf; const struct cvp_priv *priv; }; @@ -453,7 +454,11 @@ static int altera_cvp_write(struct fpga_manager *mgr, const char *buf, } len = min(conf->priv->block_size, remaining); - altera_cvp_send_block(conf, data, len); + /* Copy the requested host data into the transmit buffer */ + + memcpy(conf->send_buf, data, len); + altera_cvp_send_block(conf, (const u32 *)conf->send_buf, + conf->priv->block_size); data += len / sizeof(u32); done += len; remaining -= len; @@ -492,10 +497,13 @@ static int altera_cvp_write_complete(struct fpga_manager *mgr, if (ret) return ret; - /* STEP 16 - check CVP_CONFIG_ERROR_LATCHED bit */ - altera_read_config_dword(conf, VSE_UNCOR_ERR_STATUS, &val); - if (val & VSE_UNCOR_ERR_CVP_CFG_ERR) { - dev_err(&mgr->dev, "detected CVP_CONFIG_ERROR_LATCHED!\n"); + /* + * STEP 16 - If bitstream error (truncated/miss-matched), + * we shall exit here. + */ + ret = altera_read_config_dword(conf, VSE_CVP_STATUS, &val); + if (ret || (val & VSE_CVP_STATUS_CFG_ERR)) { + dev_err(&mgr->dev, "CVP_CONFIG_ERROR!\n"); return -EPROTO; } @@ -661,6 +669,12 @@ static int altera_cvp_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, mgr); + /* Allocate the 4096 block size transmit buffer */ + conf->send_buf = devm_kzalloc(&pdev->dev, conf->priv->block_size, GFP_KERNEL); + if (!conf->send_buf) { + ret = -ENOMEM; + goto err_unmap; + } return 0; err_unmap: -- 2.25.1