Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 234

kvm-83-270.el5_11.src.rpm

From 3f13858c05a32a792e46ccb98c02b6cd5d4d088e Mon Sep 17 00:00:00 2001
From: Don Dutile <ddutile@redhat.com>
Date: Thu, 16 Jul 2009 14:10:47 -0400
Subject: [PATCH] Use pci_reset_function() in RHEL5.4 so FLR done properly (v2)

Currently on RHEL5.4, libvirt's PCI device assignment code
skips performing a set of PCI config cycle operations
to perform a Function Level Reset (FLR) if it detects
(reads PCI config hdr fields) that a PCIe device supports FLR
-- libvirt assumes KVM will call the kernel's PCI support to do an FLR
to a device that supports it when KVM does device assignment and deassignment to/from a
FV guest.

Well, as the previous BZ, 510805, just added FLR into RHEL5.4,
without this patch, if a PCIe FLR device is given or taken away from a
FV guest, it is not properly reset.
This can cause odd system behavior.... like crashing the host...
if the device is not quiesced properly by the guest OS driver
on startup or shutdown.

The simple fix is to conditionally compile *out* the pci_reset_function()
that is stubbed to do nothing in KVM's kernel/external-module-compat-comm.h
if the kernel is < 2.6.28 (when pci_reset_function() was introduced),
and it's RHEL5.4 or higher.

Simple backport of what Chris Wright gave me a few weeks ago, but
backported to latest head of git tree (38a1e6fb3293f47698209077a8d4907d7b8e7685).

Testing: Chris Wright tested his kvm modules with this patch included
along with a brew-built RHEL5.4 kernel I provided with FLR support
(pci_reset_function()) that also had additional trace points (printk's)
to ensure the proper code flows were exec'd for FLR & non-FLR devices.
[It was printk's or a really *snappy* 2.5Gbit PCIe analyzer to decode
 PCI config cycle writes, link reset transitions, etc. ... ah, the good ole days...]

Mark McLoughlin wrote:
>>  #endif
>>
>>  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
>> +#if defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,4)
>
> Should be
>
> #if !defined(RHEL_RELEASE_CODE) || RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,4)
>
> Very minor issue, I know
>
> Cheers,
> Mark.
>

Based on above feedback as well as Eduardo's, attached is
more correct patch for upstream & RHEL5.

Please review & ACK this V2 update (esp. if you ack'd the first version).

- Don

Message-ID: <4A5F6D27.8070701@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Bugzilla: 510806
RH-Upstream-status: pending
Obsoletes: <4A5E2CD6.8010006@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Acked-by: Mark McLoughlin <markmc@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Chris Wright <chrisw@redhat.com>
---
 kernel/external-module-compat-comm.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/external-module-compat-comm.h b/kernel/external-module-compat-comm.h
index bd57d16..ae7acfd 100644
--- a/kernel/external-module-compat-comm.h
+++ b/kernel/external-module-compat-comm.h
@@ -645,6 +645,7 @@ static inline ktime_t kvm_hrtimer_expires_remaining(const struct hrtimer *timer)
 #endif
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
+#if !defined(RHEL_RELEASE_CODE) || RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(5,4)
 
 static inline int pci_reset_function(struct pci_dev *dev)
 {
@@ -652,6 +653,7 @@ static inline int pci_reset_function(struct pci_dev *dev)
 }
 
 #endif
+#endif
 
 #ifndef KMEM_CACHE
 /*
-- 
1.6.3.rc4.29.g8146