Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3829926ybb; Mon, 6 Apr 2020 17:02:35 -0700 (PDT) X-Google-Smtp-Source: APiQypIEQ6gUrGmEM2sJBHjEA1a67Ti+vkzQCRM6M6fNM4L56xboFId1MlSssZrhPMBZuY7UIcQK X-Received: by 2002:a9d:23a1:: with SMTP id t30mr18936571otb.253.1586217755430; Mon, 06 Apr 2020 17:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586217755; cv=none; d=google.com; s=arc-20160816; b=sdcueDqSNsoIyG4LgiXXbhX4PS8fADuheIQZJYSc5NFsj0fQmcaUqDX8G1byuvknI9 CTvKzXujJi3AqnqCIey8IRS3OgmVNz49RgyNubeBPC4zv1Dh4SF/6zWm3JbKv6tiLgaa A/tAT8R8mQlUCvZ14SiWHlY3g1mepvRBd8ufl34qMMCiLVVuJu6QPdAe68E3FsDURiP6 AJdsr59Ef74Foav/58K5CeCMUODrIufZ7zp5xRqOizE6ZR9v7fFmg3837Dd35YbsGlyz fpAXpub3v54xU5K53+kmiqGOEszxfENSuf8EwhujUCM8jBydb3TPrzlcx5PN2JFtpPhl KVEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0WwI/BZntg6W7pGx92tkaoiDyyid2vMFwmEYzUswk6k=; b=ioRIgpRMf+aOa+RIUG5NasLV+F5dsB8cll1Slb58KTAjmu++AtIClSwFplKF1kXTEn JX1fNivtxPVBUeNTTspDV92qf0mryJRjOHn4CrSatUBmCQOqDDazxMrQYFYfy+emsMj8 86pwtRKePCPKmj3V7VFQz5ZFRoK8Dy9mOAquC1su0nH2Pgf+6ECaI0a6dmCQXP512qtW YcbfxynJHGlvT6P76mmx90UJidHHn/B6Q0ZDWpwGKdS5wYFGSW0z8D5yhnaN8AE1pk16 wTQg/fj1TrzlaDU23HXR9CqmijEIyYfEAjCgFVzcwFEcyFtz+QDdHVEwAsu7Vd65t2rd 1gxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JKoaGiGp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y35si453970otb.315.2020.04.06.17.02.23; Mon, 06 Apr 2020 17:02:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JKoaGiGp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbgDGABe (ORCPT + 99 others); Mon, 6 Apr 2020 20:01:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:34360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726833AbgDGAB0 (ORCPT ); Mon, 6 Apr 2020 20:01:26 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EE25B208FE; Tue, 7 Apr 2020 00:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586217685; bh=muNrQiaZ8eIKGS+5LNkuEELzJtq6f1xeWtgQdhCXaFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKoaGiGpS6zQZA9nplb0m6F0EFEubaDpfOtKn7WnEzIjsqrb3WCQGohCoZ1dT6Bou hLbHHDLvAsB1ThIsns7ZPZCeqNGHb1wa5JGiqon/0EssuC4THbfulLrC1pAJt5k1je Mp3yQfVR/0L3wc4+wdZBDElpe0JnZlu+ZYA0ukxE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Luo bin , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.5 21/35] hinic: fix the bug of clearing event queue Date: Mon, 6 Apr 2020 20:00:43 -0400 Message-Id: <20200407000058.16423-21-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407000058.16423-1-sashal@kernel.org> References: <20200407000058.16423-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luo bin [ Upstream commit 614eaa943e9fc3fcdbd4aa0692ae84973d363333 ] should disable eq irq before freeing it, must clear event queue depth in hw before freeing relevant memory to avoid illegal memory access and update consumer idx to avoid invalid interrupt Signed-off-by: Luo bin Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/huawei/hinic/hinic_hw_eqs.c | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c index 79243b626ddbe..6a723c4757bce 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c @@ -188,7 +188,7 @@ static u8 eq_cons_idx_checksum_set(u32 val) * eq_update_ci - update the HW cons idx of event queue * @eq: the event queue to update the cons idx for **/ -static void eq_update_ci(struct hinic_eq *eq) +static void eq_update_ci(struct hinic_eq *eq, u32 arm_state) { u32 val, addr = EQ_CONS_IDX_REG_ADDR(eq); @@ -202,7 +202,7 @@ static void eq_update_ci(struct hinic_eq *eq) val |= HINIC_EQ_CI_SET(eq->cons_idx, IDX) | HINIC_EQ_CI_SET(eq->wrapped, WRAPPED) | - HINIC_EQ_CI_SET(EQ_ARMED, INT_ARMED); + HINIC_EQ_CI_SET(arm_state, INT_ARMED); val |= HINIC_EQ_CI_SET(eq_cons_idx_checksum_set(val), XOR_CHKSUM); @@ -347,7 +347,7 @@ static void eq_irq_handler(void *data) else if (eq->type == HINIC_CEQ) ceq_irq_handler(eq); - eq_update_ci(eq); + eq_update_ci(eq, EQ_ARMED); } /** @@ -702,7 +702,7 @@ static int init_eq(struct hinic_eq *eq, struct hinic_hwif *hwif, } set_eq_ctrls(eq); - eq_update_ci(eq); + eq_update_ci(eq, EQ_ARMED); err = alloc_eq_pages(eq); if (err) { @@ -752,18 +752,28 @@ static int init_eq(struct hinic_eq *eq, struct hinic_hwif *hwif, **/ static void remove_eq(struct hinic_eq *eq) { - struct msix_entry *entry = &eq->msix_entry; - - free_irq(entry->vector, eq); + hinic_set_msix_state(eq->hwif, eq->msix_entry.entry, + HINIC_MSIX_DISABLE); + free_irq(eq->msix_entry.vector, eq); if (eq->type == HINIC_AEQ) { struct hinic_eq_work *aeq_work = &eq->aeq_work; cancel_work_sync(&aeq_work->work); + /* clear aeq_len to avoid hw access host memory */ + hinic_hwif_write_reg(eq->hwif, + HINIC_CSR_AEQ_CTRL_1_ADDR(eq->q_id), 0); } else if (eq->type == HINIC_CEQ) { tasklet_kill(&eq->ceq_tasklet); + /* clear ceq_len to avoid hw access host memory */ + hinic_hwif_write_reg(eq->hwif, + HINIC_CSR_CEQ_CTRL_1_ADDR(eq->q_id), 0); } + /* update cons_idx to avoid invalid interrupt */ + eq->cons_idx = hinic_hwif_read_reg(eq->hwif, EQ_PROD_IDX_REG_ADDR(eq)); + eq_update_ci(eq, EQ_NOT_ARMED); + free_eq_pages(eq); } -- 2.20.1