Skip to contentSkip to conversation

x86: Cleanups around slow_down_io()

PATCH Superseded Juergen Gross 2 participants 8 messages Jan 15

Subsystems (9)
x86 KVM Block layer virtio core +5 more subsystems

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

v3 cover x86: Cleanups around slow_down_io()

While looking at paravirt cleanups I stumbled over slow_down_io() and the related REALLY_SLOW_IO define.

Do several cleanups, resulting in a deletion of REALLY_SLOW_IO and the io_delay() paravirt function hook.

Patch 4 is removing the config options for selecting the default delay mechanism and sets the default to "no delay". This is in preparation of removing the io_delay() functionality completely, as suggested by Ingo Molnar.

Patch 5 is adding an additional config option allowing to avoid building io_delay.c (default is still to build it).

Changes in V2:
- patches 2 and 3 of V1 have been applied
- new patches 4 and 5

Changes in V3:
- rebase to tip/master kernel branch

Juergen Gross (5):
x86/paravirt: Replace io_delay() hook with a bool block/floppy: Don't use REALLY_SLOW_IO for delays x86/io: Remove REALLY_SLOW_IO handling
x86/io_delay: Switch io_delay() default mechanism to "none" x86/io_delay: Add config option for controlling build of io_delay.

 arch/x86/Kconfig                      |  8 +++
 arch/x86/Kconfig.debug                | 30 ----------
 arch/x86/include/asm/floppy.h         | 31 ++++++++--
 arch/x86/include/asm/io.h             | 19 ++++---
 arch/x86/include/asm/paravirt-base.h  |  6 ++
 arch/x86/include/asm/paravirt.h       | 11 ----
 arch/x86/include/asm/paravirt_types.h |  2 -
 arch/x86/kernel/Makefile              |  3 +-
 arch/x86/kernel/cpu/vmware.c          |  2 +-
 arch/x86/kernel/io_delay.c            | 81 +--------------------------
 arch/x86/kernel/kvm.c                 |  8 +--
 arch/x86/kernel/paravirt.c            |  3 +-
 arch/x86/kernel/setup.c               |  4 +-
 arch/x86/xen/enlighten_pv.c           |  6 +-
 drivers/block/floppy.c                |  2 -
 15 files changed, 60 insertions(+), 156 deletions(-)
Signature · 1 line
2.51.0
author maintainer
#1 lore raw

PATCH v3 1/5 x86/paravirt: Replace io_delay() hook with a bool

The io_delay() paravirt hook is in no way performance critical and all users setting it to a different function than native_io_delay() are using an empty function as replacement.

This enables to replace the hook with a bool indicating whether native_io_delay() should be called.

---
V3:
- rebase to tip/master kernel branch

---
 arch/x86/include/asm/io.h             |  9 ++++++---
 arch/x86/include/asm/paravirt-base.h  |  6 ++++++
 arch/x86/include/asm/paravirt.h       | 11 -----------
 arch/x86/include/asm/paravirt_types.h |  2 --
 arch/x86/kernel/cpu/vmware.c          |  2 +-
 arch/x86/kernel/kvm.c                 |  8 +-------
 arch/x86/kernel/paravirt.c            |  3 +--
 arch/x86/xen/enlighten_pv.c           |  6 +-----
 8 files changed, 16 insertions(+), 31 deletions(-)
arch/x86/include/asm/io.h +6 -3
index ca309a3227c7..8a9292ce7d2d 100644
@@ -243,11 +243,16 @@ extern int io_delay_type;
 extern void io_delay_init(void);
 
 #if defined(CONFIG_PARAVIRT)
-#include <asm/paravirt.h>
+#include <asm/paravirt-base.h>
 #else
+#define call_io_delay() true
+#endif
 
 static inline void slow_down_io(void)
 {
+	if (!call_io_delay())
+		return;
+
 	native_io_delay();
 #ifdef REALLY_SLOW_IO
 	native_io_delay();
@@ -256,8 +261,6 @@ static inline void slow_down_io(void)
 #endif
 }
 
-#endif
-
 #define BUILDIO(bwl, type)						\
 static inline void out##bwl##_p(type value, u16 port)			\
 {									\
arch/x86/include/asm/paravirt-base.h +6 -0
index 982a0b93bc76..3b9e7772d196 100644
@@ -15,6 +15,8 @@ struct pv_info {
 #ifdef CONFIG_PARAVIRT_XXL
 	u16 extra_user_64bit_cs;  /* __USER_CS if none */
 #endif
+	bool io_delay;
+
 	const char *name;
 };
 
@@ -26,6 +28,10 @@ u64 _paravirt_ident_64(u64);
 #endif
 #define paravirt_nop	((void *)nop_func)
 
+#ifdef CONFIG_PARAVIRT
+#define call_io_delay() pv_info.io_delay
+#endif
+
 #ifdef CONFIG_PARAVIRT_SPINLOCKS
 void paravirt_set_cap(void);
 #else
arch/x86/include/asm/paravirt.h +0 -11
index b21072af731d..f4885bd98a18 100644
@@ -19,17 +19,6 @@
 #include <linux/cpumask.h>
 #include <asm/frame.h>
 
-/* The paravirtualized I/O functions */
-static inline void slow_down_io(void)
-{
-	PVOP_VCALL0(pv_ops, cpu.io_delay);
-#ifdef REALLY_SLOW_IO
-	PVOP_VCALL0(pv_ops, cpu.io_delay);
-	PVOP_VCALL0(pv_ops, cpu.io_delay);
-	PVOP_VCALL0(pv_ops, cpu.io_delay);
-#endif
-}
-
 void native_flush_tlb_local(void);
 void native_flush_tlb_global(void);
 void native_flush_tlb_one_user(unsigned long addr);
arch/x86/include/asm/paravirt_types.h +0 -2
index 7ccd41628d36..3946d0f69921 100644
@@ -30,8 +30,6 @@ struct pv_lazy_ops {
 
 struct pv_cpu_ops {
 	/* hooks for various privileged instructions */
-	void (*io_delay)(void);
-
 #ifdef CONFIG_PARAVIRT_XXL
 	unsigned long (*get_debugreg)(int regno);
 	void (*set_debugreg)(int regno, unsigned long value);
arch/x86/kernel/cpu/vmware.c +1 -1
index a3e6936839b1..eee0d1a48802 100644
@@ -339,7 +339,7 @@ arch_initcall(activate_jump_labels);
 static void __init vmware_paravirt_ops_setup(void)
 {
 	pv_info.name = "VMware hypervisor";
-	pv_ops.cpu.io_delay = paravirt_nop;
+	pv_info.io_delay = false;
 
 	if (vmware_tsc_khz == 0)
 		return;
arch/x86/kernel/kvm.c +1 -7
index de550b12d9ab..8c3221048d9f 100644
@@ -75,12 +75,6 @@ DEFINE_PER_CPU_DECRYPTED(struct kvm_steal_time, steal_time) __aligned(64) __visi
 static int has_steal_clock = 0;
 
 static int has_guest_poll = 0;
-/*
- * No need for any "IO delay" on KVM
- */
-static void kvm_io_delay(void)
-{
-}
 
 #define KVM_TASK_SLEEP_HASHBITS 8
 #define KVM_TASK_SLEEP_HASHSIZE (1<<KVM_TASK_SLEEP_HASHBITS)
@@ -314,7 +308,7 @@ static void __init paravirt_ops_setup(void)
 	pv_info.name = "KVM";
 
 	if (kvm_para_has_feature(KVM_FEATURE_NOP_IO_DELAY))
-		pv_ops.cpu.io_delay = kvm_io_delay;
+		pv_info.io_delay = false;
 
 #ifdef CONFIG_X86_IO_APIC
 	no_timer_check = 1;
arch/x86/kernel/paravirt.c +1 -2
index a6ed52cae003..792fa96b3233 100644
@@ -94,6 +94,7 @@ struct pv_info pv_info = {
 #ifdef CONFIG_PARAVIRT_XXL
 	.extra_user_64bit_cs = __USER_CS,
 #endif
+	.io_delay = true,
 };
 
 /* 64-bit pagetable entries */
@@ -101,8 +102,6 @@ struct pv_info pv_info = {
 
 struct paravirt_patch_template pv_ops = {
 	/* Cpu ops. */
-	.cpu.io_delay		= native_io_delay,
-
 #ifdef CONFIG_PARAVIRT_XXL
 	.cpu.cpuid		= native_cpuid,
 	.cpu.get_debugreg	= pv_native_get_debugreg,
arch/x86/xen/enlighten_pv.c +1 -5
index 8a19a88190ee..9c9695f5d158 100644
@@ -1046,10 +1046,6 @@ static void xen_update_io_bitmap(void)
 }
 #endif
 
-static void xen_io_delay(void)
-{
-}
-
 static DEFINE_PER_CPU(unsigned long, xen_cr0_value);
 
 static unsigned long xen_read_cr0(void)
@@ -1209,6 +1205,7 @@ void __init xen_setup_vcpu_info_placement(void)
 
 static const struct pv_info xen_info __initconst = {
 	.extra_user_64bit_cs = FLAT_USER_CS64,
+	.io_delay = false,
 	.name = "Xen",
 };
 
@@ -1392,7 +1389,6 @@ asmlinkage __visible void __init xen_start_kernel(struct start_info *si)
 	pv_ops.cpu.invalidate_io_bitmap = xen_invalidate_io_bitmap;
 	pv_ops.cpu.update_io_bitmap = xen_update_io_bitmap;
 #endif
-	pv_ops.cpu.io_delay = xen_io_delay;
 	pv_ops.cpu.start_context_switch = xen_start_context_switch;
 	pv_ops.cpu.end_context_switch = xen_end_context_switch;
 
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v3 1/5] x86/paravirt: Replace io_delay() hook with a bool

kernel test robot noticed the following build errors:

Hi Juergen,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/master]
[also build test ERROR on next-20260115]
[cannot apply to kvm/queue kvm/next tip/x86/core kvm/linux-next tip/auto-latest linus/master v6.19-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Juergen-Gross/x86-paravirt-Replace-io_delay-hook-with-a-bool/20260115-165320
base:   tip/master
patch link:    https://lore.kernel.org/r/20260115084849.31502-2-jgross%40suse.com
patch subject: [PATCH v3 1/5] x86/paravirt: Replace io_delay() hook with a bool
config: i386-randconfig-011-20260115 (https://download.01.org/0day-ci/archive/20260115/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260115/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/cpufreq/longhaul.c:145:2: error: call to undeclared function 'arch_safe_halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     145 |         safe_halt();
         |         ^
   include/linux/irqflags.h:231:3: note: expanded from macro 'safe_halt'
     231 |                 raw_safe_halt();                \
         |                 ^
   include/linux/irqflags.h:192:27: note: expanded from macro 'raw_safe_halt'
     192 | #define raw_safe_halt()                 arch_safe_halt()
         |                                         ^
>> drivers/cpufreq/longhaul.c:150:2: error: call to undeclared function 'halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     150 |         halt();
         |         ^
   drivers/cpufreq/longhaul.c:179:2: error: call to undeclared function 'arch_safe_halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     179 |         safe_halt();
         |         ^
   include/linux/irqflags.h:231:3: note: expanded from macro 'safe_halt'
     231 |                 raw_safe_halt();                \
         |                 ^
   include/linux/irqflags.h:192:27: note: expanded from macro 'raw_safe_halt'
     192 | #define raw_safe_halt()                 arch_safe_halt()
         |                                         ^
   drivers/cpufreq/longhaul.c:187:4: error: call to undeclared function 'halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     187 |                         halt();
         |                         ^
   drivers/cpufreq/longhaul.c:205:3: error: call to undeclared function 'halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     205 |                 halt();
         |                 ^
   drivers/cpufreq/longhaul.c:224:4: error: call to undeclared function 'halt'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     224 |                         halt();
         |                         ^
   drivers/cpufreq/longhaul.c:165:6: warning: variable 't' set but not used [-Wunused-but-set-variable]
     165 |         u32 t;
         |             ^

1 warning and 6 errors generated.

vim +/arch_safe_halt +145 drivers/cpufreq/longhaul.c

^1da177e4c3f41 arch/i386/kernel/cpu/cpufreq/longhaul.c Linus Torvalds 2005-04-16  134  
ac617bd0f7b959 arch/x86/kernel/cpu/cpufreq/longhaul.c  Dave Jones     2009-01-17  135  static void do_longhaul1(unsigned int mults_index)
^1da177e4c3f41 arch/i386/kernel/cpu/cpufreq/longhaul.c Linus Torvalds 2005-04-16  136  {
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  137  	union msr_bcr2 bcr2;
^1da177e4c3f41 arch/i386/kernel/cpu/cpufreq/longhaul.c Linus Torvalds 2005-04-16  138  
c435e608cf59ff drivers/cpufreq/longhaul.c              Ingo Molnar    2025-04-09  139  	rdmsrq(MSR_VIA_BCR2, bcr2.val);
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  140  	/* Enable software clock multiplier */
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  141  	bcr2.bits.ESOFTBF = 1;
ac617bd0f7b959 arch/x86/kernel/cpu/cpufreq/longhaul.c  Dave Jones     2009-01-17  142  	bcr2.bits.CLOCKMUL = mults_index & 0xff;
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  143  
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  144  	/* Sync to timer tick */
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03 @145  	safe_halt();
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  146  	/* Change frequency on next halt or sleep */
78255eb2397332 drivers/cpufreq/longhaul.c              Ingo Molnar    2025-04-09  147  	wrmsrq(MSR_VIA_BCR2, bcr2.val);
179da8e6e8903a arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-08-08  148  	/* Invoke transition */
179da8e6e8903a arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-08-08  149  	ACPI_FLUSH_CPU_CACHE();
179da8e6e8903a arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-08-08 @150  	halt();
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  151  
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  152  	/* Disable software clock multiplier */
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  153  	local_irq_disable();
c435e608cf59ff drivers/cpufreq/longhaul.c              Ingo Molnar    2025-04-09  154  	rdmsrq(MSR_VIA_BCR2, bcr2.val);
dadb49d8746bc4 arch/i386/kernel/cpu/cpufreq/longhaul.c Rafa� Bilski   2006-07-03  155  	bcr2.bits.ESOFTBF = 0;
78255eb2397332 drivers/cpufreq/longhaul.c              Ingo Molnar    2025-04-09  156  	wrmsrq(MSR_VIA_BCR2, bcr2.val);
^1da177e4c3f41 arch/i386/kernel/cpu/cpufreq/longhaul.c Linus Torvalds 2005-04-16  157  }
^1da177e4c3f41 arch/i386/kernel/cpu/cpufreq/longhaul.c Linus Torvalds 2005-04-16  158  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH v3 1/5] x86/paravirt: Replace io_delay() hook with a bool

In reply to Juergen Gross
kernel test robot noticed the following build errors:

Hi Juergen,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/master]
[also build test ERROR on next-20260115]
[cannot apply to kvm/queue kvm/next tip/x86/core kvm/linux-next tip/auto-latest linus/master v6.19-rc5] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Juergen-Gross/x86-paravirt-Replace-io_delay-hook-with-a-bool/20260115-165320
base:   tip/master
patch link:    https://lore.kernel.org/r/20260115084849.31502-2-jgross%40suse.com
patch subject: [PATCH v3 1/5] x86/paravirt: Replace io_delay() hook with a bool
config: x86_64-randconfig-006-20260115 (https://download.01.org/0day-ci/archive/20260115/[email protected]/config)
compiler: gcc-12 (Debian 12.4.0-5) 12.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260115/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

arch/x86/kernel/tboot.c: In function 'tboot_shutdown':

>> arch/x86/kernel/tboot.c:255:17: error: implicit declaration of function 'halt' [-Werror=implicit-function-declaration]
     255 |                 halt();
         |                 ^~~~

cc1: some warnings being treated as errors

vim +/halt +255 arch/x86/kernel/tboot.c

58c41d28259c24 H. Peter Anvin 2009-08-14  225  
3162534069597e Joseph Cihula  2009-06-30  226  void tboot_shutdown(u32 shutdown_type)
3162534069597e Joseph Cihula  2009-06-30  227  {
3162534069597e Joseph Cihula  2009-06-30  228  	void (*shutdown)(void);
3162534069597e Joseph Cihula  2009-06-30  229  
3162534069597e Joseph Cihula  2009-06-30  230  	if (!tboot_enabled())
3162534069597e Joseph Cihula  2009-06-30  231  		return;
3162534069597e Joseph Cihula  2009-06-30  232  
11520e5e7c1855 Linus Torvalds 2012-12-15  233  	/*
11520e5e7c1855 Linus Torvalds 2012-12-15  234  	 * if we're being called before the 1:1 mapping is set up then just
11520e5e7c1855 Linus Torvalds 2012-12-15  235  	 * return and let the normal shutdown happen; this should only be
11520e5e7c1855 Linus Torvalds 2012-12-15  236  	 * due to very early panic()
11520e5e7c1855 Linus Torvalds 2012-12-15  237  	 */
11520e5e7c1855 Linus Torvalds 2012-12-15  238  	if (!tboot_pg_dir)
11520e5e7c1855 Linus Torvalds 2012-12-15  239  		return;
11520e5e7c1855 Linus Torvalds 2012-12-15  240  
3162534069597e Joseph Cihula  2009-06-30  241  	/* if this is S3 then set regions to MAC */
3162534069597e Joseph Cihula  2009-06-30  242  	if (shutdown_type == TB_SHUTDOWN_S3)
58c41d28259c24 H. Peter Anvin 2009-08-14  243  		if (tboot_setup_sleep())
58c41d28259c24 H. Peter Anvin 2009-08-14  244  			return;
3162534069597e Joseph Cihula  2009-06-30  245  
3162534069597e Joseph Cihula  2009-06-30  246  	tboot->shutdown_type = shutdown_type;
3162534069597e Joseph Cihula  2009-06-30  247  
3162534069597e Joseph Cihula  2009-06-30  248  	switch_to_tboot_pt();
3162534069597e Joseph Cihula  2009-06-30  249  
3162534069597e Joseph Cihula  2009-06-30  250  	shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
3162534069597e Joseph Cihula  2009-06-30  251  	shutdown();
3162534069597e Joseph Cihula  2009-06-30  252  
3162534069597e Joseph Cihula  2009-06-30  253  	/* should not reach here */
3162534069597e Joseph Cihula  2009-06-30  254  	while (1)
3162534069597e Joseph Cihula  2009-06-30 @255  		halt();
3162534069597e Joseph Cihula  2009-06-30  256  }
3162534069597e Joseph Cihula  2009-06-30  257  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#4 lore raw

PATCH v3 2/5 block/floppy: Don't use REALLY_SLOW_IO for delays

In reply to Juergen Gross

Instead of defining REALLY_SLOW_IO before including io.h, add the required additional calls of native_io_delay() to the related functions in arch/x86/include/asm/floppy.h.

This will remove the last place where REALLY_SLOW_IO is being defined.

---
 arch/x86/include/asm/floppy.h | 27 ++++++++++++++++++++++-----
 drivers/block/floppy.c        |  2 --
 2 files changed, 22 insertions(+), 7 deletions(-)
arch/x86/include/asm/floppy.h +22 -5
index e7a244051c62..8d1e86687b98 100644
@@ -29,9 +29,6 @@
 #define CSW fd_routine[can_use_virtual_dma & 1]
 
 
-#define fd_inb(base, reg)		inb_p((base) + (reg))
-#define fd_outb(value, base, reg)	outb_p(value, (base) + (reg))
-
 #define fd_request_dma()	CSW._request_dma(FLOPPY_DMA, "floppy")
 #define fd_free_dma()		CSW._free_dma(FLOPPY_DMA)
 #define fd_enable_irq()		enable_irq(FLOPPY_IRQ)
@@ -49,6 +46,26 @@ static char *virtual_dma_addr;
 static int virtual_dma_mode;
 static int doing_pdma;
 
+static inline u8 fd_inb(u16 base, u16 reg)
+{
+	u8 ret = inb_p(base + reg);
+
+	native_io_delay();
+	native_io_delay();
+	native_io_delay();
+
+	return ret;
+}
+
+static inline void fd_outb(u8 value, u16 base, u16 reg)
+{
+	outb_p(value, base + reg);
+
+	native_io_delay();
+	native_io_delay();
+	native_io_delay();
+}
+
 static irqreturn_t floppy_hardint(int irq, void *dev_id)
 {
 	unsigned char st;
@@ -79,9 +96,9 @@ static irqreturn_t floppy_hardint(int irq, void *dev_id)
 			if (st != (STATUS_DMA | STATUS_READY))
 				break;
 			if (virtual_dma_mode)
-				outb_p(*lptr, virtual_dma_port + FD_DATA);
+				fd_outb(*lptr, virtual_dma_port, FD_DATA);
 			else
-				*lptr = inb_p(virtual_dma_port + FD_DATA);
+				*lptr = fd_inb(virtual_dma_port, FD_DATA);
 		}
 		virtual_dma_count = lcount;
 		virtual_dma_addr = lptr;
drivers/block/floppy.c +0 -2
index c28786e0fe1c..4422bc57a4f2 100644
@@ -145,8 +145,6 @@
  * Better audit of register_blkdev.
  */
 
-#define REALLY_SLOW_IO
-
 #define DEBUGT 2
 
 #define DPRINT(format, args...) \
Signature · 1 line
2.51.0
author maintainer
#5 lore raw

PATCH v3 3/5 x86/io: Remove REALLY_SLOW_IO handling

In reply to Juergen Gross

As there is no user of REALLY_SLOW_IO left, remove the related handling from arch/x86/include/asm/io.h.

---
 arch/x86/include/asm/io.h | 5 -----
 1 file changed, 5 deletions(-)
arch/x86/include/asm/io.h +0 -5
index 8a9292ce7d2d..843f23044754 100644
@@ -254,11 +254,6 @@ static inline void slow_down_io(void)
 		return;
 
 	native_io_delay();
-#ifdef REALLY_SLOW_IO
-	native_io_delay();
-	native_io_delay();
-	native_io_delay();
-#endif
 }
 
 #define BUILDIO(bwl, type)						\
Signature · 1 line
2.51.0
author maintainer
#6 lore raw

PATCH v3 4/5 x86/io_delay: Switch io_delay() default mechanism to "none"

In reply to Juergen Gross

The habit to delay some port operations via io_delay() is probably a no longer needed relict from i386 times.

Switch the default to no longer do delays for port operations. In case this is breaking some still supported hardware, the default can still be overwritten via boot parameter.

Remove the Kconfig options to select the default io_delay() mechanism. This makes io_delay_init() a nop, so it can be removed together with dmi_io_delay_0xed_port() and the associated io_delay_0xed_port_dmi_table().

---
V2:
- new patch (kind of suggested by Ingo Molnar)

---
 arch/x86/Kconfig.debug     | 30 --------------
 arch/x86/include/asm/io.h  |  1 -
 arch/x86/kernel/io_delay.c | 81 +-------------------------------------
 arch/x86/kernel/setup.c    |  2 -
 4 files changed, 1 insertion(+), 113 deletions(-)
arch/x86/Kconfig.debug +0 -30
index c95c3aaadf97..56888156a64b 100644
@@ -120,36 +120,6 @@ config X86_DECODER_SELFTEST
 	  decoder code.
 	  If unsure, say "N".
 
-choice
-	prompt "IO delay type"
-	default IO_DELAY_0X80
-
-config IO_DELAY_0X80
-	bool "port 0x80 based port-IO delay [recommended]"
-	help
-	  This is the traditional Linux IO delay used for in/out_p.
-	  It is the most tested hence safest selection here.
-
-config IO_DELAY_0XED
-	bool "port 0xed based port-IO delay"
-	help
-	  Use port 0xed as the IO delay. This frees up port 0x80 which is
-	  often used as a hardware-debug port.
-
-config IO_DELAY_UDELAY
-	bool "udelay based port-IO delay"
-	help
-	  Use udelay(2) as the IO delay method. This provides the delay
-	  while not having any side-effect on the IO port space.
-
-config IO_DELAY_NONE
-	bool "no port-IO delay"
-	help
-	  No port-IO delay. Will break on old boxes that require port-IO
-	  delay for certain operations. Should work on most new machines.
-
-endchoice
-
 config DEBUG_BOOT_PARAMS
 	bool "Debug boot parameters"
 	depends on DEBUG_KERNEL
arch/x86/include/asm/io.h +0 -1
index 843f23044754..d50d31023385 100644
@@ -240,7 +240,6 @@ static inline void __iowrite32_copy(void __iomem *to, const void *from,
 extern void native_io_delay(void);
 
 extern int io_delay_type;
-extern void io_delay_init(void);
 
 #if defined(CONFIG_PARAVIRT)
 #include <asm/paravirt-base.h>
arch/x86/kernel/io_delay.c +1 -80

105 lines not on this page · raw message

arch/x86/kernel/setup.c +0 -2
index 1b2edd07a3e1..8ef29c1ebb8d 100644
@@ -1176,8 +1176,6 @@ void __init setup_arch(char **cmdline_p)
 
 	vsmp_init();
 
-	io_delay_init();
-
 	early_platform_quirks();
 
 	/* Some platforms need the APIC registered for NUMA configuration */
Signature · 1 line
2.51.0
author maintainer
#7 lore raw

PATCH v3 5/5 x86/io_delay: Add config option for controlling build of io_delay.

In reply to Juergen Gross

Prepare phasing out support of io_delay() by adding a config option (default on for now) controlling the build of io_delay.c.

---
V2:
- new patch (kind of suggested by Ingo Molnar)

---
 arch/x86/Kconfig              | 8 ++++++++
 arch/x86/include/asm/floppy.h | 4 ++++
 arch/x86/include/asm/io.h     | 6 ++++++
 arch/x86/kernel/Makefile      | 3 ++-
 arch/x86/kernel/setup.c       | 2 ++
 5 files changed, 22 insertions(+), 1 deletion(-)
arch/x86/Kconfig +8 -0
index 62e11572da27..e93abd2ffeb9 100644
@@ -3169,6 +3169,14 @@ config HAVE_ATOMIC_IOMAP
 	def_bool y
 	depends on X86_32
 
+config IO_DELAY
+	bool "Support delay of I/O-port activities"
+	default y
+	help
+	  Include code allowing to delay I/O-port activities. This might be
+	  needed on some rather old hardware. The delay mechanism will still
+	  require to be selected via the "io_delay" boot parameter.
+
 source "arch/x86/kvm/Kconfig"
 
 source "arch/x86/Kconfig.cpufeatures"
arch/x86/include/asm/floppy.h +4 -0
index 8d1e86687b98..d7df95255761 100644
@@ -50,9 +50,11 @@ static inline u8 fd_inb(u16 base, u16 reg)
 {
 	u8 ret = inb_p(base + reg);
 
+#ifdef CONFIG_IO_DELAY
 	native_io_delay();
 	native_io_delay();
 	native_io_delay();
+#endif
 
 	return ret;
 }
@@ -61,9 +63,11 @@ static inline void fd_outb(u8 value, u16 base, u16 reg)
 {
 	outb_p(value, base + reg);
 
+#ifdef CONFIG_IO_DELAY
 	native_io_delay();
 	native_io_delay();
 	native_io_delay();
+#endif
 }
 
 static irqreturn_t floppy_hardint(int irq, void *dev_id)
arch/x86/include/asm/io.h +6 -0
index d50d31023385..4946f870bdb7 100644
@@ -237,6 +237,7 @@ static inline void __iowrite32_copy(void __iomem *to, const void *from,
 
 #endif /* __KERNEL__ */
 
+#ifdef CONFIG_IO_DELAY
 extern void native_io_delay(void);
 
 extern int io_delay_type;
@@ -254,6 +255,11 @@ static inline void slow_down_io(void)
 
 	native_io_delay();
 }
+#else
+static inline void slow_down_io(void)
+{
+}
+#endif
 
 #define BUILDIO(bwl, type)						\
 static inline void out##bwl##_p(type value, u16 port)			\
arch/x86/kernel/Makefile +2 -1
index e9aeeeafad17..879c1b7bf7c2 100644
@@ -66,11 +66,12 @@ obj-$(CONFIG_X86_32)	+= sys_ia32.o
 obj-$(CONFIG_IA32_EMULATION)	+= sys_ia32.o signal_32.o
 obj-$(CONFIG_X86_64)	+= sys_x86_64.o
 obj-$(CONFIG_X86_ESPFIX64)	+= espfix_64.o
+obj-$(CONFIG_IO_DELAY)	+= io_delay.o
 obj-$(CONFIG_SYSFS)	+= ksysfs.o
 obj-y			+= bootflag.o e820.o
 obj-y			+= pci-dma.o quirks.o kdebugfs.o
 obj-y			+= alternative.o i8253.o hw_breakpoint.o
-obj-y			+= tsc.o tsc_msr.o io_delay.o rtc.o
+obj-y			+= tsc.o tsc_msr.o rtc.o
 obj-y			+= resource.o
 obj-y			+= irqflags.o
 obj-y			+= static_call.o
arch/x86/kernel/setup.c +2 -0
index 8ef29c1ebb8d..a3fa38a23807 100644
@@ -183,6 +183,7 @@ static const struct ctl_table x86_sysctl_table[] = {
 		.mode		= 0444,
 		.proc_handler	= proc_dointvec,
 	},
+#ifdef CONFIG_IO_DELAY
 	{
 		.procname	= "io_delay_type",
 		.data		= &io_delay_type,
@@ -190,6 +191,7 @@ static const struct ctl_table x86_sysctl_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+#endif
 #if defined(CONFIG_ACPI_SLEEP)
 	{
 		.procname	= "acpi_video_flags",
Signature · 1 line
2.51.0