Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2146453rwb; Sun, 6 Aug 2023 10:52:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjdNaMAbGuPJqpzHIaxZvJDkucHqwPU0pFoRYkwZngYXAKenBeoRdoSL/J3+hlzkiSYdzb X-Received: by 2002:a17:907:2e0d:b0:99c:4c94:1aa5 with SMTP id ig13-20020a1709072e0d00b0099c4c941aa5mr5896037ejc.51.1691344359716; Sun, 06 Aug 2023 10:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691344359; cv=none; d=google.com; s=arc-20160816; b=z9/twWrsZiH/7aq9ViyqP0yJYln2OvpNIHBaPACS05REkpChe2ZGqxPhp/u9O/lsoZ UwXcit02YhnxzjbA9niV2R2TgkNVmYoJ3lUfI+Y9huSUQ3taU7szYCPb7dkadike0Z5a hi6JevGx+7z9oEWqcX3rCN4lQ+f+e1ZoypNw4hlRmilbE4/SuqTlpwEb2uLg2QkXtY3x ztIoRCi0IJWfVlSxXfZX7C8VN8wJll6y+6PCV6D0NjtjNKeQa2rBHOqiUeL9INA+f79E Jd5XOkPKKaFMQ+lG2drxN0WpfvOg+bMskmSejxWwxxHN/9QVuYyDfMZjgPJc46VBxsds yFeA== 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:sender :dkim-signature; bh=3E50Wyjlak98XVVuVP8qG+8W1M0fy+YEfeOVX7MTZx4=; fh=qQfQn41I33w9pejKGXOVSCM4Acfp9qIpLZp/SumhAF8=; b=tywE6BBWW5xfTSNIHTs8a/V1RymYZHeW9XUrnqacNy1pJiGOfBwr4zOV33J1PY66EP 9p2VZO6M3XK/VO/Ma3eNGRVqD1WcHEDLb3AdXGNxLyq2uLEtUEHBptxEYj7M+Og2SAEZ MtmTIhk/QilIid3Cblu/ATtFCgi/XN3Jhwb6O5JH0dPF/DQ4N5Ib4qCfLrqMDl0uyH7Q zyWtmqjgBJ55HttLnnr6ko8LrMhsenvLRScEVUEDyLUhIuVCI+8//gBgQjNzaB37sEB7 Et8aGKfjCbL2J1X0nTfIIKhPj8vnV7os8d0jSuqenACwB0VnmnZ2UJMcYuM42T7TSPqp nRTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@equiv.tech header.s=mx header.b=QR4qTxdr; 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=REJECT sp=REJECT dis=NONE) header.from=equiv.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k19-20020a1709063e1300b0098e47bbff3csi4802101eji.297.2023.08.06.10.52.04; Sun, 06 Aug 2023 10:52:39 -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=@equiv.tech header.s=mx header.b=QR4qTxdr; 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=REJECT sp=REJECT dis=NONE) header.from=equiv.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjHFRIg (ORCPT + 99 others); Sun, 6 Aug 2023 13:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbjHFRIc (ORCPT ); Sun, 6 Aug 2023 13:08:32 -0400 Received: from so254-32.mailgun.net (so254-32.mailgun.net [198.61.254.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253F319B9 for ; Sun, 6 Aug 2023 10:08:05 -0700 (PDT) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=equiv.tech; q=dns/txt; s=mx; t=1691341684; x=1691348884; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Subject: Cc: To: To: From: From: Sender: Sender; bh=3E50Wyjlak98XVVuVP8qG+8W1M0fy+YEfeOVX7MTZx4=; b=QR4qTxdr0bKuytQZGkc95DCXAongNej9JdSUY0bfTdfPwEdiJ8nrLbjKWw01tqse1CdwovdIn3OiR71u04uMXgqxyjFeclc3MKh/OEpWCV32Oj1ka7hhZZ+IylYFmtfWPFZQW11g02yJVMrejcZWvjCJ4ziaTs+D7x9jELwFilmELzQUZYaY38tKsbB5x8Nu/rLUhI21FX5nvv+YeXnM8jn4VvRMzKp6RbjF4Mt+tkNkCKz/5hBbxW0QOKusXnNA/d8yi/HYkVPkPyi+LxQ9IDZFitJzGY3y6zlijv3yv6udJZweySYtnL3PiplNpI4MvOG+W0ubjX3Mla8P6or/Rg== X-Mailgun-Sending-Ip: 198.61.254.32 X-Mailgun-Sid: WyI4ZWI3MiIsImxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmciLCI5M2Q1YWIiXQ== Received: from mail.equiv.tech (equiv.tech [142.93.28.83]) by 35c6ad30e4ae with SMTP id 64cfd37463abb9f3db29c4e5 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 06 Aug 2023 17:08:04 GMT Sender: james@equiv.tech From: James Seo To: Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani Cc: James Seo , "James E.J. Bottomley" , "Martin K. Petersen" , Kees Cook , "Gustavo A. R. Silva" , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/12] scsi: mpt3sas: Make MPI2_CONFIG_PAGE_SASIOUNIT_1::PhyData[] a flexible array Date: Sun, 6 Aug 2023 10:05:57 -0700 Message-Id: <20230806170604.16143-6-james@equiv.tech> In-Reply-To: <20230806170604.16143-1-james@equiv.tech> References: <20230806170604.16143-1-james@equiv.tech> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS 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 This terminal 1-length variable array can be directly converted into a C99 flexible array member. As all users of MPI2_CONFIG_PAGE_SASIOUNIT_1 (Mpi2SasIOUnitPage1_t) either calculate its size without depending on its sizeof() or do not use PhyData[], no further source changes are required: - mpt3sas_config.c:mpt3sas_config_get_sas_iounit_pg1() fetches a Mpi2SasIOUnitPage1_t into a caller-provided buffer, and may fetch and write PhyData[] into that buffer depending on its sz argument. Its callers: - mpt3sas_base.c:_base_assign_fw_reported_qd() passes sizeof(Mpi2SasIOUnitPage1_t) as sz, but does not use PhyData[]. - mpt3sas_base.c:mpt3sas_base_update_missing_delay(), mpt3sas_scsih.c:_scsih_sas_host_add(), mpt3sas_transport.c:_transport_phy_enable(), and mpt3sas_transport.c:_transport_phy_speed() all calculate sz independently of sizeof(Mpi2SasIOUnitPage1_t) and allocate a suitable buffer before calling mpt3sas_config_get_sas_iounit_pg1() and using PhyData[]. - mpt3sas_config.c:mpt3sas_config_set_sas_iounit_pg1() writes the contents of a caller-provided buffer to the adapter, with the size of the write depending on its sz argument. Its callers: - mpt3sas_base.c:mpt3sas_base_update_missing_delay(), mpt3sas_transport.c:_transport_phy_enable(), and mpt3sas_transport.c:_transport_phy_speed() have all previously called mpt3sas_config_get_sas_iounit_pg1() to obtain a Mpi2SasIOUnitPage1_t, and are merely writing back this same struct with the same previously calculated sz. Signed-off-by: James Seo --- drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h index 07a8d7646b6d..138f31def81d 100644 --- a/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h +++ b/drivers/scsi/mpt3sas/mpi/mpi2_cnfg.h @@ -2249,12 +2249,9 @@ typedef struct _MPI2_SAS_IO_UNIT1_PHY_DATA { *pMpi2SasIOUnit1PhyData_t; /* - *Host code (drivers, BIOS, utilities, etc.) should leave this define set to - *one and check the value returned for NumPhys at runtime. + *Host code (drivers, BIOS, utilities, etc.) should check the value returned + *for NumPhys at runtime before using PhyData[]. */ -#ifndef MPI2_SAS_IOUNIT1_PHY_MAX -#define MPI2_SAS_IOUNIT1_PHY_MAX (1) -#endif typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_1 { MPI2_CONFIG_EXTENDED_PAGE_HEADER Header; /*0x00 */ @@ -2275,7 +2272,7 @@ typedef struct _MPI2_CONFIG_PAGE_SASIOUNIT_1 { U8 IODeviceMissingDelay; /*0x13 */ MPI2_SAS_IO_UNIT1_PHY_DATA - PhyData[MPI2_SAS_IOUNIT1_PHY_MAX]; /*0x14 */ + PhyData[]; /*0x14 */ } MPI2_CONFIG_PAGE_SASIOUNIT_1, *PTR_MPI2_CONFIG_PAGE_SASIOUNIT_1, Mpi2SasIOUnitPage1_t, *pMpi2SasIOUnitPage1_t; -- 2.39.2