linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org,
	Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Lior Amsalem <alior@marvell.com>,
	linux-pci@vger.kernel.org,
	Gregory Cl??ment <gregory.clement@free-electrons.com>,
	Ezequiel Garcia <ezequiel.garcia@free-electrons.com>,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: Issue with the emulated PCI bridge implementation
Date: Fri, 3 Jan 2014 20:10:24 +0100	[thread overview]
Message-ID: <20140103201024.08ca11fb@skate> (raw)
In-Reply-To: <3246739.aRbALcNl1Y@wuerfel>

Dear Arnd Bergmann,

On Fri, 03 Jan 2014 20:04:57 +0100, Arnd Bergmann wrote:

> > Digging in the LAKML archive, I found a lspci -v output about the
> > e1000e, and it has an I/O space:
> 
> Ok, thanks for the confirmation!
> 
> Do you mind posting your hack here? It may be useful for others as
> well, such as the xgene developers that seem to be doing funny things
> with their I/O space.

The current hack is the following very ugly piece of code... It runs
some command and reads back some registers, and you should see some
well-known values (which can be found in the e1000 datasheet, I don't
remember them right now).

I'm not sure why I do the pci_request_selected_regions_exclusive() call
*after* the actual in/out. Probably a mistake, but as I said, this is
ugly stuff :)

Thomas

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index fbf75fd..739ca10 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -6045,7 +6045,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (aspm_disable_flag)
 		e1000e_disable_aspm(pdev, aspm_disable_flag);
 
-	err = pci_enable_device_mem(pdev);
+	err = pci_enable_device(pdev);
 	if (err)
 		return err;
 
@@ -6073,6 +6073,34 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (err)
 		goto err_pci_reg;
 
+	dev_info(&pdev->dev, "==> e1000e: I/O start 0x%x, len 0x%x\n",
+		 pci_resource_start(pdev, 2),
+		 pci_resource_len(pdev, 2));
+
+
+	{
+		unsigned long ioport_base = pci_resource_start(pdev, 2);
+		dev_info(&pdev->dev, "1. 0x%x 0x%x 0x%x 0x%x\n",
+			 inl(ioport_base),
+			 inl(ioport_base + 4),
+			 inl(ioport_base + 8),
+			 inl(ioport_base + 12));
+		outl(0x38, ioport_base);
+		dev_info(&pdev->dev, "2. 0x%x 0x%x 0x%x 0x%x\n",
+			 inl(ioport_base),
+			 inl(ioport_base + 4),
+			 inl(ioport_base + 8),
+			 inl(ioport_base + 12));
+	}
+
+	err = pci_request_selected_regions_exclusive(pdev,
+						     pci_select_bars(pdev, IORESOURCE_IO),
+						     e1000e_driver_name);
+	if (err) {
+		dev_err(&pdev->dev, "Cannot get I/O region\n");
+		goto err_pci_reg;
+	}
+
 	/* AER (Advanced Error Reporting) hooks */
 	pci_enable_pcie_error_reporting(pdev);
 
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  reply	other threads:[~2014-01-03 19:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-26 15:05 Issue with the emulated PCI bridge implementation Thomas Petazzoni
2013-12-26 15:52 ` Thomas Petazzoni
2014-01-02 21:41   ` Bjorn Helgaas
2014-01-03  0:26   ` Jason Gunthorpe
2014-01-03 12:22     ` Arnd Bergmann
2014-01-03 18:44       ` Jason Gunthorpe
2014-01-03 19:03         ` Arnd Bergmann
2014-01-03 19:01       ` Thomas Petazzoni
2014-01-03 19:04         ` Arnd Bergmann
2014-01-03 19:10           ` Thomas Petazzoni [this message]
2014-01-03 19:13             ` Arnd Bergmann

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=20140103201024.08ca11fb@skate \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=alior@marvell.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=ezequiel.garcia@free-electrons.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.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 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).