From patchwork Fri Jan 25 14:22:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 156601 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp418576jaa; Fri, 25 Jan 2019 06:23:15 -0800 (PST) X-Google-Smtp-Source: ALg8bN77WNHdczULClXLwWdW7D38E6W5YhgaUv6YE9xqGAujJY6ZXKXjldHfeCLDACbaDDCEfew7 X-Received: by 2002:a63:7b06:: with SMTP id w6mr10141143pgc.288.1548426195761; Fri, 25 Jan 2019 06:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548426195; cv=none; d=google.com; s=arc-20160816; b=OVYncOM2QeP+Uci7/yYsHUhfMINvGs6bOuPhf9kz8E1vjFOAuKf6o06er/YRLUIyyn HOTPyVoVFGai30KaM3MSwlZJwskUTU31hACOOie5UeWMBUmoWXdaM+WVJOSakmRY7jiO m7mFtjr+dINilb+4/xdBhIKqxzpprt7d5m2inCmkLB5yBFqN4QS/T31/XlzfPYGxvuwi r1Fk0gDW6WAGRcNdcivgAQOsdOhuVZmMgf4xA9liG0yOIbrsvYHBGf2bRrgSHuFMsS5O VmqGyJ3YXI/iQkPl6e7GlZ+QgpaG93T7rOWlSjFwv5XpM53TwMB4SbZvxwkZ1bDbPKzv ItzA== 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; bh=Y+NGZs2WGflQdxA9GMmD5FIt5RzaUvGALtbptUuDiJM=; b=IhzTj1l4r7sbKHzTgjluBJg6zv2O+EifNo65VHrd4L3Nbnfs2YONL4fuyxcIMIl2e5 CwVZ8Tl9QLYOlrkp01ivHb6k63nFnZm0sTDAITqY33a7J6FOWML1Plrap++Yd1NF50+4 U1xaujw+Lt5MxxN7S9c2bkyIyem3XrM7aoCS+kUFIlMq8GpVCfrlkz2JENSd3LKHEhju Vr8t9qfRtabq+UebapF9VEHtZa/fCqQbtEj9I5QajvoRpWqAypbXlfACNIJMeZ0t3hkV O5iJt5aBfGm+ywI66Q+X+jaepR58gdvFooE+tqPGFpFZCiIzGvfZV609ve2pIOjMNWKI UxeA== 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 x14si24398374plr.378.2019.01.25.06.23.15; Fri, 25 Jan 2019 06:23:15 -0800 (PST) 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 S1729230AbfAYOXN (ORCPT + 31 others); Fri, 25 Jan 2019 09:23:13 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2763 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728913AbfAYOWG (ORCPT ); Fri, 25 Jan 2019 09:22:06 -0500 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 572E1CA0BFAF0C75C47E; Fri, 25 Jan 2019 22:21:59 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Fri, 25 Jan 2019 22:21:52 +0800 From: John Garry To: , CC: , , , Luo Jiaxing , "John Garry" Subject: [PATCH 08/13] scsi: hisi_sas: Reject setting programmed minimum linkrate > 1.5G Date: Fri, 25 Jan 2019 22:22:34 +0800 Message-ID: <1548426159-225679-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1548426159-225679-1-git-send-email-john.garry@huawei.com> References: <1548426159-225679-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: Luo Jiaxing The SAS controller cannot support a programmed minimum linkrate of > 1.5G (it will always negotiate to 1.5G at least), so just reject it. This solves a strange situation where the PHY negotiated linkrate may be less than the programmed minimum linkrate. Signed-off-by: Luo Jiaxing Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 8f7f82d..32f6928 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -946,7 +946,7 @@ static int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags) return hisi_sas_task_exec(task, gfp_flags, 0, NULL); } -static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, +static int hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, struct sas_phy_linkrates *r) { struct sas_phy_linkrates _r; @@ -955,6 +955,9 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, struct asd_sas_phy *sas_phy = &phy->sas_phy; enum sas_linkrate min, max; + if (r->minimum_linkrate > SAS_LINK_RATE_1_5_GBPS) + return -EINVAL; + if (r->maximum_linkrate == SAS_LINK_RATE_UNKNOWN) { max = sas_phy->phy->maximum_linkrate; min = r->minimum_linkrate; @@ -962,7 +965,7 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, max = r->maximum_linkrate; min = sas_phy->phy->minimum_linkrate; } else - return; + return -EINVAL; _r.maximum_linkrate = max; _r.minimum_linkrate = min; @@ -974,6 +977,8 @@ static void hisi_sas_phy_set_linkrate(struct hisi_hba *hisi_hba, int phy_no, msleep(100); hisi_hba->hw->phy_set_linkrate(hisi_hba, phy_no, &_r); hisi_hba->hw->phy_start(hisi_hba, phy_no); + + return 0; } static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, @@ -999,8 +1004,7 @@ static int hisi_sas_control_phy(struct asd_sas_phy *sas_phy, enum phy_func func, break; case PHY_FUNC_SET_LINK_RATE: - hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata); - break; + return hisi_sas_phy_set_linkrate(hisi_hba, phy_no, funcdata); case PHY_FUNC_GET_EVENTS: if (hisi_hba->hw->get_events) { hisi_hba->hw->get_events(hisi_hba, phy_no);