Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1763668ybb; Thu, 26 Mar 2020 06:58:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvBEIa9KY08sfuGxxKN7lSbmF9XwFx/PjIUPAz0luAn0mgmDjDP4uRrBGflPHUgFQ2q1pjj X-Received: by 2002:a54:4181:: with SMTP id 1mr95975oiy.158.1585231097313; Thu, 26 Mar 2020 06:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585231097; cv=none; d=google.com; s=arc-20160816; b=Z6NegShRwKO+Z1LgdY6Q7PcNF/4oNh9M3SvcC0y2U80qZKp+OdKHbbkYPVHMi8fjul Qr30v6hBeaa00z7B8z9eWNXGtbbYOD5oJGucm4KU8U3gaqGI6VkrxIl/S0AwJhsXd4IH cUeirj5+4I3Xv8ZkEY6DMtyH1z50J/B6Pz9qR35ig7M8MB6VO+RsqZ/oDuoM4LcXsapJ 2QPXx08qcsKkm/FrABZqQRk0NVhN7ZJa662XFXfs8beANktH7+L8hGx7zWqBOf/wo/WN 7sP7LKIWLogYUiof/a24UjwSJ+SmTMmUheXRP5c1ULB0/XiVOwnfWiaR4cF54mC6ZZOi cBIQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=uTy9XzunUpSqneSBWA8G2EaCSTiTKP7tCVW6EiON0Oc=; b=K1OYshBNdJUS1CC8cSTVwX+a4hLZhtVDyU/vdkjULwHtanlubF4JnxD/VJ4UgBoq63 AYjoyz6YSPS0qusQi3Ykbue9zJd1NGBC//DDRa/XoEDT4mC7JXmWlDzHrfg6HFviVKvr Lp+BHaqBtXPqOG+nwtFeNUUUIU0+s5TuPiYSmQMebUODMlr5oFPd8z03tYohsGdPJYP4 nBm+Li6Xkef3LuLvdN30++9+jG1va8n7+CHnFESby/yBUr9a2Do1mY8U1L0ygJP7ZdbV zftH9Ca7dbfw0Tx9VsxGb69+EOgzKJhDw8Tfkk3IaT3+BswBGv/FX0KIJn/mraZUYfRY uVJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=L2p42bnG; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 192si974240oii.36.2020.03.26.06.58.03; Thu, 26 Mar 2020 06:58:17 -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=@redhat.com header.s=mimecast20190719 header.b=L2p42bnG; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727733AbgCZN5R (ORCPT + 99 others); Thu, 26 Mar 2020 09:57:17 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:45511 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727612AbgCZN5R (ORCPT ); Thu, 26 Mar 2020 09:57:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585231035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uTy9XzunUpSqneSBWA8G2EaCSTiTKP7tCVW6EiON0Oc=; b=L2p42bnGJWVElHNvl6AAemYAHywKfbRHCaq07e9DxhgvZame76U+t6/pevNU7Xdrh/8B4+ 7l4Zt2cd2a/SOkeWC1Bn3mlgoLnvw7xCvDQktGva7699/OCeTuwQxF/gR7cvicSUZIYbuc LxrYyG/ssooXVqzzLqKsCeFrlB3Jc2w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-aLmbfdiSP4iuwWm6Alh4Rw-1; Thu, 26 Mar 2020 09:57:12 -0400 X-MC-Unique: aLmbfdiSP4iuwWm6Alh4Rw-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82830800D50; Thu, 26 Mar 2020 13:57:09 +0000 (UTC) Received: from [10.72.12.19] (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFE2E60BF3; Thu, 26 Mar 2020 13:56:49 +0000 (UTC) Subject: Re: [PATCH V8 9/9] virtio: Intel IFC VF driver for VDPA To: Jason Gunthorpe Cc: mst@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, maxime.coquelin@redhat.com, cunming.liang@intel.com, zhihong.wang@intel.com, rob.miller@broadcom.com, xiao.w.wang@intel.com, lingshan.zhu@intel.com, eperezma@redhat.com, lulu@redhat.com, parav@mellanox.com, kevin.tian@intel.com, stefanha@redhat.com, rdunlap@infradead.org, hch@infradead.org, aadam@redhat.com, jiri@mellanox.com, shahafs@mellanox.com, hanand@xilinx.com, mhabets@solarflare.com, gdawar@xilinx.com, saugatm@xilinx.com, vmireyno@marvell.com, Bie Tiwei References: <20200325082711.1107-1-jasowang@redhat.com> <20200325082711.1107-10-jasowang@redhat.com> <20200325123410.GX13183@mellanox.com> <20200326121705.GJ13183@mellanox.com> From: Jason Wang Message-ID: Date: Thu, 26 Mar 2020 21:56:48 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200326121705.GJ13183@mellanox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/26 =E4=B8=8B=E5=8D=888:17, Jason Gunthorpe wrote: > On Thu, Mar 26, 2020 at 01:50:53PM +0800, Jason Wang wrote: > >>>> + adapter->vdpa.dma_dev =3D dev; >>>> + ret =3D vdpa_register_device(&adapter->vdpa); >>>> + if (ret) { >>>> + IFCVF_ERR(adapter->dev, "Failed to register ifcvf to vdpa bus"); >>>> + goto err_msix; >>>> + } >>>> + >>>> + return 0; >>>> + >>>> +err_msix: >>>> + put_device(&adapter->vdpa.dev); >>>> + return ret; >>>> +err_alloc: >>>> + pci_free_irq_vectors(pdev); >>>> +err_vectors: >>>> + pci_release_regions(pdev); >>>> +err_regions: >>>> + pci_disable_device(pdev); >>>> +err_enable: >>>> + return ret; >>>> +} >>> I personally don't like seeing goto unwinds with multiple returns, an= d >>> here I think it is actually a tiny bug. >>> >>> All touches to the PCI device must stop before the driver core >>> remove() returns - so these pci function cannot be in the kref put >>> release function anyhow. >> >> I'm not sure I get here. IFCVF held refcnt of its PCI parent, so it lo= oks to >> me it's safe to free PCI resources in vDPA free callback? > The refcnt doesn't prevent the driver core from re-binding the > pci_device to another driver. Then the refcount put would do a > pci_disable_device() after another driver has started > > For this reason all touches to a struct pci_device must stop before > remove returns. > > Jason Ok, will send a new version shortly. Thanks >