Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753345AbcC3A5Y (ORCPT ); Tue, 29 Mar 2016 20:57:24 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:47748 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752884AbcC3A5W (ORCPT ); Tue, 29 Mar 2016 20:57:22 -0400 Date: Tue, 29 Mar 2016 20:57:17 -0400 (EDT) Message-Id: <20160329.205717.1170899993877119259.davem@davemloft.net> To: babu.moger@oracle.com 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 From: David Miller In-Reply-To: <1458849742-162399-1-git-send-email-babu.moger@oracle.com> References: <1458849742-162399-1-git-send-email-babu.moger@oracle.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 29 Mar 2016 17:57:21 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1800 Lines: 48 From: Babu Moger 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 > Signed-off-by: Sowmini Varadhan > Reviewed-by: Ethan Zhao Looks good, applied and queued up for -stable, 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. 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.