From patchwork Fri Jan 4 16:01:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154786 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp762433ljp; Fri, 4 Jan 2019 08:01:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6q/ummPfGsR8nM4tJ/kfh8FwqsrGYROHWy9kv6szXL85g5Y+T8HMieYxFsYi+AMBP5IbG2 X-Received: by 2002:a63:d818:: with SMTP id b24mr20707625pgh.174.1546617698758; Fri, 04 Jan 2019 08:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546617698; cv=none; d=google.com; s=arc-20160816; b=quCUPTBV3jQxBSVBXdR44vLsFuOxrqCNLgiBmqiEgaMHWz+3Vam/248WTQe+HI7ey1 S7nhMi/QEi6YnqgPk1XekgVFe37lraa/mGigxuNs1m3qULfKL1X2dj2WA+X/0WAsCOpk UzAlC+Sp4g4LRP8i2NL3Zsher+T/Q9vSYphpQa9UdhhXnFCjuua7ZZ2dD984U48fUD37 jHqexInhRORMCDbbbi2NbtgQCsLrzZisduVpfm+t6AxIRHZ84ze5UaHKTgo3FPyQ5hvW 2RKbqtRGiC7tvwM3XAn3m6GFZkEFTqkLUGtH7Pw3+x4Qo8mdp6W7hZZr1gWRI8+3YqTT 21Lg== 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=l7Pf62t6aTFBDSE9d9EoOZT53GJmi5N7fRz86jR6UAU=; b=D2V8Hmizd+yXXGdKfAXcAf34IOlrG4+C4O+6N2gLmE3tBCqAtTQSSkzITmF6gxCQoF t7E22OR3rnGKNYLs9Gk7evLpByv2PcdajPD1EfvJWiTW6fDhjsqzuxAWH8nZdu+2S6LY Zmilzj4WbR9O7mn+J0PsP6gtt3K8oLUbOJo/2+T32X8vB7VhHg0v2HtjnvHUyxozmgPp zb1il8lM52FMEhgdxO7YC7ojlq9H49iyLfKrC0PoDDYPnx8Sl5fblMZd8ypgjDEU/m0a RQKGpZ1WfxcCJvH3rA1nyvB9sWe1okGPlGJkzAwlMynvtVNPhMzekVc3lYQEbY4FoQhb B57w== 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 gn20si52945551plb.98.2019.01.04.08.01.38; Fri, 04 Jan 2019 08:01:38 -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 S1728490AbfADQBi (ORCPT + 31 others); Fri, 4 Jan 2019 11:01:38 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:35485 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727745AbfADQBe (ORCPT ); Fri, 4 Jan 2019 11:01:34 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5F1796794278; Sat, 5 Jan 2019 00:01:28 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Sat, 5 Jan 2019 00:00:25 +0800 From: John Garry To: , CC: , , , , John Garry Subject: [PATCH 1/3] scsi: libsas: Fix some indentation in libsas.h Date: Sat, 5 Jan 2019 00:01:26 +0800 Message-ID: <1546617688-240623-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1546617688-240623-1-git-send-email-john.garry@huawei.com> References: <1546617688-240623-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 Currently much indentation in this file is done with whitespaces instead of tabs, which can make reading difficult, so fix this up. Some other little minor tidy-up is done, but this file still has many other checkpatch warnings (generally linelength > 80 or function arguments have no identifier names). All libsas code can be audited for checkpatch issues later. Signed-off-by: John Garry --- include/scsi/libsas.h | 56 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) -- 1.9.1 diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 3de3b10..857086c 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -52,8 +52,8 @@ enum sas_phy_role { }; enum sas_phy_type { - PHY_TYPE_PHYSICAL, - PHY_TYPE_VIRTUAL + PHY_TYPE_PHYSICAL, + PHY_TYPE_VIRTUAL }; /* The events are mnemonically described in sas_dump.c @@ -91,7 +91,7 @@ enum discover_event { #define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj) #define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\ - attr) + attr) enum routing_attribute { DIRECT_ROUTING, @@ -184,37 +184,37 @@ struct domain_device { spinlock_t done_lock; enum sas_device_type dev_type; - enum sas_linkrate linkrate; - enum sas_linkrate min_linkrate; - enum sas_linkrate max_linkrate; + enum sas_linkrate linkrate; + enum sas_linkrate min_linkrate; + enum sas_linkrate max_linkrate; - int pathways; + int pathways; - struct domain_device *parent; - struct list_head siblings; /* devices on the same level */ - struct asd_sas_port *port; /* shortcut to root of the tree */ + struct domain_device *parent; + struct list_head siblings; /* devices on the same level */ + struct asd_sas_port *port; /* shortcut to root of the tree */ struct sas_phy *phy; - struct list_head dev_list_node; + struct list_head dev_list_node; struct list_head disco_list_node; /* awaiting probe or destruct */ - enum sas_protocol iproto; - enum sas_protocol tproto; + enum sas_protocol iproto; + enum sas_protocol tproto; - struct sas_rphy *rphy; + struct sas_rphy *rphy; - u8 sas_addr[SAS_ADDR_SIZE]; - u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE]; + u8 sas_addr[SAS_ADDR_SIZE]; + u8 hashed_sas_addr[HASHED_SAS_ADDR_SIZE]; - u8 frame_rcvd[32]; + u8 frame_rcvd[32]; - union { - struct expander_device ex_dev; - struct sata_device sata_dev; /* STP & directly attached */ + union { + struct expander_device ex_dev; + struct sata_device sata_dev; /* STP & directly attached */ struct ssp_device ssp_dev; - }; + }; - void *lldd_dev; + void *lldd_dev; unsigned long state; struct kref kref; }; @@ -512,10 +512,10 @@ enum exec_status { /* When a task finishes with a response, the LLDD examines the * response: - * - For an ATA task task_status_struct::stat is set to + * - For an ATA task task_status_struct::stat is set to * SAS_PROTO_RESPONSE, and the task_status_struct::buf is set to the * contents of struct ata_task_resp. - * - For SSP tasks, if no data is present or status/TMF response + * - For SSP tasks, if no data is present or status/TMF response * is valid, task_status_struct::stat is set. If data is present * (SENSE data), the LLDD copies up to SAS_STATUS_BUF_SIZE, sets * task_status_struct::buf_valid_size, and task_status_struct::stat is @@ -671,15 +671,13 @@ struct sas_domain_function_template { extern void sas_resume_ha(struct sas_ha_struct *sas_ha); extern void sas_suspend_ha(struct sas_ha_struct *sas_ha); -int sas_set_phy_speed(struct sas_phy *phy, - struct sas_phy_linkrates *rates); +int sas_set_phy_speed(struct sas_phy *phy, struct sas_phy_linkrates *rates); int sas_phy_reset(struct sas_phy *phy, int hard_reset); -extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *); +extern int sas_queuecommand(struct Scsi_Host *, struct scsi_cmnd *); extern int sas_target_alloc(struct scsi_target *); extern int sas_slave_configure(struct scsi_device *); extern int sas_change_queue_depth(struct scsi_device *, int new_depth); -extern int sas_bios_param(struct scsi_device *, - struct block_device *, +extern int sas_bios_param(struct scsi_device *, struct block_device *, sector_t capacity, int *hsc); extern struct scsi_transport_template * sas_domain_attach_transport(struct sas_domain_function_template *); From patchwork Fri Jan 4 16:01:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 154785 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp762389ljp; Fri, 4 Jan 2019 08:01:36 -0800 (PST) X-Google-Smtp-Source: ALg8bN5GzU+j+KCFxYmuq+PLc/lQ3zjhLoL8kOzI3tNw8/f5fDkjK58Nhv+3LaJZg8Mr/2VcwezG X-Received: by 2002:a17:902:b592:: with SMTP id a18mr45992221pls.293.1546617696600; Fri, 04 Jan 2019 08:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546617696; cv=none; d=google.com; s=arc-20160816; b=rgZW1a95zD/YStgPOcJx1qUxE2BP0ER9N+kGGk8loHIptKtF8dFUqI8eE/IxNiE7Qb Ky3k1Q66ihubOgyKRRjU+cixtVwNzxEd8aVePrxsGA0l8mRpAxkKdsfiui7gZDLMNu6f frrqACVW0inPhiXHUdeLF2uRZNsQT49uMQiZqclwWhKF94IV7I1g5eYRx6EA0pW533qg 2f5O8zPHX/XjRCN3gqccBRVaTmZJCeHz4hRLiKgZj11fav1/ieasQqRhJZ/k3NxAEDWi iqVQ/0JLL6S/RZu/8PXKeQSpY/GwElr5wPtuQRWMC8dnO9GUpeAKyE3xwFabWprhS4aI X+Lg== 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=U+Bk5nnyHOaUf6B936rt1YeaFe87xFTiGsbqoU848kI=; b=BW+sj675DTAOAFZQAS+TCntn6gwvcjMcK/k03bmYMiNEuVkL7PeBIEtyJD4eXO732G DtaMIcny6y/hfYTdZ0v2f0U2fjrBExz+C8RLqfjDChPp66ynNrrWOtBsdOO+9F6F33RV 3f7rRPbGv97Ag/U3Jo1O7P1giVVflC4cjXIC8tblm5XzoC+67dhWFUtFXscUCjQCFSdT HSy4MU14PMIO0rYEFVaWj7Wt29YN7cTyHXrpFadivTEH77xBJJVqVj1zwddwATM/Ih01 +M5+cu86ERw08iGTd5t57aXKO7fwHGHaOUUBz3DrPddwQfBsRL1z+ur52nVX2Nmz8Yag p+xw== 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 gn20si52945551plb.98.2019.01.04.08.01.36; Fri, 04 Jan 2019 08:01:36 -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 S1728459AbfADQBe (ORCPT + 31 others); Fri, 4 Jan 2019 11:01:34 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:35488 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727192AbfADQBc (ORCPT ); Fri, 4 Jan 2019 11:01:32 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 694635C97288D; Sat, 5 Jan 2019 00:01:28 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Sat, 5 Jan 2019 00:00:26 +0800 From: John Garry To: , CC: , , , , John Garry Subject: [PATCH 3/3] scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery Date: Sat, 5 Jan 2019 00:01:28 +0800 Message-ID: <1546617688-240623-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1546617688-240623-1-git-send-email-john.garry@huawei.com> References: <1546617688-240623-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 +----------+ +----------+ | | | | | |--- 3.0 G ---| |--- 6.0 G --- SAS disk | | | | | |--- 3.0 G ---| |--- 6.0 G --- SAS disk |initiator | | | | device |--- 3.0 G ---| Expander |--- 6.0 G --- SAS disk | | | | | |--- 3.0 G ---| |--- 6.0 G --- SATA disk -->failed to connect | | | | | | | |--- 6.0 G --- SATA disk -->failed to connect | | | | +----------+ +----------+ According to Serial Attached SCSI - 1.1 (SAS-1.1): If an expander PHY attached to a SATA PHY is using a physical link rate greater than the maximum connection rate supported by the pathway from an STP initiator port, a management application client should use the SMP PHY CONTROL function (see 10.4.3.10) to set the PROGRAMMED MAXIMUM PHYSICAL LINK RATE field of the expander PHY to the maximum connection rate supported by the pathway from that STP initiator port. Currently libsas does not support checking if this condition occurs, nor rectifying when it does. Such a condition is not at all common, however it has been seen on some pre-silicon environments where the initiator PHY only supports a 1.5 Gbit maximum linkrate, mated with 12G expander PHYs and 3/6G SATA phy. This patch adds support for checking and rectifying this condition during initial device discovery only. We do support checking min pathway connection rate during revalidation phase, when new devices can be detected in the topology. However we do not support in the case of the the user reprogramming PHY linkrates, such that min pathway condition is not met/maintained. A note on root port PHY rates: The libsas root port PHY rates calculation is broken. Libsas sets the rates (min, max, and current linkrate) of a root port to the same linkrate of the first PHY member of that same port. In doing so, it assumes that all other PHYs which subsequently join the port to have the same negotiated linkrate, when they could actually be different. In practice this doesn't happen, as initiator and expander PHYs are normally initialised with consistent min/max linkrates. This has not caused an issue so far, so leave alone for now. Tested-by: Jian Luo Signed-off-by: John Garry --- drivers/scsi/libsas/sas_expander.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) -- 1.9.1 diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 8817b8e..83e3715 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -824,6 +824,26 @@ static struct domain_device *sas_ex_discover_end_dev( #ifdef CONFIG_SCSI_SAS_ATA if ((phy->attached_tproto & SAS_PROTOCOL_STP) || phy->attached_sata_dev) { + if (child->linkrate > parent->min_linkrate) { + struct sas_phy_linkrates rates = { + .maximum_linkrate = parent->min_linkrate, + .minimum_linkrate = parent->min_linkrate, + }; + int ret; + + pr_notice("ex %016llx phy%02d SATA device linkrate > min pathway connection rate, attempting to lower device linkrate\n", + SAS_ADDR(child->sas_addr), phy_id); + ret = sas_smp_phy_control(parent, phy_id, + PHY_FUNC_LINK_RESET, &rates); + if (ret) { + pr_err("ex %016llx phy%02d SATA device could not set linkrate (%d)\n", + SAS_ADDR(child->sas_addr), phy_id, ret); + goto out_free; + } + pr_notice("ex %016llx phy%02d SATA device set linkrate successfully\n", + SAS_ADDR(child->sas_addr), phy_id); + child->linkrate = child->min_linkrate; + } res = sas_get_ata_info(child, phy); if (res) goto out_free;