Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3756141pxj; Tue, 15 Jun 2021 08:01:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSKnm63ylvVsSF8RRUwmuc2A52W7obpepN1cSkKX1YP+AN0lQ5SrXo82ooXl4jphfeVCfp X-Received: by 2002:a05:6638:379d:: with SMTP id w29mr22085796jal.2.1623769289998; Tue, 15 Jun 2021 08:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623769289; cv=none; d=google.com; s=arc-20160816; b=VfJoW0xVhk4saclrc0PLjwMICP3rCV6XOmrDc9Aa+D3ILGH4m83uk3anjQ19cqls8z 5E13Td4UCydD0+TtZAFL4SY9vbgcf0JDTxEm5Olb3qr7qUw9PxfrTqrvzdSuO6Oh/dR8 6ZK+sycatqAqK2J9PV+NA6Vv/Z59NXsUPFwIVwRzUD0Pbdw2ZpwYM79NqK60mNZoHvy2 q+a6qEgo2Cn/gao7QkRJO3+ED5rVqXCIWMsGE1c2gBq+Fgg4SwPoHNiftOBjStw49vVt 6GTemET0brji5OwRuleKWlRbFbt8XUIzAA0KUmV49Imz1ZBWCEnFJ48b+q3F7kHD4jG8 +GRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=kvDRHIPTMWRdjunH7atJ0Ekx4bg6biP+/uO+nH2vm70=; b=AfWQiw8hOT0xjZhDU6G6DqGQYaUbnGXlPBcZnqkQRWYw6baH8DLkZbOqxI+S0Sg+m0 IFfHi0BB1+jUMiqkKZcrb56nU1+5T34VmrZoy/bA6Dj7ZMU0NGXmdUvEHAMiExYvSzQQ n+6QgXG6gp96ob5AVJRxrdWroR3SJYsNxwKGOv28UdPvvx/LNyq9xVciZb1cHaFUMFTo NeeA1LR8uc8piNAHOgxTei3sdb0rTlGckr0Z99om8SvE1oVeMEnV0qxJfWZnzMGHE1Ff 3Wc33o8aaRBKBRCpsXL08WFac7wF5GR3khPWQG+eJdyudz7ogD1mZ+f1psin76yAD+nu Utag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ULQlAKTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p14si23359558ils.62.2021.06.15.08.01.14; Tue, 15 Jun 2021 08:01:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ULQlAKTB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230391AbhFOPCj (ORCPT + 99 others); Tue, 15 Jun 2021 11:02:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27502 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbhFOPCj (ORCPT ); Tue, 15 Jun 2021 11:02:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623769234; 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=kvDRHIPTMWRdjunH7atJ0Ekx4bg6biP+/uO+nH2vm70=; b=ULQlAKTBrc+7LnNpz62EUUADfVOLOZW3mW0VMp5xBJj3MJf0t6o4qFmDqrbIMpYld+DJGy cYlx1nfcdevV4nSCJUogCsvrr6Pn60YAJ6bnkH5cUrhfq5m5PWIMUEEfy5wqxqFgD+YkCV jQUPly/ndtDgfFwCeBHK+B09UhZxcGk= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-MB5863zxMc6j015A5aNf9A-1; Tue, 15 Jun 2021 11:00:32 -0400 X-MC-Unique: MB5863zxMc6j015A5aNf9A-1 Received: by mail-ot1-f71.google.com with SMTP id n4-20020a9d6f040000b029041298cb18cdso7315958otq.21 for ; Tue, 15 Jun 2021 08:00:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=kvDRHIPTMWRdjunH7atJ0Ekx4bg6biP+/uO+nH2vm70=; b=e54YZhjExWjiHcODeG+3p+IPCdOp2R4dLBgljWagdJjcVbBrbcRTfWHJkUQwAI9F5v 473w3YNght6RO/PsnBKJkkJ81lRzcGfvKBuwDD4I12cS7GiZIc6ZmmpQZnE+3mW8sKwx CgtxFxs0U819u33+BROi8/Cq/ucgRiUnd+gsqlMcKkXe90EimsENqkTauVquW36xJ/R6 UBZ9ORUM0AEm2hxpLIESolejC6UbfEzs7HM8KN9ocW6q+zlhZWpCxDCYiD43QaL9W/i/ mJ/PlvKYjjuKAhT5SLu4iIYjRFTsgFUPiCG+nZCjJLRFAKOTPzLMQ7TVRnSVeO6x7JlN AEGQ== X-Gm-Message-State: AOAM532m0gsqWSCHsCRTtFCTJkgKZTKQntPq/YVyYe5LJXiBFiUh+gzb 9oLV9z6Ysv0vzEEHKE8QVnrIR6+8376t7jAQRmdD6VywGjcyXdzgurk6N4F3aIgmXYVkrV8qO4g 0NpZD3YHk0BDnthhiW8X1sMZx X-Received: by 2002:a9d:20a2:: with SMTP id x31mr17536687ota.263.1623769231658; Tue, 15 Jun 2021 08:00:31 -0700 (PDT) X-Received: by 2002:a9d:20a2:: with SMTP id x31mr17536660ota.263.1623769231344; Tue, 15 Jun 2021 08:00:31 -0700 (PDT) Received: from redhat.com ([198.99.80.109]) by smtp.gmail.com with ESMTPSA id u10sm4050146otj.75.2021.06.15.08.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 08:00:30 -0700 (PDT) Date: Tue, 15 Jun 2021 09:00:29 -0600 From: Alex Williamson To: Max Gurtovoy Cc: Jason Gunthorpe , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH 09/11] PCI: add matching checks for driver_override binding Message-ID: <20210615090029.41849d7a.alex.williamson@redhat.com> In-Reply-To: <70a1b23f-764d-8b3e-91a4-bf5d67ac9f1f@nvidia.com> References: <20210603160809.15845-1-mgurtovoy@nvidia.com> <20210603160809.15845-10-mgurtovoy@nvidia.com> <20210608152643.2d3400c1.alex.williamson@redhat.com> <20210608224517.GQ1002214@nvidia.com> <20210608192711.4956cda2.alex.williamson@redhat.com> <117a5e68-d16e-c146-6d37-fcbfe49cb4f8@nvidia.com> <20210614124250.0d32537c.alex.williamson@redhat.com> <70a1b23f-764d-8b3e-91a4-bf5d67ac9f1f@nvidia.com> Organization: Red Hat X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Jun 2021 02:12:15 +0300 Max Gurtovoy wrote: > On 6/14/2021 9:42 PM, Alex Williamson wrote: > > On Sun, 13 Jun 2021 11:19:46 +0300 > > Max Gurtovoy wrote: > > =20 > >> On 6/9/2021 4:27 AM, Alex Williamson wrote: =20 > >>> On Tue, 8 Jun 2021 19:45:17 -0300 > >>> Jason Gunthorpe wrote: > >>> =20 > >>>> On Tue, Jun 08, 2021 at 03:26:43PM -0600, Alex Williamson wrote: =20 > >>>>>> drivers that specifically opt into this feature and the driver now= has > >>>>>> the opportunity to provide a proper match table that indicates wha= t HW > >>>>>> it can properly support. vfio-pci continues to support everything.= =20 > >>>>> In doing so, this also breaks the new_id method for vfio-pci. =20 > >>>> Does it? How? The driver_override flag is per match entry not for the > >>>> entire device so new_id added things will work the same as before as > >>>> their new match entry's flags will be zero. =20 > >>> Hmm, that might have been a testing issue; combining driverctl with > >>> manual new_id testing might have left a driver_override in place. > >>> =20 > >>>>> Sorry, with so many userspace regressions, crippling the > >>>>> driver_override interface with an assumption of such a narrow focus, > >>>>> creating a vfio specific match flag, I don't see where this can go. > >>>>> Thanks, =20 > >>>> On the other hand it overcomes all the objections from the last go > >>>> round: how userspace figures out which driver to use with > >>>> driver_override and integrating the universal driver into the scheme. > >>>> > >>>> pci_stub could be delt with by marking it for driver_override like > >>>> vfio_pci. =20 > >>> By marking it a "vfio driver override"? :-\ > >>> =20 > >>>> But driverctl as a general tool working with any module is not really > >>>> addressable. > >>>> > >>>> Is the only issue the blocking of the arbitary binding? That is not a > >>>> critical peice of this, IIRC =20 > >>> We can't break userspace, which means new_id and driver_override need > >>> to work as they do now. There are scads of driver binding scripts in > >>> the wild, for vfio-pci and other drivers. We can't assume such a > >>> narrow scope. Thanks, =20 > >> what about the following code ? > >> > >> @@ -152,12 +152,28 @@ static const struct pci_device_id > >> *pci_match_device(struct pci_driver *drv, > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 spin_unlock(&drv->dynids.= lock); > >> > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!found_id) > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 found_id =3D pci_match_id(drv->id_table, dev); > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (found_id) > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 return found_id; =20 > > a) A dynamic ID match always works regardless of driver override... > > =20 > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* driver_override will always m= atch, send a dummy id */ > >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!found_id && dev->driver_ove= rride) > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 found_id =3D pci_match_id(drv->i= d_table, dev); > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (found_id) { > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 /* > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * if we found id in the static table, we must fulfill= the > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * matching flags (i.e. if PCI_ID_F_DRIVER_OVERRIDE fl= ag is > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * set, driver_override should be provided). > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 */ > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 bool is_driver_override =3D > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (found_id->= flags & PCI_ID_F_DRIVER_OVERRIDE) !=3D 0; > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 if ((is_driver_override && !dev->driver_override) || =20 > > b) A static ID match fails if the driver provides an override flag and > > the device does not have an override set, or... > > =20 > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (dev->driver_override && !is_driver= _override)) =20 > > c) The device has an override set and the driver does not support the > > override flag. > > =20 > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return NULL; > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } else if (dev->driver_override)= { > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 /* > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * if we didn't find suitable id in the static table, > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 * driver_override will still , send a dummy id > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 */ > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 found_id =3D &pci_device_id_any; > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > >> > >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return found_id; > >> =C2=A0} > >> > >> > >> dynamic ids (new_id) works as before. > >> > >> Old driver_override works as before. =20 > > This is deceptively complicated, but no, I don't believe it does. By > > my understanding of c) an "old" driver can no longer use > > driver_override for binding a known device. It seems that if we have a > > static ID match, then we cannot have a driver_override set for the > > device in such a case. This is a userspace regression. =20 >=20 > If I'll remove condition c) everyone will be happy ? >=20 > I really would like to end this ongoing discussion and finally have a=20 > clear idea of what we want. >=20 > By clear I mean C code. >=20 > If we'll continue raising ideas we'll never reach our goal. And my goal=20 > is the next merge window. Bjorn would ultimately need to make the call on that, I don't see an obvious regression if c) is dropped. pci-stub and pci-pf-stub should be included in the proposal so we can better understand how creating a "vfio" override in PCI-core plays out for other override types. Also I don't think dynamic IDs should be handled uniquely, new_id_store() should gain support for flags and userspace should be able to add new dynamic ID with override-only matches to the table. Thanks, Alex