Skip to contentSkip to conversation

pci_update_resource() getting called on sparc64

PATCH New David S. Miller 7 participants 27 messages Aug 8, 2005 – Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Some recent change last week causes pci_update_resource() to be invoked on sparc64 now, and this is why my workstation couldn't cleanly boot into current 2.6.13 when I tried to remotely try out some new kernels while I was in the UK.

This thing is supposed to only be invoked if you support power management, and therefore we made it just BUG() on sparc64.

But some change last week causes it to be invoked when the radeonfb driver registers a device, and that's why my workstation failed to boot up current 2.6.13 kernels.

pci_restore_bars() is the only invoker of pci_update_resource() and that should only be invoked by pci_set_power_state() if the local variable "need_restore" is set, which occurs if

	if (dev->current_state >= PCI_D3hot) {
		if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
			need_restore = 1;

and I don't see how that can happen to my radeon which is fully operational when the kernel boots and the radeon device is registered.

I'm tempted to just make pci_update_resource() not BUG() any longer, but that definitely feels like the wrong way to fix this. And in any event, I'd like to get this fixed before 2.6.13 goes out the door.

Does anyone have a clue what change made last week could have made this start happening?

#1 lore raw
Quoted 26 lines · David S. Miller

Some recent change last week causes pci_update_resource() to be invoked on sparc64 now, and this is why my workstation couldn't cleanly boot into current 2.6.13 when I tried to remotely try out some new kernels while I was in the UK.

This thing is supposed to only be invoked if you support power management, and therefore we made it just BUG() on sparc64.

But some change last week causes it to be invoked when the radeonfb driver registers a device, and that's why my workstation failed to boot up current 2.6.13 kernels.

pci_restore_bars() is the only invoker of pci_update_resource() and that should only be invoked by pci_set_power_state() if the local variable "need_restore" is set, which occurs if

	if (dev->current_state >= PCI_D3hot) {
		if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET))
			need_restore = 1;

and I don't see how that can happen to my radeon which is fully operational when the kernel boots and the radeon device is registered.

Quoted 7 lines

I'm tempted to just make pci_update_resource() not BUG() any longer, but that definitely feels like the wrong way to fix this. And in any event, I'd like to get this fixed before 2.6.13 goes out the door.

Does anyone have a clue what change made last week could have made this start happening?

Perhaps this patch:
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=43c34735524d5b1c9b9e5d63b49dd4c1b394bde4

Although in glancing at it, it might not be the reason...

thanks,

greg k-h

#3 lore raw
Quoted 4 lines · David S. Miller

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 07:44:40 -0700

Quoted 8 lines
Quoted 3 lines

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=43c34735524d5b1c9b9e5d63b49dd4c1b394bde4

Although in glancing at it, it might not be the reason...

No, that isn't it.

Perhaps it was one of those changes that Linus was doing to deal with interrupt setting restoration after resume?

Not likely.

Sounds like fec59a711eef002d4ef9eb8de09dd0a26986eb77, which came in through Greg. I'm surprised Greg didn't pick up on that one.

Linus

#4 lore raw
Quoted 13 lines · Linus Torvalds
Quoted 10 lines · David S. Miller

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 07:44:40 -0700

Quoted 3 lines

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=43c34735524d5b1c9b9e5d63b49dd4c1b394bde4

Although in glancing at it, it might not be the reason...

No, that isn't it.

Quoted 7 lines
Quoted 2 lines

Perhaps it was one of those changes that Linus was doing to deal with interrupt setting restoration after resume?

Not likely.

Sounds like fec59a711eef002d4ef9eb8de09dd0a26986eb77, which came in through Greg. I'm surprised Greg didn't pick up on that one.

I didn't pick up on that one, as David acked it a while ago :)

{sigh} I only pushed that one as Ralf insisted that he needed it for some of his hardware and that there wasn't any bad side-affects. Ralf, any objections to removing this for 2.6.13?

thanks,

greg k-h

#5 lore raw

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 09:08:46 -0700

Quoted 12 lines · Linus Torvalds
Quoted 5 lines

Not likely.

Sounds like fec59a711eef002d4ef9eb8de09dd0a26986eb77, which came in through Greg. I'm surprised Greg didn't pick up on that one.

I didn't pick up on that one, as David acked it a while ago :)

{sigh} I only pushed that one as Ralf insisted that he needed it for some of his hardware and that there wasn't any bad side-affects. Ralf, any objections to removing this for 2.6.13?

But this is so puzzling, because this code path should only trigger if the device is not in D0 state. There is no way any of the devices in my sparc64 box should be in any powered down state at bootup time. Unless the kernel would do that, which I hope it does not.

Therefore, I can't figure out how this code path could even trigger.

It happens for every device in my machine, my primary framebuffer radeonfb, my e1000, the tg3 card in the machine. In short, every single PCI device triggers this when it registers.

I think something fishy is going on here, and the sparc64 BUG() is just a symptom. Why are devices in D3hot state at bootup?

And lo' and behold, we find the answer in the PCI probing code. It initializes every PCI device's PCI power state to "unknown":

	/* "Unknown power state" */
	dev->current_state = 4;

and thus makes this test ">= D3hot" pass in the pci_set_power_state() code.

That looks very wrong.

#6 lore raw
Quoted 30 lines · David S. Miller

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 09:08:46 -0700

Quoted 12 lines · Linus Torvalds
Quoted 5 lines

Not likely.

Sounds like fec59a711eef002d4ef9eb8de09dd0a26986eb77, which came in through Greg. I'm surprised Greg didn't pick up on that one.

I didn't pick up on that one, as David acked it a while ago :)

{sigh} I only pushed that one as Ralf insisted that he needed it for some of his hardware and that there wasn't any bad side-affects. Ralf, any objections to removing this for 2.6.13?

But this is so puzzling, because this code path should only trigger if the device is not in D0 state. There is no way any of the devices in my sparc64 box should be in any powered down state at bootup time. Unless the kernel would do that, which I hope it does not.

Therefore, I can't figure out how this code path could even trigger.

It happens for every device in my machine, my primary framebuffer radeonfb, my e1000, the tg3 card in the machine. In short, every single PCI device triggers this when it registers.

I think something fishy is going on here, and the sparc64 BUG() is just a symptom. Why are devices in D3hot state at bootup?

Quoted 8 lines

And lo' and behold, we find the answer in the PCI probing code. It initializes every PCI device's PCI power state to "unknown":

	/* "Unknown power state" */
	dev->current_state = 4;

and thus makes this test ">= D3hot" pass in the pci_set_power_state() code.

Crap, gotta love >= checks on enumerated types...

Linus, can you just revert that changeset for now? That will sove David's problem, and I'll work on getting this patch working properly for after 2.6.13 is out.

Hm, how do you revert a git patch?

thanks,

greg k-h

#7 lore raw

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 12:42:49 -0700

Quoted 3 lines

Linus, can you just revert that changeset for now? That will sove David's problem, and I'll work on getting this patch working properly for after 2.6.13 is out.

Agreed.

I even have a patch I'll submit to you which will get sparc64 converted over to using drivers/pci/setup-res.c so that none of this kind of non-sense will occur in the future.

Quoted 1 line

Hm, how do you revert a git patch?

"patch -p1 -R" the patch, then use a changelog like:

[PCI]: Revert $(SHA1)

The $(SHA1) even shows up in gitk as a hyperlink so you can see the original changeset and assosciated changelog entry by just clicking on it.

#8 lore raw
Quoted 7 lines · David S. Miller

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 12:42:49 -0700

Quoted 3 lines

Linus, can you just revert that changeset for now? That will sove David's problem, and I'll work on getting this patch working properly for after 2.6.13 is out.

Quoted 5 lines

Agreed.

I even have a patch I'll submit to you which will get sparc64 converted over to using drivers/pci/setup-res.c so that none of this kind of non-sense will occur in the future.

That sounds even better.

thanks,

greg k-h

#9 lore raw

PATCH 1/1 : Make sparc64 use setup-res.c

From: Greg KH <[email protected]>
Date: Mon, 8 Aug 2005 13:02:52 -0700

Quoted 6 lines · David S. Miller
Quoted 3 lines

I even have a patch I'll submit to you which will get sparc64 converted over to using drivers/pci/setup-res.c so that none of this kind of non-sense will occur in the future.

That sounds even better.

Ok, here is the patch.

There were three changes necessary in order to allow sparc64 to use setup-res.c:

1) Sparc64 roots the PCI I/O and MEM address space using parent resources contained in the PCI controller structure. I'm actually surprised no other platforms do this, especially ones like Alpha and PPC{,64}. These resources get linked into the iomem/ioport tree when PCI controllers are probed.

So the hierarchy looks like this:

iomem --|
PCI controller 1 MEM space --|
device 1
device 2
etc.
PCI controller 2 MEM space --|
...
ioport --|
PCI controller 1 IO space --|
...
PCI controller 2 IO space --|
...

You get the idea. The drivers/pci/setup-res.c code allocates using plain iomem_space and ioport_space as the root, so that wouldn't work with the above setup.

So I added a pcibios_select_root() that is used to handle this. It uses the PCI controller struct's io_space and mem_space on sparc64, and io{port,mem}_resource on every other platform to keep current behavior.

2) quirk_io_region() is buggy. It takes in raw BUS view addresses and tries to use them as a PCI resource.

pci_claim_resource() expects the resource to be fully formed when it gets called. The sparc64 implementation would do the translation but that's absolutely wrong, because if the same resource gets released then re-claimed we'll adjust things twice.

So I fixed up quirk_io_region() to do the proper pcibios_bus_to_resource() conversion before passing it on to pci_claim_resource().

3) I was mistakedly __init'ing the function methods the PCI controller drivers provide on sparc64 to implement some parts of these routines. This was, of course, easy to fix.

So we end up with the following, and that nasty SPARC64 makefile ifdef in drivers/pci/Makefile is finally zapped.

arch/sparc64/kernel/pci.c +5 -128
@@ -359,140 +359,17 @@ void pcibios_fixup_bus(struct pci_bus *p
 	pbus->resource[1] = &pbm->mem_space;
 }
 
-int pci_claim_resource(struct pci_dev *pdev, int resource)
+struct resource *pcibios_select_root(struct pci_dev *pdev, struct resource *r)
 {
 	struct pci_pbm_info *pbm = pdev->bus->sysdata;
-	struct resource *res = &pdev->resource[resource];
-	struct resource *root;
-
-	if (!pbm)
-		return -EINVAL;
+	struct resource *root = NULL;
 
-	if (res->flags & IORESOURCE_IO)
+	if (r->flags & IORESOURCE_IO)
 		root = &pbm->io_space;
-	else
+	if (r->flags & IORESOURCE_MEM)
 		root = &pbm->mem_space;
 
-	pbm->parent->resource_adjust(pdev, res, root);
-
-	return request_resource(root, res);
-}
-
-/*
- * Given the PCI bus a device resides on, try to
- * find an acceptable resource allocation for a
- * specific device resource..
- */
-static int pci_assign_bus_resource(const struct pci_bus *bus,
-	struct pci_dev *dev,
-	struct resource *res,
-	unsigned long size,
-	unsigned long min,
-	int resno)
-{
-	unsigned int type_mask;
-	int i;
-
-	type_mask = IORESOURCE_IO | IORESOURCE_MEM;
-	for (i = 0 ; i < 4; i++) {
-		struct resource *r = bus->resource[i];
-		if (!r)
-			continue;
-
-		/* type_mask must match */
-		if ((res->flags ^ r->flags) & type_mask)
-			continue;
-
-		/* Ok, try it out.. */
-		if (allocate_resource(r, res, size, min, -1, size, NULL, NULL) < 0)
-			continue;
-
-		/* PCI config space updated by caller.  */
-		return 0;
-	}
-	return -EBUSY;
-}
-
-void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno)
-{
-	/* Not implemented for sparc64... */
-	BUG();
-}
-
-int pci_assign_resource(struct pci_dev *pdev, int resource)
-{
-	struct pcidev_cookie *pcp = pdev->sysdata;
-	struct pci_pbm_info *pbm = pcp->pbm;
-	struct resource *res = &pdev->resource[resource];
-	unsigned long min, size;
-	int err;
-
-	if (res->flags & IORESOURCE_IO)
-		min = pbm->io_space.start + 0x400UL;
-	else
-		min = pbm->mem_space.start;
-
-	size = res->end - res->start + 1;
-
-	err = pci_assign_bus_resource(pdev->bus, pdev, res, size, min, resource);
-
-	if (err < 0) {
-		printk("PCI: Failed to allocate resource %d for %s\n",
-		       resource, pci_name(pdev));
-	} else {
-		/* Update PCI config space. */
-		pbm->parent->base_address_update(pdev, resource);
-	}
-
-	return err;
-}
-
-/* Sort resources by alignment */
-void pdev_sort_resources(struct pci_dev *dev, struct resource_list *head)
-{
-	int i;
-
-	for (i = 0; i < PCI_NUM_RESOURCES; i++) {
-		struct resource *r;
-		struct resource_list *list, *tmp;
-		unsigned long r_align;
-
-		r = &dev->resource[i];
-		r_align = r->end - r->start;
-		
-		if (!(r->flags) || r->parent)
-			continue;
-		if (!r_align) {
-			printk(KERN_WARNING "PCI: Ignore bogus resource %d "
-					    "[%lx:%lx] of %s\n",
-					    i, r->start, r->end, pci_name(dev));
-			continue;
-		}
-		r_align = (i < PCI_BRIDGE_RESOURCES) ? r_align + 1 : r->start;
-		for (list = head; ; list = list->next) {
-			unsigned long align = 0;
-			struct resource_list *ln = list->next;
-			int idx;
-
-			if (ln) {
-				idx = ln->res - &ln->dev->resource[0];
-				align = (idx < PCI_BRIDGE_RESOURCES) ?
-					ln->res->end - ln->res->start + 1 :
-					ln->res->start;
-			}
-			if (r_align > align) {
-				tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
-				if (!tmp)
-					panic("pdev_sort_resources(): "
-					      "kmalloc() failed!\n");
-				tmp->next = ln;
-				tmp->res = r;
-				tmp->dev = dev;
-				list->next = tmp;
-				break;
-			}
-		}
-	}
+	return root;
 }
 
 void pcibios_update_irq(struct pci_dev *pdev, int irq)
arch/sparc64/kernel/pci_psycho.c +17 -17
@@ -307,7 +307,7 @@ static unsigned char psycho_pil_table[] 
 /*0x32*/15,		/* Power Management		*/
 };
 
-static int __init psycho_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
+static int psycho_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
 {
 	int ret;
 
@@ -344,9 +344,9 @@ static int __init psycho_ino_to_pil(stru
 	return ret;
 }
 
-static unsigned int __init psycho_irq_build(struct pci_pbm_info *pbm,
-					    struct pci_dev *pdev,
-					    unsigned int ino)
+static unsigned int psycho_irq_build(struct pci_pbm_info *pbm,
+				     struct pci_dev *pdev,
+				     unsigned int ino)
 {
 	struct ino_bucket *bucket;
 	unsigned long imap, iclr;
@@ -1024,7 +1024,7 @@ static irqreturn_t psycho_pcierr_intr(in
 #define PSYCHO_CE_INO		0x2f
 #define PSYCHO_PCIERR_A_INO	0x30
 #define PSYCHO_PCIERR_B_INO	0x31
-static void __init psycho_register_error_handlers(struct pci_controller_info *p)
+static void psycho_register_error_handlers(struct pci_controller_info *p)
 {
 	struct pci_pbm_info *pbm = &p->pbm_A; /* arbitrary */
 	unsigned long base = p->pbm_A.controller_regs;
@@ -1091,15 +1091,15 @@ static void __init psycho_register_error
 }
 
 /* PSYCHO boot time probing and initialization. */
-static void __init psycho_resource_adjust(struct pci_dev *pdev,
-					  struct resource *res,
-					  struct resource *root)
+static void psycho_resource_adjust(struct pci_dev *pdev,
+				   struct resource *res,
+				   struct resource *root)
 {
 	res->start += root->start;
 	res->end += root->start;
 }
 
-static void __init psycho_base_address_update(struct pci_dev *pdev, int resource)
+static void psycho_base_address_update(struct pci_dev *pdev, int resource)
 {
 	struct pcidev_cookie *pcp = pdev->sysdata;
 	struct pci_pbm_info *pbm = pcp->pbm;
@@ -1144,7 +1144,7 @@ static void __init psycho_base_address_u
 		pci_write_config_dword(pdev, where + 4, 0);
 }
 
-static void __init pbm_config_busmastering(struct pci_pbm_info *pbm)
+static void pbm_config_busmastering(struct pci_pbm_info *pbm)
 {
 	u8 *addr;
 
@@ -1161,8 +1161,8 @@ static void __init pbm_config_busmasteri
 	pci_config_write8(addr, 64);
 }
 
-static void __init pbm_scan_bus(struct pci_controller_info *p,
-				struct pci_pbm_info *pbm)
+static void pbm_scan_bus(struct pci_controller_info *p,
+			 struct pci_pbm_info *pbm)
 {
 	struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL);
 
@@ -1189,7 +1189,7 @@ static void __init pbm_scan_bus(struct p
 	pci_setup_busmastering(pbm, pbm->pci_bus);
 }
 
-static void __init psycho_scan_bus(struct pci_controller_info *p)
+static void psycho_scan_bus(struct pci_controller_info *p)
 {
 	pbm_config_busmastering(&p->pbm_B);
 	p->pbm_B.is_66mhz_capable = 0;
@@ -1204,7 +1204,7 @@ static void __init psycho_scan_bus(struc
 	psycho_register_error_handlers(p);
 }
 
-static void __init psycho_iommu_init(struct pci_controller_info *p)
+static void psycho_iommu_init(struct pci_controller_info *p)
 {
 	struct pci_iommu *iommu = p->pbm_A.iommu;
 	unsigned long tsbbase, i;
@@ -1327,8 +1327,8 @@ static void psycho_controller_hwinit(str
 	psycho_write(p->pbm_A.controller_regs + PSYCHO_PCIB_DIAG, tmp);
 }
 
-static void __init pbm_register_toplevel_resources(struct pci_controller_info *p,
-						   struct pci_pbm_info *pbm)
+static void pbm_register_toplevel_resources(struct pci_controller_info *p,
+					    struct pci_pbm_info *pbm)
 {
 	char *name = pbm->name;
 
@@ -1481,7 +1481,7 @@ static void psycho_pbm_init(struct pci_c
 
 #define PSYCHO_CONFIGSPACE	0x001000000UL
 
-void __init psycho_init(int node, char *model_name)
+void psycho_init(int node, char *model_name)
 {
 	struct linux_prom64_registers pr_regs[3];
 	struct pci_controller_info *p;
arch/sparc64/kernel/pci_sabre.c +18 -18
@@ -554,7 +554,7 @@ static unsigned char sabre_pil_table[] =
 /*0x32*/15,		/* Power Management		*/
 };
 
-static int __init sabre_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
+static int sabre_ino_to_pil(struct pci_dev *pdev, unsigned int ino)
 {
 	int ret;
 
@@ -612,9 +612,9 @@ static void sabre_wsync_handler(struct i
 	sabre_read(sync_reg);
 }
 
-static unsigned int __init sabre_irq_build(struct pci_pbm_info *pbm,
-					   struct pci_dev *pdev,
-					   unsigned int ino)
+static unsigned int sabre_irq_build(struct pci_pbm_info *pbm,
+				    struct pci_dev *pdev,
+				    unsigned int ino)
 {
 	struct ino_bucket *bucket;
 	unsigned long imap, iclr;
@@ -1009,7 +1009,7 @@ static irqreturn_t sabre_pcierr_intr(int
 #define SABRE_UE_INO		0x2e
 #define SABRE_CE_INO		0x2f
 #define SABRE_PCIERR_INO	0x30
-static void __init sabre_register_error_handlers(struct pci_controller_info *p)
+static void sabre_register_error_handlers(struct pci_controller_info *p)
 {
 	struct pci_pbm_info *pbm = &p->pbm_A; /* arbitrary */
 	unsigned long base = pbm->controller_regs;
@@ -1056,9 +1056,9 @@ static void __init sabre_register_error_
 	sabre_write(base + SABRE_PCICTRL, tmp);
 }
 
-static void __init sabre_resource_adjust(struct pci_dev *pdev,
-					 struct resource *res,
-					 struct resource *root)
+static void sabre_resource_adjust(struct pci_dev *pdev,
+				  struct resource *res,
+				  struct resource *root)
 {
 	struct pci_pbm_info *pbm = pdev->bus->sysdata;
 	unsigned long base;
@@ -1072,7 +1072,7 @@ static void __init sabre_resource_adjust
 	res->end += base;
 }
 
-static void __init sabre_base_address_update(struct pci_dev *pdev, int resource)
+static void sabre_base_address_update(struct pci_dev *pdev, int resource)
 {
 	struct pcidev_cookie *pcp = pdev->sysdata;
 	struct pci_pbm_info *pbm = pcp->pbm;
@@ -1118,7 +1118,7 @@ static void __init sabre_base_address_up
 		pci_write_config_dword(pdev, where + 4, 0);
 }
 
-static void __init apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus)
+static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus)
 {
 	struct pci_dev *pdev;
 
@@ -1181,7 +1181,7 @@ static struct pcidev_cookie *alloc_bridg
 	return cookie;
 }
 
-static void __init sabre_scan_bus(struct pci_controller_info *p)
+static void sabre_scan_bus(struct pci_controller_info *p)
 {
 	static int once;
 	struct pci_bus *sabre_bus, *pbus;
@@ -1262,9 +1262,9 @@ static void __init sabre_scan_bus(struct
 	sabre_register_error_handlers(p);
 }
 
-static void __init sabre_iommu_init(struct pci_controller_info *p,
-				    int tsbsize, unsigned long dvma_offset,
-				    u32 dma_mask)
+static void sabre_iommu_init(struct pci_controller_info *p,
+			     int tsbsize, unsigned long dvma_offset,
+			     u32 dma_mask)
 {
 	struct pci_iommu *iommu = p->pbm_A.iommu;
 	unsigned long tsbbase, i, order;
@@ -1345,8 +1345,8 @@ static void __init sabre_iommu_init(stru
 	}
 }
 
-static void __init pbm_register_toplevel_resources(struct pci_controller_info *p,
-						   struct pci_pbm_info *pbm)
+static void pbm_register_toplevel_resources(struct pci_controller_info *p,
+					    struct pci_pbm_info *pbm)
 {
 	char *name = pbm->name;
 	unsigned long ibase = p->pbm_A.controller_regs + SABRE_IOSPACE;
@@ -1415,7 +1415,7 @@ static void __init pbm_register_toplevel
 					    &pbm->mem_space);
 }
 
-static void __init sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dma_begin)
+static void sabre_pbm_init(struct pci_controller_info *p, int sabre_node, u32 dma_begin)
 {
 	struct pci_pbm_info *pbm;
 	char namebuf[128];
@@ -1552,7 +1552,7 @@ static void __init sabre_pbm_init(struct
 	}
 }
 
-void __init sabre_init(int pnode, char *model_name)
+void sabre_init(int pnode, char *model_name)
 {
 	struct linux_prom64_registers pr_regs[2];
 	struct pci_controller_info *p;
arch/sparc64/kernel/pci_schizo.c +24 -24

142 lines not on this page · raw message

drivers/pci/Makefile +1 -5
@@ -4,13 +4,9 @@
 
 obj-y		+= access.o bus.o probe.o remove.o pci.o quirks.o \
 			names.o pci-driver.o search.o pci-sysfs.o \
-			rom.o
+			rom.o setup-res.o
 obj-$(CONFIG_PROC_FS) += proc.o
 
-ifndef CONFIG_SPARC64
-obj-y += setup-res.o
-endif
-
 obj-$(CONFIG_HOTPLUG) += hotplug.o
 
 # Build the PCI Hotplug drivers if we were asked to
drivers/pci/quirks.c +7 -0
@@ -245,12 +245,19 @@ static void __devinit quirk_io_region(st
 {
 	region &= ~(size-1);
 	if (region) {
+		struct pci_bus_region bus_region;
 		struct resource *res = dev->resource + nr;
 
 		res->name = pci_name(dev);
 		res->start = region;
 		res->end = region + size - 1;
 		res->flags = IORESOURCE_IO;
+
+		/* Convert from PCI bus to resource space.  */
+		bus_region.start = res->start;
+		bus_region.end = res->end;
+		pcibios_bus_to_resource(dev, res, &bus_region);
+
 		pci_claim_resource(dev, nr);
 	}
 }	
drivers/pci/setup-res.c +1 -4
@@ -95,10 +95,7 @@ pci_claim_resource(struct pci_dev *dev, 
 	char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge";
 	int err;
 
-	if (res->flags & IORESOURCE_IO)
-		root = &ioport_resource;
-	if (res->flags & IORESOURCE_MEM)
-		root = &iomem_resource;
+	root = pcibios_select_root(dev, res);
 
 	err = -EINVAL;
 	if (root != NULL)
include/asm-alpha/pci.h +13 -0
@@ -254,6 +254,19 @@ extern void pcibios_resource_to_bus(stru
 extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 				    struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
 
 static inline int pci_proc_domain(struct pci_bus *bus)
include/asm-arm/pci.h +13 -0
@@ -64,6 +64,19 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
 {
 }
include/asm-generic/pci.h +13 -0
@@ -30,6 +30,19 @@ pcibios_bus_to_resource(struct pci_dev *
 	res->end = region->end;
 }
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 #define pcibios_scan_all_fns(a, b)	0
 
 #ifndef HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
include/asm-ia64/pci.h +13 -0
@@ -156,6 +156,19 @@ extern void pcibios_resource_to_bus(stru
 extern void pcibios_bus_to_resource(struct pci_dev *dev,
 		struct resource *res, struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 #define pcibios_scan_all_fns(a, b)	0
 
 #endif /* _ASM_IA64_PCI_H */
include/asm-parisc/pci.h +13 -0
@@ -257,6 +257,19 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
 {
 }
include/asm-ppc/pci.h +13 -0
@@ -109,6 +109,19 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 extern void pcibios_add_platform_entries(struct pci_dev *dev);
 
 struct file;
include/asm-ppc64/pci.h +13 -0
@@ -138,6 +138,19 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			struct pci_bus_region *region);
 
+static inline struct resource *
+pcibios_select_root(struct pci_dev *pdev, struct resource *res)
+{
+	struct resource *root = NULL;
+
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
+	return root;
+}
+
 extern int
 unmap_bus_range(struct pci_bus *bus);
 
include/asm-sparc64/pci.h +2 -0
@@ -269,6 +269,8 @@ extern void
 pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
 			struct pci_bus_region *region);
 
+extern struct resource *pcibios_select_root(struct pci_dev *, struct resource *);
+
 static inline void pcibios_add_platform_entries(struct pci_dev *dev)
 {
 }
#10 lore raw
In reply to Greg KH
Quoted 2 lines · Greg KH

Hm, how do you revert a git patch?

Something like this?

	#!/bin/sh
	. git-sh-setup-script || die "Not a git archive"
	rev=$(git-rev-parse --verify --revs-only "$@") || exit
	git-diff-tree -R -p $rev | git-apply --index &&
		echo "Revert $rev" | git commit

Just name it "git-revert-script" and it might do what you want to do.

It may not have the nicest error messages: if you try to revert a merge (which won't have a diff), git-apply will say something like

fatal: No changes

which isn't exactly being helpful. And the revert message could be made more interesting (like putting the first line of the description of what we reverted into the message instead of just the revision number).

Linus

#11 lore raw

"git revert" (Re: pci_update_resource() getting called on sparc64)

Comments?

Linus

Quoted 27 lines · Linus Torvalds
Quoted 2 lines · Greg KH

Hm, how do you revert a git patch?

Something like this?

	#!/bin/sh
	. git-sh-setup-script || die "Not a git archive"
	rev=$(git-rev-parse --verify --revs-only "$@") || exit
	git-diff-tree -R -p $rev | git-apply --index &&
		echo "Revert $rev" | git commit

Just name it "git-revert-script" and it might do what you want to do.

It may not have the nicest error messages: if you try to revert a merge (which won't have a diff), git-apply will say something like

fatal: No changes

which isn't exactly being helpful. And the revert message could be made more interesting (like putting the first line of the description of what we reverted into the message instead of just the revision number).

Linus

#12 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 5 lines · Linus Torvalds
Quoted 5 lines

It may not have the nicest error messages: if you try to revert a merge (which won't have a diff), git-apply will say something like

fatal: No changes

Quoted 7 lines
Quoted 3 lines

which isn't exactly being helpful. And the revert message could be made more interesting (like putting the first line of the description of what we reverted into the message instead of just the revision number).

Comments?

Linus

I like the general idea, and if we had a commit pretty format "oneline", then something like this would make it look nicer.

Totally untested. I acquired your habit of coding in my e-mail client ;-).

        #!/bin/sh
        . git-sh-setup-script || die "Not a git archive"

        rev=$(git-rev-parse --verify --revs-only "$@") &&
        commit=$(git-rev-parse --verify --revs-only "$commit^0") || exit
        if git-diff-tree -R -p $commit | git-apply --index &&
           msg=$(git-rev-list --pretty=oneline --max-count=1 $commit)
        then
                {
                        echo "Revert $msg"
                        echo
                        echo "This reverts $commit commit."
                        test "$rev" = "$commit" ||
                        echo "(original 'git revert' arguments: $@)"
                } | git commit
        else
                # Now why did it fail?
                parents=`git-cat-file commit "$commit" 2>/dev/null |
                        sed -ne '/^$/q;/^parent /p' |
                        wc -l`
                case $parents in
                0) die "Cannot revert the root commit nor non commit-ish" ;;
                1) die "The patch does not apply" ;;
                *) die "Cannot revert a merge commit" ;;
                esac
        fi
#13 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 3 lines · Junio C Hamano

Totally untested. I acquired your habit of coding in my e-mail client ;-).

Looks good. Although I also have this advanced testing habit of just reading the email and if it looks sane it tested out ok ;)

But it strikes me that we could use the "-M" flag to git-diff-tree, which makes it a lot more likely that we can revert renames, even if the file has been slightly changed afterwards.

Linus

#14 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 7 lines · Linus Torvalds
Quoted 3 lines · Junio C Hamano

Totally untested. I acquired your habit of coding in my e-mail client ;-).

Looks good. Although I also have this advanced testing habit of just reading the email and if it looks sane it tested out ok ;)

Heh, I immediately spotted two bugs after I sent it out, one mine, another yours.

* dereferencing potential tag to get to the underlying commit was a good idea of mine, poorly executed. It should rev-parse $rev^0, not $commit^0.

* git commit does not take commit message from stdin. I think we should do something like this:

git-commit-script +6 -4
@@ -92,11 +92,13 @@ then
 	rm .editmsg
 	exit 1
 fi
-case "$use_commit" in
-'')
+if test -t 0 && "$use_commit" = ""
+then
 	${VISUAL:-${EDITOR:-vi}} .editmsg
-	;;
-esac
+else
+	echo >&2 "(reading commit message from standard input)"
+	cat >.editmsg
+fi
 grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
 [ -s .cmitmsg ] && 
 	tree=$(git-write-tree) &&
#15 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 3 lines · Junio C Hamano

* git commit does not take commit message from stdin. I think we should do something like this:

Yes. Alteratively (or additionally), we should add a command line option to set the commit message.

CVS uses "-m", but you already took that. I forget what BK used, but I think it was "-Y" (with lowercase "-y" being "take message from file". Or maybe the other way around).

Or if you want to be more CVS-like, use "-F", and accept "-" for stdin?

But I like "test -t 0" regardless. Very few editors are ok with non-tty stdin, although I could imagine some disturbed individual having "ed" as their editor and expecting to be able to pipe commands into it or something.

Linus

#16 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 1 line · Linus Torvalds

Or if you want to be more CVS-like, use "-F", and accept "-" for stdin?

Yes my vote goes:

-m "message"
-c "from this commit, literally."
-C "from this commit, but let me edit the log further." -F "from this file."
-F - <stdin

Quoted 4 lines

But I like "test -t 0" regardless. Very few editors are ok with non-tty stdin, although I could imagine some disturbed individual having "ed" as their editor and expecting to be able to pipe commands into it or something.

I am a disturbed individual who always works in Emacs and run "git commit" in the compilation buffer, setting EDITOR to emacsclient. Admittably the compilation buffer uses pty, so "test -t 0" would succeed, though.

#17 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Hi,

Quoted 11 lines · Junio C Hamano
Quoted 1 line · Linus Torvalds

Or if you want to be more CVS-like, use "-F", and accept "-" for stdin?

Yes my vote goes:

-m "message"
-c "from this commit, literally."
-C "from this commit, but let me edit the log further." -F "from this file."
-F - <stdin

The royal penguin speaketh, and the little blue penguin gets a fish:

[PATCH] git commit usage is more like cvs's

Teach git-commit-script about different ways to provide a commit message, including the famous -m flag from CVS.

---

 git-commit-script |   48 ++++++++++++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 14 deletions(-)

457d879496cb5f742ed6bccc9a435f414b0fd2a7

git-commit-script +34 -14
@@ -6,20 +6,41 @@
 . git-sh-setup-script || die "Not a git archive"
 
 usage () {
-	die 'git commit [--all] [-m existing-commit] [<path>...]'
+	die 'git commit [options] [<path>...]
+Options:
+	--all		automatically do a git-update-cache on all modified
+			files
+	-m <message>	use this message in the commit
+	-c <commit>	use the same message as in the given commit
+	-C <commit>	as -c, but let me edit it
+	-F <file>	take the message from file
+	-F -		take the message from stdin'
 }
 
 files=()
+call_editor=true
+rm -f .editmsg || die "Could not write edit message"
 while case "$#" in 0) break ;; esac
 do
     case "$1" in
+    -m|-c|-C|-F)
+	[ "$#" -ne 1 ] || usage;;
+    esac
+
+    case "$1" in
     -m) shift
-        case "$#" in
-	0) usage ;;
-	*) use_commit=`git-rev-parse --verify "$1"` ||
-	   exit ;;
-	esac
-	;;
+	call_editor=""
+	echo "$1" >> .editmsg;;
+    -c) shift
+	call_editor=""
+	use_commit=`git-rev-parse --verify "$1"` ||
+	exit ;;
+    -C) shift
+	use_commit=`git-rev-parse --verify "$1"` ||
+	exit ;;
+    -F) shift
+	call_editor=""
+	cat "$1" >> .editmsg;;
     --all)
 	files=($(git-diff-files --name-only))\
 	;;
@@ -42,7 +63,7 @@ if [ ! -r "$GIT_DIR/HEAD" ]; then
 		echo "#"
 		git-ls-files | sed 's/^/# New file: /'
 		echo "#"
-	) > .editmsg
+	) >> .editmsg
 	PARENTS=""
 else
 	if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
@@ -83,7 +104,7 @@ else
 		export GIT_AUTHOR_DATE
 		git-cat-file commit "$use_commit" |
 		sed -e '1,/^$/d'
-	fi >.editmsg
+	fi >> .editmsg
 	git-status-script >>.editmsg
 fi
 if [ "$?" != "0" -a ! -f $GIT_DIR/MERGE_HEAD ]
@@ -92,11 +113,10 @@ then
 	rm .editmsg
 	exit 1
 fi
-case "$use_commit" in
-'')
-	${VISUAL:-${EDITOR:-vi}} .editmsg
-	;;
-esac
+
+[ -z "$use_commit" -o "$call_editor" = true ] &&
+${VISUAL:-${EDITOR:-vi}} .editmsg
+
 grep -v '^#' < .editmsg | git-stripspace > .cmitmsg
 [ -s .cmitmsg ] && 
 	tree=$(git-write-tree) &&
#18 lore raw

Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

[PATCH] Adapt git-cherry and git-rebase-script to latest changes of git commit

Teach git-cherry and git-rebase-script to use the "-c" option, since "-m" means something different to git-commit-script now.

---

 git-cherry        |    2 +-
 git-rebase-script |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

34d6840882e65109a17fa02bf2cefec269fd7637

git-cherry +1 -1
@@ -23,7 +23,7 @@ The output is intended to be used as:
     while read commit
     do
         GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p "$commit" &&
-	git-commit-script -m "$commit"
+	git-commit-script -c "$commit"
     done
 '
 
git-rebase-script +1 -1
@@ -37,7 +37,7 @@ do
 	esac
 	S=`cat "$GIT_DIR/HEAD"` &&
         GIT_EXTERNAL_DIFF=git-apply-patch-script git-diff-tree -p $commit &&
-	git-commit-script -m "$commit" || {
+	git-commit-script -c "$commit" || {
 		echo $commit >>$fail
 		git-read-tree --reset -u $S
 	}
#19 lore raw

git-commit-script, was Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

In reply to Junio C Hamano

Hi,

Quoted 4 lines · Junio C Hamano

* git commit does not take commit message from stdin. I think we should do something like this:

[...]

And could we rename the *-m* flag at the same time? Because I often catch myself typing

git commit -m "Some_commit_message"

Ciao,
Dscho

#20 lore raw

Re: git-commit-script, was Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 4 lines · Johannes Schindelin

And could we rename the *-m* flag at the same time? Because I often catch myself typing

git commit -m "Some_commit_message"

Sure, what's the alternative spelling for the current -m, though? Would -c be OK for commit?

#21 lore raw

Re: git-commit-script, was Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 3 lines · Junio C Hamano

Sure, what's the alternative spelling for the current -m, though? Would -c be OK for commit?

How about using long names?

	git commit --reuse-message <sha1>

looks a lot more intuitively understandable to me than something like "-c"

Most of us don't use 300bps terminals any more, so typing a few extra characters is probably ok.

Now, to make things be backwards-compatible, it should be easy enough to notice

"Oh, the argument to '-m' is just a single SHA1, let's see if it's a
commit, and turn '-m' into '--reuse-message' automatically"

If anybody cares. Does cogito already use "-m"?

Linus

#22 lore raw

Re: git-commit-script, was Re: "git revert" (Re: pci_update_resource() getting called on sparc64)

Quoted 2 lines · Linus Torvalds

Most of us don't use 300bps terminals any more, so typing a few extra characters is probably ok.

Again you are right.

#23 lore raw
In reply to Greg KH
Quoted 5 lines · Greg KH
Quoted 3 lines · David S. Miller

And lo' and behold, we find the answer in the PCI probing code. It initializes every PCI device's PCI power state to "unknown":

Quoted 7 lines
Quoted 5 lines
	/* "Unknown power state" */
	dev->current_state = 4;

and thus makes this test ">= D3hot" pass in the pci_set_power_state() code.

Crap, gotta love >= checks on enumerated types...

The "dev->current_state = 4" is what prompted the ">= D3hot" in the first place... :-)

I had seen a patch from earlier this year that changed the probing code to actually get the power state from the device (and added a pci_get_power_state API). I don't know why that never got merged, but since it didn't I had to account for the case of the power state being unknown (i.e dev->current_state == 4).

So, w/ Dave's patch for Sparc64 to use setup-res.c, does the patch stay? Is there anything else I need to do?

Thanks,

John

Signature · 2 lines
John W. Linville
[email protected]
#24 lore raw

From: "John W. Linville" <[email protected]>
Date: Mon, 8 Aug 2005 17:38:43 -0400

Quoted 2 lines

So, w/ Dave's patch for Sparc64 to use setup-res.c, does the patch stay? Is there anything else I need to do?

The plan is to revert your patch for 2.6.13, and then put it back in with my (invasive at this point in the 2.6.13 development cycle) sparc64 patch on top.

#25 lore raw
Quoted 9 lines · David S. Miller

From: "John W. Linville" <[email protected]>
Date: Mon, 8 Aug 2005 17:38:43 -0400

Quoted 2 lines

So, w/ Dave's patch for Sparc64 to use setup-res.c, does the patch stay? Is there anything else I need to do?

The plan is to revert your patch for 2.6.13, and then put it back in with my (invasive at this point in the 2.6.13 development cycle) sparc64 patch on top.

Cool...thanks for clarifying!

Let me know if I can be helpful...

John

Signature · 2 lines
John W. Linville
[email protected]
#26 lore raw
In reply to Greg KH
Quoted 3 lines · Greg KH

{sigh} I only pushed that one as Ralf insisted that he needed it for some of his hardware and that there wasn't any bad side-affects. Ralf, any objections to removing this for 2.6.13?

Hmm... I didn't see any potencial side effects. If it causes trouble, away with it. The currently only affected card that I know of is the 3com 3c556B mini-PCI card.

Ralf