Skip to content

Commit

Permalink
x86, hpet: Introduce x86_msi_ops.setup_hpet_msi
Browse files Browse the repository at this point in the history
This function pointer can be overwritten by the IRQ
remapping code. The irq_remapping_enabled check can be
removed from default_setup_hpet_msi.

Signed-off-by: Joerg Roedel <joro@8bytes.org>
Acked-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
  • Loading branch information
Joerg Roedel committed Jan 28, 2013
1 parent afcc8a4 commit 71054d8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
5 changes: 3 additions & 2 deletions arch/x86/include/asm/hpet.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ extern void hpet_msi_write(struct hpet_dev *hdev, struct msi_msg *msg);
extern void hpet_msi_read(struct hpet_dev *hdev, struct msi_msg *msg);

#ifdef CONFIG_PCI_MSI
extern int arch_setup_hpet_msi(unsigned int irq, unsigned int id);
extern int default_setup_hpet_msi(unsigned int irq, unsigned int id);
#else
static inline int arch_setup_hpet_msi(unsigned int irq, unsigned int id)
static inline int default_setup_hpet_msi(unsigned int irq, unsigned int id)
{
return -EINVAL;
}
Expand Down Expand Up @@ -111,6 +111,7 @@ extern void hpet_unregister_irq_handler(rtc_irq_handler handler);
static inline int hpet_enable(void) { return 0; }
static inline int is_hpet_enabled(void) { return 0; }
#define hpet_readl(a) 0
#define default_setup_hpet_msi NULL

#endif
#endif /* _ASM_X86_HPET_H */
1 change: 1 addition & 0 deletions arch/x86/include/asm/x86_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct x86_msi_ops {
void (*teardown_msi_irq)(unsigned int irq);
void (*teardown_msi_irqs)(struct pci_dev *dev);
void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
};

struct x86_io_apic_ops {
Expand Down
8 changes: 1 addition & 7 deletions arch/x86/kernel/apic/io_apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3399,18 +3399,12 @@ static struct irq_chip hpet_msi_type = {
.irq_retrigger = ioapic_retrigger_irq,
};

int arch_setup_hpet_msi(unsigned int irq, unsigned int id)
int default_setup_hpet_msi(unsigned int irq, unsigned int id)
{
struct irq_chip *chip = &hpet_msi_type;
struct msi_msg msg;
int ret;

if (irq_remapping_enabled) {
ret = setup_hpet_msi_remapped(irq, id);
if (ret)
return ret;
}

ret = msi_compose_msg(NULL, irq, &msg, id);
if (ret < 0)
return ret;
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/kernel/hpet.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ static int hpet_msi_next_event(unsigned long delta,

static int hpet_setup_msi_irq(unsigned int irq)
{
if (arch_setup_hpet_msi(irq, hpet_blockid)) {
if (x86_msi.setup_hpet_msi(irq, hpet_blockid)) {
destroy_irq(irq);
return -EINVAL;
}
Expand Down
10 changes: 6 additions & 4 deletions arch/x86/kernel/x86_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <asm/time.h>
#include <asm/irq.h>
#include <asm/io_apic.h>
#include <asm/hpet.h>
#include <asm/pat.h>
#include <asm/tsc.h>
#include <asm/iommu.h>
Expand Down Expand Up @@ -111,10 +112,11 @@ struct x86_platform_ops x86_platform = {

EXPORT_SYMBOL_GPL(x86_platform);
struct x86_msi_ops x86_msi = {
.setup_msi_irqs = native_setup_msi_irqs,
.teardown_msi_irq = native_teardown_msi_irq,
.teardown_msi_irqs = default_teardown_msi_irqs,
.restore_msi_irqs = default_restore_msi_irqs,
.setup_msi_irqs = native_setup_msi_irqs,
.teardown_msi_irq = native_teardown_msi_irq,
.teardown_msi_irqs = default_teardown_msi_irqs,
.restore_msi_irqs = default_restore_msi_irqs,
.setup_hpet_msi = default_setup_hpet_msi,
};

struct x86_io_apic_ops x86_io_apic_ops = {
Expand Down
3 changes: 2 additions & 1 deletion drivers/iommu/irq_remapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ static void irq_remapping_disable_io_apic(void)

static void __init irq_remapping_modify_x86_ops(void)
{
x86_io_apic_ops.disable = irq_remapping_disable_io_apic;
x86_io_apic_ops.disable = irq_remapping_disable_io_apic;
x86_msi.setup_hpet_msi = setup_hpet_msi_remapped;
}

static __init int setup_nointremap(char *str)
Expand Down

0 comments on commit 71054d8

Please sign in to comment.