From patchwork Fri Dec 8 17:16:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 121203 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp865346qgn; Fri, 8 Dec 2017 08:33:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMaqFc6dxi7Psg9q1xbk0msILypVRNrtZUhVekfr6B6llcWv8QBZRqemnDSx4DzlbV2UkxJs X-Received: by 10.99.119.134 with SMTP id s128mr30184157pgc.409.1512750789410; Fri, 08 Dec 2017 08:33:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512750789; cv=none; d=google.com; s=arc-20160816; b=Xu30pJN4ww1s/PlYt9Laygxvp5P/0vXZcg6B4SRhr4yRBUZxBxyaDUmvZz/cfsT98N vOSorJTK845m8e61q4hfbMjRqH+QudUubdoW3SenRhIgdHdBhMZhYQhWDS1Y7VjVdUkd hWWeCINj9ZlcbC7SqjR3kEjqZTt+WGnWYHYzaC9TuD35UlC3osguWw/EREyfPqK12ZH3 rXagcuNxJwXrIdEnujNFVIc5X5Ica78BqWHPJD6QfVYUnDZSVLnHqn8dT2EJ9VmoXXuv XNdw8BQklwnW8tl6ghAKQxmCwzQ5vHNbeYgM0QAZB4zsd2mtrskougTVOz9MYL2krdPI 3lNw== 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=g9NJ+cnUrTDSRAJeY7nBlaM07rxUksYI1QTY9c8uBHs=; b=oABvg3P2kFmKaKU8w9MG2FW++OdLAwn3Bv08WDtoIt60lKPcWyC3WJ6wpDmsZDwNCW 67PxQzzMY8pQn9dHSxvfh+ArBnjbQ0pdFgeF93GfNr05RJx1LQA9KMhNHG+zKt8rvc95 cEJTpEnyFFzCvFRcFOU5N5td18/cH5P0aNi18w4TXnMPH04AuxvVXvEzannoPVqRt5hg YboJSTjlKhj5suXcLLeU2ZWvbwQt0oJUNYTn9DLaZUdTjwPasJ/CTcg5XC2I7cJLwK60 1YUEtvKxb22ourET6BQ8biVmTtOQ7l45Z7/ZFpTIO811P0NpQz6MvFnKTy3Dpl803HuA iAsQ== 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 3si5769485pgi.649.2017.12.08.08.33.03; Fri, 08 Dec 2017 08:33:09 -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 S1753768AbdLHQdC (ORCPT + 18 others); Fri, 8 Dec 2017 11:33:02 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2227 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753246AbdLHQbO (ORCPT ); Fri, 8 Dec 2017 11:31:14 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BFE5D7B2C237C; Sat, 9 Dec 2017 00:30:44 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.361.1; Sat, 9 Dec 2017 00:30:36 +0800 From: John Garry To: , CC: , , , Xiaofei Tan , "John Garry" Subject: [PATCH 03/19] scsi: hisi_sas: relocate clearing ITCT and freeing device Date: Sat, 9 Dec 2017 01:16:34 +0800 Message-ID: <1512753410-50924-4-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512753410-50924-1-git-send-email-john.garry@huawei.com> References: <1512753410-50924-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 In certain scenarios we may just want to clear the ITCT for a device, and not free other resources like the SATA bitmap using in v2 hw. To facilitate this, this patch relocates the code of clearing ITCT from free_device() to an new hw interface clear_itct(). Then for some hw, we should not realise free_device() if there's nothing left to do for it. Signed-off-by: Xiaofei Tan Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 3 ++- drivers/scsi/hisi_sas/hisi_sas_main.c | 7 +++++-- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 4 ++-- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 16 +++++++++++----- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) -- 1.9.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 83357b03..b2534ca 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -205,8 +205,9 @@ struct hisi_sas_hw { void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, struct sas_phy_linkrates *linkrates); enum sas_linkrate (*phy_get_max_linkrate)(void); - void (*free_device)(struct hisi_hba *hisi_hba, + void (*clear_itct)(struct hisi_hba *hisi_hba, struct hisi_sas_device *dev); + void (*free_device)(struct hisi_sas_device *sas_dev); int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); void (*dereg_device)(struct hisi_hba *hisi_hba, struct domain_device *device); diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index d842530..6446ce2 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -743,7 +743,10 @@ static void hisi_sas_dev_gone(struct domain_device *device) hisi_sas_dereg_device(hisi_hba, device); - hisi_hba->hw->free_device(hisi_hba, sas_dev); + hisi_hba->hw->clear_itct(hisi_hba, sas_dev); + if (hisi_hba->hw->free_device) + hisi_hba->hw->free_device(sas_dev); + device->lldd_dev = NULL; memset(sas_dev, 0, sizeof(*sas_dev)); sas_dev->dev_type = SAS_PHY_UNUSED; @@ -1001,7 +1004,7 @@ static void hisi_sas_refresh_port_id(struct hisi_hba *hisi_hba, || !device || (device->port != sas_port)) continue; - hisi_hba->hw->free_device(hisi_hba, sas_dev); + hisi_hba->hw->clear_itct(hisi_hba, sas_dev); /* Update linkrate of directly attached device. */ if (!device->parent) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index dc6eca8..8cb9061 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -544,7 +544,7 @@ static void setup_itct_v1_hw(struct hisi_hba *hisi_hba, (0xff00ULL << ITCT_HDR_REJ_OPEN_TL_OFF)); } -static void free_device_v1_hw(struct hisi_hba *hisi_hba, +static void clear_itct_v1_hw(struct hisi_hba *hisi_hba, struct hisi_sas_device *sas_dev) { u64 dev_id = sas_dev->device_id; @@ -1850,7 +1850,7 @@ static int hisi_sas_v1_init(struct hisi_hba *hisi_hba) .hw_init = hisi_sas_v1_init, .setup_itct = setup_itct_v1_hw, .sl_notify = sl_notify_v1_hw, - .free_device = free_device_v1_hw, + .clear_itct = clear_itct_v1_hw, .prep_smp = prep_smp_v1_hw, .prep_ssp = prep_ssp_v1_hw, .get_free_slot = get_free_slot_v1_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 5d3467f..cd9cd84 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c @@ -952,7 +952,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba, (0x1ULL << ITCT_HDR_RTOLT_OFF)); } -static void free_device_v2_hw(struct hisi_hba *hisi_hba, +static void clear_itct_v2_hw(struct hisi_hba *hisi_hba, struct hisi_sas_device *sas_dev) { DECLARE_COMPLETION_ONSTACK(completion); @@ -963,10 +963,6 @@ static void free_device_v2_hw(struct hisi_hba *hisi_hba, sas_dev->completion = &completion; - /* SoC bug workaround */ - if (dev_is_sata(sas_dev->sas_device)) - clear_bit(sas_dev->sata_idx, hisi_hba->sata_dev_bitmap); - /* clear the itct interrupt state */ if (ENT_INT_SRC3_ITC_INT_MSK & reg_val) hisi_sas_write32(hisi_hba, ENT_INT_SRC3, @@ -981,6 +977,15 @@ static void free_device_v2_hw(struct hisi_hba *hisi_hba, } } +static void free_device_v2_hw(struct hisi_sas_device *sas_dev) +{ + struct hisi_hba *hisi_hba = sas_dev->hisi_hba; + + /* SoC bug workaround */ + if (dev_is_sata(sas_dev->sas_device)) + clear_bit(sas_dev->sata_idx, hisi_hba->sata_dev_bitmap); +} + static int reset_hw_v2_hw(struct hisi_hba *hisi_hba) { int i, reset_val; @@ -3415,6 +3420,7 @@ static int soft_reset_v2_hw(struct hisi_hba *hisi_hba) .alloc_dev = alloc_dev_quirk_v2_hw, .sl_notify = sl_notify_v2_hw, .get_wideport_bitmap = get_wideport_bitmap_v2_hw, + .clear_itct = clear_itct_v2_hw, .free_device = free_device_v2_hw, .prep_smp = prep_smp_v2_hw, .prep_ssp = prep_ssp_v2_hw, diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index 19b1f2f..44f07bc 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -588,7 +588,7 @@ static void setup_itct_v3_hw(struct hisi_hba *hisi_hba, (0x1ULL << ITCT_HDR_RTOLT_OFF)); } -static void free_device_v3_hw(struct hisi_hba *hisi_hba, +static void clear_itct_v3_hw(struct hisi_hba *hisi_hba, struct hisi_sas_device *sas_dev) { DECLARE_COMPLETION_ONSTACK(completion); @@ -1951,7 +1951,7 @@ static int soft_reset_v3_hw(struct hisi_hba *hisi_hba) .max_command_entries = HISI_SAS_COMMAND_ENTRIES_V3_HW, .get_wideport_bitmap = get_wideport_bitmap_v3_hw, .complete_hdr_size = sizeof(struct hisi_sas_complete_v3_hdr), - .free_device = free_device_v3_hw, + .clear_itct = clear_itct_v3_hw, .sl_notify = sl_notify_v3_hw, .prep_ssp = prep_ssp_v3_hw, .prep_smp = prep_smp_v3_hw,