From patchwork Mon Dec 20 14:11:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 526250 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 95B10C433F5 for ; Mon, 20 Dec 2021 14:04:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233281AbhLTOEe (ORCPT ); Mon, 20 Dec 2021 09:04:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233450AbhLTOE0 (ORCPT ); Mon, 20 Dec 2021 09:04:26 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39510C061574 for ; Mon, 20 Dec 2021 06:04:26 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id m15so9467955pgu.11 for ; Mon, 20 Dec 2021 06:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=jmVeIOiXKynkJZkPAaqcacQXO/NuhSZDckmBkXP/NVY=; b=WjPmqwFo8RYE2JN122BtkPRoWi2vQ7louBKVyurAFRoA6PEYi0JUB1M33kPxo3bjB2 r3cltludF8OirWDIu8sEWDiE0a9SHvdBRFUqK3AeNsdSQMNbmwgCT1kRBDv88H00EH65 xoNk4uLUtnlJHLKh2QSYcABW8mivnPt+pw0gw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=jmVeIOiXKynkJZkPAaqcacQXO/NuhSZDckmBkXP/NVY=; b=4uF5pL/nnWV5uiAA2g6EzwSUL2HoP3f3ruIeVbSyABkcMbYIvq3jg9DoLm9FebRH11 HR4DYTn4QrdILQfquMsa5wTumq5CXJ70+6YdCooN/+aZu6k1uWwlZVphJQxsU640d85J xBgp80iY+VLMIs7PRm6UjkwaDy/QOaSFylrCS6bXEEvvYT9zKBdMzA02hTt+ZtGzcyee 8APTVHNDG4pG0uLfiZaKF3jJxbDBq7Q/zCJhM/ToPBiuswnE6sycTEBoxnK+N8YvdUlV sWfKPMB5QVm20XeR+uPidFgh4Tugq5wzpd9J/+2YzgRACLZARoJeeoTyGpc9INqd7sIg 6yDQ== X-Gm-Message-State: AOAM531ZIiSXJQEha900AhBYp4+BU5TyLhE1zcVPrQWq38GjF/768+sJ 2w5ASh/KQyykQ8irSEsLiXoJZa0rhDRqzR+z47VYfh+/Gpnli/LYP5fJqF6AKQIePcBQ+3BpTh2 FWuzYHwj93YRttEZBvkst0wvXpJxYKSe1g9hJFoIaKAHdFwVuufIqWVJGjc9Ip0Ry4R6SS4f3cE l0d6mVR623 X-Google-Smtp-Source: ABdhPJyAffZ++Ps0UDtblpY3mhRj12u6EwgaDPwB/2ns9SkljLr1oHBQbur3G6Dzavcp6UDQD/Qfwg== X-Received: by 2002:a63:115d:: with SMTP id 29mr15156971pgr.276.1640009064023; Mon, 20 Dec 2021 06:04:24 -0800 (PST) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b4sm5434180pjm.17.2021.12.20.06.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 06:04:23 -0800 (PST) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, mpi3mr-linuxdrv.pdl@broadcom.com, Sreekanth Reddy Subject: [PATCH 10/25] mpi3mr: Display IOC firmware package version Date: Mon, 20 Dec 2021 19:41:44 +0530 Message-Id: <20211220141159.16117-11-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> References: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Display IOC firmware package version by reading component image upload data. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 89 +++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index 12d5106..6b534ed 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -1971,6 +1971,89 @@ out: return retval; } +/** + * mpi3mr_print_pkg_ver - display controller fw package version + * @mrioc: Adapter reference + * + * Retrieve firmware package version from the component image + * header of the controller flash and display it. + * + * Return: 0 on success and non-zero on failure. + */ +static int mpi3mr_print_pkg_ver(struct mpi3mr_ioc *mrioc) +{ + struct mpi3_ci_upload_request ci_upload; + int retval = -1; + void *data = NULL; + dma_addr_t data_dma; + struct mpi3_ci_manifest_mpi *manifest; + u32 data_len = sizeof(struct mpi3_ci_manifest_mpi); + u8 sgl_flags = MPI3MR_SGEFLAGS_SYSTEM_SIMPLE_END_OF_LIST; + + data = dma_alloc_coherent(&mrioc->pdev->dev, data_len, &data_dma, + GFP_KERNEL); + if (!data) + return -ENOMEM; + + memset(&ci_upload, 0, sizeof(ci_upload)); + mutex_lock(&mrioc->init_cmds.mutex); + if (mrioc->init_cmds.state & MPI3MR_CMD_PENDING) { + ioc_err(mrioc, "sending get package version failed due to command in use\n"); + mutex_unlock(&mrioc->init_cmds.mutex); + goto out; + } + mrioc->init_cmds.state = MPI3MR_CMD_PENDING; + mrioc->init_cmds.is_waiting = 1; + mrioc->init_cmds.callback = NULL; + ci_upload.host_tag = cpu_to_le16(MPI3MR_HOSTTAG_INITCMDS); + ci_upload.function = MPI3_FUNCTION_CI_UPLOAD; + ci_upload.msg_flags = MPI3_CI_UPLOAD_MSGFLAGS_LOCATION_PRIMARY; + ci_upload.signature1 = cpu_to_le32(MPI3_IMAGE_HEADER_SIGNATURE1_MANIFEST); + ci_upload.image_offset = cpu_to_le32(MPI3_IMAGE_HEADER_SIZE); + ci_upload.segment_size = cpu_to_le32(data_len); + + mpi3mr_add_sg_single(&ci_upload.sgl, sgl_flags, data_len, + data_dma); + init_completion(&mrioc->init_cmds.done); + retval = mpi3mr_admin_request_post(mrioc, &ci_upload, + sizeof(ci_upload), 1); + if (retval) { + ioc_err(mrioc, "posting get package version failed\n"); + goto out_unlock; + } + wait_for_completion_timeout(&mrioc->init_cmds.done, + (MPI3MR_INTADMCMD_TIMEOUT * HZ)); + if (!(mrioc->init_cmds.state & MPI3MR_CMD_COMPLETE)) { + ioc_err(mrioc, "get package version timed out\n"); + retval = -1; + goto out_unlock; + } + if ((mrioc->init_cmds.ioc_status & MPI3_IOCSTATUS_STATUS_MASK) + == MPI3_IOCSTATUS_SUCCESS) { + manifest = (struct mpi3_ci_manifest_mpi *) data; + if (manifest->manifest_type == MPI3_CI_MANIFEST_TYPE_MPI) { + ioc_info(mrioc, + "firmware package version(%d.%d.%d.%d.%05d-%05d)\n", + manifest->package_version.gen_major, + manifest->package_version.gen_minor, + manifest->package_version.phase_major, + manifest->package_version.phase_minor, + manifest->package_version.customer_id, + manifest->package_version.build_num); + } + } + retval = 0; +out_unlock: + mrioc->init_cmds.state = MPI3MR_CMD_NOTUSED; + mutex_unlock(&mrioc->init_cmds.mutex); + +out: + if (data) + dma_free_coherent(&mrioc->pdev->dev, data_len, data, + data_dma); + return retval; +} + /** * mpi3mr_watchdog_work - watchdog thread to monitor faults * @work: work struct @@ -3362,6 +3445,12 @@ int mpi3mr_init_ioc(struct mpi3mr_ioc *mrioc, u8 init_type) writel(mrioc->sbq_host_index, &mrioc->sysif_regs->sense_buffer_free_host_index); + retval = mpi3mr_print_pkg_ver(mrioc); + if (retval) { + ioc_err(mrioc, "failed to get package version\n"); + goto out_failed; + } + if (init_type != MPI3MR_IT_RESET) { retval = mpi3mr_setup_isr(mrioc, 0); if (retval) {