Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3558707iob; Tue, 17 May 2022 02:39:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUPmTEaZfU+AN7f+QQVdLrpqSu2Lyj8k6WXxrs5Mi7KBiTj95/skhRI0j3WGNk474jLCZ9 X-Received: by 2002:a17:907:72ce:b0:6f4:d139:c2b1 with SMTP id du14-20020a17090772ce00b006f4d139c2b1mr18570552ejc.563.1652780384676; Tue, 17 May 2022 02:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652780384; cv=none; d=google.com; s=arc-20160816; b=kGpkbXOwWn9ASv0qEg5va2wxrR8wjGRGvKe8jGQvTtIbYhV0ZdhAurzhDkD8rvWoTb Whj/O9Pppm2LPAQUbtkEMpZzEgpMlRpdgkYnpfNHHVoPpEdUljQ7lOPjxJSeF97p1TXc 5p/+HW/ERxTt4zLO4eohgwbPv5LUAdD5iKaAojCZYg8Ius7xyzwcaxd1FEVB8Klm5w7h Ol/VKqfyZKdkeDQOrFJg9UxQLCftNUDlGJfARsGy25ylgfX5hP6Lokna9ZZ1QB9JOgCZ G6KI9h9RTsAIUBs4XG/0JIwH2cvjmruP21sH9CBtTu0IFfTLzwFEFr/sdcliXk/V0zQ+ 3MxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CFELpoLm/T5bCWScTqAlgx1Rhso0AgfMtDUILvVD5Tg=; b=VMSpIuwNVSP+Y0FLyWdsM3aLck4aEz80aO00ROQHyinTnhZrSOWz0QFpNN+oA4k9Nz k3BpykKEa+ozskyw7M/wR/1BUu0y5Wv3yaQIEif0jJ3i51oqAy14mh67j3LTT9IcxsiR tJ9PffnYpeJW/St0AcX5OmKK1kbs0gCDJXXq2bU57gm/Yg6x+KlY0m3SG6no6qCteoc/ u8tlkPAzeIHZHTRmdeHE2kHIjhfyQFbi8fvtca4c+hWB0iVGhZ4CnZ2mcJ9J28MevrwZ ePhGD26oHhT+LhwOXRfXuhLocfK1Y2bY7Nk7tdabnFyMA0/dY+vHhg6qSPFSQRoDmaXx P3Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Ert0PJDq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020aa7d6c8000000b0042abfc20c39si2682134edr.450.2022.05.17.02.39.18; Tue, 17 May 2022 02:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Ert0PJDq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239274AbiEQGVZ (ORCPT + 99 others); Tue, 17 May 2022 02:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234922AbiEQGVY (ORCPT ); Tue, 17 May 2022 02:21:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4642F3EAB8; Mon, 16 May 2022 23:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CFELpoLm/T5bCWScTqAlgx1Rhso0AgfMtDUILvVD5Tg=; b=Ert0PJDqria2bGBH515+4RdK3V k+JtKPX5RybqvZ0ZJOosCf6K+4egaua0MGLR7MNJVRO4S7soYpMJdvWzd/s6wTCSGwNqZoiCTv30i /ONPxsQHJp8tLb9VFvfmDuqk9s5o1NBLa+16Mfmlgec+N0xyWoM0Jb4ir3xTDfHt6zlm2Ot22sRf7 RXl1GD7L0D8ucd3+LorFuGrXa9JqDOv8TGZ0lbLLBX9FKck83HgYmCPO0fveeh6LbYt+eCxBg+UfD lee/RAdY/nKAnsxLM7GmKNUf9wIjaKXZkuSS9A+/uz630QxRVDdXsmY3qWnCiTaIGi0R68673bDVN ZeFyfamw==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqqa7-00Bn0U-T9; Tue, 17 May 2022 06:21:19 +0000 Date: Mon, 16 May 2022 23:21:19 -0700 From: Christoph Hellwig To: Jason Gunthorpe Cc: Matthew Rosato , linux-s390@vger.kernel.org, alex.williamson@redhat.com, cohuck@redhat.com, schnelle@linux.ibm.com, farman@linux.ibm.com, pmorel@linux.ibm.com, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, frankja@linux.ibm.com, david@redhat.com, imbrenda@linux.ibm.com, vneethv@linux.ibm.com, oberpar@linux.ibm.com, freude@linux.ibm.com, thuth@redhat.com, pasic@linux.ibm.com, pbonzini@redhat.com, corbet@lwn.net, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v7 17/22] vfio-pci/zdev: add open/close device hooks Message-ID: References: <20220513191509.272897-1-mjrosato@linux.ibm.com> <20220513191509.272897-18-mjrosato@linux.ibm.com> <20220516172734.GE1343366@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220516172734.GE1343366@nvidia.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 16, 2022 at 02:27:34PM -0300, Jason Gunthorpe wrote: > Normally you'd want to do what is kvm_s390_pci_register_kvm() here, > where a failure can be propogated but then you have a race condition > with the kvm. > > Blech, maybe it is time to just fix this race condition permanently, > what do you think? (I didn't even compile it) This is roughly were I was planning to get to, with one difference: I don't think we need or even want the VFIO_DEVICE_NEEDS_KVM flag. Instead just propagation ->kvm to the device whenever it is set and let drivers that have a hard requirements on it like gvt fail if it isn't there. This could still allow using vfio for userspace PCI drivers on s390 for example or in general allow expressing a soft requirement, just without the whole notifier mess. The other question is if we even need an extra reference per device, can't we hold the group reference until all devices are gone anyway? That would remove the need to include kvm_host.h in the vfio code.