Skip to contentSkip to conversation

ahci: Add support for non-PCI devices

PATCH Applied Anton Vorontsov 6 participants 24 messages Mar 3, 2010

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ahci: Add support for non-PCI devices

On Wed, Mar 03, 2010 at 08:40:30AM -0500, Jeff Garzik wrote:
[...]

Quoted 3 lines

Well, the general idea is to have a kernel module libahci.ko, upon which ahci.ko, mv-ahci.ko, acard-ahci.ko and platform-ahci.ko depends.

Yep, that's exactly the purpose of my patches.

Quoted 3 lines

That would imply a bunch of exports, when the library code is moved from ahci.c to libahci.c, because libahci should be a separate kernel module.

Yep. Though, I don't bother with exporting symbols that neither ahci (PCI driver) nor platform driver need. Later we might export some more for mv/acard-ahci...

Quoted 5 lines

I'm not overly picky about file naming. However, in existing installations, people, scripts, knowledgebase articles and configuration files expect "ahci" to be the driver for PCI AHCI devices. We don't want to break that if we can avoid it. Simply using a different name avoids any breakage related to name changes.

OK. So in these series:

- I kept PCI driver in ahci.c (built as ahci.ko);
- Moved generic code into libahci.{c,h} (built as libahci.ko)

Also in these series:

- Rebased on top of linux-next (the patches also apply onto the current Linus' git tree, fwiw).
- Dropped sparse fixes patch, as the issue appears to be already fixed in linux-next.
- Addressed Sergei's comments on ahci_platform driver.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#1 lore raw

PATCH 1/11 ahci: Get rid of host->iomap usage

Currently the driver uses host->iomap to store all the iomapped BARs of a PCI device (while AHCI devices actually use just a single memory window).

We're going to teach AHCI to work with non-PCI buses, so there are two options to make this work:

1. "fake" host->iomap array for non-PCI devices, and place the needed address at iomap[AHCI_PCI_BAR];
2. Get rid of host->iomap usage, instead introduce a private mmio field.

This patch implements the second option.

---
 drivers/ata/ahci.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)
drivers/ata/ahci.c +20 -14
index 6bd930b..fcf00ca 100644
@@ -294,6 +294,7 @@ struct ahci_em_priv {
 };
 
 struct ahci_host_priv {
+	void __iomem *		mmio;		/* bus-independant mem map */
 	unsigned int		flags;		/* AHCI_HFLAG_* */
 	u32			cap;		/* cap to use */
 	u32			cap2;		/* cap2 to use */
@@ -744,7 +745,8 @@ static inline int ahci_nr_ports(u32 cap)
 static inline void __iomem *__ahci_port_base(struct ata_host *host,
 					     unsigned int port_no)
 {
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	struct ahci_host_priv *hpriv = host->private_data;
+	void __iomem *mmio = hpriv->mmio;
 
 	return mmio + 0x100 + (port_no * 0x80);
 }
@@ -804,7 +806,8 @@ static ssize_t ahci_show_host_version(struct device *dev,
 {
 	struct Scsi_Host *shost = class_to_shost(dev);
 	struct ata_port *ap = ata_shost_to_port(shost);
-	void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+	void __iomem *mmio = hpriv->mmio;
 
 	return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION));
 }
@@ -837,7 +840,7 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
 static void ahci_save_initial_config(struct pci_dev *pdev,
 				     struct ahci_host_priv *hpriv)
 {
-	void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	u32 cap, cap2, vers, port_map;
 	int i;
 	int mv;
@@ -966,7 +969,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 static void ahci_restore_initial_config(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 
 	writel(hpriv->saved_cap, mmio + HOST_CAP);
 	if (hpriv->saved_cap2)
@@ -1325,7 +1328,7 @@ static int ahci_reset_controller(struct ata_host *host)
 {
 	struct pci_dev *pdev = to_pci_dev(host->dev);
 	struct ahci_host_priv *hpriv = host->private_data;
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	u32 tmp;
 
 	/* we must be in AHCI mode, before using anything
@@ -1456,7 +1459,8 @@ static void ahci_init_sw_activity(struct ata_link *link)
 
 static int ahci_reset_em(struct ata_host *host)
 {
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	struct ahci_host_priv *hpriv = host->private_data;
+	void __iomem *mmio = hpriv->mmio;
 	u32 em_ctl;
 
 	em_ctl = readl(mmio + HOST_EM_CTL);
@@ -1472,7 +1476,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
 {
 	struct ahci_host_priv *hpriv = ap->host->private_data;
 	struct ahci_port_priv *pp = ap->private_data;
-	void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	u32 em_ctl;
 	u32 message[] = {0, 0};
 	unsigned long flags;
@@ -1640,7 +1644,7 @@ static void ahci_init_controller(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
 	struct pci_dev *pdev = to_pci_dev(host->dev);
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	int i;
 	void __iomem *port_mmio;
 	u32 tmp;
@@ -2348,7 +2352,7 @@ static irqreturn_t ahci_interrupt(int irq, void *dev_instance)
 	VPRINTK("ENTER\n");
 
 	hpriv = host->private_data;
-	mmio = host->iomap[AHCI_PCI_BAR];
+	mmio = hpriv->mmio;
 
 	/* sigh.  0xffffffff is a valid return from h/w */
 	irq_stat = readl(mmio + HOST_IRQ_STAT);
@@ -2449,7 +2453,8 @@ static void ahci_freeze(struct ata_port *ap)
 
 static void ahci_thaw(struct ata_port *ap)
 {
-	void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
+	struct ahci_host_priv *hpriv = ap->host->private_data;
+	void __iomem *mmio = hpriv->mmio;
 	void __iomem *port_mmio = ahci_port_base(ap);
 	u32 tmp;
 	struct ahci_port_priv *pp = ap->private_data;
@@ -2614,7 +2619,7 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
 	struct ata_host *host = dev_get_drvdata(&pdev->dev);
 	struct ahci_host_priv *hpriv = host->private_data;
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	u32 ctl;
 
 	if (mesg.event & PM_EVENT_SUSPEND &&
@@ -2783,7 +2788,7 @@ static void ahci_print_info(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
 	struct pci_dev *pdev = to_pci_dev(host->dev);
-	void __iomem *mmio = host->iomap[AHCI_PCI_BAR];
+	void __iomem *mmio = hpriv->mmio;
 	u32 vers, cap, cap2, impl, speed;
 	const char *speed_s;
 	u16 cc;
@@ -3269,6 +3274,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if ((hpriv->flags & AHCI_HFLAG_NO_MSI) || pci_enable_msi(pdev))
 		pci_intx(pdev, 1);
 
+	hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
+
 	/* save initial config */
 	ahci_save_initial_config(pdev, hpriv);
 
@@ -3289,7 +3296,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
 		u8 messages;
-		void __iomem *mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
+		void __iomem *mmio = hpriv->mmio;
 		u32 em_loc = readl(mmio + HOST_EM_LOC);
 		u32 em_ctl = readl(mmio + HOST_EM_CTL);
 
@@ -3333,7 +3340,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
 	if (!host)
 		return -ENOMEM;
-	host->iomap = pcim_iomap_table(pdev);
 	host->private_data = hpriv;
 
 	if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
Signature · 1 line
1.7.0
#2 lore raw

Re: [PATCH 01/11] ahci: Get rid of host->iomap usage

Quoted 12 lines · Anton Vorontsov

Currently the driver uses host->iomap to store all the iomapped BARs of a PCI device (while AHCI devices actually use just a single memory window).

We're going to teach AHCI to work with non-PCI buses, so there are two options to make this work:

1. "fake" host->iomap array for non-PCI devices, and place the needed

    address at iomap[AHCI_PCI_BAR];

2. Get rid of host->iomap usage, instead introduce a private mmio field.

Quoted 6 lines

This patch implements the second option.

---
  drivers/ata/ahci.c |   34 ++++++++++++++++++++--------------
  1 files changed, 20 insertions(+), 14 deletions(-)

Does platform code not contain any devres support?

At a minimum, you should be using devm_ioremap(), yes?

Jeff

#3 lore raw

Re: [PATCH 01/11] ahci: Get rid of host->iomap usage

Quoted 15 lines · Jeff Garzik
Quoted 14 lines · Anton Vorontsov

Currently the driver uses host->iomap to store all the iomapped BARs of a PCI device (while AHCI devices actually use just a single memory window).

We're going to teach AHCI to work with non-PCI buses, so there are two options to make this work:

1. "fake" host->iomap array for non-PCI devices, and place the needed address at iomap[AHCI_PCI_BAR];
2. Get rid of host->iomap usage, instead introduce a private mmio field.

This patch implements the second option.

Quoted 8 lines
Quoted 4 lines

---
drivers/ata/ahci.c | 34 ++++++++++++++++++++--------------

1 files changed, 20 insertions(+), 14 deletions(-)

Does platform code not contain any devres support?

At a minimum, you should be using devm_ioremap(), yes?

Nevermind, I see this now in the platform driver.

#4 lore raw

PATCH 2/11 ahci: Factor out PCI specifics from ahci_save_initial_config()

In reply to Anton Vorontsov

Make ahci_save_initial_config() a bit more generic by introducing force_port_map and mask_port_map arguments.

Move PCI stuff into ahci_pci_save_initial_config().

---
 drivers/ata/ahci.c |   66 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 42 insertions(+), 24 deletions(-)
drivers/ata/ahci.c +42 -24
index fcf00ca..98c9c6a 100644
@@ -826,6 +826,8 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
  *	ahci_save_initial_config - Save and fixup initial config values
  *	@pdev: target PCI device
  *	@hpriv: host private area to store config values
+ *	@force_port_map: force port map to a specified value
+ *	@mask_port_map: mask out particular bits from port map
  *
  *	Some registers containing configuration info might be setup by
  *	BIOS and might be cleared on reset.  This function saves the
@@ -838,12 +840,13 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
  *	None.
  */
 static void ahci_save_initial_config(struct pci_dev *pdev,
-				     struct ahci_host_priv *hpriv)
+				     struct ahci_host_priv *hpriv,
+				     unsigned int force_port_map,
+				     unsigned int mask_port_map)
 {
 	void __iomem *mmio = hpriv->mmio;
 	u32 cap, cap2, vers, port_map;
 	int i;
-	int mv;
 
 	/* make sure AHCI mode is enabled before accessing CAP */
 	ahci_enable_ahci(mmio);
@@ -893,32 +896,19 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 		cap &= ~HOST_CAP_SNTF;
 	}
 
-	if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361 &&
-	    port_map != 1) {
+	if (force_port_map && port_map != force_port_map) {
 		dev_printk(KERN_INFO, &pdev->dev,
-			   "JMB361 has only one port, port_map 0x%x -> 0x%x\n",
-			   port_map, 1);
-		port_map = 1;
+			   "forcing port_map 0x%x -> 0x%x\n",
+			   port_map, force_port_map);
+		port_map = force_port_map;
 	}
 
-	/*
-	 * Temporary Marvell 6145 hack: PATA port presence
-	 * is asserted through the standard AHCI port
-	 * presence register, as bit 4 (counting from 0)
-	 */
-	if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
-		if (pdev->device == 0x6121)
-			mv = 0x3;
-		else
-			mv = 0xf;
+	if (mask_port_map) {
 		dev_printk(KERN_ERR, &pdev->dev,
-			   "MV_AHCI HACK: port_map %x -> %x\n",
+			   "masking port_map 0x%x -> 0x%x\n",
 			   port_map,
-			   port_map & mv);
-		dev_printk(KERN_ERR, &pdev->dev,
-			  "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
-
-		port_map &= mv;
+			   port_map & mask_port_map);
+		port_map &= mask_port_map;
 	}
 
 	/* cross check port_map and cap.n_ports */
@@ -957,6 +947,34 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 	hpriv->port_map = port_map;
 }
 
+static void ahci_pci_save_initial_config(struct pci_dev *pdev,
+					 struct ahci_host_priv *hpriv)
+{
+	unsigned int force_port_map = 0;
+	unsigned int mask_port_map = 0;
+
+	if (pdev->vendor == PCI_VENDOR_ID_JMICRON && pdev->device == 0x2361) {
+		dev_info(&pdev->dev, "JMB361 has only one port\n");
+		force_port_map = 1;
+	}
+
+	/*
+	 * Temporary Marvell 6145 hack: PATA port presence
+	 * is asserted through the standard AHCI port
+	 * presence register, as bit 4 (counting from 0)
+	 */
+	if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
+		if (pdev->device == 0x6121)
+			mask_port_map = 0x3;
+		else
+			mask_port_map = 0xf;
+		dev_info(&pdev->dev,
+			  "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
+	}
+
+	ahci_save_initial_config(pdev, hpriv, force_port_map, mask_port_map);
+}
+
 /**
  *	ahci_restore_initial_config - Restore initial config
  *	@host: target ATA host
@@ -3277,7 +3295,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR];
 
 	/* save initial config */
-	ahci_save_initial_config(pdev, hpriv);
+	ahci_pci_save_initial_config(pdev, hpriv);
 
 	/* prepare host */
 	if (hpriv->cap & HOST_CAP_NCQ) {
Signature · 1 line
1.7.0
#5 lore raw

PATCH 3/11 ahci: Get rid of pci_dev argument in ahci_save_initial_config()

In reply to Anton Vorontsov

To make the function generic we have to get rid of "struct pci_dev *", so let's pass just a "struct devce *".

---
 drivers/ata/ahci.c |   27 +++++++++++++--------------
 1 files changed, 13 insertions(+), 14 deletions(-)
drivers/ata/ahci.c +13 -14
index 98c9c6a..9d9af3c 100644
@@ -824,7 +824,7 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
 
 /**
  *	ahci_save_initial_config - Save and fixup initial config values
- *	@pdev: target PCI device
+ *	@dev: target AHCI device
  *	@hpriv: host private area to store config values
  *	@force_port_map: force port map to a specified value
  *	@mask_port_map: mask out particular bits from port map
@@ -839,7 +839,7 @@ static ssize_t ahci_show_port_cmd(struct device *dev,
  *	LOCKING:
  *	None.
  */
-static void ahci_save_initial_config(struct pci_dev *pdev,
+static void ahci_save_initial_config(struct device *dev,
 				     struct ahci_host_priv *hpriv,
 				     unsigned int force_port_map,
 				     unsigned int mask_port_map)
@@ -867,45 +867,43 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 
 	/* some chips have errata preventing 64bit use */
 	if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) {
-		dev_printk(KERN_INFO, &pdev->dev,
+		dev_printk(KERN_INFO, dev,
 			   "controller can't do 64bit DMA, forcing 32bit\n");
 		cap &= ~HOST_CAP_64;
 	}
 
 	if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) {
-		dev_printk(KERN_INFO, &pdev->dev,
+		dev_printk(KERN_INFO, dev,
 			   "controller can't do NCQ, turning off CAP_NCQ\n");
 		cap &= ~HOST_CAP_NCQ;
 	}
 
 	if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) {
-		dev_printk(KERN_INFO, &pdev->dev,
+		dev_printk(KERN_INFO, dev,
 			   "controller can do NCQ, turning on CAP_NCQ\n");
 		cap |= HOST_CAP_NCQ;
 	}
 
 	if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) {
-		dev_printk(KERN_INFO, &pdev->dev,
+		dev_printk(KERN_INFO, dev,
 			   "controller can't do PMP, turning off CAP_PMP\n");
 		cap &= ~HOST_CAP_PMP;
 	}
 
 	if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) {
-		dev_printk(KERN_INFO, &pdev->dev,
+		dev_printk(KERN_INFO, dev,
 			   "controller can't do SNTF, turning off CAP_SNTF\n");
 		cap &= ~HOST_CAP_SNTF;
 	}
 
 	if (force_port_map && port_map != force_port_map) {
-		dev_printk(KERN_INFO, &pdev->dev,
-			   "forcing port_map 0x%x -> 0x%x\n",
+		dev_printk(KERN_INFO, dev, "forcing port_map 0x%x -> 0x%x\n",
 			   port_map, force_port_map);
 		port_map = force_port_map;
 	}
 
 	if (mask_port_map) {
-		dev_printk(KERN_ERR, &pdev->dev,
-			   "masking port_map 0x%x -> 0x%x\n",
+		dev_printk(KERN_ERR, dev, "masking port_map 0x%x -> 0x%x\n",
 			   port_map,
 			   port_map & mask_port_map);
 		port_map &= mask_port_map;
@@ -923,7 +921,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 		 * port_map and let it be generated from n_ports.
 		 */
 		if (map_ports > ahci_nr_ports(cap)) {
-			dev_printk(KERN_WARNING, &pdev->dev,
+			dev_printk(KERN_WARNING, dev,
 				   "implemented port map (0x%x) contains more "
 				   "ports than nr_ports (%u), using nr_ports\n",
 				   port_map, ahci_nr_ports(cap));
@@ -934,7 +932,7 @@ static void ahci_save_initial_config(struct pci_dev *pdev,
 	/* fabricate port_map from cap.nr_ports */
 	if (!port_map) {
 		port_map = (1 << ahci_nr_ports(cap)) - 1;
-		dev_printk(KERN_WARNING, &pdev->dev,
+		dev_printk(KERN_WARNING, dev,
 			   "forcing PORTS_IMPL to 0x%x\n", port_map);
 
 		/* write the fixed up value to the PI register */
@@ -972,7 +970,8 @@ static void ahci_pci_save_initial_config(struct pci_dev *pdev,
 			  "Disabling your PATA port. Use the boot option 'ahci.marvell_enable=0' to avoid this.\n");
 	}
 
-	ahci_save_initial_config(pdev, hpriv, force_port_map, mask_port_map);
+	ahci_save_initial_config(&pdev->dev, hpriv, force_port_map,
+				 mask_port_map);
 }
 
 /**
Signature · 1 line
1.7.0
#6 lore raw

PATCH 4/11 ahci: Factor out PCI specifics from ahci_reset_controller()

In reply to Anton Vorontsov

Move PCI stuff into ahci_pci_reset_controller().

---
 drivers/ata/ahci.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +12 -3
index 9d9af3c..830a6fe 100644
@@ -1343,7 +1343,6 @@ static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
 
 static int ahci_reset_controller(struct ata_host *host)
 {
-	struct pci_dev *pdev = to_pci_dev(host->dev);
 	struct ahci_host_priv *hpriv = host->private_data;
 	void __iomem *mmio = hpriv->mmio;
 	u32 tmp;
@@ -1387,7 +1386,17 @@ static int ahci_reset_controller(struct ata_host *host)
 		dev_printk(KERN_INFO, host->dev,
 			   "skipping global host reset\n");
 
+	return 0;
+}
+
+static int ahci_pci_reset_controller(struct ata_host *host)
+{
+	struct pci_dev *pdev = to_pci_dev(host->dev);
+
+	ahci_reset_controller(host);
+
 	if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
+		struct ahci_host_priv *hpriv = host->private_data;
 		u16 tmp16;
 
 		/* configure PCS */
@@ -2670,7 +2679,7 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
 		return rc;
 
 	if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
-		rc = ahci_reset_controller(host);
+		rc = ahci_pci_reset_controller(host);
 		if (rc)
 			return rc;
 
@@ -3398,7 +3407,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return rc;
 
-	rc = ahci_reset_controller(host);
+	rc = ahci_pci_reset_controller(host);
 	if (rc)
 		return rc;
 
Signature · 1 line
1.7.0
#7 lore raw

PATCH 5/11 ahci: Get rid of pci_dev argument in ahci_port_init()

In reply to Anton Vorontsov

To make the function bus-independand we have to get rid of "struct pci_dev *", so let's pass just "struct devce *".

---
 drivers/ata/ahci.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
drivers/ata/ahci.c +3 -4
index 830a6fe..b646364 100644
@@ -1638,7 +1638,7 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
 	return sprintf(buf, "%d\n", emp->blink_policy);
 }
 
-static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap,
+static void ahci_port_init(struct device *dev, struct ata_port *ap,
 			   int port_no, void __iomem *mmio,
 			   void __iomem *port_mmio)
 {
@@ -1649,8 +1649,7 @@ static void ahci_port_init(struct pci_dev *pdev, struct ata_port *ap,
 	/* make sure port is not active */
 	rc = ahci_deinit_port(ap, &emsg);
 	if (rc)
-		dev_printk(KERN_WARNING, &pdev->dev,
-			   "%s (%d)\n", emsg, rc);
+		dev_warn(dev, "%s (%d)\n", emsg, rc);
 
 	/* clear SError */
 	tmp = readl(port_mmio + PORT_SCR_ERR);
@@ -1699,7 +1698,7 @@ static void ahci_init_controller(struct ata_host *host)
 		if (ata_port_is_dummy(ap))
 			continue;
 
-		ahci_port_init(pdev, ap, i, mmio, port_mmio);
+		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
 	}
 
 	tmp = readl(mmio + HOST_CTL);
Signature · 1 line
1.7.0
#8 lore raw

PATCH 6/11 ahci: Factor out PCI specifics from ahci_init_controller()

In reply to Anton Vorontsov

Move PCI stuff into ahci_pci_init_controller().

---
 drivers/ata/ahci.c |   45 +++++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 18 deletions(-)
drivers/ata/ahci.c +27 -18
index b646364..439ff90 100644
@@ -1668,11 +1668,34 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 static void ahci_init_controller(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
-	struct pci_dev *pdev = to_pci_dev(host->dev);
 	void __iomem *mmio = hpriv->mmio;
 	int i;
 	void __iomem *port_mmio;
 	u32 tmp;
+
+	for (i = 0; i < host->n_ports; i++) {
+		struct ata_port *ap = host->ports[i];
+
+		port_mmio = ahci_port_base(ap);
+		if (ata_port_is_dummy(ap))
+			continue;
+
+		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
+	}
+
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+	writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+}
+
+static void ahci_pci_init_controller(struct ata_host *host)
+{
+	struct ahci_host_priv *hpriv = host->private_data;
+	struct pci_dev *pdev = to_pci_dev(host->dev);
+	void __iomem *port_mmio;
+	u32 tmp;
 	int mv;
 
 	if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
@@ -1691,21 +1714,7 @@ static void ahci_init_controller(struct ata_host *host)
 			writel(tmp, port_mmio + PORT_IRQ_STAT);
 	}
 
-	for (i = 0; i < host->n_ports; i++) {
-		struct ata_port *ap = host->ports[i];
-
-		port_mmio = ahci_port_base(ap);
-		if (ata_port_is_dummy(ap))
-			continue;
-
-		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
-	}
-
-	tmp = readl(mmio + HOST_CTL);
-	VPRINTK("HOST_CTL 0x%x\n", tmp);
-	writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
-	tmp = readl(mmio + HOST_CTL);
-	VPRINTK("HOST_CTL 0x%x\n", tmp);
+	ahci_init_controller(host);
 }
 
 static void ahci_dev_config(struct ata_device *dev)
@@ -2682,7 +2691,7 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
 		if (rc)
 			return rc;
 
-		ahci_init_controller(host);
+		ahci_pci_init_controller(host);
 	}
 
 	ata_host_resume(host);
@@ -3410,7 +3419,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return rc;
 
-	ahci_init_controller(host);
+	ahci_pci_init_controller(host);
 	ahci_print_info(host);
 
 	pci_set_master(pdev);
Signature · 1 line
1.7.0
#9 lore raw

PATCH 7/11 ahci: Factor out PCI specifics from ahci_print_info()

In reply to Anton Vorontsov

Introduce ahci_pci_print_info() that now handles PCI stuff.

---
 drivers/ata/ahci.c |   40 +++++++++++++++++++++++-----------------
 1 files changed, 23 insertions(+), 17 deletions(-)
drivers/ata/ahci.c +23 -17
index 439ff90..f904683 100644
@@ -2818,15 +2818,12 @@ static int ahci_configure_dma_masks(struct pci_dev *pdev, int using_dac)
 	return 0;
 }
 
-static void ahci_print_info(struct ata_host *host)
+static void ahci_print_info(struct ata_host *host, const char *scc_s)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
-	struct pci_dev *pdev = to_pci_dev(host->dev);
 	void __iomem *mmio = hpriv->mmio;
 	u32 vers, cap, cap2, impl, speed;
 	const char *speed_s;
-	u16 cc;
-	const char *scc_s;
 
 	vers = readl(mmio + HOST_VERSION);
 	cap = hpriv->cap;
@@ -2843,17 +2840,7 @@ static void ahci_print_info(struct ata_host *host)
 	else
 		speed_s = "?";
 
-	pci_read_config_word(pdev, 0x0a, &cc);
-	if (cc == PCI_CLASS_STORAGE_IDE)
-		scc_s = "IDE";
-	else if (cc == PCI_CLASS_STORAGE_SATA)
-		scc_s = "SATA";
-	else if (cc == PCI_CLASS_STORAGE_RAID)
-		scc_s = "RAID";
-	else
-		scc_s = "unknown";
-
-	dev_printk(KERN_INFO, &pdev->dev,
+	dev_info(host->dev,
 		"AHCI %02x%02x.%02x%02x "
 		"%u slots %u ports %s Gbps 0x%x impl %s mode\n"
 		,
@@ -2869,7 +2856,7 @@ static void ahci_print_info(struct ata_host *host)
 		impl,
 		scc_s);
 
-	dev_printk(KERN_INFO, &pdev->dev,
+	dev_info(host->dev,
 		"flags: "
 		"%s%s%s%s%s%s%s"
 		"%s%s%s%s%s%s%s"
@@ -2899,6 +2886,25 @@ static void ahci_print_info(struct ata_host *host)
 		);
 }
 
+static void ahci_pci_print_info(struct ata_host *host)
+{
+	struct pci_dev *pdev = to_pci_dev(host->dev);
+	u16 cc;
+	const char *scc_s;
+
+	pci_read_config_word(pdev, 0x0a, &cc);
+	if (cc == PCI_CLASS_STORAGE_IDE)
+		scc_s = "IDE";
+	else if (cc == PCI_CLASS_STORAGE_SATA)
+		scc_s = "SATA";
+	else if (cc == PCI_CLASS_STORAGE_RAID)
+		scc_s = "RAID";
+	else
+		scc_s = "unknown";
+
+	ahci_print_info(host, scc_s);
+}
+
 /* On ASUS P5W DH Deluxe, the second port of PCI device 00:1f.2 is
  * hardwired to on-board SIMG 4726.  The chipset is ICH8 and doesn't
  * support PMP and the 4726 either directly exports the device
@@ -3420,7 +3426,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return rc;
 
 	ahci_pci_init_controller(host);
-	ahci_print_info(host);
+	ahci_pci_print_info(host);
 
 	pci_set_master(pdev);
 	return ata_host_activate(host, pdev->irq, ahci_interrupt, IRQF_SHARED,
Signature · 1 line
1.7.0
#10 lore raw

PATCH 8/11 ahci: Introduce ahci_set_em_messages()

In reply to Anton Vorontsov

Factor out some ahci_em_messages handling code from ahci_init_one(). We would like to reuse it for non-PCI devices.

---
 drivers/ata/ahci.c |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)
drivers/ata/ahci.c +24 -17
index f904683..4f05cf0 100644
@@ -3231,6 +3231,29 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
 {}
 #endif
 
+static void ahci_set_em_messages(struct ahci_host_priv *hpriv,
+				 struct ata_port_info *pi)
+{
+	u8 messages;
+	void __iomem *mmio = hpriv->mmio;
+	u32 em_loc = readl(mmio + HOST_EM_LOC);
+	u32 em_ctl = readl(mmio + HOST_EM_CTL);
+
+	if (!ahci_em_messages || !(hpriv->cap & HOST_CAP_EMS))
+		return;
+
+	messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
+
+	/* we only support LED message type right now */
+	if ((messages & 0x01) && (ahci_em_messages == 1)) {
+		/* store em_loc */
+		hpriv->em_loc = ((em_loc >> 16) * 4);
+		pi->flags |= ATA_FLAG_EM;
+		if (!(em_ctl & EM_CTL_ALHD))
+			pi->flags |= ATA_FLAG_SW_ACTIVITY;
+	}
+}
+
 static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	static int printed_version;
@@ -3334,23 +3357,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (hpriv->cap & HOST_CAP_PMP)
 		pi.flags |= ATA_FLAG_PMP;
 
-	if (ahci_em_messages && (hpriv->cap & HOST_CAP_EMS)) {
-		u8 messages;
-		void __iomem *mmio = hpriv->mmio;
-		u32 em_loc = readl(mmio + HOST_EM_LOC);
-		u32 em_ctl = readl(mmio + HOST_EM_CTL);
-
-		messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
-
-		/* we only support LED message type right now */
-		if ((messages & 0x01) && (ahci_em_messages == 1)) {
-			/* store em_loc */
-			hpriv->em_loc = ((em_loc >> 16) * 4);
-			pi.flags |= ATA_FLAG_EM;
-			if (!(em_ctl & EM_CTL_ALHD))
-				pi.flags |= ATA_FLAG_SW_ACTIVITY;
-		}
-	}
+	ahci_set_em_messages(hpriv, &pi);
 
 	if (ahci_broken_system_poweroff(pdev)) {
 		pi.flags |= ATA_FLAG_NO_POWEROFF_SPINDOWN;
Signature · 1 line
1.7.0
Applied
#11 lore raw

Re: [PATCH 08/11] ahci: Introduce ahci_set_em_messages()

Quoted 7 lines · Anton Vorontsov

Factor out some ahci_em_messages handling code from ahci_init_one(). We would like to reuse it for non-PCI devices.

---
  drivers/ata/ahci.c |   41 ++++++++++++++++++++++++-----------------
  1 files changed, 24 insertions(+), 17 deletions(-)

applied patches 1-8 (ie. up to and including this patch) to libata-dev.git#upstream. Will drop all other patches, awaiting revision and resend.

#12 lore raw

PATCH 9/11 ahci: Move generic code into libahci

In reply to Anton Vorontsov

This patch should contain no functional changes, just moves code around.

Currently libahci.c and ahci.c are built into a single module, so there is no need for EXPORT_SYMBOL_GPL()s, yet. Exports will be added in a subsequent patch.

---
 drivers/ata/Makefile  |    2 +-
 drivers/ata/ahci.c    | 2271 +------------------------------------------------
 drivers/ata/libahci.c | 2059 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libahci.h |  330 +++++++
 4 files changed, 2391 insertions(+), 2271 deletions(-)
 create mode 100644 drivers/ata/libahci.c
 create mode 100644 drivers/ata/libahci.h
drivers/ata/Makefile +1 -1
index b7d4923..75e3abd 100644
@@ -1,7 +1,7 @@
 
 obj-$(CONFIG_ATA)		+= libata.o
 
-obj-$(CONFIG_SATA_AHCI)		+= ahci.o
+obj-$(CONFIG_SATA_AHCI)		+= libahci.o ahci.o
 obj-$(CONFIG_SATA_SVW)		+= sata_svw.o
 obj-$(CONFIG_ATA_PIIX)		+= ata_piix.o
 obj-$(CONFIG_SATA_PROMISE)	+= sata_promise.o
drivers/ata/ahci.c +1 -2270

2,369 lines not on this page · raw message

drivers/ata/libahci.c new file +2059 -0

623 lines not on this page · raw message

drivers/ata/libahci.h new file +330 -0

330 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.0

Part of the diff is not shown here. View the raw message.

#13 lore raw

Re: [PATCH 09/11] ahci: Move generic code into libahci

Hello.

Quoted 7 lines · Anton Vorontsov

This patch should contain no functional changes, just moves code around.

Currently libahci.c and ahci.c are built into a single module, so there is no need for EXPORT_SYMBOL_GPL()s, yet. Exports will be added in a subsequent patch.

This is not true anymore, so the exports are probably needed.

Quoted 15 lines
---
 drivers/ata/Makefile  |    2 +-
 drivers/ata/ahci.c    | 2271 +------------------------------------------------
 drivers/ata/libahci.c | 2059 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libahci.h |  330 +++++++
 4 files changed, 2391 insertions(+), 2271 deletions(-)
 create mode 100644 drivers/ata/libahci.c
 create mode 100644 drivers/ata/libahci.h
drivers/ata/Makefile +0 -0
index b7d4923..75e3abd 100644

drivers/ata/Makefile line 5

Quoted 6 lines
drivers/ata/Makefile +1 -1
@@ -1,7 +1,7 @@
 
 obj-$(CONFIG_ATA)		+= libata.o
 
-obj-$(CONFIG_SATA_AHCI)		+= ahci.o
+obj-$(CONFIG_SATA_AHCI)		+= libahci.o ahci.o
 

This means 2 different modules: libahci.ko and ahci.ko.

MBR, Sergei

#14 lore raw

Re: [PATCH 09/11] ahci: Move generic code into libahci

On Wed, Mar 03, 2010 at 08:33:47PM +0300, Sergei Shtylyov wrote:
[...]

Quoted 10 lines

drivers/ata/Makefile line 4

Quoted 8 lines
drivers/ata/Makefile +0 -0
index b7d4923..75e3abd 100644
@@ -1,7 +1,7 @@

obj-$(CONFIG_ATA) += libata.o

drivers/ata/Makefile +1 -1
-obj-$(CONFIG_SATA_AHCI)		+= ahci.o
+obj-$(CONFIG_SATA_AHCI)		+= libahci.o ahci.o

This means 2 different modules: libahci.ko and ahci.ko.

Right you are. And we can't do ahci-objs += libahci.o ahci.o, since that would be a circular dependency. Oh well, I'll merge 09 and 10 patches.

Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#15 lore raw

Re: [PATCH 09/11] ahci: Move generic code into libahci

In reply to Anton Vorontsov
Quoted 2 lines · Anton Vorontsov

This patch should contain no functional changes, just moves code around.

Excellent! I like how this patch series is split up. You've precisely what you needed to do here -- major code movement should avoid any changes outside the minimum required to build this patch.

Others should follow your example :)

drivers/ata/libahci.c line 2

Quoted 8 lines
drivers/ata/libahci.c new file +2 -0
new file mode 100644
index 0000000..3ec32ee
@@ -0,0 +1,2059 @@
+/*
+ *  ahci.c - AHCI SATA low-level routines

this should reflect new filename

drivers/ata/libahci.h line 2

Quoted 8 lines
drivers/ata/libahci.h new file +2 -0
new file mode 100644
index 0000000..60bce4e
@@ -0,0 +1,330 @@
+/*
+ *  ahci.c - AHCI SATA low-level routines

Ditto.

Note that my preference for header file name would be ahci.h rather than libahci.h, to reflect that it includes generic AHCI hardware definitions as well as libahci structures and function prototypes.

#16 lore raw

Re: [PATCH 09/11] ahci: Move generic code into libahci

Quoted 5 lines · Jeff Garzik
Quoted 2 lines · Anton Vorontsov

This patch should contain no functional changes, just moves code around.

Excellent! I like how this patch series is split up.

..

Yes. Excellent work!

#17 lore raw

PATCH 10/11 ahci: Export generic AHCI symbols, turn libahci into a separate module

In reply to Anton Vorontsov

This is needed for non-PCI drivers that will be added soon.

Since the symbols are exported now, libahci and ahci can be built as a separate modules.

---
 drivers/ata/Kconfig   |    8 +++++++-
 drivers/ata/Makefile  |    3 ++-
 drivers/ata/libahci.c |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
drivers/ata/Kconfig +7 -1
index 01c52c4..365a9da 100644
@@ -59,12 +59,18 @@ config SATA_PMP
 
 config SATA_AHCI
 	tristate "AHCI SATA support"
-	depends on PCI
 	help
 	  This option enables support for AHCI Serial ATA.
 
 	  If unsure, say N.
 
+config SATA_AHCI_PCI
+	tristate "PCI AHCI SATA support"
+	depends on SATA_AHCI && PCI
+	default y
+	help
+	  This option enables support for PCI AHCI Serial ATA controllers.
+
 config SATA_SIL24
 	tristate "Silicon Image 3124/3132 SATA support"
 	depends on PCI
drivers/ata/Makefile +2 -1
index 75e3abd..a438cef 100644
@@ -1,7 +1,8 @@
 
 obj-$(CONFIG_ATA)		+= libata.o
 
-obj-$(CONFIG_SATA_AHCI)		+= libahci.o ahci.o
+obj-$(CONFIG_SATA_AHCI)		+= libahci.o
+obj-$(CONFIG_SATA_AHCI_PCI)	+= ahci.o
 obj-$(CONFIG_SATA_SVW)		+= sata_svw.o
 obj-$(CONFIG_ATA_PIIX)		+= ata_piix.o
 obj-$(CONFIG_SATA_PROMISE)	+= sata_promise.o
drivers/ata/libahci.c +20 -0
index 3ec32ee..d2eacc4 100644
@@ -47,6 +47,7 @@
 
 static int ahci_skip_host_reset;
 int ahci_ignore_sss;
+EXPORT_SYMBOL_GPL(ahci_ignore_sss);
 
 module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
 MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
@@ -137,6 +138,7 @@ struct scsi_host_template ahci_sht = {
 	.shost_attrs		= ahci_shost_attrs,
 	.sdev_attrs		= ahci_sdev_attrs,
 };
+EXPORT_SYMBOL_GPL(ahci_sht);
 
 struct ata_port_operations ahci_ops = {
 	.inherits		= &sata_pmp_port_ops,
@@ -174,8 +176,10 @@ struct ata_port_operations ahci_ops = {
 	.port_start		= ahci_port_start,
 	.port_stop		= ahci_port_stop,
 };
+EXPORT_SYMBOL_GPL(ahci_ops);
 
 int ahci_em_messages = 1;
+EXPORT_SYMBOL_GPL(ahci_em_messages);
 module_param(ahci_em_messages, int, 0444);
 /* add other LED protocol types when they become supported */
 MODULE_PARM_DESC(ahci_em_messages,
@@ -369,6 +373,7 @@ void ahci_save_initial_config(struct device *dev,
 	hpriv->cap2 = cap2;
 	hpriv->port_map = port_map;
 }
+EXPORT_SYMBOL_GPL(ahci_save_initial_config);
 
 /**
  *	ahci_restore_initial_config - Restore initial config
@@ -443,6 +448,7 @@ void ahci_start_engine(struct ata_port *ap)
 	writel(tmp, port_mmio + PORT_CMD);
 	readl(port_mmio + PORT_CMD); /* flush */
 }
+EXPORT_SYMBOL_GPL(ahci_start_engine);
 
 int ahci_stop_engine(struct ata_port *ap)
 {
@@ -467,6 +473,7 @@ int ahci_stop_engine(struct ata_port *ap)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ahci_stop_engine);
 
 static void ahci_start_fis_rx(struct ata_port *ap)
 {
@@ -784,6 +791,7 @@ int ahci_reset_controller(struct ata_host *host)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ahci_reset_controller);
 
 static void ahci_sw_activity(struct ata_link *link)
 {
@@ -871,6 +879,7 @@ int ahci_reset_em(struct ata_host *host)
 	writel(em_ctl | EM_CTL_RST, mmio + HOST_EM_CTL);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ahci_reset_em);
 
 static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
 					ssize_t size)
@@ -1064,6 +1073,7 @@ void ahci_init_controller(struct ata_host *host)
 	tmp = readl(mmio + HOST_CTL);
 	VPRINTK("HOST_CTL 0x%x\n", tmp);
 }
+EXPORT_SYMBOL_GPL(ahci_init_controller);
 
 static void ahci_dev_config(struct ata_device *dev)
 {
@@ -1147,6 +1157,7 @@ int ahci_kick_engine(struct ata_port *ap)
 	ahci_start_engine(ap);
 	return rc;
 }
+EXPORT_SYMBOL_GPL(ahci_kick_engine);
 
 static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
 				struct ata_taskfile *tf, int is_cmd, u16 flags,
@@ -1253,6 +1264,7 @@ int ahci_check_ready(struct ata_link *link)
 
 	return ata_check_ready(status);
 }
+EXPORT_SYMBOL_GPL(ahci_check_ready);
 
 static int ahci_softreset(struct ata_link *link, unsigned int *class,
 			  unsigned long deadline)
@@ -1263,6 +1275,7 @@ static int ahci_softreset(struct ata_link *link, unsigned int *class,
 
 	return ahci_do_softreset(link, class, pmp, deadline, ahci_check_ready);
 }
+EXPORT_SYMBOL_GPL(ahci_do_softreset);
 
 static int ahci_hardreset(struct ata_link *link, unsigned int *class,
 			  unsigned long deadline)
@@ -1665,6 +1678,7 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance)
 
 	return IRQ_RETVAL(handled);
 }
+EXPORT_SYMBOL_GPL(ahci_interrupt);
 
 static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
 {
@@ -2034,6 +2048,7 @@ void ahci_print_info(struct ata_host *host, const char *scc_s)
 		cap2 & HOST_CAP2_BOH ? "boh " : ""
 		);
 }
+EXPORT_SYMBOL_GPL(ahci_print_info);
 
 void ahci_set_em_messages(struct ahci_host_priv *hpriv,
 			  struct ata_port_info *pi)
@@ -2057,3 +2072,8 @@ void ahci_set_em_messages(struct ahci_host_priv *hpriv,
 			pi->flags |= ATA_FLAG_SW_ACTIVITY;
 	}
 }
+EXPORT_SYMBOL_GPL(ahci_set_em_messages);
+
+MODULE_AUTHOR("Jeff Garzik");
+MODULE_DESCRIPTION("AHCI SATA low-level routines");
+MODULE_LICENSE("GPL");
Signature · 1 line
1.7.0
#18 lore raw

Re: [PATCH 10/11] ahci: Export generic AHCI symbols, turn libahci into a separate module

Hello.

Quoted 20 lines · Anton Vorontsov

This is needed for non-PCI drivers that will be added soon.

Since the symbols are exported now, libahci and ahci can be built as a separate modules.

---
 drivers/ata/Kconfig   |    8 +++++++-
 drivers/ata/Makefile  |    3 ++-
 drivers/ata/libahci.c |   20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
drivers/ata/Kconfig +0 -0
index 01c52c4..365a9da 100644
@@ -59,12 +59,18 @@ config SATA_PMP
 
 config SATA_AHCI
 	tristate "AHCI SATA support"

drivers/ata/Kconfig config SATA_PMP · line 70

Quoted 10 lines
drivers/ata/Kconfig +3 -1
-	depends on PCI
 	help
 	  This option enables support for AHCI Serial ATA.
 
 	  If unsure, say N.
 
+config SATA_AHCI_PCI
+	tristate "PCI AHCI SATA support"
+	depends on SATA_AHCI && PCI
 

Perhaps it's worth to turn that into select SATA_AHCI and make
SATA_AHCI invisible to users instead, so that each particular AHCI implementation could select it.

drivers/ata/Kconfig config SATA_PMP · line 72

Quoted 2 lines
drivers/ata/Kconfig +1 -0
+	default y
 

Why force the default "y" if the predecessor option SATA_AHCI didn't
do it?

MBR, Sergei

#19 lore raw

Re: [PATCH 10/11] ahci: Export generic AHCI symbols, turn libahci into a separate module

On Wed, Mar 03, 2010 at 08:53:30PM +0300, Sergei Shtylyov wrote:
[...]

Quoted 10 lines
Quoted 10 lines
drivers/ata/Kconfig +0 -0
index 01c52c4..365a9da 100644
@@ -59,12 +59,18 @@ config SATA_PMP

config SATA_AHCI
tristate "AHCI SATA support"

drivers/ata/Kconfig +0 -1
-	depends on PCI

help
This option enables support for AHCI Serial ATA.

Quoted 8 lines

drivers/ata/Kconfig config SATA_PMP · line 69

Quoted 4 lines

If unsure, say N.

drivers/ata/Kconfig +3 -0
+config SATA_AHCI_PCI
+	tristate "PCI AHCI SATA support"
+	depends on SATA_AHCI && PCI

Perhaps it's worth to turn that into select SATA_AHCI and make
SATA_AHCI invisible to users instead, so that each particular AHCI implementation could select it.

No, we must maintain old .config's semantics. SATA_AHCI is already visible to the users, and if we remove it, we'll break 'make oldconfig'.

Quoted 4 lines

drivers/ata/Kconfig config SATA_PMP · line 70

Quoted 1 line
drivers/ata/Kconfig +1 -0
+	default y

Why force the default "y" if the predecessor option SATA_AHCI
didn't do it?

For the same reason, to keep old .configs working.

Thanks,

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#20 lore raw

Re: [PATCH 10/11] ahci: Export generic AHCI symbols, turn libahci into a separate module

Quoted 25 lines · Anton Vorontsov

On Wed, Mar 03, 2010 at 08:53:30PM +0300, Sergei Shtylyov wrote:
[...]

Quoted 10 lines
Quoted 10 lines
drivers/ata/Kconfig +0 -0
index 01c52c4..365a9da 100644
@@ -59,12 +59,18 @@ config SATA_PMP

config SATA_AHCI
tristate "AHCI SATA support"

drivers/ata/Kconfig +0 -1
-	depends on PCI

help
This option enables support for AHCI Serial ATA.

Quoted 8 lines

drivers/ata/Kconfig config SATA_PMP · line 69

Quoted 4 lines

If unsure, say N.

drivers/ata/Kconfig +3 -0
+config SATA_AHCI_PCI
+	tristate "PCI AHCI SATA support"
+	depends on SATA_AHCI && PCI

Perhaps it's worth to turn that into select SATA_AHCI and make
SATA_AHCI invisible to users instead, so that each particular AHCI implementation could select it.

No, we must maintain old .config's semantics. SATA_AHCI is already visible to the users, and if we remove it, we'll break 'make oldconfig'.

Quoted 6 lines
Quoted 4 lines

drivers/ata/Kconfig config SATA_PMP · line 70

Quoted 1 line
drivers/ata/Kconfig +1 -0
+	default y

Why force the default "y" if the predecessor option SATA_AHCI
didn't do it?

For the same reason, to keep old .configs working.

OTOH, we can introduce invisible SATA_LIBAHCI, which is better, I think.

#21 lore raw

Re: [PATCH 10/11] ahci: Export generic AHCI symbols, turn libahci into a separate module

Quoted 31 lines · Anton Vorontsov
Quoted 30 lines · Anton Vorontsov

On Wed, Mar 03, 2010 at 08:53:30PM +0300, Sergei Shtylyov wrote:
[...]

Quoted 10 lines
Quoted 10 lines
drivers/ata/Kconfig +0 -0
index 01c52c4..365a9da 100644
@@ -59,12 +59,18 @@ config SATA_PMP

config SATA_AHCI
tristate "AHCI SATA support"

drivers/ata/Kconfig +0 -1
-	depends on PCI

help
This option enables support for AHCI Serial ATA.

Quoted 8 lines

drivers/ata/Kconfig config SATA_PMP

Quoted 4 lines

If unsure, say N.

drivers/ata/Kconfig +3 -0
+config SATA_AHCI_PCI
+	tristate "PCI AHCI SATA support"
+	depends on SATA_AHCI&&  PCI

Perhaps it's worth to turn that into select SATA_AHCI and make
SATA_AHCI invisible to users instead, so that each particular AHCI implementation could select it.

No, we must maintain old .config's semantics. SATA_AHCI is already visible to the users, and if we remove it, we'll break 'make oldconfig'.

Quoted 4 lines

drivers/ata/Kconfig config SATA_PMP · line 70

Quoted 1 line
drivers/ata/Kconfig +1 -0
+	default y

Why force the default "y" if the predecessor option SATA_AHCI
didn't do it?

Quoted 4 lines
Quoted 1 line

For the same reason, to keep old .configs working.

OTOH, we can introduce invisible SATA_LIBAHCI, which is better, I think.

There is no need for any Kconfig wrangling. Just do it in the Makefile:

obj-$(SATA_AHCI_EXAMPLE1) += sata_example1.o libahci.o obj-$(SATA_AHCI_EXAMPLE2) += sata_example2.o libahci.o

Thus,

1) update PCI ahci's Makefile entry
2) add Kconfig and Makefile entry for platform_ahci

No need to touch PCI AHCI's Kconfig bits at all.

Regards,

Jeff

#22 lore raw

Re: [PATCH 10/11] ahci: Export generic AHCI symbols, turn libahci into a separate module

On Wed, Mar 03, 2010 at 01:34:01PM -0500, Jeff Garzik wrote:
[...]

Quoted 8 lines
Quoted 2 lines

OTOH, we can introduce invisible SATA_LIBAHCI, which is better, I think.

There is no need for any Kconfig wrangling. Just do it in the Makefile:

obj-$(SATA_AHCI_EXAMPLE1) += sata_example1.o libahci.o obj-$(SATA_AHCI_EXAMPLE2) += sata_example2.o libahci.o

Quoted 6 lines

Thus,

1) update PCI ahci's Makefile entry
2) add Kconfig and Makefile entry for platform_ahci

No need to touch PCI AHCI's Kconfig bits at all.

Ah, I see. Will do.

Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#23 lore raw

PATCH 11/11 ahci: Add platform driver

In reply to Anton Vorontsov

This can be used for AHCI-compatible interfaces implemented inside System-On-Chip solutions, or AHCI devices connected via localbus.

---
 drivers/ata/Kconfig           |    9 ++
 drivers/ata/Makefile          |    1 +
 drivers/ata/ahci_platform.c   |  191 +++++++++++++++++++++++++++++++++++++++++
 include/linux/ahci_platform.h |   29 ++++++
 4 files changed, 230 insertions(+), 0 deletions(-)
 create mode 100644 drivers/ata/ahci_platform.c
 create mode 100644 include/linux/ahci_platform.h
drivers/ata/Kconfig +9 -0
index 365a9da..980a40a 100644
@@ -71,6 +71,15 @@ config SATA_AHCI_PCI
 	help
 	  This option enables support for PCI AHCI Serial ATA controllers.
 
+config SATA_AHCI_PLATFORM
+	tristate "Platform AHCI SATA support"
+	depends on SATA_AHCI
+	help
+	  This option enables support for Platform AHCI Serial ATA
+	  controllers.
+
+	  If unsure, say N.
+
 config SATA_SIL24
 	tristate "Silicon Image 3124/3132 SATA support"
 	depends on PCI
drivers/ata/Makefile +1 -0
index a438cef..e235321 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_ATA)		+= libata.o
 
 obj-$(CONFIG_SATA_AHCI)		+= libahci.o
 obj-$(CONFIG_SATA_AHCI_PCI)	+= ahci.o
+obj-$(CONFIG_SATA_AHCI_PLATFORM)+= ahci_platform.o
 obj-$(CONFIG_SATA_SVW)		+= sata_svw.o
 obj-$(CONFIG_ATA_PIIX)		+= ata_piix.o
 obj-$(CONFIG_SATA_PROMISE)	+= sata_promise.o
drivers/ata/ahci_platform.c new file +191 -0

191 lines not on this page · raw message

include/linux/ahci_platform.h new file +29 -0
new file mode 100644
index 0000000..f7dd576
@@ -0,0 +1,29 @@
+/*
+ * AHCI SATA platform driver
+ *
+ * Copyright 2004-2005  Red Hat, Inc.
+ *   Jeff Garzik <[email protected]>
+ * Copyright 2010  MontaVista Software, LLC.
+ *   Anton Vorontsov <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ */
+
+#ifndef _AHCI_PLATFORM_H
+#define _AHCI_PLATFORM_H
+
+struct device;
+struct ata_port_info;
+
+struct ahci_platform_data {
+	int (*init)(struct device *dev);
+	void (*exit)(struct device *dev);
+	const struct ata_port_info *ata_port_info;
+	unsigned int force_port_map;
+	unsigned int mask_port_map;
+};
+
+#endif /* _AHCI_PLATFORM_H */
Signature · 1 line
1.7.0