Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1842933yba; Thu, 25 Apr 2019 06:39:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtZ5WKbHOLZ1Pn6W8sU8mOyPNHlu9Z6JTCjmBU0KI2/Q8qmcGYiVLUSiSqS2su0fjm7h8g X-Received: by 2002:a17:902:1103:: with SMTP id d3mr1918285pla.247.1556199547246; Thu, 25 Apr 2019 06:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556199547; cv=none; d=google.com; s=arc-20160816; b=nQdzGOVjppvWf1Bh348nY5AHNNGhrW9QMkChQ30ONg+Ke49K+DsjMpoFy3Qi6YzWDz o05vscdyOCnacRlQNK8wCwY9SYG7A5OwnOgLLusLAmYyGZnk1Ibv4WbMHL9/PqmIu5xc 2K1KbO89GJfCVr7+N5DEXz0D+bgOvIqhB8TvgGWWN6+8fcnmMNralqK4jUjtuTgP2K89 SXPWYFNmTBMR7htgmcRRpfvGErGZYSZgQwOHNLyuuGP/YXfa6Cb3eGYT/n0U3yxTVlNZ ULRaJhbk1OaAcahuSPFkUbXyj7PbuCiWi8i++E/8Auiyq+spVotItBhmhefDzB0YDU1X xmEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=K2ih8MpLb8bI6MFhoYp8cEnZ8Y5Myr0EgHsYIIxqDC8=; b=BANjn3AhiyovBomiXXJsPMv3WuUlgmwZ6rMyPeZ/lSBUuKwcQF0VcXa7ubQBZNtrj9 qPmPL2otp/KIVxnZ1O7cwi74H0AqQqJT1YgMSu10YBJPYa7oT6L+rTC8tjJEjT5YLkT9 YOxbPPsJHI9JKSOSffIq0WN9bNEd7APEsj1mu+YlIxIZ2JxvqMXe0/NkhQGIOLLUOkKS jIz4+Uh5pgYaR0WMVRwMGEr5LSv1Zuq09Teszj/9RNzHWQRzz8frvkGsXhyV2yuPO5tL +7RJ3y+4LcmBP2LB2Dt37Qx/WOLNcXz4V+oXNunCtlDwyElPmNtPnf8fjV6iqO/s50tg uJ6A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v37si6004313pgl.168.2019.04.25.06.38.52; Thu, 25 Apr 2019 06:39:07 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730853AbfDYLlH (ORCPT + 99 others); Thu, 25 Apr 2019 07:41:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43918 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726165AbfDYLlH (ORCPT ); Thu, 25 Apr 2019 07:41:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3640C04FFF1; Thu, 25 Apr 2019 11:41:06 +0000 (UTC) Received: from hmswarspite.think-freely.org (ovpn-121-75.rdu2.redhat.com [10.10.121.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD23E60C70; Thu, 25 Apr 2019 11:41:05 +0000 (UTC) Date: Thu, 25 Apr 2019 07:41:04 -0400 From: Neil Horman To: tanhuazhong Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, salil.mehta@huawei.com, yisen.zhuang@huawei.com, linuxarm@huawei.com, Peng Li Subject: Re: [PATCH V2 net-next 08/12] net: hns3: stop schedule reset service while unloading driver Message-ID: <20190425114104.GC15861@hmswarspite.think-freely.org> References: <1556103931-64031-1-git-send-email-tanhuazhong@huawei.com> <1556103931-64031-9-git-send-email-tanhuazhong@huawei.com> <20190424135524.GE6661@hmswarspite.think-freely.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 25 Apr 2019 11:41:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 25, 2019 at 02:06:07PM +0800, tanhuazhong wrote: > > > On 2019/4/24 21:55, Neil Horman wrote: > > On Wed, Apr 24, 2019 at 07:05:27PM +0800, Huazhong Tan wrote: > > > This patch uses HCLGE_STATE_REMOVING/HCLGEVF_STATE_REMOVING flag to > > > indicate that the driver is unloading, and we should stop new coming > > > reset service to be scheduled, otherwise, reset service will access > > > some resource which has been freed by unloading. > > > > > > Signed-off-by: Huazhong Tan > > > Signed-off-by: Peng Li > > > --- > > > V1->V2: fixes a flag setting error > > > --- > > > drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- > > > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 +++- > > > drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + > > > 3 files changed, 7 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c > > > index 4d5568e..ead8308 100644 > > > --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c > > > +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c > > > @@ -2175,7 +2175,8 @@ static void hclge_mbx_task_schedule(struct hclge_dev *hdev) > > > static void hclge_reset_task_schedule(struct hclge_dev *hdev) > > > { > > > - if (!test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state)) > > > + if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) && > > > + !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state)) > > > schedule_work(&hdev->rst_service_task); > > > } > > > > In what use case do you need an extra bit for this? From my read, this work > > task only gets scheduled from: > > 1) Interrupt handlers > > 2) Its own service task > > > > Based on the fact that you are calling cancel_work_sync(...rst_service_task) > > from the pci teardown routine, irqs should all be disabled on your devices > > already (meaning interrupts shouldn't schedule it), and cancel_work_sync > > guarantees that rearming cant happen from within its own service task. > > > > Neil > > > > Beside these two cases, when the client detects an error and requests a > reset, it will call hclge_reset_event and schedule the reset work task to > deal with the request. This may happen after calling > cancel_work_sync(...rst_service_task) from the pci teardown routine. > > Best Regards, Huazhong > But that is handled from either: 1) hns_roce_v2_msix_interrupt_abn or 2) hns3_nic_net_timeout or 3) hns3_slot_reset You should be protected from (1) because interrupts should be disabled before you call cancel_work_syn. You should be protected from (2) because the network interface will have been brought down first (disabling the watchdog timer for the any interfaces on this hardware You should be protected from (3) because you are tearing down the pci device anyway, and the pci subsystem should be ignoring resets Neil > > > > . > > >