Commit f070d671 authored by Suman Tripathi's avatar Suman Tripathi Committed by Tejun Heo

libahci: Implement the capability to override the generic ahci interrupt handler.

This patch implements the capability to override the generic AHCI
interrupt handler so that specific ahci drivers can implement their
own custom interrupt handler routines.  It also exports
ahci_handle_port_intr so that custom irq_handler implementations can
use it.

tj: s/ahci_irq_handler/irq_handler/ and updated description.
Signed-off-by: default avatarSuman Tripathi <stripathi@apm.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 342decff
...@@ -361,6 +361,7 @@ struct ahci_host_priv { ...@@ -361,6 +361,7 @@ struct ahci_host_priv {
* be overridden anytime before the host is activated. * be overridden anytime before the host is activated.
*/ */
void (*start_engine)(struct ata_port *ap); void (*start_engine)(struct ata_port *ap);
irqreturn_t (*irq_handler)(int irq, void *dev_instance);
}; };
#ifdef CONFIG_PCI_MSI #ifdef CONFIG_PCI_MSI
...@@ -424,6 +425,7 @@ int ahci_reset_em(struct ata_host *host); ...@@ -424,6 +425,7 @@ int ahci_reset_em(struct ata_host *host);
void ahci_print_info(struct ata_host *host, const char *scc_s); void ahci_print_info(struct ata_host *host, const char *scc_s);
int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht); int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht);
void ahci_error_handler(struct ata_port *ap); void ahci_error_handler(struct ata_port *ap);
u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked);
static inline void __iomem *__ahci_port_base(struct ata_host *host, static inline void __iomem *__ahci_port_base(struct ata_host *host,
unsigned int port_no) unsigned int port_no)
......
...@@ -113,6 +113,9 @@ static ssize_t ahci_store_em_buffer(struct device *dev, ...@@ -113,6 +113,9 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
const char *buf, size_t size); const char *buf, size_t size);
static ssize_t ahci_show_em_supported(struct device *dev, static ssize_t ahci_show_em_supported(struct device *dev,
struct device_attribute *attr, char *buf); struct device_attribute *attr, char *buf);
static irqreturn_t ahci_single_edge_irq_intr(int irq, void *dev_instance);
static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance);
static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL); static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL); static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
...@@ -512,6 +515,11 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv) ...@@ -512,6 +515,11 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
if (!hpriv->start_engine) if (!hpriv->start_engine)
hpriv->start_engine = ahci_start_engine; hpriv->start_engine = ahci_start_engine;
if (!hpriv->irq_handler)
hpriv->irq_handler = (hpriv->flags & AHCI_HFLAG_EDGE_IRQ) ?
ahci_single_edge_irq_intr :
ahci_single_level_irq_intr;
} }
EXPORT_SYMBOL_GPL(ahci_save_initial_config); EXPORT_SYMBOL_GPL(ahci_save_initial_config);
...@@ -1846,7 +1854,7 @@ static irqreturn_t ahci_multi_irqs_intr_hard(int irq, void *dev_instance) ...@@ -1846,7 +1854,7 @@ static irqreturn_t ahci_multi_irqs_intr_hard(int irq, void *dev_instance)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked) u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
{ {
unsigned int i, handled = 0; unsigned int i, handled = 0;
...@@ -1872,6 +1880,7 @@ static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked) ...@@ -1872,6 +1880,7 @@ static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
return handled; return handled;
} }
EXPORT_SYMBOL_GPL(ahci_handle_port_intr);
static irqreturn_t ahci_single_edge_irq_intr(int irq, void *dev_instance) static irqreturn_t ahci_single_edge_irq_intr(int irq, void *dev_instance)
{ {
...@@ -2535,14 +2544,18 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht) ...@@ -2535,14 +2544,18 @@ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
int irq = hpriv->irq; int irq = hpriv->irq;
int rc; int rc;
if (hpriv->flags & (AHCI_HFLAG_MULTI_MSI | AHCI_HFLAG_MULTI_MSIX)) if (hpriv->flags & (AHCI_HFLAG_MULTI_MSI | AHCI_HFLAG_MULTI_MSIX)) {
if (hpriv->irq_handler)
dev_warn(host->dev, "both AHCI_HFLAG_MULTI_MSI flag set \
and custom irq handler implemented\n");
rc = ahci_host_activate_multi_irqs(host, sht); rc = ahci_host_activate_multi_irqs(host, sht);
else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ) } else {
rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr, rc = ata_host_activate(host, irq, hpriv->irq_handler,
IRQF_SHARED, sht);
else
rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
IRQF_SHARED, sht); IRQF_SHARED, sht);
}
return rc; return rc;
} }
EXPORT_SYMBOL_GPL(ahci_host_activate); EXPORT_SYMBOL_GPL(ahci_host_activate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment