From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.48 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796284212; b=i0/Mcqfxh5WeDHWpajkeE8aprQwa7jtpkYo3HSm6hPAfNwe31Spx9Vr3J1l7oQxxUNms Wf54w2scVLcr3xNqMKI74Kvxu8oL9kfIQZhq7K5zHYhyNgCozHgP6s75/zEejUmc+Ca1O p9EMqgqtgA2QyStQuIySUasqpEN8xc9DMbJJ0i0i/SgK2HeMlYwpYP1fJNQYz/NOnEWL4 T9UYCeeh6It5s0NueEdZwW0A0ooiLCR1NAd3LRuhgjv+aKK9ajMtWkGOAym1FUx3J8BJG JGya+vz0ow1hshfJ380bUQOJ8sNvmlcafWcoReTxyHXRbc0FGhGwlSlaZKEVnHUmgSQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796284212; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-MS-Exchange-AtpMessageProperties:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=VT3OF/m0TxmMg21Qi6VJcEMLkEzQfnGylJeAaRKaRJw=; b=ng4wpEugYGgksi9fmp7eqFuhp3asGsBzl7T0FG9/X5l4AJUIOyFialyiSCThE1/OHHXz v2tFhOgraySCR4y2PkUvfulMnzgzxZh9Z3P1XY9PWe+0Mh3N05H6SywTE6kUfTdwHck6X hjsugVR9fhhYDQZqS1egl72qHPh5kuL2wn5IOWLb1lftsnuysBjaudewXTj/7tImWvJ5U TrN8N1E5HcW4yTNG8tnmH28aU/+qzPfKm16NdVHP/crf2rzuMN9KF3kedVH1SxHLiE5+1 GC+PXisaPSXJ1EH7s37VRaURi1GEBKUs/zxTDIqA9UVRjnbU4vrSMqTk4mQlOxlKBaQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=altera.com; spf=pass smtp.mailfrom=altera.com; dkim=pass header.d=altera.com header.i=@altera.com header.a=rsa-sha256 header.s=selector2 header.b=I6gCE5D4; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.57.48 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011048.outbound.protection.outlook.com [52.101.57.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DB50606A322; Thu, 3 Dec 2026 07:50:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1DB50606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=altera.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altera.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=altera.com header.i=@altera.com header.a=rsa-sha256 header.s=selector2 header.b=I6gCE5D4 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nMcQNBP4s9tCk4B4LBgLfaLnp5gF4aD62zKCrnc5Rrzwwhqv1EOBAmUnf97HF+rkZdCe5grpqWgGBRHup4O/ZX7DUrm7g3+GYTZLrNoByAKXpHsi6qTV6QhE/uuVq4UvStIvwgF5zeqY8YekMOaj4cV1aJRlFKYNtAOnRbSF19C28uBFjO6zPJn89Gf20swn+LjdszE7PG+1PEVNiUOtQeGLofrZePVZGtDGklv5PBAlYPXXRNHCdfe0TVUl4ziIw8Nri992IOBBn98iugwypmSUQIvomZlBeCbRIEvaaJDzRKp0cn0w73QrVdcSMVPNzdHzUo2fjoY2mRjovYdBlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VT3OF/m0TxmMg21Qi6VJcEMLkEzQfnGylJeAaRKaRJw=; b=wuAQqA1rp+G9hKdOYYj93R68LMFNnjjLNXuDuj74NIL+WQvJ7Wd9WCXtvZSbhBRsXhgmhXuksPeNS8YJwUENB/IHtUEcqBrEYPZTAgMUKuvvcA0oOti533UcU6wmnlXLNc9M635dte5uXIkrsPF1wLTuV4WLw2XyZVm0lw/YJ2L7Z2VtEd4DX5XNoHS1xb3E+0OtT1wnGV+0l0rqMU4i3s+zUvX+rYIdFz4Jxh0VOWtjG+TBlOyJ7CdgnmwuFqF84lJFUx0dnzvLC8a9smwMu+6y5MDuedB6Pv4WeIejQsEnZpfAthaqFQE5x6xTunmMOGJQHOPwmOpcWnYyo/abgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=altera.com; dmarc=pass action=none header.from=altera.com; dkim=pass header.d=altera.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=altera.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VT3OF/m0TxmMg21Qi6VJcEMLkEzQfnGylJeAaRKaRJw=; b=I6gCE5D4sDsqPz8E31LGyRPoUvS7W91zelh+oKeXVtEWWOllNLDtkVUxy9mf7qatt4iqXKt+I+Mrmnsy18CEPQdRgYtruyuNZ16sf17O7hDMnMQ0fr4EFUmnPlTkXe177cdA5jrVgM/eh8lVDTXuF+HL317O7V0Ui5GyzEDIoo9jgJiX03IqWhCrsakpmFpq4gmW15ndfMnirvM5RJtbpQ/h7fZbpvDKk0rdOiwluupNKubr1GeS4TLpXZCW6t3oMMQ+DbFMXxp6Cz7diVoturYDMqtKhRIqHkfiOXN1bf44qiJJl9blPf5vPodM7FHuidlsf8PoDkamKKB8oZEfcw== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=altera.com; Received: from SJ0PR03MB5950.namprd03.prod.outlook.com (2603:10b6:a03:2d3::20) by PH0PR03MB6399.namprd03.prod.outlook.com (2603:10b6:510:b3::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Thu, 3 Dec 2026 07:50:07 +0000 Received: from SJ0PR03MB5950.namprd03.prod.outlook.com ([fe80::53a0:bf93:6b6b:de01]) by SJ0PR03MB5950.namprd03.prod.outlook.com ([fe80::53a0:bf93:6b6b:de01%3]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 07:50:07 +0000 Message-ID: Date: Thu, 3 Dec 2026 15:50:01 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] fpga: altera-cvp: Handle truncated bitstream with padding buffer To: Xu Yilun Cc: Moritz Fischer , Xu Yilun , Tom Rix , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org References: <3c1bb384cb9cd5bb35b3c7e68a4feab95ef4ad60.1794987679.git.tze.yee.ng@altera.com> <17e00dfd-c744-45e3-aba9-e404210bc481@altera.com> Content-Language: en-US From: "NG, TZE YEE" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed X-ClientProxiedBy: SI3PR02CA0010.apcprd02.prod.outlook.com (2603:1096:4:295::19) To SJ0PR03MB5950.namprd03.prod.outlook.com (2603:10b6:a03:2d3::20) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR03MB5950:EE_|PH0PR03MB6399:EE_ X-MS-Office365-Filtering-Correlation-Id: c56e8d4b-0917-483a-29cb-08df51120ca0 X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|23010399003|4143699003|6133799003|18002099003|22082099003|4133799003|55112099003|5023799004|10067099003|261021133027099003|56012099006|11063799006|261102123227099003|261028144727099003|261026130827099003|261026135527099003|261026121527099003|261026140227099003|261021121427099003|261022105027099003|261021135927099003|261021123027099003|261021130227099003|261022075727099003|261022115727099003|261022113327099003|261009223027099003; X-Microsoft-Antispam-Message-Info: jLASpmqn37QuRMF4uDITtXQ2H9BEgR8Y9U1J98gj/lA4ZQxwC87U/5F2ltwbvgVyW4CeOG1aIGJwXwmsaASdEzDhvphD6XV36LaPpunZ33ZftCZuBjMrkcrHMDGdwVTcuW/I8GpJ1Afa0KxgH3YyLrx1cJkghf8Wvz2zkXvMZBf3iqd7UPzM0JV56CKLpOX1NJ1DQ3FKTRDo5aqTswc0Q3o9o8ZRqEcCesPFyPek0CwHOR7KRTNBhOj7miL51UxpkY6TYHHEwXQIzX7jaEPjwcUSov69aNXTJtRTl+c0DwQ3qiHBLggPXythbP17mEty2wtPQc8BmxsSKw1FmR7wQjNTV67hX/A8vLu+v4wsTmPpU016ChSDCH/BZwc/unm4Fu3qvBaQRWo0MSFosyQJJmZ1qYiu8gsYoyL4d7geCwut1WBbgarJ2zkoCBqeTcJFfyWGXHLIA0VMTmzKwtmp3A4doLNra93whmH4zH4xgOG6BGg8InkyPUGcBxIGyzbdL/jRFEFGUnhSIMLtaO8/rJnA6zBSLBxRnTCUCe2LkvOnbuLLHLdd9jFCXmXy4hYp4xwQ15eSQIny1B54AnEmL8P/hKzTVLrsXzU9T+DPt0k= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR03MB5950.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(23010399003)(4143699003)(6133799003)(18002099003)(22082099003)(4133799003)(55112099003)(5023799004)(10067099003)(261021133027099003)(56012099006)(11063799006)(261102123227099003)(261028144727099003)(261026130827099003)(261026135527099003)(261026121527099003)(261026140227099003)(261021121427099003)(261022105027099003)(261021135927099003)(261021123027099003)(261021130227099003)(261022075727099003)(261022115727099003)(261022113327099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UXMzb2dKaDc1MXU2eHUxd0YzbmdlaUtTc2toOGtaZHg4RlZEWnZnaVBCYU1Q?= =?utf-8?B?dm5jWDlsYitBU0FtRk5CREp3MFJvNnFsancwelpZSzZVS0NPZEMrVktqQmZn?= =?utf-8?B?SDRVQzQ4SjhwcjNQRGkrek0vV0tHZmdnMkFPRHplR0VjQkoyd3ZRY2RWYmQ1?= =?utf-8?B?UWY2b0lNMzJ5NmxYSmlZMm5XSzhla0xKUUhCb3oxcmx2WWhuTE9CZmRWK1ky?= =?utf-8?B?eTZGY2RSNXhIU1FnMWtxQzhseWx4c1h0ZTV4SkF6QXJlMTVQd05rdVBnWkdX?= =?utf-8?B?RThGVXVMR3kzcjR0OXh6YmtPa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= =?utf-8?B?Ykw4UzhRMmJBWTNiTHAzekprZXdSQW11WGl0K0tvTGpLYkZtQkRJOERWK1dX?= =?utf-8?B?TWVTa0FUR25JeHFqUStTWDJwZTgzeVZneXFCYUhhZ2pNOEc0QlNkdGxEU2k2?= =?utf-8?B?SkZVeWZlN2I1a1Y1QW9kZURVcStuWW5HeWgxOTF5eDBBcitkdllMNmxaeXhQ?= =?utf-8?B?aWhZSE1BeGtJYjNxY3haTjVpWDF5VU1ydEhUdVNFUDBSa0VDRGVGZz09?= X-OriginatorOrg: altera.com X-MS-Exchange-CrossTenant-Network-Message-Id: c56e8d4b-0917-483a-29cb-08df51120ca0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR03MB5950.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 07:50:07.4311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fbd72e03-d4a5-4110-adce-614d51f2077a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RlINc5x568Xufzp6cuvalbXUDiVVwFnbBN25i2yxBxec3ID4HaKBpCPENhDK065wdt1k2LhJ6aXYrT7X74pRWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR03MB6399 Hi Yilun, On 2/12/2026 8:48 pm, Xu Yilun wrote: > On Tue, Dec 01, 2026 at 03:32:38PM +0800, NG, TZE YEE wrote: >> Hi Yilun, >> >> Thanks for the review. >> >> On 28/11/2026 10:15 pm, Xu Yilun wrote: >>> On Wed, Nov 18, 2026 at 03:43:15PM +0800, tze.yee.ng@altera.com wrote: >>>> From: Nazim Amirul >>>> >>>> The AIB CvP firmware requires a minimum transfer size of 4096 bytes. >>>> When a bitstream smaller than this is sent, the firmware DMA engine >>> >>> Only when < 4096? E.g. if a bitstream is 4096 + 1, it is good? >>> >> >> No, the log was wrong. The CvP firmware moves data in 4096-byte blocks, >> one per TX credit, and requires the host to send exactly 4096 bytes per >> block. The driver sends the last block with only the remaining bytes, >> so any image whose size is not a multiple of 4096 stalls on the last >> block, 4096 + 1 included. I'll correct this in v3. >> >>>> stalls waiting for the remaining data, causing a hang. >>>> >>>> Allocate a 4096-byte send_buf at probe time and copy host data into >>>> it before each block transfer, ensuring the full block size is always >>>> sent regardless of the actual data length. Also improve error >>>> detection in write_complete() by checking VSE_CVP_STATUS_CFG_ERR >>>> instead of VSE_UNCOR_ERR_CVP_CFG_ERR to catch truncated or >>>> mismatched bitstream errors. >>> >>> What VSE_CVP_STATUS_CFG_ERR checks? and what VSE_UNCOR_ERR_CVP_CFG_ERR >>> checks? why it is an improvement? Please specify in log. >>> >> >> VSE_UNCOR_ERR_CVP_CFG_ERR (CVP_CONFIG_ERROR_LATCHED) is a sticky RW1CS >> copy of CVP_CONFIG_ERROR, set whenever CVP_CONFIG_ERROR rises in CvP >> mode. The driver never clears it, so after one failed configuration every >> later attempt is reported as failed, even with a good image. On >> newer devices it is also only reported on PCIe port 0. >> >> VSE_CVP_STATUS_CFG_ERR (CVP_CONFIG_ERROR) is driven by the configuration >> firmware, which keeps it set until the next configuration starts, so it is >> still valid in write_complete(). Since the latched bit is only a sticky copy >> of it, checking CVP_CONFIG_ERROR covers every error the latched bit reports. >> I'll explain this in the v3 log. > > Then what's the connection to this 4096-byte requirement? Other errors > doesn't trigger VSE_UNCOR_ERR_CVP_CFG_ERR? > They are independent. Any configuration error sets the latched bit, and since the driver never clears it, every later load fails after one failed configuration, even with a good image. The padding lets the firmware detect a truncated image; the CVP_CONFIG_ERROR check lets the driver recover afterwards. Recovering from a truncated image needs both, which is why they are in one patch. >> >>>> >>>> Signed-off-by: Nazim Amirul >>>> Signed-off-by: Tze Yee Ng >>>> --- >>>> Note: I am taking over this patch from Nazim Amirul, who is no longer >>>> working on it. Nazim is kept as the author. >>>> >>>> Changes in v2: >>>> - Rebase from linux-fpga/for-next without code changes. >>> >>> I'm wondering if you agree with all his code/log so you don't change, or >>> you just wait for me to find all the issues anyway. >>> >> >> That's fair. I should have reviewed the patch properly before resending >> it instead of only rebasing it. I've gone through it now and reworked >> it as described below. >> >>>> >>>> v1: https://lore.kernel.org/all/20260619040811.20038-1-muhammad.nazim.amirul.nazle.asmade@altera.com/ >>>> --- >>>> drivers/fpga/altera-cvp.c | 18 +++++++++++++----- >>>> 1 file changed, 13 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c >>>> index 103446465e0c..c9357cbe7fc0 100644 >>>> --- a/drivers/fpga/altera-cvp.c >>>> +++ b/drivers/fpga/altera-cvp.c >>>> @@ -82,6 +82,7 @@ struct altera_cvp_conf { >>>> u8 numclks; >>>> u32 sent_packets; >>>> u32 vsec_offset; >>>> + u8 *send_buf; >>>> const struct cvp_priv *priv; >>>> }; >>>> @@ -518,7 +519,9 @@ 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); >>>> + memcpy(conf->send_buf, data, len); >>> >>> So you copied the whole bitstream just because of some bytes of unalignment? >>> >> Agreed, that was unnecessary. The copy was there so the last block >> could be sent at full length without reading past the end of the >> image. It also meant the last block was padded with leftover data from >> the previous block rather than zeros. >> >> v3 drops it: full blocks are written directly from the image buffer, >> and the last short block is completed with zero words in >> altera_cvp_send_block(), so nothing is read beyond the data. V1 devices >> use a 4-byte block size and are not affected. >> >>> Frankly speaking, I really think the image or the firmware should fix, >>> you can't produce a image that the FW can't handle. >>> >> >> The firmware side has been fixed: when the host terminates early, the >> firmware now completes the session, reports CVP_CONFIG_ERROR, and >> accepts a new configuration afterwards. But the CvP host interface >> requires every block to be exactly 4096 bytes, and the driver currently >> breaks that rule for the last block. With full blocks, a truncated > > No, it's not the driver's responsibility. If you want the rule, the > image should obey the rule, otherwise it's a broken image. > >> image is rejected with CVP_CONFIG_ERROR and a good image can be loaded >> afterwards. Without them, the firmware is left waiting for the rest of >> the last block and the device cannot be reconfigured. >> >> A truncated or corrupted image is input the driver can't rule out, so >> it should report an error rather than leave the device stuck. > > The corrupted image are expected to fail, is it? As you said the > firmware can already fail the case correctly. Why adding zero words? Yes, a broken image is expected to fail, and the padding does not make it pass. The rule is on the transfer between the host and the device, not on the image. The CvP specification says: The device transfers data between internal elements in exactly 4096 byte blocks. [...] the internal FIFO sizes combined with the Credit Tracking Mechanism [...] drive the requirement that transfers occur in 4096 byte blocks. Sending less than 4096 bytes at a time can result in a CVP stall due to a DMA waiting for completion. This is a hardware requirement of the CvP host interface, set by the device's internal FIFO sizes and credit tracking. The driver splits the image into blocks and sends one block per credit, so keeping every block at 4096 bytes is the driver's job, whatever the image contains. Today the driver sends the last block with only the remaining bytes, which breaks this requirement whenever the image size is not a multiple of 4096. The firmware can only fail an image on data it receives. A short last block can leave its DMA waiting for the rest of the block, as the specification describes, so the firmware may never raise CVP_CONFIG_ERROR and the device cannot be reconfigured. With the zero words, the firmware receives a full block, finds the image is bad and raises CVP_CONFIG_ERROR. Valid images are always a multiple of 4096 bytes, so the padding never triggers for them. The driver already zero-fills the last 1-3 bytes up to a full word; this extends it to a full block. v3 is already posted with these changes, and its commit log explains the 4096-byte requirement and the two error bits: https://lore.kernel.org/all/20261202082654.91189-1-tze.yee.ng@altera.com/ Could you take a look at v3 when you have time? If the explanation above should be in the commit log in more detail, I'll add it in v4. Thanks, Tze Yee