From patchwork Mon Oct 12 15:20:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 54782 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 1477023001 for ; Mon, 12 Oct 2015 15:06:40 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf70884406lbc.1 for ; Mon, 12 Oct 2015 08:06:39 -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=uA1vxEBCFfDR883QD4UO2f+yVdUDZpFkfPOj4b8NaMM=; b=BMROgZyq/INsOIHA+sTFyApiIVSN6HfT7c5DoAzJi6cLxAmkA1zYd1mZJqC6g/00BR 1dRDc0Al4gzA9Ww41W1i2lE3+NZ7R9uZonERX3/Ni8QWsSjRCD7NEgCBzdfXaKSKzdBp CcziI/B2hgPbaAxNhExX/upam4V/c8AnYlkhEZEJr2zunQdtlAxGjbtvO8qhWJ8Frpj0 YTvHhDloP3QR/Bz3zJU1Re1qM/ajWPcsnfy40S0nNj1g3v7p/sJW+S3qXxxtTtJrOqyz NM7W3EyAqmZJaELvcIKpTKzc4EP4dO3vmWhklBWSTvonforSSbFbziNVKwZfdTAXbtFh qTKw== X-Gm-Message-State: ALoCoQm/Xe43bog6h30eK+jhVpCBicyN25rY1M0fELX7QpiGJh2UYIJE0w0PlTHwuLDxKg2Q1zwQ X-Received: by 10.180.10.135 with SMTP id i7mr3018116wib.2.1444662398991; Mon, 12 Oct 2015 08:06:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.18.226 with SMTP id 95ls550968lfs.1.gmail; Mon, 12 Oct 2015 08:06:38 -0700 (PDT) X-Received: by 10.25.163.199 with SMTP id m190mr8437893lfe.13.1444662398835; Mon, 12 Oct 2015 08:06:38 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id d133si11536474lfd.46.2015.10.12.08.06.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 08:06:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbwr8 with SMTP id r8so144471714lbw.2 for ; Mon, 12 Oct 2015 08:06:38 -0700 (PDT) X-Received: by 10.112.168.228 with SMTP id zz4mr12904339lbb.73.1444662398247; Mon, 12 Oct 2015 08:06: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 w3csp1599891lbq; Mon, 12 Oct 2015 08:06:37 -0700 (PDT) X-Received: by 10.50.137.97 with SMTP id qh1mr13272436igb.60.1444662397105; Mon, 12 Oct 2015 08:06:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f65si6799540ioj.52.2015.10.12.08.06.36; Mon, 12 Oct 2015 08:06:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 S1751451AbbJLPGf (ORCPT + 7 others); Mon, 12 Oct 2015 11:06:35 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:12228 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751073AbbJLPGf (ORCPT ); Mon, 12 Oct 2015 11:06:35 -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 CUB61536; Mon, 12 Oct 2015 23:05:17 +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:02 +0800 From: John Garry To: CC: , , , , , , , , , John Garry Subject: [PATCH 13/25] scsi: hisi_sas: add path from phyup irq to SAS framework Date: Mon, 12 Oct 2015 23:20:25 +0800 Message-ID: <1444663237-238302-14-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: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.175 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: , Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas.h | 1 + drivers/scsi/hisi_sas/hisi_sas_main.c | 55 ++++++++++++++++++++++++++++++++++ drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 24 +++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/drivers/scsi/hisi_sas/hisi_sas.h b/drivers/scsi/hisi_sas/hisi_sas.h index 18fd30b..802c000 100644 --- a/drivers/scsi/hisi_sas/hisi_sas.h +++ b/drivers/scsi/hisi_sas/hisi_sas.h @@ -333,4 +333,5 @@ extern int interrupt_init_v1_hw(struct hisi_hba *hisi_hba); extern int interrupt_openall_v1_hw(struct hisi_hba *hisi_hba); extern int hw_init_v1_hw(struct hisi_hba *hisi_hba); extern int phys_init_v1_hw(struct hisi_hba *hisi_hba); +extern void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no); #endif diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 882ff79..72831db 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -27,10 +27,65 @@ void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba) hisi_sas_slot_index_clear(hisi_hba, i); } + +void hisi_sas_bytes_dmaed(struct hisi_hba *hisi_hba, int phy_no) +{ + 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; + + if (!phy->phy_attached) + return; + + sas_ha = &hisi_hba->sha; + sas_ha->notify_phy_event(sas_phy, PHYE_OOB_DONE); + + if (sas_phy->phy) { + struct sas_phy *sphy = sas_phy->phy; + + sphy->negotiated_linkrate = sas_phy->linkrate; + sphy->minimum_linkrate = phy->minimum_linkrate; + sphy->minimum_linkrate_hw = SAS_LINK_RATE_1_5_GBPS; + sphy->maximum_linkrate = phy->maximum_linkrate; + } + + if (phy->phy_type & PORT_TYPE_SAS) { + struct sas_identify_frame *id; + + id = (struct sas_identify_frame *)phy->frame_rcvd; + id->dev_type = phy->identify.device_type; + id->initiator_bits = SAS_PROTOCOL_ALL; + id->target_bits = phy->identify.target_port_protocols; + } else if (phy->phy_type & PORT_TYPE_SATA) { + /*Nothing*/ + } + + sas_phy->frame_rcvd_size = phy->frame_rcvd_size; + + sas_ha->notify_port_event(sas_phy, PORTE_BYTES_DMAED); +} + + +static void hisi_sas_phyup_work(struct hisi_hba *hisi_hba, + int phy_no) +{ + sl_notify_v1_hw(hisi_hba, phy_no); /* This requires a sleep */ + hisi_sas_bytes_dmaed(hisi_hba, phy_no); +} + void hisi_sas_wq_process(struct work_struct *work) { struct hisi_sas_wq *wq = container_of(work, struct hisi_sas_wq, work_struct); + struct hisi_hba *hisi_hba = wq->hisi_hba; + int event = wq->event; + int phy_no = wq->phy_no; + + switch (event) { + case PHYUP: + hisi_sas_phyup_work(hisi_hba, phy_no); + break; + } kfree(wq); } diff --git a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c index 20291b4..df56b3a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c @@ -738,6 +738,19 @@ int phys_init_v1_hw(struct hisi_hba *hisi_hba) return 0; } +void sl_notify_v1_hw(struct hisi_hba *hisi_hba, int phy_no) +{ + u32 sl_control; + + sl_control = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL); + sl_control |= SL_CONTROL_NOTIFY_EN_MSK; + hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control); + msleep(1); + sl_control = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL); + sl_control &= ~SL_CONTROL_NOTIFY_EN_MSK; + hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL, sl_control); +} + /* Interrupts */ static irqreturn_t int_phyup_v1_hw(int irq_no, void *p) { @@ -750,6 +763,7 @@ static irqreturn_t int_phyup_v1_hw(int irq_no, void *p) struct sas_identify_frame *id = (struct sas_identify_frame *)frame_rcvd; u32 irq_value, context, port_id, link_rate; int i; + struct hisi_sas_wq *wq = NULL; irqreturn_t res = IRQ_HANDLED; irq_value = hisi_sas_phy_read32(hisi_hba, phy_no, CHL_INT2); @@ -804,6 +818,16 @@ static irqreturn_t int_phyup_v1_hw(int irq_no, void *p) phy->identify.target_port_protocols = SAS_PROTOCOL_SMP; + wq = kmalloc(sizeof(*wq), GFP_ATOMIC); + if (!wq) + goto end; + + wq->event = PHYUP; + wq->hisi_hba = hisi_hba; + wq->phy_no = phy_no; + + INIT_WORK(&wq->work_struct, hisi_sas_wq_process); + queue_work(hisi_hba->wq, &wq->work_struct); end: hisi_sas_phy_write32(hisi_hba, phy_no, CHL_INT2,