From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9193C6379F for ; Wed, 15 Feb 2023 11:49:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233696AbjBOLtH (ORCPT ); Wed, 15 Feb 2023 06:49:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233554AbjBOLtG (ORCPT ); Wed, 15 Feb 2023 06:49:06 -0500 Received: from bmailout1.hostsharing.net (bmailout1.hostsharing.net [IPv6:2a01:37:1000::53df:5f64:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B4123659; Wed, 15 Feb 2023 03:49:04 -0800 (PST) Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "*.hostsharing.net", Issuer "RapidSSL Global TLS RSA4096 SHA256 2022 CA1" (verified OK)) by bmailout1.hostsharing.net (Postfix) with ESMTPS id 2613A300291F4; Wed, 15 Feb 2023 12:49:01 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 19B2D263F6; Wed, 15 Feb 2023 12:49:01 +0100 (CET) Date: Wed, 15 Feb 2023 12:49:01 +0100 From: Lukas Wunner To: "Li, Ming" Cc: Gregory Price , Ira Weiny , Jonathan Cameron , Dan Williams , Alison Schofield , Vishal Verma , Dave Jiang , Hillf Danton , Ben Widawsky , linuxarm@huawei.com, linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas Subject: Re: [PATCH v3 15/16] PCI/DOE: Relax restrictions on request and response size Message-ID: <20230215114901.GA19157@wunner.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Wed, Feb 15, 2023 at 01:05:20PM +0800, Li, Ming wrote: > On 2/11/2023 4:25 AM, Lukas Wunner wrote: > > An upcoming user of DOE is CMA (Component Measurement and Authentication, > > PCIe r6.0 sec 6.31). > > > > It builds on SPDM (Security Protocol and Data Model): > > https://www.dmtf.org/dsp/DSP0274 > > > > SPDM message sizes are not always a multiple of dwords. To transport > > them over DOE without using bounce buffers, allow sending requests and > > receiving responses whose final dword is only partially populated. [...] > > + if (payload_length) { > > + /* Read all payload dwords except the last */ > > + for (; i < payload_length - 1; i++) { > > + pci_read_config_dword(pdev, offset + PCI_DOE_READ, > > + &val); > > + task->response_pl[i] = cpu_to_le32(val); > > + pci_write_config_dword(pdev, offset + PCI_DOE_READ, 0); > > + } > > + > > + /* Read last payload dword */ > > pci_read_config_dword(pdev, offset + PCI_DOE_READ, &val); > > - task->response_pl[i] = cpu_to_le32(val); > > + cpu_to_le32s(&val); > > + memcpy(&task->response_pl[i], &val, remainder); > > This "Read last payload dword" seems like making sense only when remainder != sizeof(u32). > If remainder == sizeof(u32), it should be read in above reading loops. > But this implementation also looks good to me. The last payload dword requires special handling anyway because of the Data Object Ready check (see quoted remainder of the function below). Up until now that special handling is done with an if-clause that checks if the last loop iteration has been reached. The support for non-dword responses adds more special handling of the last payload dword, which is why I decided to go the full distance and move handling of the last dword out of the loop. Thanks, Lukas > > /* Prior to the last ack, ensure Data Object Ready */ > > - if (i == (payload_length - 1) && !pci_doe_data_obj_ready(doe_mb)) > > + if (!pci_doe_data_obj_ready(doe_mb)) > > return -EIO; > > pci_write_config_dword(pdev, offset + PCI_DOE_READ, 0); > > + i++; > > } > > > > /* Flush excess length */