Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp37665pxj; Wed, 16 Jun 2021 19:37:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz383lYsY3zssW4B4sEUrQ7mIhe3z/AvXKUOYXpf84QVCFa1YY2Pme/PIfhEUhWT5bzGF7P X-Received: by 2002:a05:6638:349f:: with SMTP id t31mr2244514jal.95.1623897430198; Wed, 16 Jun 2021 19:37:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1623897430; cv=pass; d=google.com; s=arc-20160816; b=YMQ7Hm83K5MIUf53fI+3N/q+ZFAaZq1QZy2MpazvuMy/fBKtawdftk4CO6w1+YGdK4 Zf2eWR0ua7A2P/dyyujZS5jC7VXgZuS/2vupHeh+5KU24pp1FCVYHEKr5UhBjls2JpmP B/vmWKgHmmgU/17BLkoFOfYfTEi3qgFd7B9650Gg3naZBNVpvQrUuR/fY8BKZu09z41J gK/Wr74zZbLIC3v7Q5tTYK11hrSigHYWfHLLzDQ7DVnCrsnxmRxZoN8H3AEmWrVw+vsx GHVB9XplZaElU/KJhfbT8H9Vx6dTooNP01dGJkpTueE0TXWLLb7347gvoSDssewblFZ6 WWKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=K/uyzV9+SzMs6u5H6pgtoUJ3EKwETB6N1rP4r2JLN64=; b=NKwaBnNcQ93FF5ynwA3j5Ig7tLwxKFRO7ADh5TjWQ/hryG7NWDTjTiPZ0WspsVjKPM zjwAMUTU+OcwzacKbtzWgNMoy4e6F8TU6q0sN6hNm7mcbPkvn4fr73BwOPV4mnX8IzAm A6cvKuZE4tNjlMDwdvL5iXESYpW/OKe2aH2g+SfIyeU23fM5yc3oA/7MObPsZjyVaAiX CoQ5Xvmm6Ue7eZLbTJyjCAEoaBBz9DPeX9BkwY//r0PJqD7F+8GDQNP0Mcy5n1JT+EiH JwzcFAZxEnVqxJxhLTY4DuC96Rkn20twt3U4ypquQmH7RQkZnHdvkaY0hLWRqZc0IA2p HAtw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Gr56P0+I; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t9si5133053jan.117.2021.06.16.19.36.58; Wed, 16 Jun 2021 19:37:10 -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=@Nvidia.com header.s=selector2 header.b=Gr56P0+I; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234637AbhFPXfc (ORCPT + 99 others); Wed, 16 Jun 2021 19:35:32 -0400 Received: from mail-dm3nam07on2088.outbound.protection.outlook.com ([40.107.95.88]:55585 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234530AbhFPXf1 (ORCPT ); Wed, 16 Jun 2021 19:35:27 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hR2lQzgfQlAh2G0z++YXwKYKNnkYniR/uu4PgDZ5wDRnHYiNF2Isz7Q6gvwoijGf2oOc2iluLz/YH7RujzdmcYr3LuTQiGn/bSaTc/apXEuNJtBwcqA7Ok9eN6IqxQKE4P4cI+Zfw6C/0ljPcyl10NCWp+ReuLWI9UldrLAYS3DMnY5Kyc9L8BplT/5oii2eAcuE8QX2YFAPe8jfCsgfpAaXaT5lq/+tbHBorQ5X7bv1hnfHnxDnHili+xredKqFQn89u70GB03BJGZFz5VFhFcK5DkW5ANJnfT8rdpQtX+p6zGeujvf8Se64fIDgg3OziDddmTOmSixOwOUB8fTVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K/uyzV9+SzMs6u5H6pgtoUJ3EKwETB6N1rP4r2JLN64=; b=CUXPVRwmL8EL4mLqjRy40AxxZhfqmGi/a7H/mRm9CtrX8jYeH3Jbc/RK0T7uRBX6hzNu7VU+hPB225t5q+9cO2X3bBMPjTWJtjazmfVxCeeVcFlngUbuQuiuGgmxs0xXbQBliji/hUvbOvGuDqDyXAl3p8yBjLMFkwpk32QLK/DtrHdY0YmoK5g7abHpiVfXFHtHBOED5FUByJtkVogATmnNC7h2x38YGUn8WKzLuXzvUt/OuZmW/bwJvM6V95p/6wV5STdoz/p692nC2jLgtsoIb/C4efNiN31Gl8XUpw4GhiwEYtgywygiGPnJncq5gAt6FdTRgjAEcJuev/TimA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K/uyzV9+SzMs6u5H6pgtoUJ3EKwETB6N1rP4r2JLN64=; b=Gr56P0+ID0+oNaa2fOp57KUWWpGPJAAeUMU7/rz9qtxnOsm5vkSoohGDyrbj083evlDltXJgyQIDfsUdBKCevlzAzKI8eyYQZOPSt9x+iRSMXqRGS/7Xszxa9ekKk9KX/bC+kl27S2J3ol2tkMNkgsNkxtOkqWZcwYeIkJPGI7HmFlA+yK3ZWufw5xgO/4LYfmP2YfAQh+C+2CJJ5WJVCE3oJn0xvtFtYXiXF0UNewkUBbPAMz9CMyueKnh6epGT7kCwa1fSqJy/jUmKUUpDDnp7cJmpBGoBp0iWDiw8T2KeT/V6JXBq/yUnzkjuRxe929/BkgPwBQ+lKks6RgnP8g== Authentication-Results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=nvidia.com; Received: from BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) by BL1PR12MB5032.namprd12.prod.outlook.com (2603:10b6:208:30a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Wed, 16 Jun 2021 23:33:19 +0000 Received: from BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e]) by BL0PR12MB5506.namprd12.prod.outlook.com ([fe80::3d51:a3b9:8611:684e%8]) with mapi id 15.20.4242.019; Wed, 16 Jun 2021 23:33:19 +0000 Date: Wed, 16 Jun 2021 20:33:17 -0300 From: Jason Gunthorpe To: Max Gurtovoy Cc: Alex Williamson , cohuck@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, aviadye@nvidia.com, oren@nvidia.com, shahafs@nvidia.com, parav@nvidia.com, artemp@nvidia.com, kwankhede@nvidia.com, ACurrid@nvidia.com, cjia@nvidia.com, yishaih@nvidia.com, kevin.tian@intel.com, hch@infradead.org, targupta@nvidia.com, shameerali.kolothum.thodi@huawei.com, liulongfang@huawei.com, yan.y.zhao@intel.com Subject: Re: [PATCH 09/11] PCI: add matching checks for driver_override binding Message-ID: <20210616233317.GR1002214@nvidia.com> References: <20210615150458.GR1002214@nvidia.com> <20210615102049.71a3c125.alex.williamson@redhat.com> <20210615204216.GY1002214@nvidia.com> <20210615155900.51f09c15.alex.williamson@redhat.com> <20210615230017.GZ1002214@nvidia.com> <20210615172242.4b2be854.alex.williamson@redhat.com> <20210615233257.GB1002214@nvidia.com> <20210615182245.54944509.alex.williamson@redhat.com> <20210616003417.GH1002214@nvidia.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Originating-IP: [47.55.113.94] X-ClientProxiedBy: MN2PR13CA0017.namprd13.prod.outlook.com (2603:10b6:208:160::30) To BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mlx.ziepe.ca (47.55.113.94) by MN2PR13CA0017.namprd13.prod.outlook.com (2603:10b6:208:160::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.7 via Frontend Transport; Wed, 16 Jun 2021 23:33:19 +0000 Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1ltf25-007wUo-CH; Wed, 16 Jun 2021 20:33:17 -0300 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d87364c0-4d8e-4f9c-966b-08d9311f1f8d X-MS-TrafficTypeDiagnostic: BL1PR12MB5032: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rLIsCrIXLxzqZvoA+G4D+FwrVXuzxFREb+yW2ywmtO7XRa4aP6RlPbD7Tls16r/goZ8BS3ssUxaSgLdq47BFdEvB34GKhpEFHoxO2ByRjup5s3PWuxn7sp6tzsQS/Gt3fkAaRfNms5RzjMx9p6whwG3Qcy/p1BRnpEBkXbqtJTesO46xZe3F5BmTUVwcwnzxlHUUGTDvkYY/b/VS5+yS8v+hjcdYd1QlRRSgnn0ieWni7Szt8xV7DDLU83wo4zLPC5zGByHNMxO8j42g8yJxnE/8O6hGxi9zfyLIomEjdm14pO69JA9NTerhROkPtzTEU3+6KZOVuudR1abmjI6gjpaRJQSHVle6AqnWpuNBB8rf7Ub7GSq5ChevYJBhrXuE3YW/Iuu6pWPtXdH2rj7Bq2XKJaZ9282ADIBv4om3kDipeOdyjYg8fRXpwZw/9NgL0v9avAE+sosOiaPp+xYu/wNc1ysPt1ddmp3HKuNdMBp8niD/p9om8N3pgZqwUf7vtF+f2Gal2XRmZnAnbpvs7zaXRjhka0ELJLA7sXw+uhFcreaxqy+tO/DVAZg9mrVkxoWW1IbxOhT1vI/alVbBBM5GWvtAFdly1Id8nSwxDRo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR12MB5506.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(396003)(376002)(366004)(136003)(346002)(4326008)(6862004)(33656002)(9746002)(9786002)(8936002)(8676002)(5660300002)(186003)(2906002)(1076003)(26005)(86362001)(37006003)(2616005)(426003)(6636002)(53546011)(66476007)(38100700002)(36756003)(66946007)(66556008)(316002)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fF3YdPmykKi4i4h0z8UUuRDQjGe7M7aaLdocevOHLK3ks3dWaUkFRM0XwLlH?= =?us-ascii?Q?q5byGGk2I7T1Tqym6zduATHQPNT1FI+K7fCIMpEfwhlMIClDdluZRYrHiz4K?= =?us-ascii?Q?2uQVo5I6ndriSVVF+o99iRfVqxVIKsBlDKZk/kjgNs4TMsHe/xb3qgwM30Vc?= =?us-ascii?Q?7dcgKm/OxYMNBfXTI3E8MVib217LVwTdhESDu5Cir9q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yItMJ5MtUBOjPN9JJymV5cCbqgZbHVD/n+SCWREg/gy18D/0YwazvMxKSNz?= =?us-ascii?Q?6peBWUqgZT3Pv5ofM5z/Y8FgGzMfT30vUS3iAlbm8TyMlEg/Sv2XHqL2dCOC?= =?us-ascii?Q?U5U/mrS4OJ0YHm0/yJu5DxqEnLCJ1D9DhvBa3EkHDYUH6fRU0P66V9DvuIzx?= =?us-ascii?Q?k0HIZ3NxJALHE33jQUBX8nD/mUjOQt1sUXPXIOXHnnlXgxPuadwl2Q96wNY1?= =?us-ascii?Q?FDsp+oAFK0nLhnF53X/rVDZG?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d87364c0-4d8e-4f9c-966b-08d9311f1f8d X-MS-Exchange-CrossTenant-AuthSource: BL0PR12MB5506.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 23:33:19.4836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LcefQdjRAFxZTSu2rZhnj/CFPLuKPD4nSdeE/xHOTzb9BKKXhaFp0TNeqLQ7WR8F X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5032 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021 at 02:28:36AM +0300, Max Gurtovoy wrote: > > On 6/16/2021 3:34 AM, Jason Gunthorpe wrote: > > On Tue, Jun 15, 2021 at 06:22:45PM -0600, Alex Williamson wrote: > > > On Tue, 15 Jun 2021 20:32:57 -0300 > > > Jason Gunthorpe wrote: > > > > > > > On Tue, Jun 15, 2021 at 05:22:42PM -0600, Alex Williamson wrote: > > > > > > > > > > > b) alone is a functional, runtime difference. > > > > > > I would state b) differently: > > > > > > > > > > > > b) Ignore the driver-override-only match entries in the ID table. > > > > > No, pci_match_device() returns NULL if a match is found that is marked > > > > > driver-override-only and a driver_override is not specified. That's > > > > > the same as no match at all. We don't then go on to search past that > > > > > match in the table, we fail to bind the driver. That's effectively an > > > > > anti-match when there's no driver_override on the device. > > > > anti-match isn't the intention. The deployment will have match tables > > > > where all entires are either flags=0 or are driver-override-only. > > > I'd expect pci-pf-stub to have one of each, an any-id with > > > override-only flag and the one device ID currently in the table with > > > no flag. > > Oh Hum. Actually I think this shows the anti-match behavior is > > actually a bug.. :( > > > > For something like pci_pf_stub_whitelist, if we add a > > driver_override-only using the PCI any id then it effectively disables > > new_id completely because the match search will alway find the > > driver_override match first and stop searching. There is no chance to > > see things new_id adds. > > Actually the dynamic table is the first table the driver search. So new_id > works exactly the same AFAIU. Oh, even better, so it isn't really an issue > But you're right for static mixed table (I assumed that this will never > happen I guess). Me too, we could organize the driver-overrides to be last > - found_id = pci_match_id(drv->id_table, dev); > - if (found_id) { > + ids = drv->id_table; > + while ((found_id = pci_match_id(ids, dev))) { Yeah, keep searching makes logical sense to me > diff --git a/drivers/pci/pci-pf-stub.c b/drivers/pci/pci-pf-stub.c > index 45855a5e9fca..49544ba9a7af 100644 > +++ b/drivers/pci/pci-pf-stub.c > @@ -19,6 +19,7 @@ > */ > static const struct pci_device_id pci_pf_stub_whitelist[] = { > { PCI_VDEVICE(AMAZON, 0x0053) }, > + { PCI_DEVICE_FLAGS(PCI_ANY_ID, PCI_ANY_ID, > PCI_ID_F_STUB_DRIVER_OVERRIDE) }, /* match all by default (override) */ > /* required last entry */ > { 0 } And we don't really want this change any more right? No reason to put pci_stub in the module.alias file? Thanks, Jason