From patchwork Fri Mar 23 16:05:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 132349 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp776960ljb; Fri, 23 Mar 2018 09:06:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELuxsceHQad5DZmS6GPejQx57kQprrPjtlkN5mUgZl3wsEIjQ32sjkrsRJNpl3gvDlaSTT0T X-Received: by 10.99.182.73 with SMTP id v9mr21082255pgt.158.1521821179551; Fri, 23 Mar 2018 09:06:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521821179; cv=none; d=google.com; s=arc-20160816; b=BHF+uts+6H9E4dTiBTdG8phvmZGJ3DmM+SJDSwAKYlx3EdgcpPzes9ZH7arukdchhX fPWB9a7S90ItK/wlLCXQLE5Br62I4s5ZVjWGTl4kQ1WB5ZuC+22zGofEZojsQsGTkF/J VMNWlZv8f6Y4LEhC0RbnZX0R+nofCErylPRGxSiE9uFZVrxhCiLN4jPsDKfzuGAwcYK/ izySFtHu3go1YErOVUOZZhskeSMtD6Gd+gu7WgkHbXtcojibWuvRubrOoivHf0vidlD0 oxi5ca91MayQb6oCw64A5u1x0NbtSgjlVx/85AvxUt7kqsfwCheAOyzZGJpDQtY244gC 4B9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=05pDpoGG/nTpHWbfUOY/gxOFs0iC+CcL3inK221LYhw=; b=pMUWyCV0mgYqkYYfx1kc3W8Ba23HyUdmCvUVe0Uvug/z/lR1lZ4npRO8YVBMU/mOvl 4rZWotuehquQJKt73trnE5JfOa5rSsAlKnyakWYdttCvrH2I4GBNOhqRXhtHqs7Jxglr uBlgvExCAt10jK1J4NkCkJHHJ1VFhpuGfH4VMtdAymzQ9Hzfu2V3y0efcH0bV9Pqc+yX gyAumP71PsY7homXbUBz5tDwyBkNM7vnsplQO6QSXY037J/wjvUxzVdF/yqwjpmccgn4 2bagJ8tzIOavGRwmrpEavDeOt5vLiMWtK6xWOimM3sRHdsOD5BBh8lmChnQGapkYDuxD lh3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si3058025pla.32.2018.03.23.09.06.19; Fri, 23 Mar 2018 09:06:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752310AbeCWQGQ (ORCPT + 28 others); Fri, 23 Mar 2018 12:06:16 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6685 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752229AbeCWQGO (ORCPT ); Fri, 23 Mar 2018 12:06:14 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id AC815C78AEC85; Sat, 24 Mar 2018 00:05:50 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.361.1; Sat, 24 Mar 2018 00:05:46 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 6/8] scsi: hisi_sas: check IPTT is valid before using it for v3 hw Date: Sat, 24 Mar 2018 00:05:13 +0800 Message-ID: <1521821115-120040-7-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521821115-120040-1-git-send-email-john.garry@huawei.com> References: <1521821115-120040-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaofei Tan There is a bug of v3 hw development version. When AXI error happen, hw may return an abnormal CQ that IPTT value is 0xffff. This will cause IPTT out-of-bounds reference. This patch add an check of IPTT in cq_tasklet_v3_hw(), and discard invalid slot. This workaround scheme is just to enhance fault-tolerance of the driver. So, we will apply this scheme for all version of v3 hw, although release version has fixed this SoC bug. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index efe64bc..aa52d5e 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -1731,15 +1731,19 @@ static void cq_tasklet_v3_hw(unsigned long val) while (rd_point != wr_point) { struct hisi_sas_complete_v3_hdr *complete_hdr; + struct device *dev = hisi_hba->dev; int iptt; complete_hdr = &complete_queue[rd_point]; iptt = (complete_hdr->dw1) & CMPLT_HDR_IPTT_MSK; - slot = &hisi_hba->slot_info[iptt]; - slot->cmplt_queue_slot = rd_point; - slot->cmplt_queue = queue; - slot_complete_v3_hw(hisi_hba, slot); + if (likely(iptt < HISI_SAS_COMMAND_ENTRIES_V3_HW)) { + slot = &hisi_hba->slot_info[iptt]; + slot->cmplt_queue_slot = rd_point; + slot->cmplt_queue = queue; + slot_complete_v3_hw(hisi_hba, slot); + } else + dev_err(dev, "IPTT %d is invalid, discard it.\n", iptt); if (++rd_point >= HISI_SAS_QUEUE_SLOTS) rd_point = 0;