From patchwork Mon Oct 12 15:20:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 54790 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id 7D8E023001 for ; Mon, 12 Oct 2015 15:08:39 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf60978065wic.3 for ; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=MoWhfsXc8Ro4q5PYRvfuXIIoKTuctUF6fKA3y+XxPuk=; b=HMK/q7558eYgTPShiYv6Tyj6O/rO0lk4xMtCQ5mFv6BF3q3fVD59noiqN4lyl3dLuN 93iBYispfWncl3dE+12NGuvnigJfN8jCiahfwba3/L4iCztetJv+/TTHs9Y1y7rYpPKT oIpOKRnpjwM3erWPEKJxEz0z493ShErI7JSQMihGlWtDxikcZbreZpLKhKm+TWIKElVT cZjX1yllZeI3T9Irx4QOOEUbOm/x1wcDMOW+maJMrbO5edWJtxr+icO7FrHezZFO9x+/ GdGNh9pjda0M+PluKWC+d8TrTgYB6/9KOlRxY9wijl52rwcFA7FLiVyjCzSwVi5qpoNk 23+w== X-Gm-Message-State: ALoCoQlXjCAOLVZe9f0GMYnQjky0/CR1kcx4W6rKRTcPX4N+vLZN8GstBBar2CG+nMo16u9D4ii4 X-Received: by 10.180.91.233 with SMTP id ch9mr3010633wib.4.1444662518854; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.87.8 with SMTP id l8ls592025lfb.92.gmail; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr12328811lbs.41.1444662518709; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id o196si11549894lfb.9.2015.10.12.08.08.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 08:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbwr8 with SMTP id r8so144532870lbw.2 for ; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) X-Received: by 10.112.151.106 with SMTP id up10mr13184278lbb.106.1444662518580; Mon, 12 Oct 2015 08:08:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1601030lbq; Mon, 12 Oct 2015 08:08:37 -0700 (PDT) X-Received: by 10.50.134.161 with SMTP id pl1mr13272233igb.60.1444662515668; Mon, 12 Oct 2015 08:08:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r79si12406160ioi.75.2015.10.12.08.08.35 for ; Mon, 12 Oct 2015 08:08:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752068AbbJLPIe (ORCPT ); Mon, 12 Oct 2015 11:08:34 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:12591 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbbJLPIb (ORCPT ); Mon, 12 Oct 2015 11:08:31 -0400 Received: from 172.24.1.49 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CUB61538; Mon, 12 Oct 2015 23:05:19 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Mon, 12 Oct 2015 23:05:03 +0800 From: John Garry To: CC: , , , , , , , , , John Garry Subject: [PATCH 17/25] scsi: hisi_sas: add abnormal irq handler Date: Mon, 12 Oct 2015 23:20:29 +0800 Message-ID: <1444663237-238302-18-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1444663237-238302-1-git-send-email-john.garry@huawei.com> References: <1444663237-238302-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-scsi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.garry@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add abnormal irq handler. This handler is concerned with phy down event. Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 24 +++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 56 ++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 3516d6f..3f61a4a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -354,6 +354,7 @@ void hisi_sas_phy_init(struct hisi_hba *hisi_hba, int i); int hisi_sas_dev_found(struct domain_device *dev); int hisi_sas_queue_command(struct sas_task *task, gfp_t gfp_flags); void hisi_sas_port_formed(struct asd_sas_phy *sas_phy); +void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); void hisi_sas_wq_process(struct work_struct *work); void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task, struct hisi_sas_slot *slot); diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 44cb9085..fbc2cca 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -529,3 +529,27 @@ void hisi_sas_port_formed(struct asd_sas_phy *sas_phy) { hisi_sas_port_notify_formed(sas_phy, 1); } +static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy) +{ + phy->phy_attached = 0; + phy->phy_type = 0; +} + +void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy) +{ + struct hisi_sas_phy *phy = &hisi_hba->phy[phy_no]; + struct asd_sas_phy *sas_phy = &phy->sas_phy; + struct sas_ha_struct *sas_ha = &hisi_hba->sha; + + if (rdy) { + /* Phy down but ready */ + hisi_sas_bytes_dmaed(hisi_hba, phy_no); + hisi_sas_port_notify_formed(sas_phy, 0); + } else { + /* Phy down and not ready */ + sas_ha->notify_phy_event(sas_phy, PHYE_LOSS_OF_SIGNAL); + phy->phy_attached = 0; + sas_phy_disconnected(sas_phy); + hisi_sas_phy_disconnected(phy); + } +} diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index e8b9dc3..fadd163 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -1342,7 +1342,61 @@ end: return res; } +static irqreturn_t int_abnormal_v1_hw(int irq, void *p) +{ + struct hisi_sas_phy *phy = p; + struct hisi_hba *hisi_hba = phy->hisi_hba; + u32 irq_value, irq_mask_old; + struct device *dev = &hisi_hba->pdev->dev; + struct asd_sas_phy *sas_phy = &phy->sas_phy; + int phy_no = sas_phy->id; + /* mask_int0 */ + irq_mask_old = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0_MSK); + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK, 0x3fffff); + + /* read int0 */ + irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT0); + + if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK) { + u32 phy_state = hisi_sas_read32(hisi_hba, PHY_STATE); + + hisi_sas_phy_down(hisi_hba, + phy_no, + (phy_state & 1 << phy_no) ? 1 : 0); + } + + if (irq_value & CHL_INT0_ID_TIMEOUT_MSK) + dev_dbg(dev, "abnormal: ID_TIMEOUT phy%d identify timeout\n", + phy_no); + + if (irq_value & CHL_INT0_DWS_LOST_MSK) + dev_dbg(dev, "abnormal: DWS_LOST phy%d dws lost\n", phy_no); + + if (irq_value & CHL_INT0_SN_FAIL_NGR_MSK) + dev_dbg(dev, "abnormal: SN_FAIL_NGR phy%d sn fail ngr\n", + phy_no); + + if (irq_value & CHL_INT0_SL_IDAF_FAIL_MSK || + irq_value & CHL_INT0_SL_OPAF_FAIL_MSK) + dev_dbg(dev, "abnormal: SL_ID/OPAF_FAIL phy%d check adr frm err\n", + phy_no); + + if (irq_value & CHL_INT0_SL_PS_FAIL_OFF) + dev_dbg(dev, "abnormal: SL_PS_FAIL phy%d fail\n", phy_no); + + /* write to zero */ + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0, irq_value); + + if (irq_value & CHL_INT0_PHYCTRL_NOTRDY_MSK) + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK, + 0x3fffff & ~CHL_INT0_MSK_PHYCTRL_NOTRDY_MSK); + else + hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT0_MSK, + irq_mask_old); + + return IRQ_HANDLED; +} static irqreturn_t cq_interrupt_v1_hw(int irq, void *p) { @@ -1397,12 +1451,14 @@ static irqreturn_t cq_interrupt_v1_hw(int irq, void *p) static const char phy_int_names[HISI_SAS_PHY_INT_NR][32] = { {"Phy Up"}, + {"Abnormal"}, }; static const char cq_int_name[32] = "cq"; static irq_handler_t phy_interrupts[HISI_SAS_PHY_INT_NR] = { int_phyup_v1_hw, + int_abnormal_v1_hw }; int interrupt_init_v1_hw(struct hisi_hba *hisi_hba)