All of lore.kernel.org
 help / color / mirror / Atom feed
From: Babu Moger <babu.moger@oracle.com>
To: David Miller <davem@davemloft.net>
Cc: bhelgaas@google.com, wangyijing@huawei.com,
	sowmini.varadhan@oracle.com, jiang.liu@linux.intel.com,
	eric.snowberg@oracle.com, yinghai@kernel.org,
	dan.j.williams@intel.com, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	ethan.zhao@oracle.com
Subject: Re: [PATCH v4] sparc/PCI: Fix for panic while enabling SR-IOV
Date: Wed, 30 Mar 2016 10:31:18 -0500	[thread overview]
Message-ID: <56FBF146.3020701@oracle.com> (raw)
In-Reply-To: <20160329.205717.1170899993877119259.davem@davemloft.net>

Hi David,

On 3/29/2016 7:57 PM, David Miller wrote:
> From: Babu Moger <babu.moger@oracle.com>
> Date: Thu, 24 Mar 2016 13:02:22 -0700
> 
>> We noticed this panic while enabling SR-IOV in sparc.
>  ...
>> SR-IOV code looks for arch specific data while enabling
>> VFs. When VF device is added, driver probe function makes set
>> of calls to initialize the pci device. Because the VF device is
>> added different way than the normal PF device(which happens via
>> of_create_pci_dev for sparc), some of the arch specific initialization
>> does not happen for VF device.  That causes panic when archdata is
>> accessed.
>>
>> To fix this, I have used already defined weak function
>> pcibios_setup_device to copy archdata from PF to VF.
>> Also verified the fix.
>>
>> Signed-off-by: Babu Moger <babu.moger@oracle.com>
>> Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
>> Reviewed-by: Ethan Zhao <ethan.zhao@oracle.com>
> 
> Looks good, applied and queued up for -stable, thanks.

Thanks.

> 
> Just a note, I am assuming that the VFs are not instantiated in the
> device tree.  Because when you just memcpy the arch data over from the
> PF, one thing we end up doing is using the device node of the PF.

No. VFs are not instantiated in device tree(/proc/device-tree)

> 
> I slightly cringed at the memcpy, because at least one of these
> pointers are to objects which are reference counted, the OF device.
> 
> Generally speaking we don't really support hot-plug for OF probed
> devices, but if we did all of the device tree pointers have to be
> refcounted properly.
> 
> So in the long term that whole sequence where we go:
> 
> 	struct dev_archdata *sd;
>  ...
> 	sd = &dev->dev.archdata;
> 	sd->iommu = pbm->iommu;
> 	sd->stc = &pbm->stc;
> 	sd->host_controller = pbm;
> 	sd->op = op = of_find_device_by_node(node);
> 	sd->numa_node = pbm->numa_node;
> 
> should be encapsulated into a helper function, and both
> of_create_pci_dev() and this new pcibios_setup_device() can
> invoke it.
> 

Yes. Agree. We need to refactor the whole of_create_pci_dev path to support
hot-plug for the long term. I will start looking at it. For now we should be
fine with the current patch. thanks

WARNING: multiple messages have this Message-ID (diff)
From: Babu Moger <babu.moger@oracle.com>
To: David Miller <davem@davemloft.net>
Cc: bhelgaas@google.com, wangyijing@huawei.com,
	sowmini.varadhan@oracle.com, jiang.liu@linux.intel.com,
	eric.snowberg@oracle.com, yinghai@kernel.org,
	dan.j.williams@intel.com, sparclinux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	ethan.zhao@oracle.com
Subject: Re: [PATCH v4] sparc/PCI: Fix for panic while enabling SR-IOV
Date: Wed, 30 Mar 2016 15:31:18 +0000	[thread overview]
Message-ID: <56FBF146.3020701@oracle.com> (raw)
In-Reply-To: <20160329.205717.1170899993877119259.davem@davemloft.net>

Hi David,

On 3/29/2016 7:57 PM, David Miller wrote:
> From: Babu Moger <babu.moger@oracle.com>
> Date: Thu, 24 Mar 2016 13:02:22 -0700
> 
>> We noticed this panic while enabling SR-IOV in sparc.
>  ...
>> SR-IOV code looks for arch specific data while enabling
>> VFs. When VF device is added, driver probe function makes set
>> of calls to initialize the pci device. Because the VF device is
>> added different way than the normal PF device(which happens via
>> of_create_pci_dev for sparc), some of the arch specific initialization
>> does not happen for VF device.  That causes panic when archdata is
>> accessed.
>>
>> To fix this, I have used already defined weak function
>> pcibios_setup_device to copy archdata from PF to VF.
>> Also verified the fix.
>>
>> Signed-off-by: Babu Moger <babu.moger@oracle.com>
>> Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
>> Reviewed-by: Ethan Zhao <ethan.zhao@oracle.com>
> 
> Looks good, applied and queued up for -stable, thanks.

Thanks.

> 
> Just a note, I am assuming that the VFs are not instantiated in the
> device tree.  Because when you just memcpy the arch data over from the
> PF, one thing we end up doing is using the device node of the PF.

No. VFs are not instantiated in device tree(/proc/device-tree)

> 
> I slightly cringed at the memcpy, because at least one of these
> pointers are to objects which are reference counted, the OF device.
> 
> Generally speaking we don't really support hot-plug for OF probed
> devices, but if we did all of the device tree pointers have to be
> refcounted properly.
> 
> So in the long term that whole sequence where we go:
> 
> 	struct dev_archdata *sd;
>  ...
> 	sd = &dev->dev.archdata;
> 	sd->iommu = pbm->iommu;
> 	sd->stc = &pbm->stc;
> 	sd->host_controller = pbm;
> 	sd->op = op = of_find_device_by_node(node);
> 	sd->numa_node = pbm->numa_node;
> 
> should be encapsulated into a helper function, and both
> of_create_pci_dev() and this new pcibios_setup_device() can
> invoke it.
> 

Yes. Agree. We need to refactor the whole of_create_pci_dev path to support
hot-plug for the long term. I will start looking at it. For now we should be
fine with the current patch. thanks

  reply	other threads:[~2016-03-30 15:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-24 20:02 [PATCH v4] sparc/PCI: Fix for panic while enabling SR-IOV Babu Moger
2016-03-24 20:02 ` Babu Moger
2016-03-30  0:57 ` David Miller
2016-03-30  0:57   ` David Miller
2016-03-30 15:31   ` Babu Moger [this message]
2016-03-30 15:31     ` Babu Moger
2016-03-30 19:37     ` Bjorn Helgaas
2016-03-30 19:37       ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56FBF146.3020701@oracle.com \
    --to=babu.moger@oracle.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=eric.snowberg@oracle.com \
    --cc=ethan.zhao@oracle.com \
    --cc=jiang.liu@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sowmini.varadhan@oracle.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=wangyijing@huawei.com \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.