2014-02-12 23:36:04

by David E. Box

[permalink] [raw]
Subject: [PATCH] x86: iosf_mbi: Provide dummy functions if CONFIG_IOSF_MBI not set

From: "David E. Box" <[email protected]>

Add iosf_mbi_available function for loadable modules.
Add dummy functions to prevent symbol lookup errors on loadable modules.
Clarify that the write opcode is to be used for iosf_mbi_modify().
Changes Kconfig for IOSF_MBI to default built-in.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 2 +-
arch/x86/include/asm/iosf_mbi.h | 39 +++++++++++++++++++++++++++++++++++----
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..e25baf1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,7 +2385,7 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ def_bool y
depends on PCI
---help---
To be selected by modules requiring access to the Intel OnChip System
diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..1c93591 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+extern bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -60,7 +64,7 @@
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
+extern int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);

/**
* iosf_mbi_write() - MailBox unmasked write command
@@ -72,19 +76,46 @@ int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
+extern int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);

/**
* iosf_mbi_modify() - MailBox masked write command
* @port: port indicating subunit being accessed
- * @opcode: port specific read or write opcode
+ * @opcode: port specific write opcode
* @offset: register address offset
* @mdr: register data being modified
* @mask: mask indicating bits in mdr to be modified
*
+ * Use write opcode for this function.
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+extern int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+
+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ return 0;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ return 0;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ return 0;
+}
+#endif /* CONFIG_IOSF_MBI */

#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4


2014-02-23 01:04:14

by David E. Box

[permalink] [raw]
Subject: [PATCH RESEND] x86: iosf_mbi: Provide dummy functions if CONFIG_IOSF_MBI not set

From: "David E. Box" <[email protected]>

Add iosf_mbi_available function for loadable modules.
Add dummy functions to prevent symbol lookup errors on loadable modules.
Clarify that the write opcode is to be used for iosf_mbi_modify().
Changes Kconfig for IOSF_MBI to default built-in.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 2 +-
arch/x86/include/asm/iosf_mbi.h | 39 +++++++++++++++++++++++++++++++++++----
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..e25baf1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,7 +2385,7 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ def_bool y
depends on PCI
---help---
To be selected by modules requiring access to the Intel OnChip System
diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..1c93591 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+extern bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -60,7 +64,7 @@
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
+extern int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);

/**
* iosf_mbi_write() - MailBox unmasked write command
@@ -72,19 +76,46 @@ int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
+extern int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);

/**
* iosf_mbi_modify() - MailBox masked write command
* @port: port indicating subunit being accessed
- * @opcode: port specific read or write opcode
+ * @opcode: port specific write opcode
* @offset: register address offset
* @mdr: register data being modified
* @mask: mask indicating bits in mdr to be modified
*
+ * Use write opcode for this function.
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+extern int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+
+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ return 0;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ return 0;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ return 0;
+}
+#endif /* CONFIG_IOSF_MBI */

#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4

2014-02-24 13:19:35

by Alan Cox

[permalink] [raw]
Subject: Re: [PATCH RESEND] x86: iosf_mbi: Provide dummy functions if CONFIG_IOSF_MBI not set

On Sat, 22 Feb 2014 17:02:32 -0800
"David E. Box" <[email protected]> wrote:

> From: "David E. Box" <[email protected]>
>
> Add iosf_mbi_available function for loadable modules.
> Add dummy functions to prevent symbol lookup errors on loadable modules.
> Clarify that the write opcode is to be used for iosf_mbi_modify().
> Changes Kconfig for IOSF_MBI to default built-in.

Other than _available I would have expected all the others to resolve to
returning an error or doing a WARN() in the not compiled in case.

If someone is dumb enough to miss the checks we want the kernel to spew
forth copious announcements of the fact, not silently do nothing.

Alan

2014-02-24 13:22:10

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH RESEND] x86: iosf_mbi: Provide dummy functions if CONFIG_IOSF_MBI not set

On 02/24/2014 05:19 AM, One Thousand Gnomes wrote:
>
> Other than _available I would have expected all the others to resolve to
> returning an error or doing a WARN() in the not compiled in case.
>

WARN() or BUG()?

-hpa

2014-02-24 13:29:45

by Alan Cox

[permalink] [raw]
Subject: Re: [PATCH RESEND] x86: iosf_mbi: Provide dummy functions if CONFIG_IOSF_MBI not set

On Mon, 24 Feb 2014 05:21:43 -0800
"H. Peter Anvin" <[email protected]> wrote:

> On 02/24/2014 05:19 AM, One Thousand Gnomes wrote:
> >
> > Other than _available I would have expected all the others to resolve to
> > returning an error or doing a WARN() in the not compiled in case.
> >
>
> WARN() or BUG()?

WARN I think. The usage cases I am aware of don't end up in catastrophic
failure if you get this wrong, but would be annoying to debug if missed.

Alan

2014-02-25 02:49:07

by David E. Box

[permalink] [raw]
Subject: [PATCH V2 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

From: "David E. Box" <[email protected]>

The IOSF Mailbox interface is an access mechanism used by multiple drivers to
communicate with key configuration registers on new Intel SOC platforms. The
interface is ubiquitous enough that we need to ensure the availability of the
driver in non-EXPERT x86 kernels.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..4de5205 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,11 +2385,12 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ bool "IOSF MBI support" if EXPERT
+ default y
depends on PCI
---help---
To be selected by modules requiring access to the Intel OnChip System
- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
+ Fabric (IOSF) Sideband MailBox Interface (MBI). For IOSF platforms
enumerable by PCI.

source "net/Kconfig"
--
1.7.10.4

2014-02-25 02:49:05

by David E. Box

[permalink] [raw]
Subject: [PATCH V2 1/2] x86: IOSF: add dummy functions for loadable modules

From: "David E. Box" <[email protected]>

Some loadable modules only need IOSF access on the platforms where it exists.
Provide dummy functions to allow these modules to compile and load on the
platforms where it doesn't exist.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/include/asm/iosf_mbi.h | 39 ++++++++++++++++++++++++++++++++++++---
arch/x86/kernel/iosf_mbi.c | 6 ++++++
2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..6dcaa1d 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+extern bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -60,7 +64,7 @@
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
+extern int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);

/**
* iosf_mbi_write() - MailBox unmasked write command
@@ -72,7 +76,7 @@ int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr);
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
+extern int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);

/**
* iosf_mbi_modify() - MailBox masked write command
@@ -85,6 +89,35 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
* Locking is handled by spinlock - cannot sleep.
* Return: Nonzero on error
*/
-int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+extern int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);
+
+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ WARN();
+ return -EPERM;
+}
+#endif /* CONFIG_IOSF_MBI */

#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4

2014-02-25 02:49:04

by David E. Box

[permalink] [raw]
Subject: [PATCH V2 0/2] x86: IOSF: Add loadable module support

From: "David E. Box" <[email protected]>

This patch series adds missing functionalty that mostly affected loadable
modules.

The first patch adds dummy functions to allow drivers not completely
dependant on the IOSF MBI driver to compile on systems that don't have it.

The second ensures the availabilty of the MBI driver in the kernel, limiting the
possibility of requiring a rebuild when new modules needing the MBI are added.

Changes from V1:

- Force default y for non-EXPERT to allow easier custom configuration
as suggested by hpa <[email protected]>
- Add WARN() to dummy functions, other than iosf_mbi_available(), to
signal incorrect use as suggested by Alan <[email protected]>
Also return EPERM in these functions
- Splits single patch into two patch series

David E. Box (2):
x86: IOSF: add dummy functions for loadable modules
x86: IOSF: Change IOSF_MBI Kconfig to default y

arch/x86/Kconfig | 5 +++--
arch/x86/include/asm/iosf_mbi.h | 39 ++++++++++++++++++++++++++++++++++++---
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 45 insertions(+), 5 deletions(-)

--
1.7.10.4

2014-02-26 19:44:22

by David E. Box

[permalink] [raw]
Subject: [PATCH V3 0/2] x86: IOSF: Add loadable module support

From: "David E. Box" <[email protected]>

This patch series adds missing functionalty that mostly affected loadable
modules.

The first patch adds dummy functions to allow drivers not completely
dependant on the IOSF MBI driver to compile on systems that don't have it.

The second ensures the availabilty of the MBI driver in the kernel, limiting the
possibility of requiring a rebuild when new modules needing the MBI are added.

Changes from V2:

- Remove non linux style externs from iosf_mbi.h

Changes from V1:

- Force default y for non-EXPERT to allow easier custom configuration
as suggested by hpa <[email protected]>
- Add WARN() to dummy functions, other than iosf_mbi_available(), to
signal incorrect use as suggested by Alan <[email protected]>
Also return EPERM in these functions
- Splits single patch into two patch series

David E. Box (2):
x86: IOSF: add dummy functions for loadable modules
x86: IOSF: Change IOSF_MBI Kconfig to default y

arch/x86/Kconfig | 5 +++--
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 42 insertions(+), 2 deletions(-)

--
1.7.10.4

2014-02-26 19:44:21

by David E. Box

[permalink] [raw]
Subject: [PATCH V3 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

From: "David E. Box" <[email protected]>

The IOSF Mailbox interface is an access mechanism used by multiple drivers to
communicate with key configuration registers on new Intel SOC platforms. The
interface is ubiquitous enough that we need to ensure the availability of the
driver in non-EXPERT configured x86 kernels.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..4de5205 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,11 +2385,12 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ bool "IOSF MBI support" if EXPERT
+ default y
depends on PCI
---help---
To be selected by modules requiring access to the Intel OnChip System
- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
+ Fabric (IOSF) Sideband MailBox Interface (MBI). For IOSF platforms
enumerable by PCI.

source "net/Kconfig"
--
1.7.10.4

2014-02-26 19:44:53

by David E. Box

[permalink] [raw]
Subject: [PATCH V3 1/2] x86: IOSF: add dummy functions for loadable modules

From: "David E. Box" <[email protected]>

Some loadable modules only need IOSF access on the platforms where it exists.
Provide dummy functions to allow these modules to compile and load on the
platforms where it doesn't exist.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
2 files changed, 39 insertions(+)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..9fc5402 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -87,4 +91,33 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
*/
int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);

+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ WARN();
+ return -EPERM;
+}
+#endif /* CONFIG_IOSF_MBI */
+
#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4

2014-02-27 03:26:37

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH V3 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

On 02/26/2014 11:40 AM, David E. Box wrote:
> From: "David E. Box" <[email protected]>
>
> The IOSF Mailbox interface is an access mechanism used by multiple drivers to
> communicate with key configuration registers on new Intel SOC platforms. The
> interface is ubiquitous enough that we need to ensure the availability of the
> driver in non-EXPERT configured x86 kernels.
>
> Signed-off-by: David E. Box <[email protected]>

Hi David,

Could you please update the patch description to explain to people who
may not be familiar why the IOSF driver can't be a module?

-hpa

2014-02-27 16:52:07

by David E. Box

[permalink] [raw]
Subject: [PATCH RESEND V3 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

From: "David E. Box" <[email protected]>

The IOSF Mailbox interface is an access mechanism used by drivers to communicate
with the configuration registers of devices connected on the fabric of Intel SOC
platforms. The interface is ubiquitous enough that we need to ensure the
availability of the driver in non-EXPERT configured x86 kernels. Make the module
built-in so drivers can access device registers that need configuration during
early boot.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..4de5205 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,11 +2385,12 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ bool "IOSF MBI support" if EXPERT
+ default y
depends on PCI
---help---
To be selected by modules requiring access to the Intel OnChip System
- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
+ Fabric (IOSF) Sideband MailBox Interface (MBI). For IOSF platforms
enumerable by PCI.

source "net/Kconfig"
--
1.7.10.4

2014-02-28 17:49:45

by David E. Box

[permalink] [raw]
Subject: [PATCH V4 1/2] x86: IOSF: add dummy functions for loadable modules

From: "David E. Box" <[email protected]>

Some loadable modules only need IOSF access on the platforms where it exists.
Provide dummy functions to allow these modules to compile and load on the
platforms where it doesn't exist.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
2 files changed, 39 insertions(+)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..9fc5402 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -87,4 +91,33 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
*/
int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);

+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ WARN();
+ return -EPERM;
+}
+#endif /* CONFIG_IOSF_MBI */
+
#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4

2014-02-28 17:49:44

by David E. Box

[permalink] [raw]
Subject: [PATCH V4 0/2] x86: IOSF: Add loadable module support

From: "David E. Box" <[email protected]>

This patch series adds missing functionalty that mostly affected loadable
modules.

The first patch adds dummy functions to allow drivers not completely
dependant on the IOSF MBI driver to compile on systems that don't have it.

The second makes MBI driver built in.

Changes from V3:

- Code is agreed to be small enough to not warrant forcing for
non-EXPERT only

Changes from V2:

- Remove non linux style externs from iosf_mbi.h

Changes from V1:

- Force default y for non-EXPERT to allow easier custom configuration
as suggested by hpa <[email protected]>
- Add WARN() to dummy functions, other than iosf_mbi_available(), to
signal incorrect use as suggested by Alan <[email protected]>
Also return EPERM in these functions
- Splits single patch into two patch series

David E. Box (2):
x86: IOSF: add dummy functions for loadable modules
x86: IOSF: Change IOSF_MBI Kconfig to default y

arch/x86/Kconfig | 6 +-----
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 40 insertions(+), 5 deletions(-)

--
1.7.10.4

2014-02-28 17:50:25

by David E. Box

[permalink] [raw]
Subject: [PATCH V4 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

From: "David E. Box" <[email protected]>

Make the IOSF Mailbox driver built in as it's a very small piece of code that
provides core functionality needed for new Intel SOC platforms to access the
device registers on the SOC.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..4f31ad3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,12 +2385,8 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ def_bool y
depends on PCI
- ---help---
- To be selected by modules requiring access to the Intel OnChip System
- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
- enumerable by PCI.

source "net/Kconfig"

--
1.7.10.4

2014-02-28 18:01:45

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH V4 0/2] x86: IOSF: Add loadable module support

On 02/28/2014 09:47 AM, David E. Box wrote:
>
> Changes from V3:
>
> - Code is agreed to be small enough to not warrant forcing for
> non-EXPERT only
>

Did I miss part of the discussion? How small is "small"?

-hpa

2014-03-01 02:42:44

by David E. Box

[permalink] [raw]
Subject: [PATCH V5 0/2] x86: IOSF: Add loadable module support

From: "David E. Box" <[email protected]>

This patch series adds missing functionalty that mostly affected loadable
modules.

The first patch adds dummy functions to allow drivers not completely
dependant on the IOSF MBI driver to compile on systems that don't have it.

The second makes MBI driver built in.

Changes from V4:

- Put back Kconfig prompt for IOSF_MBI.

Changes from V3:

- Code is agreed to be small enough to not warrant forcing for
non-EXPERT only

Changes from V2:

- Remove non linux style externs from iosf_mbi.h

Changes from V1:

- Force default y for non-EXPERT to allow easier custom configuration
as suggested by hpa <[email protected]>
- Add WARN() to dummy functions, other than iosf_mbi_available(), to
signal incorrect use as suggested by Alan <[email protected]>
Also return EPERM in these functions
- Splits single patch into two patch series

David E. Box (2):
x86: IOSF: add dummy functions for loadable modules
x86: IOSF: Change IOSF_MBI Kconfig to default y

arch/x86/Kconfig | 7 ++-----
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
3 files changed, 41 insertions(+), 5 deletions(-)

--
1.7.10.4

2014-03-01 02:42:43

by David E. Box

[permalink] [raw]
Subject: [PATCH V5 2/2] x86: IOSF: Change IOSF_MBI Kconfig to default y

From: "David E. Box" <[email protected]>

Make the IOSF Mailbox driver built in as it provides core functionality needed
for new Intel SOC platforms to access the device registers on the SOC.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/Kconfig | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d3b1f8b..e34b252 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2385,12 +2385,9 @@ config X86_DMA_REMAP
depends on STA2X11

config IOSF_MBI
- bool
+ bool "Intel IOSF Mailbox Driver support"
+ default y
depends on PCI
- ---help---
- To be selected by modules requiring access to the Intel OnChip System
- Fabric (IOSF) Sideband MailBox Interface (MBI). For MBI platforms
- enumerable by PCI.

source "net/Kconfig"

--
1.7.10.4

2014-03-01 02:43:16

by David E. Box

[permalink] [raw]
Subject: [PATCH V5 1/2] x86: IOSF: add dummy functions for loadable modules

From: "David E. Box" <[email protected]>

Some loadable modules only need IOSF access on the platforms where it exists.
Provide dummy functions to allow these modules to compile and load on the
platforms where it doesn't exist.

Signed-off-by: David E. Box <[email protected]>
---
arch/x86/include/asm/iosf_mbi.h | 33 +++++++++++++++++++++++++++++++++
arch/x86/kernel/iosf_mbi.c | 6 ++++++
2 files changed, 39 insertions(+)

diff --git a/arch/x86/include/asm/iosf_mbi.h b/arch/x86/include/asm/iosf_mbi.h
index 8e71c79..9fc5402 100644
--- a/arch/x86/include/asm/iosf_mbi.h
+++ b/arch/x86/include/asm/iosf_mbi.h
@@ -5,6 +5,8 @@
#ifndef IOSF_MBI_SYMS_H
#define IOSF_MBI_SYMS_H

+#ifdef CONFIG_IOSF_MBI
+
#define MBI_MCR_OFFSET 0xD0
#define MBI_MDR_OFFSET 0xD4
#define MBI_MCRX_OFFSET 0xD8
@@ -50,6 +52,8 @@
#define BT_MBI_PCIE_READ 0x00
#define BT_MBI_PCIE_WRITE 0x01

+bool iosf_mbi_available(void);
+
/**
* iosf_mbi_read() - MailBox Interface read command
* @port: port indicating subunit being accessed
@@ -87,4 +91,33 @@ int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr);
*/
int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask);

+#else /* CONFIG_IOSF_MBI is not enabled */
+static inline
+bool iosf_mbi_available(void)
+{
+ return false;
+}
+
+static inline
+int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr)
+{
+ WARN();
+ return -EPERM;
+}
+
+static inline
+int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
+{
+ WARN();
+ return -EPERM;
+}
+#endif /* CONFIG_IOSF_MBI */
+
#endif /* IOSF_MBI_SYMS_H */
diff --git a/arch/x86/kernel/iosf_mbi.c b/arch/x86/kernel/iosf_mbi.c
index c3aae66..d3803c6 100644
--- a/arch/x86/kernel/iosf_mbi.c
+++ b/arch/x86/kernel/iosf_mbi.c
@@ -177,6 +177,12 @@ int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask)
}
EXPORT_SYMBOL(iosf_mbi_modify);

+bool iosf_mbi_available(void)
+{
+ return mbi_pdev;
+}
+EXPORT_SYMBOL(iosf_mbi_available);
+
static int iosf_mbi_probe(struct pci_dev *pdev,
const struct pci_device_id *unused)
{
--
1.7.10.4