Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp333682rdb; Mon, 18 Sep 2023 17:25:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdwjif+H8zYQnmbpDBJmxVgg+zwjYo6L+XquQIbhOI/1Boyo94je8grps1UlhqAAvZ4DiV X-Received: by 2002:a05:6a20:13d3:b0:137:2d73:707f with SMTP id ho19-20020a056a2013d300b001372d73707fmr8435667pzc.5.1695083153694; Mon, 18 Sep 2023 17:25:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695083153; cv=none; d=google.com; s=arc-20160816; b=cSNGcVt6JpQjBeegf0PHVAxHvac/XsOOcG9lDMQd4LcPW4TTAAs5up9IcLc+IEu8jj wkD9ijPqMFN1yOckNr6m8lBzOJMJjlAnhq923QEPmkfj3FQoR4m+Yno9FXcie8XqhsU3 wD6gsH9Hv0vCJ5nM9wR+i3KySE52bn9ERNkAAvhzxhRKVV2fo336WHVpixcby7uuXOpf +2BPMDJpIIWASX946luwDnfkQlj35vFXtEn04N43vmlDz2kIvBEe4TuD9aAedxUzra5F qvpmxsdm/EgKFlfJWZgMpanx5XfLTlTuLi91NHsNgkppU0k7drP1tlyDmjbhyokgXp3N jYRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=UtdQF5K+1l0ENXntUVNj4BS3SxZvs83N54x6+7JhxdQ=; fh=sv9TbEkfvjSw6GeHZfiJBrLlmVUXPWGhP8Y1ju690VY=; b=jyXhqjspU8dEQXjO1224IHpFMVLBRTDKqSRZKHtYLlh0o20Ce7TAEV7fZY41JLFom7 4+0Ug2hxbWvj++Dyh0YWlIGdql42lHDrpeWmvdVrgsWM7oS8RkAvuvBeKoKKqYy2YCWP zBrHcyKo9zID/el9JIDb/GH+HKsavJY9Cuewe9BXwAyFjOdXok7UlozWH3r9x9aTEidY r6Y/+3+unPGq3BXuOu48u6VTvNURYvKjwsFY73zEcDpEe3+9dp1d8Zcirjc1YN7l7bRK 1/55sVSuNYyhfwo+0LddBkwvSZYAbn42fWJ+uO3D+fKSP8D4Pt1dXXnlLYGbqMrSsos/ lKng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VPWQdq3y; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z1-20020a056a00240100b0068a6eb3b548si8855267pfh.401.2023.09.18.17.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 17:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VPWQdq3y; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 95DEF81DF756; Mon, 18 Sep 2023 17:25:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjISAZk (ORCPT + 99 others); Mon, 18 Sep 2023 20:25:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbjISAZk (ORCPT ); Mon, 18 Sep 2023 20:25:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58108E; Mon, 18 Sep 2023 17:25:34 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695083133; 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: in-reply-to:in-reply-to:references:references; bh=UtdQF5K+1l0ENXntUVNj4BS3SxZvs83N54x6+7JhxdQ=; b=VPWQdq3yXUWysjn6WiIh+IrT0eDRKqnKbp/TjGW24UoIUG4R+SIscUN1KsaFwBoCC6VCpp hOw7iNJmLCcyBj/I//sUIoU5Jtzackmjsvhz059Tf0CYoJhYWjgnnLLfQQ/Ol1e4+zS7MP KPLmo/wnLulki9pM9ZFOfbvU1bCai6KIk/o0PsIkhM1lQmpcYX0hTa1QsRLFeidj+1iLSQ kl6YEE6/omuaEQE1rYBDTi6KEIq8Lnbzky/eJhZGec+ytWrEHwJDNK/ylH63Cz7rKJ3QDG 0qOnSp4aNo75gw4gwipnU9OR3Cqb8l/zrFISMp2Uf8PAaM0zsowNtZjG8gUoyw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695083133; 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: in-reply-to:in-reply-to:references:references; bh=UtdQF5K+1l0ENXntUVNj4BS3SxZvs83N54x6+7JhxdQ=; b=rcJB7qjlq6ul/jZ8EG1DAn0R4wg74zv0IkkxKnuf8uML/MnZgPVLhR846BiiPsjSiUPJnd V6FzqugZuNBURXDQ== To: Jason Gunthorpe Cc: Shannon Nelson , alex.williamson@redhat.com, kevin.tian@intel.com, reinette.chatre@intel.com, kvm@vger.kernel.org, brett.creeley@amd.com, linux-kernel@vger.kernel.org, Leon Romanovsky Subject: Re: [PATCH vfio] vfio/pci: remove msi domain on msi disable In-Reply-To: <20230919000215.GQ13795@ziepe.ca> References: <20230914191406.54656-1-shannon.nelson@amd.com> <20230918141705.GE13795@ziepe.ca> <87led3xqye.ffs@tglx> <20230918233735.GP13795@ziepe.ca> <87a5tjxcva.ffs@tglx> <20230919000215.GQ13795@ziepe.ca> Date: Tue, 19 Sep 2023 02:25:32 +0200 Message-ID: <874jjrxb43.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 18 Sep 2023 17:25:50 -0700 (PDT) On Mon, Sep 18 2023 at 21:02, Jason Gunthorpe wrote: > On Tue, Sep 19, 2023 at 01:47:37AM +0200, Thomas Gleixner wrote: >> >> > The intree way to alter the MSI configuration is via >> >> > sriov_set_msix_vec_count, and there is only one in-tree driver that >> >> > uses it right now. >> >> >> >> Right, but that only addresses the driver specific issues. >> > >> > Sort of.. sriov_vf_msix_count_store() is intended to be the entry >> > point for this and if the kernel grows places that cache the value or >> > something then this function should flush those caches too. >> >> Sorry. What I wanted to say is that the driver callback is not the right >> place to reload the MSI domains after the change. > > Oh, that isn't even what Shannon's patch does, it patched VFIO's main > PCI driver - not a sriov_set_msix_vec_count() callback :( Shannon's > scenario doesn't even use sriov_vf_msix_count_store() at all - the AMD > device just randomly changes its MSI count whenever it likes. Ooops. When real hardware changes things behind the kernels back we consider it a hardware bug. The same applies to virtualization muck. So all we should do is add some code which yells when the "hardware" plays silly buggers. >> > I suppose flushing happens implicitly because Shannon reports that >> > things work fine if the driver is rebound. Since >> > sriov_vf_msix_count_store() ensures there is no driver bound before >> > proceeding it probe/unprobe must be flushing out everything? >> >> Correct. So sriov_set_msix_vec_count() could just do: >> >> ret = pdev->driver->sriov_set_msix_vec_count(vf_dev, val); >> if (!ret) >> teardown_msi_domain(pdev); >> >> Right? > > It subtly isn't needed, sriov_vf_msix_count_store() already requires > no driver is associated with the device and this: > > int msi_setup_device_data(struct device *dev) > { > struct msi_device_data *md; > int ret, i; > > if (dev->msi.data) > return 0; > > md = devres_alloc(msi_device_data_release, sizeof(*md), GFP_KERNEL); > if (!md) > return -ENOMEM; > > Already ensured that msi_remove_device_irq_domain() was called via > msi_device_data_release() triggering as part of the devm shutdown of > the bound driver. Indeed. > So, the intree mechanism to change the MSI vector size works. The > crazy mechanism where the device just changes its value without > synchronizing to the OS does not. > > I don't think we need to try and fix that.. We might want to detect it and yell about it, right? Thanks, tglx