linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* legacy libata IDE missing reservation
@ 2007-06-04 23:51 Jeff Garzik
  2007-06-08 11:41 ` [PATCH] libata: claim ctl port for legacy SFF ports Tejun Heo
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Garzik @ 2007-06-04 23:51 UTC (permalink / raw)
  To: linux-ide; +Cc: Alan Cox


FYI:  I noticed this weekend that libata does not reserve the legacy
IDE control block I/O port region, like it does the command block
I/O region.

	Jeff




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-04 23:51 legacy libata IDE missing reservation Jeff Garzik
@ 2007-06-08 11:41 ` Tejun Heo
  2007-06-08 11:51   ` Alan Cox
  2007-06-08 13:55   ` Jeff Garzik
  0 siblings, 2 replies; 11+ messages in thread
From: Tejun Heo @ 2007-06-08 11:41 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, Alan Cox

libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
ports too.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
This has been this way as long as I can remember.  It's almost
pleasant to see that it survived through all the devres/init rework.
I guess it's time for a change.

 drivers/ata/libata-sff.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index e35d134..99a9f98 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -712,6 +712,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev,
 struct ata_legacy_devres {
 	unsigned int	mask;
 	unsigned long	cmd_port[2];
+	unsigned long	ctl_port[2];
 	void __iomem *	cmd_addr[2];
 	void __iomem *	ctl_addr[2];
 	unsigned int	irq[2];
@@ -764,12 +765,16 @@ static int ata_init_legacy_port(struct ata_port *ap,
 		ctl_port = ATA_SECONDARY_CTL;
 	}
 
-	/* request cmd_port */
+	/* request cmd and ctl port */
 	if (request_region(cmd_port, 8, "libata"))
 		legacy_dr->cmd_port[port_no] = cmd_port;
-	else {
+
+	if (request_region(ctl_port, 8, "libata"))
+		legacy_dr->ctl_port[port_no] = ctl_port;
+
+	if (!legacy_dr->cmd_port[port_no] || !legacy_dr->ctl_port[port_no]) {
 		dev_printk(KERN_WARNING, host->dev,
-			   "0x%0lX IDE port busy\n", cmd_port);
+			   "0x%0lX/0x%0lX IDE port busy\n", cmd_port, ctl_port);
 		return -EBUSY;
 	}
 

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 11:41 ` [PATCH] libata: claim ctl port for legacy SFF ports Tejun Heo
@ 2007-06-08 11:51   ` Alan Cox
  2007-06-08 12:01     ` Tejun Heo
  2007-06-08 13:55   ` Jeff Garzik
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Cox @ 2007-06-08 11:51 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jeff Garzik, linux-ide

On Fri, 8 Jun 2007 20:41:19 +0900
Tejun Heo <htejun@gmail.com> wrote:

> libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
> ports too.

Just use pci resource functions. The quirk handlers do the rest for you
already.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 11:51   ` Alan Cox
@ 2007-06-08 12:01     ` Tejun Heo
  2007-06-08 12:30       ` [PATCH] libata: claim legacy SFF ctl ioport in legacy_dr Tejun Heo
  2007-06-08 12:50       ` [PATCH] libata: claim ctl port for legacy SFF ports Alan Cox
  0 siblings, 2 replies; 11+ messages in thread
From: Tejun Heo @ 2007-06-08 12:01 UTC (permalink / raw)
  To: Alan Cox; +Cc: Jeff Garzik, linux-ide

Alan Cox wrote:
> On Fri, 8 Jun 2007 20:41:19 +0900
> Tejun Heo <htejun@gmail.com> wrote:
> 
>> libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
>> ports too.
> 
> Just use pci resource functions. The quirk handlers do the rest for you
> already.

It was that way to allow legacy SFF code to be used in non-PCI
environment.  Is it gonna?

BTW, the original patch is broken and I tested the wrong kernel.
Brewing fixed one now.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] libata: claim legacy SFF ctl ioport in legacy_dr
  2007-06-08 12:01     ` Tejun Heo
@ 2007-06-08 12:30       ` Tejun Heo
  2007-06-08 12:50       ` [PATCH] libata: claim ctl port for legacy SFF ports Alan Cox
  1 sibling, 0 replies; 11+ messages in thread
From: Tejun Heo @ 2007-06-08 12:30 UTC (permalink / raw)
  To: Alan Cox; +Cc: Jeff Garzik, linux-ide

For legacy SFF port, cmd ioport is claimed in legacy_dr while ctl
ioport is claimed using resource-managed pci_request_region().  Move
ctl port claiming into legacy_dr for consistency.  This also makes
legacy SFF code easier to use for non-PCI device.

Signed-off-by: Tejun Heo <htejun@gmail.com>
---
ctl ports *were* claimed - this is why my wrong kernel test looked
fine.  It was just done in a different place.

Thanks.

 drivers/ata/libata-sff.c |   32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index e35d134..36d5f38 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -712,6 +712,7 @@ int ata_pci_prepare_native_host(struct pci_dev *pdev,
 struct ata_legacy_devres {
 	unsigned int	mask;
 	unsigned long	cmd_port[2];
+	unsigned long	ctl_port[2];
 	void __iomem *	cmd_addr[2];
 	void __iomem *	ctl_addr[2];
 	unsigned int	irq[2];
@@ -746,6 +747,8 @@ static void ata_legacy_release(struct device *gdev, void *res)
 			ioport_unmap(this->ctl_addr[i]);
 		if (this->cmd_port[i])
 			release_region(this->cmd_port[i], 8);
+		if (this->ctl_port[i])
+			release_region(this->ctl_port[i], 1);
 	}
 }
 
@@ -764,7 +767,7 @@ static int ata_init_legacy_port(struct ata_port *ap,
 		ctl_port = ATA_SECONDARY_CTL;
 	}
 
-	/* request cmd_port */
+	/* request and map cmd/ctl ports */
 	if (request_region(cmd_port, 8, "libata"))
 		legacy_dr->cmd_port[port_no] = cmd_port;
 	else {
@@ -773,15 +776,30 @@ static int ata_init_legacy_port(struct ata_port *ap,
 		return -EBUSY;
 	}
 
-	/* iomap cmd and ctl ports */
 	legacy_dr->cmd_addr[port_no] = ioport_map(cmd_port, 8);
-	legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1);
-	if (!legacy_dr->cmd_addr[port_no] || !legacy_dr->ctl_addr[port_no]) {
+	if (!legacy_dr->cmd_addr[port_no]) {
 		dev_printk(KERN_WARNING, host->dev,
-			   "failed to map cmd/ctl ports\n");
+			   "failed to map cmd port\n");
 		return -ENOMEM;
 	}
 
+	if (ctl_port) {
+		if (request_region(ctl_port, 1, "libata"))
+			legacy_dr->ctl_port[port_no] = ctl_port;
+		else {
+			dev_printk(KERN_WARNING, host->dev,
+				   "0x%0lX IDE port busy\n", ctl_port);
+			return -EBUSY;
+		}
+
+		legacy_dr->ctl_addr[port_no] = ioport_map(ctl_port, 1);
+		if (!legacy_dr->ctl_addr[port_no]) {
+			dev_printk(KERN_WARNING, host->dev,
+				   "failed to map ctl port\n");
+			return -ENOMEM;
+		}
+	}
+
 	/* init IO addresses */
 	ap->ioaddr.cmd_addr = legacy_dr->cmd_addr[port_no];
 	ap->ioaddr.altstatus_addr = legacy_dr->ctl_addr[port_no];
@@ -1029,10 +1047,6 @@ int ata_pci_init_one(struct pci_dev *pdev,
 			pcim_pin_device(pdev);
 		if (rc)
 			goto err_out;
-
-		/* request respective PCI regions, may fail */
-		rc = pci_request_region(pdev, 1, DRV_NAME);
-		rc = pci_request_region(pdev, 3, DRV_NAME);
 	}
 
 	/* init BMDMA, may fail */

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 12:01     ` Tejun Heo
  2007-06-08 12:30       ` [PATCH] libata: claim legacy SFF ctl ioport in legacy_dr Tejun Heo
@ 2007-06-08 12:50       ` Alan Cox
  1 sibling, 0 replies; 11+ messages in thread
From: Alan Cox @ 2007-06-08 12:50 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Jeff Garzik, linux-ide

> It was that way to allow legacy SFF code to be used in non-PCI
> environment.  Is it gonna?

Probably best to keep that in the affected driver - we have two drivers
at the moment which know bits about ISA legacy and I'm currently folding
them into one. I don't think they can usefully use the libata-sff PCI/IDE
helper code - not all of it anyway.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 11:41 ` [PATCH] libata: claim ctl port for legacy SFF ports Tejun Heo
  2007-06-08 11:51   ` Alan Cox
@ 2007-06-08 13:55   ` Jeff Garzik
  2007-06-08 14:12     ` Tejun Heo
  1 sibling, 1 reply; 11+ messages in thread
From: Jeff Garzik @ 2007-06-08 13:55 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Alan Cox

On Fri, Jun 08, 2007 at 08:41:19PM +0900, Tejun Heo wrote:
> libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
> ports too.
> 
> Signed-off-by: Tejun Heo <htejun@gmail.com>
> ---
> This has been this way as long as I can remember.  It's almost
> pleasant to see that it survived through all the devres/init rework.
> I guess it's time for a change.

pci_request_regions() should claims everything, if Alan did his job :)

All this goes through ata_pci_init_one(), which guarantees it's PCI IDE.

	Jeff



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 13:55   ` Jeff Garzik
@ 2007-06-08 14:12     ` Tejun Heo
  2007-06-08 14:24       ` Jeff Garzik
  0 siblings, 1 reply; 11+ messages in thread
From: Tejun Heo @ 2007-06-08 14:12 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-ide, Alan Cox

Jeff Garzik wrote:
> On Fri, Jun 08, 2007 at 08:41:19PM +0900, Tejun Heo wrote:
>> libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
>> ports too.
>>
>> Signed-off-by: Tejun Heo <htejun@gmail.com>
>> ---
>> This has been this way as long as I can remember.  It's almost
>> pleasant to see that it survived through all the devres/init rework.
>> I guess it's time for a change.
> 
> pci_request_regions() should claims everything, if Alan did his job :)
> 
> All this goes through ata_pci_init_one(), which guarantees it's PCI IDE.

Allowing legacy to be used on non-PCI systems was your idea!  Alright,
then we can drop a lot of junk from legacy SFF code.  Will prep another
patch.  Please ignore two patches in this thread.

-- 
tejun

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 14:12     ` Tejun Heo
@ 2007-06-08 14:24       ` Jeff Garzik
  2007-06-08 15:33         ` Alan Cox
  0 siblings, 1 reply; 11+ messages in thread
From: Jeff Garzik @ 2007-06-08 14:24 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Alan Cox

On Fri, Jun 08, 2007 at 11:12:01PM +0900, Tejun Heo wrote:
> Jeff Garzik wrote:
> > On Fri, Jun 08, 2007 at 08:41:19PM +0900, Tejun Heo wrote:
> >> libata used to claim only cmd ports for legacy SFF ports.  Claim ctl
> >> ports too.
> >>
> >> Signed-off-by: Tejun Heo <htejun@gmail.com>
> >> ---
> >> This has been this way as long as I can remember.  It's almost
> >> pleasant to see that it survived through all the devres/init rework.
> >> I guess it's time for a change.
> > 
> > pci_request_regions() should claims everything, if Alan did his job :)
> > 
> > All this goes through ata_pci_init_one(), which guarantees it's PCI IDE.
> 
> Allowing legacy to be used on non-PCI systems was your idea!  Alright,
> then we can drop a lot of junk from legacy SFF code.  Will prep another
> patch.  Please ignore two patches in this thread.

Alan seems to be ignoring that idea, so it turned out to be useless...  :/

	Jeff




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 14:24       ` Jeff Garzik
@ 2007-06-08 15:33         ` Alan Cox
  2007-06-08 15:36           ` Jeff Garzik
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Cox @ 2007-06-08 15:33 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: Tejun Heo, linux-ide

> > Allowing legacy to be used on non-PCI systems was your idea!  Alright,
> > then we can drop a lot of junk from legacy SFF code.  Will prep another
> > patch.  Please ignore two patches in this thread.
> 
> Alan seems to be ignoring that idea, so it turned out to be useless...  :/

For the init code stuff it turns out to be useless, for the rest of the
general chip kicking it turns out to be very useful indeed.

Alan

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] libata: claim ctl port for legacy SFF ports
  2007-06-08 15:33         ` Alan Cox
@ 2007-06-08 15:36           ` Jeff Garzik
  0 siblings, 0 replies; 11+ messages in thread
From: Jeff Garzik @ 2007-06-08 15:36 UTC (permalink / raw)
  To: Alan Cox; +Cc: Tejun Heo, linux-ide

On Fri, Jun 08, 2007 at 04:33:37PM +0100, Alan Cox wrote:
> > > Allowing legacy to be used on non-PCI systems was your idea!  Alright,
> > > then we can drop a lot of junk from legacy SFF code.  Will prep another
> > > patch.  Please ignore two patches in this thread.
> > 
> > Alan seems to be ignoring that idea, so it turned out to be useless...  :/
> 
> For the init code stuff it turns out to be useless, for the rest of the
> general chip kicking it turns out to be very useful indeed.

Unless I've completely lost the thread, it's the only init code that
is being discussed and patched...

	Jeff




^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-06-08 15:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-04 23:51 legacy libata IDE missing reservation Jeff Garzik
2007-06-08 11:41 ` [PATCH] libata: claim ctl port for legacy SFF ports Tejun Heo
2007-06-08 11:51   ` Alan Cox
2007-06-08 12:01     ` Tejun Heo
2007-06-08 12:30       ` [PATCH] libata: claim legacy SFF ctl ioport in legacy_dr Tejun Heo
2007-06-08 12:50       ` [PATCH] libata: claim ctl port for legacy SFF ports Alan Cox
2007-06-08 13:55   ` Jeff Garzik
2007-06-08 14:12     ` Tejun Heo
2007-06-08 14:24       ` Jeff Garzik
2007-06-08 15:33         ` Alan Cox
2007-06-08 15:36           ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).