Received: by 10.223.164.221 with SMTP id h29csp2061063wrb; Thu, 2 Nov 2017 05:22:51 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SxyUq4lEdvf09hmdq5xm1PSL1C/wmesd24au0r5N+G1rOkOmal3K/hfUGmDJ+568KmKRow X-Received: by 10.159.229.136 with SMTP id az8mr2982491plb.133.1509625371335; Thu, 02 Nov 2017 05:22:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509625371; cv=none; d=google.com; s=arc-20160816; b=jtMLG3oWMXWbG4EGEulRklQvZYxidbBNxb3Uqmfv7uONhdBq5QsFARpibF0WKl50EW iP7GlKyT7sbUZpuLOkbsyQ3JOHUmPTDGlB+/Uk4DOX8/xjzojpZ3NSV1Q/WrH6ggF+1R JQkoW+UKfhYCPD/tB6sMyfmIFAij32dwN1xUx6lksT7JnqlKHbOUEP+sLMXFUgoz4NZP k2TWOs1bUe0Xq5f5ZA3T1NCYs+P4hvujbUM17Wmje8NANKLjki8kX+FSVi1E1K4MxKZl f0QfmEYjPMcgN6Q0mQYf9pls18UvvFSp9MsCoxW2PX1WCT9q4A5vix56a4zY4wGk2Om/ 7F7Q== 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=WCtvloPF8HqxpIAWKDCG2NJjWAAuVNKdunjBt8QXcXI=; b=It1wB/YvP+kat2s2g5CC3/22mO2mexFOSM6ISLd9vzo3fadrQmaD+SC9Mgh5AX3PbC 4V6gvPE7XblsGFNlf1IGLMLH8U5/eXrg9jMMy/hQOEhokBoUGRV17gFcyHkyo3wXXax5 zCIljPyn5aa76nKun0rsJefE8VIGPOVX1HdHrIim0+SEGD8OTzuUrI0e6Ilv2sZssQT7 Zxq149ViapQiUoGl14/d5/s5MOSHnWwZm+hrB9NXWe7CT9YYgUiUzU5kXu4NosgQuTNq QWWi1c4qmFFsrQs+sItDgIYoDlwo1ATI9UD2hS85hYaCr091H6nBxRL3aOMYeUloZFzG 8Hkw== 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 m63si1959819pld.405.2017.11.02.05.22.32; Thu, 02 Nov 2017 05:22:51 -0700 (PDT) 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 S1755562AbdKBMVN (ORCPT + 96 others); Thu, 2 Nov 2017 08:21:13 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51482 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751370AbdKBMTE (ORCPT ); Thu, 2 Nov 2017 08:19:04 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id A259F926F0B63; Thu, 2 Nov 2017 20:18:50 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Thu, 2 Nov 2017 20:17:47 +0800 From: Lipeng To: CC: , , , , Subject: [PATCH V2 net-next 4/9] net: hns3: Add support for misc interrupt Date: Thu, 2 Nov 2017 20:45:18 +0800 Message-ID: <1509626723-18619-5-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509626723-18619-1-git-send-email-lipeng321@huawei.com> References: <1509626723-18619-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds initialization and deinitialization for misc interrupt. This interrupt will be used to handle reset message(IRQ). Signed-off-by: qumingguang Signed-off-by: Lipeng Signed-off-by: Yunsheng Lin --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 5 ++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 74 ++++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 + 3 files changed, 81 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index 6bdc216..db4d887 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -63,6 +63,11 @@ enum hclge_cmd_status { HCLGE_ERR_CSQ_ERROR = -3, }; +struct hclge_misc_vector { + u8 __iomem *addr; + int vector_irq; +}; + struct hclge_cmq { struct hclge_cmq_ring csq; struct hclge_cmq_ring crq; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index cf0fafe..e45842e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2392,11 +2392,71 @@ static void hclge_service_complete(struct hclge_dev *hdev) clear_bit(HCLGE_STATE_SERVICE_SCHED, &hdev->state); } +static void hclge_enable_vector(struct hclge_misc_vector *vector, bool enable) +{ + writel(enable ? 1 : 0, vector->addr); +} + +static irqreturn_t hclge_misc_irq_handle(int irq, void *data) +{ + struct hclge_dev *hdev = data; + + hclge_enable_vector(&hdev->misc_vector, false); + if (!test_and_set_bit(HCLGE_STATE_SERVICE_SCHED, &hdev->state)) + schedule_work(&hdev->service_task); + + return IRQ_HANDLED; +} + +static void hclge_free_vector(struct hclge_dev *hdev, int vector_id) +{ + hdev->vector_status[vector_id] = HCLGE_INVALID_VPORT; + hdev->num_msi_left += 1; + hdev->num_msi_used -= 1; +} + +static void hclge_get_misc_vector(struct hclge_dev *hdev) +{ + struct hclge_misc_vector *vector = &hdev->misc_vector; + + vector->vector_irq = pci_irq_vector(hdev->pdev, 0); + + vector->addr = hdev->hw.io_base + HCLGE_MISC_VECTOR_REG_BASE; + hdev->vector_status[0] = 0; + + hdev->num_msi_left -= 1; + hdev->num_msi_used += 1; +} + +static int hclge_misc_irq_init(struct hclge_dev *hdev) +{ + int ret; + + hclge_get_misc_vector(hdev); + + ret = devm_request_irq(&hdev->pdev->dev, + hdev->misc_vector.vector_irq, + hclge_misc_irq_handle, 0, "hclge_misc", hdev); + if (ret) { + hclge_free_vector(hdev, 0); + dev_err(&hdev->pdev->dev, "request misc irq(%d) fail\n", + hdev->misc_vector.vector_irq); + } + + return ret; +} + +static void hclge_misc_irq_service_task(struct hclge_dev *hdev) +{ + hclge_enable_vector(&hdev->misc_vector, true); +} + static void hclge_service_task(struct work_struct *work) { struct hclge_dev *hdev = container_of(work, struct hclge_dev, service_task); + hclge_misc_irq_service_task(hdev); hclge_update_speed_duplex(hdev); hclge_update_link_status(hdev); hclge_update_stats_for_all(hdev); @@ -4480,6 +4540,14 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) return ret; } + ret = hclge_misc_irq_init(hdev); + if (ret) { + dev_err(&pdev->dev, + "Misc IRQ(vector0) init error, ret = %d.\n", + ret); + return ret; + } + ret = hclge_alloc_tqps(hdev); if (ret) { dev_err(&pdev->dev, "Allocate TQPs error, ret = %d.\n", ret); @@ -4545,6 +4613,9 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) timer_setup(&hdev->service_timer, hclge_service_timer, 0); INIT_WORK(&hdev->service_task, hclge_service_task); + /* Enable MISC vector(vector0) */ + hclge_enable_vector(&hdev->misc_vector, true); + set_bit(HCLGE_STATE_SERVICE_INITED, &hdev->state); set_bit(HCLGE_STATE_DOWN, &hdev->state); @@ -4577,6 +4648,9 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) if (mac->phydev) mdiobus_unregister(mac->mdio_bus); + /* Disable MISC vector(vector0) */ + hclge_enable_vector(&hdev->misc_vector, false); + hclge_free_vector(hdev, 0); hclge_destroy_cmd_queue(&hdev->hw); hclge_pci_uninit(hdev); ae_dev->priv = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index bca4430..2a1d4d6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -27,6 +27,7 @@ (HCLGE_PF_CFG_BLOCK_SIZE / HCLGE_CFG_RD_LEN_BYTES) #define HCLGE_VECTOR_REG_BASE 0x20000 +#define HCLGE_MISC_VECTOR_REG_BASE 0x20400 #define HCLGE_VECTOR_REG_OFFSET 0x4 #define HCLGE_VECTOR_VF_OFFSET 0x100000 @@ -400,6 +401,7 @@ struct hclge_dev { struct pci_dev *pdev; struct hnae3_ae_dev *ae_dev; struct hclge_hw hw; + struct hclge_misc_vector misc_vector; struct hclge_hw_stats hw_stats; unsigned long state; -- 1.9.1 From 1582952917477945782@xxx Thu Nov 02 11:19:01 +0000 2017 X-GM-THRID: 1582952917477945782 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread