From patchwork Fri Jun 3 12:12:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Chiou X-Patchwork-Id: 9152969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA23160221 for ; Fri, 3 Jun 2016 12:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99FC82804C for ; Fri, 3 Jun 2016 12:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EF3228309; Fri, 3 Jun 2016 12:13:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60C6A2804C for ; Fri, 3 Jun 2016 12:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932857AbcFCMM4 (ORCPT ); Fri, 3 Jun 2016 08:12:56 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33416 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932461AbcFCMMz (ORCPT ); Fri, 3 Jun 2016 08:12:55 -0400 Received: by mail-pf0-f195.google.com with SMTP id b124so11423005pfb.0; Fri, 03 Jun 2016 05:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=OiOxWoH7f94ieGx1fje+VZ6HyIb8C2pPXo7po01dc9k=; b=IVwsLShD6lOFQGKNR10Bl/owpCv21AHD059OgG0Ht6+jONYJo3P9gtKFNTtjZL+8oe L8M7CUDirUvd6oQo1PlDWsGN0e+oqOtNzTmTHN7cdK7p93zByzdUNzghZP4P7EFQvNRv g7ZasEeYU8FKGD9/qttcwmrgr7tHEWBEPG/QERYC1XBiobePMgL8EXqkE+36Y1EoDVhw zldWZXawvI6tCZsv+ATUTyC+m/xTWlxNQpzNrvxdVAwg7nRcDXisBRrSU3QDEextQj7j TFWTQpJycd34XCSmAMgPrukIb5msTJfSjsgXsUrf0rJUkVjhbdKD59N/bCyUfWmh8NH3 64pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OiOxWoH7f94ieGx1fje+VZ6HyIb8C2pPXo7po01dc9k=; b=UndlFfvsGwZGLmzlWwmy7mi5gOFFcHEkWfGDMHlSriEicY51tuJ+RMABBxDqb6PcAd BkwuazjR3C4eJ6IYPSWKeM88k7PmUOhHpANiX8hhnK3FVkdcR7PXu4bensAXo+km00Ni PeRKahCdMBClKXj9yarUv0v7biPTVIXDsCYD4LjvfiQH0Zw1yoSnqEFOjWWgbKdGrmrA R+igzpND+bYtzSn7sF4pH2sylJz+rhftLtRVcFsWsRQrKaimU+++Y509trXJHT9YJdQS /IePiyPF6oN7URN0IHGRIhRMaEeQZ7EraET15EC+u0JcY2LB70RBt+ps8goc58VbHuFe Bc6g== X-Gm-Message-State: ALyK8tIEvcCCZRCRahTNvaztuVjlf6ocXgyApy+qbR71kt8HkCVpDd2sfPlG23CCBvBKFg== X-Received: by 10.98.43.209 with SMTP id r200mr5866483pfr.24.1464955974542; Fri, 03 Jun 2016 05:12:54 -0700 (PDT) Received: from charles-desktop.promise.com.tw (vpn.promise.com.tw. [61.222.81.253]) by smtp.gmail.com with ESMTPSA id i8sm5662065pao.26.2016.06.03.05.12.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Jun 2016 05:12:54 -0700 (PDT) From: Charles Chiou To: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linus.chen@tw.promise.com, grace.chang@tw.promise.com, victor.p@promise.com, eva.cheng@tw.promise.com, charles.chiou@tw.promise.com Cc: Paul Subject: [PATCH 2/5] Add P3 support, modify probe, irq & handshake Date: Fri, 3 Jun 2016 20:12:49 +0800 Message-Id: <1464955969-16788-1-git-send-email-ch1102chiou@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Paul 1.In probe, add p3 card_type for pm, offset, scract & SG 2.Init P3 to use msi interrupt 3.Handshake add P3 read/write reg Signed-off-by: Paul --- drivers/scsi/stex.c | 122 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 88 insertions(+), 34 deletions(-) diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c index f8195c0..921f4e3 100644 --- a/drivers/scsi/stex.c +++ b/drivers/scsi/stex.c @@ -94,7 +94,7 @@ enum { MU_STATE_STOP = 5, MU_STATE_NOCONNECT = 6, - MU_MAX_DELAY = 120, + MU_MAX_DELAY = 50, MU_HANDSHAKE_SIGNATURE = 0x55aaaa55, MU_HANDSHAKE_SIGNATURE_HALF = 0x5a5a0000, MU_HARD_RESET_WAIT = 30000, @@ -1093,14 +1093,27 @@ static int stex_ss_handshake(struct st_hba *hba) int ret = 0; before = jiffies; - while ((readl(base + YIOA_STATUS) & SS_MU_OPERATIONAL) == 0) { - if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { - printk(KERN_ERR DRV_NAME - "(%s): firmware not operational\n", - pci_name(hba->pdev)); - return -1; + + if (hba->cardtype == st_yel) { + while ((readl(base + YIOA_STATUS) & SS_MU_OPERATIONAL) == 0) { + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { + printk(KERN_ERR DRV_NAME + "(%s): firmware not operational\n", + pci_name(hba->pdev)); + return -1; + } + msleep(1); + } + } else if (hba->cardtype == st_P3) { + while ((readl(base + PSCRATCH3) & SS_MU_OPERATIONAL) == 0) { + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { + printk(KERN_ERR DRV_NAME + "(%s): firmware not operational\n", + pci_name(hba->pdev)); + return -1; + } + msleep(1); } - msleep(1); } msg_h = (struct st_msg_header *)hba->dma_mem; @@ -1119,30 +1132,59 @@ static int stex_ss_handshake(struct st_hba *hba) scratch_size = (hba->sts_count+1)*sizeof(u32); h->scratch_size = cpu_to_le32(scratch_size); - data = readl(base + YINT_EN); - data &= ~4; - writel(data, base + YINT_EN); - writel((hba->dma_handle >> 16) >> 16, base + YH2I_REQ_HI); - readl(base + YH2I_REQ_HI); - writel(hba->dma_handle, base + YH2I_REQ); - readl(base + YH2I_REQ); /* flush */ + if (hba->cardtype == st_yel) { + data = readl(base + YINT_EN); + data &= ~4; + writel(data, base + YINT_EN); + writel((hba->dma_handle >> 16) >> 16, base + YH2I_REQ_HI); + readl(base + YH2I_REQ_HI); + writel(hba->dma_handle, base + YH2I_REQ); + readl(base + YH2I_REQ); /* flush */ + } else if (hba->cardtype == st_P3) { + data = readl(base + YINT_EN); + data &= ~(1 << 0); + data &= ~(1 << 2); + writel(data, base + YINT_EN); + writel((1 << 6), base + YH2I_INT); + writel((hba->dma_handle >> 16) >> 16, base + YH2I_REQ_HI); + writel(hba->dma_handle, base + YH2I_REQ); + } - scratch = hba->scratch; before = jiffies; - while (!(le32_to_cpu(*scratch) & SS_STS_HANDSHAKE)) { - if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { - printk(KERN_ERR DRV_NAME - "(%s): no signature after handshake frame\n", - pci_name(hba->pdev)); - ret = -1; - break; + + if (hba->cardtype == st_yel) { + scratch = hba->scratch; + + while (!(le32_to_cpu(*scratch) & SS_STS_HANDSHAKE)) { + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { + printk(KERN_ERR DRV_NAME + "(%s): no signature after handshake frame\n", + pci_name(hba->pdev)); + ret = -1; + break; + } + rmb(); + msleep(1); } - rmb(); - msleep(1); + memset(scratch, 0, scratch_size); + } else if (hba->cardtype == st_P3) { + while ((readl(base + MAILBOX_BASE + MAILBOX_HNDSHK_STS) + & SS_STS_HANDSHAKE) == 0) { + if (time_after(jiffies, before + MU_MAX_DELAY * HZ)) { + printk(KERN_ERR DRV_NAME + "(%s): no signature after handshake frame\n", + pci_name(hba->pdev)); + ret = -1; + break; + } + rmb(); + msleep(1); + } + memset(hba->scratch, 0, scratch_size); } - memset(scratch, 0, scratch_size); msg_h->flag = 0; + return ret; } @@ -1152,7 +1194,7 @@ static int stex_handshake(struct st_hba *hba) unsigned long flags; unsigned int mu_status; - err = (hba->cardtype == st_yel) ? + err = (hba->cardtype == st_yel || hba->cardtype == st_P3) ? stex_ss_handshake(hba) : stex_common_handshake(hba); spin_lock_irqsave(hba->host->host_lock, flags); mu_status = hba->mu_status; @@ -1530,18 +1572,30 @@ static int stex_request_irq(struct st_hba *hba) struct pci_dev *pdev = hba->pdev; int status; - if (msi) { + if (hba->cardtype == st_yel) { + if (msi) { + status = pci_enable_msi(pdev); + if (status != 0) + printk(KERN_ERR DRV_NAME + "(%s): error %d setting up MSI\n", + pci_name(pdev), status); + else + hba->msi_enabled = 1; + } else + hba->msi_enabled = 0; + } else if (hba->cardtype == st_P3) { status = pci_enable_msi(pdev); if (status != 0) printk(KERN_ERR DRV_NAME "(%s): error %d setting up MSI\n", - pci_name(pdev), status); + pci_name(pdev), status); else hba->msi_enabled = 1; } else hba->msi_enabled = 0; - status = request_irq(pdev->irq, hba->cardtype == st_yel ? + status = request_irq(pdev->irq, + (hba->cardtype == st_yel || hba->cardtype == st_P3) ? stex_ss_intr : stex_intr, IRQF_SHARED, DRV_NAME, hba); if (status != 0) { @@ -1625,12 +1679,12 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) case 0x4265: break; default: - if (hba->cardtype == st_yel) + if (hba->cardtype == st_yel || hba->cardtype == st_P3) hba->supports_pm = 1; } sts_offset = scratch_offset = (ci->rq_count+1) * ci->rq_size; - if (hba->cardtype == st_yel) + if (hba->cardtype == st_yel || hba->cardtype == st_P3) sts_offset += (ci->sts_count+1) * sizeof(u32); cp_offset = sts_offset + (ci->sts_count+1) * sizeof(struct status_msg); hba->dma_size = cp_offset + sizeof(struct st_frame); @@ -1670,7 +1724,7 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_pci_free; } - if (hba->cardtype == st_yel) + if (hba->cardtype == st_yel || hba->cardtype == st_P3) hba->scratch = (__le32 *)(hba->dma_mem + scratch_offset); hba->status_buffer = (struct status_msg *)(hba->dma_mem + sts_offset); hba->copy_buffer = hba->dma_mem + cp_offset; @@ -1682,7 +1736,7 @@ static int stex_probe(struct pci_dev *pdev, const struct pci_device_id *id) hba->send = ci->send; hba->mu_status = MU_STATE_STARTING; - if (hba->cardtype == st_yel) + if (hba->cardtype == st_yel || hba->cardtype == st_P3) host->sg_tablesize = 38; else host->sg_tablesize = 32;