All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH 19/19] [POWERPC] Disable PCI IO/Mem on a device when resources can't be allocated
Date: Thu, 20 Dec 2007 14:55:05 +1100	[thread overview]
Message-ID: <20071220035507.B9B94DDF34@ozlabs.org> (raw)
In-Reply-To: <1198122881.874131.56762399546.qpush@grosgo>

This patch changes the PowerPC PCI code to disable IO and/or Memory
decoding on a PCI device when a resource of that type failed to be
allocated. This is done to avoid having unallocated dangling BARs enabled
that might try to decode on top of other devices.

If a proper resource is assigned later on, then pci_enable_device()
will take care of re-enabling decoding.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

 arch/powerpc/kernel/pci-common.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- linux-merge.orig/arch/powerpc/kernel/pci-common.c	2007-12-20 14:51:19.000000000 +1100
+++ linux-merge/arch/powerpc/kernel/pci-common.c	2007-12-20 14:51:20.000000000 +1100
@@ -1034,7 +1034,7 @@ clear_resource:
 	}
 }
 
-static inline void __devinit alloc_resource(struct pci_dev *dev, int idx)
+static inline int __devinit alloc_resource(struct pci_dev *dev, int idx)
 {
 	struct resource *pr, *r = &dev->resource[idx];
 
@@ -1058,7 +1058,10 @@ static inline void __devinit alloc_resou
 		r->flags |= IORESOURCE_UNSET;
 		r->end -= r->start;
 		r->start = 0;
+
+		return -EBUSY;
 	}
+	return 0;
 }
 
 static void __init pcibios_allocate_resources(int pass)
@@ -1080,8 +1083,12 @@ static void __init pcibios_allocate_reso
 				disabled = !(command & PCI_COMMAND_IO);
 			else
 				disabled = !(command & PCI_COMMAND_MEMORY);
-			if (pass == disabled)
-				alloc_resource(dev, idx);
+			if (pass == disabled && alloc_resource(dev, idx)) {
+				command &= ~(r->flags & (IORESOURCE_IO |
+							 IORESOURCE_MEM));
+				pci_write_config_word(dev,
+						      PCI_COMMAND, command);
+			}
 		}
 		if (pass)
 			continue;

      parent reply	other threads:[~2007-12-20  3:55 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-20  3:54 [PATCH 0/19] [POWERPC] PCI updates & merges Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 1/19] [POWERPC] pci32: remove bogus alignment message Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 2/19] [POWERPC] pci32: use generic pci_assign_unassign_resources Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 3/19] [POWERPC] pci32: Remove PowerMac P2P bridge IO hack Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 4/19] [POWERPC] pci32: Add flags modifying the PCI code behaviour Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 5/19] [POWERPC] pci32: Remove obsolete PowerMac bus number hack Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 6/19] [POWERPC] pci32: Add platform option to enable /proc PCI domains Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 7/19] [POWERPC] Merge pcibios_resource_to_bus/bus_to_resource Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 8/19] [POWERPC] Merge PCI resource fixups Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 9/19] [POWERPC] Merge PCI resource allocation & assignment Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 10/19] [POWERPC] fix iSeries PCI resource management Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 11/19] [POWERPC] Updates/fixes to 32 bits pcibios_enable_device() Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 13/19] [POWERPC] Fixup powermac enable device hook Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 12/19] [POWERPC] Merge 32 and 64 bits pcibios_enable_device Benjamin Herrenschmidt
2007-12-20  3:54 ` [PATCH 14/19] [POWERPC] Clear pci_probe_only on 64 bits PowerMac Benjamin Herrenschmidt
2007-12-20  3:55 ` [PATCH 15/19] [POWERPC] Various fixes to pcibios_enable_device() Benjamin Herrenschmidt
2007-12-20  3:55 ` [PATCH 16/19] [POWERPC] Enable self-view of the HT host bridge on PowerMac G5 Benjamin Herrenschmidt
2007-12-20  3:55 ` [PATCH 17/19] [POWERPC] Improve resource setup of PowerMac G5 HT bridge Benjamin Herrenschmidt
2007-12-20  3:55 ` [PATCH 18/19] [POWERPC] Fixup skipping of PowerMac PCI<->PCI bridge "closed" resources Benjamin Herrenschmidt
2007-12-20  3:55 ` Benjamin Herrenschmidt [this message]

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=20071220035507.B9B94DDF34@ozlabs.org \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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.