From patchwork Fri Jan 5 13:27:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10146583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7064601A1 for ; Fri, 5 Jan 2018 13:29:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B63C4287CD for ; Fri, 5 Jan 2018 13:29:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA04D287D3; Fri, 5 Jan 2018 13:29:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22746287CD for ; Fri, 5 Jan 2018 13:29:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbeAEN3d (ORCPT ); Fri, 5 Jan 2018 08:29:33 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45243 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751815AbeAEN3c (ORCPT ); Fri, 5 Jan 2018 08:29:32 -0500 Received: by mail-pg0-f66.google.com with SMTP id c194so1018137pga.12 for ; Fri, 05 Jan 2018 05:29:32 -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:content-transfer-encoding; bh=JhjROWPV7LmSjtvZ2pVPlfmISaXROIllVZKXNe4ehfE=; b=BMVPoUbBEyXETzLJbipDFm/XI9y8gSQ57YVYyGnfLOrk6xyBx9gQloALXO+oYK4tT4 7iH/nQolcz4rZ0oaAWuIHQFZ+zkMtAQZ+QxdXZLyv84OufBTSrccF3NSGUToGIRAxBfv EgkYRxlFHbjTc0JQ45xrkPf8LcNG1X68MAMec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JhjROWPV7LmSjtvZ2pVPlfmISaXROIllVZKXNe4ehfE=; b=GmEOCfI/dbuX3+H08UtvhWha8ZnPDf9IOWsCYFi0zOs1rX4A4bdaS7Lm9uApVgn8zZ QSVR3l30bBPyV6iBx9pmVR1cRnGYnFtArLHoM5bFTmORQRsRWxpC6Rwy5PuM1K7phAJv lN9lt5d3qGmOB04hLBB9erfHr+nUXCov/aRjpqWn6Ob6gj7I7FWyTPk59wDoXnzOu4wV gAEEOtPixVjKG64hxbmAVLUHoKIDwhXAte/wev1GJXPxXVzEkV4vFuFSJU+v3McKeods sU1CEbPuilK5MuTy3pBdXoz50Vvmnt5XXeFx8v4mthKeWovHdjpq4zBkYNRBUHCZTW7j IZ2Q== X-Gm-Message-State: AKGB3mIESdn217O/Okl9bSkShMeTPNSwBXyycPHuqEN6tjC+LZJs4agn Iy/YyVbm88uApi+xiplw9ofOrUfV X-Google-Smtp-Source: ACJfBovUsNxmxn7P18Mq4yCBr91yftMRmudZ99pFxQd0ONGFXj/ZsYuq4OYHretSNSqOmlnxGNsjdw== X-Received: by 10.99.140.65 with SMTP id q1mr2603579pgn.280.1515158971661; Fri, 05 Jan 2018 05:29:31 -0800 (PST) Received: from dhcp-135-24-192-142.localdomain ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id 68sm12588733pfx.186.2018.01.05.05.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 05:29:30 -0800 (PST) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Shivasharan S Subject: [PATCH 09/14] megaraid_sas: Update LD map after populating drv_map driver map copy Date: Fri, 5 Jan 2018 05:27:44 -0800 Message-Id: <1515158869-26693-10-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1515158869-26693-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1515158869-26693-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Issue – There may be some IO accessing incorrect raid map, but driver has checks in IO path to handle those cases. It is always better to move to new raid map only once raid map is populated and validated. No functional defect. Fix is provided as part of review. Fix – Update instance->map_id after driver has populated new driver raid map from firmware raid map. Signed-off-by: Sumit Saxena Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas.h | 2 +- drivers/scsi/megaraid/megaraid_sas_base.c | 20 ++++++++++++-------- drivers/scsi/megaraid/megaraid_sas_fp.c | 16 ++++++++-------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h index 0a66935ddf33..14b82c0b0461 100644 --- a/drivers/scsi/megaraid/megaraid_sas.h +++ b/drivers/scsi/megaraid/megaraid_sas.h @@ -230,7 +230,7 @@ enum MFI_CMD_OP { /* * Global functions */ -extern u8 MR_ValidateMapInfo(struct megasas_instance *instance); +extern u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id); /* diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 34d1fb75285a..6da2766694cb 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3331,10 +3331,10 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, && (cmd->frame->dcmd.mbox.b[1] == 1)) { fusion->fast_path_io = 0; spin_lock_irqsave(instance->host->host_lock, flags); + status = cmd->frame->hdr.cmd_status; instance->map_update_cmd = NULL; - if (cmd->frame->hdr.cmd_status != 0) { - if (cmd->frame->hdr.cmd_status != - MFI_STAT_NOT_FOUND) + if (status != MFI_STAT_OK) { + if (status != MFI_STAT_NOT_FOUND) dev_warn(&instance->pdev->dev, "map syncfailed, status = 0x%x\n", cmd->frame->hdr.cmd_status); else { @@ -3344,8 +3344,8 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, flags); break; } - } else - instance->map_id++; + } + megasas_return_cmd(instance, cmd); /* @@ -3353,10 +3353,14 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, * Validate Map will set proper value. * Meanwhile all IOs will go as LD IO. */ - if (MR_ValidateMapInfo(instance)) + if (status == MFI_STAT_OK && + (MR_ValidateMapInfo(instance, (instance->map_id + 1)))) { + instance->map_id++; fusion->fast_path_io = 1; - else + } else { fusion->fast_path_io = 0; + } + megasas_sync_map_info(instance); spin_unlock_irqrestore(instance->host->host_lock, flags); @@ -5432,7 +5436,7 @@ static int megasas_init_fw(struct megasas_instance *instance) ctrl_info->adapterOperations2.supportUnevenSpans; if (instance->UnevenSpanSupport) { struct fusion_context *fusion = instance->ctrl_context; - if (MR_ValidateMapInfo(instance)) + if (MR_ValidateMapInfo(instance, instance->map_id)) fusion->fast_path_io = 1; else fusion->fast_path_io = 0; diff --git a/drivers/scsi/megaraid/megaraid_sas_fp.c b/drivers/scsi/megaraid/megaraid_sas_fp.c index f2ffde430ec1..59ecbb3b53b5 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fp.c +++ b/drivers/scsi/megaraid/megaraid_sas_fp.c @@ -168,7 +168,7 @@ static struct MR_LD_SPAN *MR_LdSpanPtrGet(u32 ld, u32 span, /* * This function will Populate Driver Map using firmware raid map */ -static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) +static int MR_PopulateDrvRaidMap(struct megasas_instance *instance, u64 map_id) { struct fusion_context *fusion = instance->ctrl_context; struct MR_FW_RAID_MAP_ALL *fw_map_old = NULL; @@ -181,7 +181,7 @@ static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) struct MR_DRV_RAID_MAP_ALL *drv_map = - fusion->ld_drv_map[(instance->map_id & 1)]; + fusion->ld_drv_map[(map_id & 1)]; struct MR_DRV_RAID_MAP *pDrvRaidMap = &drv_map->raidMap; void *raid_map_data = NULL; @@ -190,7 +190,7 @@ static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) 0xff, (sizeof(u16) * MAX_LOGICAL_DRIVES_DYN)); if (instance->max_raid_mapsize) { - fw_map_dyn = fusion->ld_map[(instance->map_id & 1)]; + fw_map_dyn = fusion->ld_map[(map_id & 1)]; desc_table = (struct MR_RAID_MAP_DESC_TABLE *)((void *)fw_map_dyn + le32_to_cpu(fw_map_dyn->desc_table_offset)); if (desc_table != fw_map_dyn->raid_map_desc_table) @@ -255,7 +255,7 @@ static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) } else if (instance->supportmax256vd) { fw_map_ext = - (struct MR_FW_RAID_MAP_EXT *)fusion->ld_map[(instance->map_id & 1)]; + (struct MR_FW_RAID_MAP_EXT *)fusion->ld_map[(map_id & 1)]; ld_count = (u16)le16_to_cpu(fw_map_ext->ldCount); if (ld_count > MAX_LOGICAL_DRIVES_EXT) { dev_dbg(&instance->pdev->dev, "megaraid_sas: LD count exposed in RAID map in not valid\n"); @@ -282,7 +282,7 @@ static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) cpu_to_le32(sizeof(struct MR_FW_RAID_MAP_EXT)); } else { fw_map_old = (struct MR_FW_RAID_MAP_ALL *) - fusion->ld_map[(instance->map_id & 1)]; + fusion->ld_map[(map_id & 1)]; pFwRaidMap = &fw_map_old->raidMap; ld_count = (u16)le32_to_cpu(pFwRaidMap->ldCount); if (ld_count > MAX_LOGICAL_DRIVES) { @@ -313,7 +313,7 @@ static int MR_PopulateDrvRaidMap(struct megasas_instance *instance) /* * This function will validate Map info data provided by FW */ -u8 MR_ValidateMapInfo(struct megasas_instance *instance) +u8 MR_ValidateMapInfo(struct megasas_instance *instance, u64 map_id) { struct fusion_context *fusion; struct MR_DRV_RAID_MAP_ALL *drv_map; @@ -325,11 +325,11 @@ u8 MR_ValidateMapInfo(struct megasas_instance *instance) u16 ld; u32 expected_size; - if (MR_PopulateDrvRaidMap(instance)) + if (MR_PopulateDrvRaidMap(instance, map_id)) return 0; fusion = instance->ctrl_context; - drv_map = fusion->ld_drv_map[(instance->map_id & 1)]; + drv_map = fusion->ld_drv_map[(map_id & 1)]; pDrvRaidMap = &drv_map->raidMap; lbInfo = fusion->load_balance_info; diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index ea3312205a0e..74dadd052be4 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -1320,7 +1320,7 @@ megasas_get_map_info(struct megasas_instance *instance) fusion->fast_path_io = 0; if (!megasas_get_ld_map_info(instance)) { - if (MR_ValidateMapInfo(instance)) { + if (MR_ValidateMapInfo(instance, instance->map_id)) { fusion->fast_path_io = 1; return 0; }