Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp727383pxb; Tue, 2 Feb 2021 16:52:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4HccREg4XNQLsJxHeA/6E2BwNX3RZVmgwgFXlSW0zdMrI5gzyFip6tyXOWwjrBn34zURP X-Received: by 2002:aa7:c2c5:: with SMTP id m5mr668720edp.250.1612313547107; Tue, 02 Feb 2021 16:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313547; cv=none; d=google.com; s=arc-20160816; b=eLPShej6b5/huB/S6J6olExg57jBGZCzxPyCfelmNfuG3c77Yjr/QCZNyOosYb7uJS meTt036JqSh1g1p8wFP7c0LaKoV1Xheg4t54TTw+WH8+uMFJQ7aqtqLKBaxgDmb2lSnD hwKY51iqrzxsflxQzOgva5SbWk97w+I7MVVESbyCfSEqPDAWNtan1ovbGbqu9wBD81Yw HM9TnBFwVGLeH9IeDR9BAoRX2rnnDV3Qktq2+yhlxy82MNs3PSZ4E2Uh5KoDTzteICt7 lMkhQnctLIERTVQ96OLRt8B51Z31eUbrJndu3YlP8143VRdrd65tCDHaS2FhkjGqGwWJ WbNw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=G0kfi1Ead2f7sUwvPloDcAYNgV5q97py1bBvH50YBqM=; b=k+6xBW12hy80/IIBxAf/+ANoeYxUWzHrfvpAEQ3SJIdAnKlKCUXTUoN17n/De/KXmF wVtqiuqkyMxJ2x+UN8VgOGw9szrxjgCR3YOEPNqou3vJH7xp7fgB9T5FGvTzdlaogsmn 2nr9PXxFXHZZhrNiD9VU1Ws50Fr+Q7VhhJVVaHawi0dR3LoWaT8x72pYwN/UyFO/5ek1 Ei2YU9mAoTGo/5dS1i/8bacoDM/4aifcbn3tleVRIvBWEmOcYWsguyo1boaYg5EAcF+m Vq0NIx0lnbY9Q3a/JH7viDG2lWgqPFu0E7Nfl4dsewxnEaKGxKVXkjdUpZ+c/J8c09aw 0dvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="VSmKMp/u"; 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 b15si242855edz.486.2021.02.02.16.52.02; Tue, 02 Feb 2021 16:52:27 -0800 (PST) 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="VSmKMp/u"; 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 S231352AbhBBVbw (ORCPT + 99 others); Tue, 2 Feb 2021 16:31:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41634 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229502AbhBBVbr (ORCPT ); Tue, 2 Feb 2021 16:31:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612301420; 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=G0kfi1Ead2f7sUwvPloDcAYNgV5q97py1bBvH50YBqM=; b=VSmKMp/uuE10BsIFXIRh89IZ5BgYtHG9tPbGDkGlffXJWW0omawlnGnHGkpRALAb4r76KI FBSTU9jJeAOuBBtjJbm8U18Tf7xAlfsNkfowA8L2/GJt58vF5S6PRL7tCrQV09J/YriSsz d+6ugbvMdgLB3qV/OiUMUyWMe7qCT9M= 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-62-tUNrQbiCMC6gMWru6ngMiA-1; Tue, 02 Feb 2021 16:30:17 -0500 X-MC-Unique: tUNrQbiCMC6gMWru6ngMiA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7A781800D55; Tue, 2 Feb 2021 21:30:15 +0000 (UTC) Received: from omen.home.shazbot.org (ovpn-112-255.phx2.redhat.com [10.3.112.255]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E3901899A; Tue, 2 Feb 2021 21:30:14 +0000 (UTC) Date: Tue, 2 Feb 2021 14:30:13 -0700 From: Alex Williamson To: Max Gurtovoy Cc: Jason Gunthorpe , Cornelia Huck , Matthew Rosato , , , , , , , , , , , , , , , , Subject: Re: [PATCH 8/9] vfio/pci: use x86 naming instead of igd Message-ID: <20210202143013.06366e9d@omen.home.shazbot.org> In-Reply-To: <5e9ee84e-d950-c8d9-ac70-df042f7d8b47@nvidia.com> References: <20210201162828.5938-1-mgurtovoy@nvidia.com> <20210201162828.5938-9-mgurtovoy@nvidia.com> <20210201181454.22112b57.cohuck@redhat.com> <599c6452-8ba6-a00a-65e7-0167f21eac35@linux.ibm.com> <20210201114230.37c18abd@omen.home.shazbot.org> <20210202170659.1c62a9e8.cohuck@redhat.com> <20210202105455.5a358980@omen.home.shazbot.org> <20210202185017.GZ4247@nvidia.com> <20210202123723.6cc018b8@omen.home.shazbot.org> <20210202204432.GC4247@nvidia.com> <5e9ee84e-d950-c8d9-ac70-df042f7d8b47@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2 Feb 2021 22:59:27 +0200 Max Gurtovoy wrote: > On 2/2/2021 10:44 PM, Jason Gunthorpe wrote: > > On Tue, Feb 02, 2021 at 12:37:23PM -0700, Alex Williamson wrote: > > > >> For the most part, this explicit bind interface is redundant to > >> driver_override, which already avoids the duplicate ID issue. > > No, the point here is to have the ID tables in the PCI drivers because > > they fundamentally only work with their supported IDs. The normal > > driver core ID tables are a replacement for all the hardwired if's in > > vfio_pci. > > > > driver_override completely disables all the ID checking, it seems only > > useful for vfio_pci which works with everything. It should not be used > > with something like nvlink_vfio_pci.ko that needs ID checking. > > This mechanism of driver_override seems weird to me. In case of hotplug > and both capable drivers (native device driver and vfio-pci) are loaded, > both will compete on the device. How would the hot-added device have driver_override set? There's no competition, the native device driver would claim the device and the user could set driver_override, unbind and re-probe to get their specified driver. Once a driver_override is set, there cannot be any competition, driver_override is used for match exclusively if set. > I think the proposed flags is very powerful and it does fix the original > concern Alex had ("if we start adding ids for vfio drivers then we > create conflicts with the native host driver") and it's very deterministic. > > In this way we'll bind explicitly to a driver. > > And the way we'll choose a vfio-pci driver is by device_id + vendor_id + > subsystem_device + subsystem_vendor. > > There shouldn't be 2 vfio-pci drivers that support a device with same > above 4 ids. It's entirely possible there could be, but without neural implant devices to interpret the user's intentions, I think we'll have to accept there could be non-determinism here. The first set of users already fail this specification though, we can't base it strictly on device and vendor IDs, we need wildcards, class codes, revision IDs, etc., just like any other PCI drvier. We're not going to maintain a set of specific device IDs for the IGD extension, nor I suspect the NVLINK support as that would require a kernel update every time a new GPU is released that makes use of the same interface. As I understand Jason's reply, these vendor drivers would have an ids table and a user could look at modalias for the device to compare to the driver supported aliases for a match. Does kmod already have this as a utility outside of modprobe? > if you don't find a suitable vendor-vfio-pci.ko, you'll try binding > vfio-pci.ko. > > Each driver will publish its supported ids in sysfs to help the user to > decide. Seems like it would be embedded in the aliases for the module, with this explicit binding flag being the significant difference that prevents auto loading the device. We still have one of the races that driver_override resolves though, the proposed explicit bind flag is on the driver not the device, so a native host driver being loaded due to a hotplug operation or independent actions of different admins could usurp the device between unbind of old driver and bind to new driver. > > Yes, this DRIVER_EXPLICIT_BIND_ONLY idea somewhat replaces > > driver_override because we could set the PCI any match on vfio_pci and > > manage the driver binding explicitly instead. > > > >> A driver id table doesn't really help for binding the device, > >> ultimately even if a device is in the id table it might fail to > >> probe due to the missing platform support that each of these igd and > >> nvlink drivers expose, > > What happens depends on what makes sense for the driver, some missing > > optional support could continue without it, or it could fail. > > > > IGD and nvlink can trivially go onwards and work if they don't find > > the platform support. This seems unpredictable from a user perspective. In either the igd or nvlink cases, if the platform features aren't available, the feature set of the device is reduced. That's not apparent until the user tries to start interacting with the device if the device specific driver doesn't fail the probe. Userspace policy would need to decide if a fallback driver is acceptable or the vendor specific driver failure is fatal. Thanks, Alex