From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18832 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbgHMNLd (ORCPT ); Thu, 13 Aug 2020 09:11:33 -0400 Subject: Re: [PATCH v2] PCI: Introduce flag for detached virtual functions References: <1597260071-2219-1-git-send-email-mjrosato@linux.ibm.com> <1597260071-2219-2-git-send-email-mjrosato@linux.ibm.com> <2a862199-16c8-2141-d27f-79761c1b1b25@linux.ibm.com> <17be8c41-8989-f1da-a843-30f0761f42de@linux.ibm.com> From: Matthew Rosato Message-ID: <6ffa5f39-3607-88c7-81f9-dc97d12d09df@linux.ibm.com> Date: Thu, 13 Aug 2020 09:11:20 -0400 MIME-Version: 1.0 In-Reply-To: <17be8c41-8989-f1da-a843-30f0761f42de@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-s390-owner@vger.kernel.org List-ID: To: Niklas Schnelle , Oliver O'Halloran Cc: Alex Williamson , Bjorn Helgaas , pmorel@linux.ibm.com, Michael Ellerman , linux-s390@vger.kernel.org, Linux Kernel Mailing List , KVM list , linux-pci , Alexey Kardashevskiy On 8/13/20 8:34 AM, Niklas Schnelle wrote: > > > On 8/13/20 12:40 PM, Niklas Schnelle wrote: >> >> >> On 8/13/20 11:59 AM, Oliver O'Halloran wrote: >>> On Thu, Aug 13, 2020 at 7:00 PM Niklas Schnelle wrote: >>>> >>>> >>>> On 8/13/20 3:55 AM, Oliver O'Halloran wrote: >>>>> On Thu, Aug 13, 2020 at 5:21 AM Matthew Rosato wrote: >>>>>> *snip* >>>>>> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c >>>>>> index 3902c9f..04ac76d 100644 >>>>>> --- a/arch/s390/pci/pci.c >>>>>> +++ b/arch/s390/pci/pci.c >>>>>> @@ -581,6 +581,14 @@ int pcibios_enable_device(struct pci_dev *pdev, int mask) >>>>>> { >>>>>> struct zpci_dev *zdev = to_zpci(pdev); >>>>>> >>>>>> + /* >>>>>> + * If we have a VF on a non-multifunction bus, it must be a VF that is >>>>>> + * detached from its parent PF. We rely on firmware emulation to >>>>>> + * provide underlying PF details. >>>>>> + */ >>>>>> + if (zdev->vfn && !zdev->zbus->multifunction) >>>>>> + pdev->detached_vf = 1; >>>>> >>>>> The enable hook seems like it's a bit too late for this sort of >>>>> screwing around with the pci_dev. Anything in the setup path that >>>>> looks at ->detached_vf would see it cleared while anything that looks >>>>> after the device is enabled will see it set. Can this go into >>>>> pcibios_add_device() or a fixup instead? >>>>> >>>> >>>> This particular check could go into pcibios_add_device() yes. >>>> We're also currently working on a slight rework of how >>>> we establish the VF to parent PF linking including the sysfs >>>> part of that. The latter sadly can only go after the sysfs >>>> for the virtfn has been created and that only happens >>>> after all fixups. We would like to do both together because >>>> the latter sets pdev->is_virtfn which I think is closely related. >>>> >>>> I was thinking of starting another discussion >>>> about adding a hook that is executed just after the sysfs entries >>>> for the PCI device are created but haven't yet. >>> >>> if all you need is sysfs then pcibios_bus_add_device() or a bus >>> notifier should work >> >> So this might go a bit off track but the problem is that >> on s390 a VF can be disabled and reenabled with disable_slot()/enable_slot(). >> In this case pcibios_bus_add_device() is not called again but >> the PF/VF link needs to be reestablished. > > Scratch that I must have made some stupid mistake last time I tried > this, with your suggestion I tried again and it works perfectly > moving the setup into pcibios_bus_add_device(). > Thank you, this is actually much nicer! > OK, and I can likewise relocate the setting of detached_vf to pcibios_bus_add_device().