CC: [email protected] CC: [email protected] BCC: [email protected] CC: [email protected] TO: John Ogness <[email protected]> CC: Sebastian Andrzej Siewior <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-5.18.y-rt-rebase head: 09785bc060d1469b0991de26d21a7fd67ca3532c commit: 4a3bd8aca2d6d6c09ea11aafa780e6b68d76fc2d [17/78] serial: 8250: implement write_atomic :::::: branch date: 2 days ago :::::: commit date: 2 days ago config: x86_64-randconfig-c007 (https://download.01.org/0day-ci/archive/20220501/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 400775649969b9baf3bc2a510266e7912bb16ae9) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git/commit/?id=4a3bd8aca2d6d6c09ea11aafa780e6b68d76fc2d git remote add rt-devel https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git git fetch --no-tags rt-devel linux-5.18.y-rt-rebase git checkout 4a3bd8aca2d6d6c09ea11aafa780e6b68d76fc2d # save the config file COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) drivers/tty/serial/8250/8250_port.c:3225:6: note: Assuming field 'iotype' is equal to field 'cur_iotype' if (port->iotype != up->cur_iotype) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3225:2: note: Taking false branch if (port->iotype != up->cur_iotype) ^ drivers/tty/serial/8250/8250_port.c:3228:6: note: Assuming the condition is false if (flags & UART_CONFIG_TYPE) ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3228:2: note: Taking false branch if (flags & UART_CONFIG_TYPE) ^ drivers/tty/serial/8250/8250_port.c:3231:6: note: Assuming the condition is false if (port->rs485.flags & SER_RS485_ENABLED) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3231:2: note: Taking false branch if (port->rs485.flags & SER_RS485_ENABLED) ^ drivers/tty/serial/8250/8250_port.c:3235:6: note: Assuming field 'type' is not equal to PORT_16550A if (port->type == PORT_16550A && port->iotype == UPIO_AU) ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3235:32: note: Left side of '&&' is false if (port->type == PORT_16550A && port->iotype == UPIO_AU) ^ drivers/tty/serial/8250/8250_port.c:3239:6: note: Assuming field 'type' is not equal to PORT_TEGRA if (port->type == PORT_TEGRA) ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3239:2: note: Taking false branch if (port->type == PORT_TEGRA) ^ drivers/tty/serial/8250/8250_port.c:3242:6: note: Assuming field 'type' is not equal to PORT_UNKNOWN if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3242:6: note: Left side of '&&' is true drivers/tty/serial/8250/8250_port.c:3242:36: note: Assuming the condition is true if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) ^~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:3242:2: note: Taking true branch if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) ^ drivers/tty/serial/8250/8250_port.c:3243:3: note: Calling 'autoconfig_irq' autoconfig_irq(up); ^~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:1414:6: note: Assuming the condition is true if (port->flags & UPF_FOURPORT) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:1414:2: note: Taking true branch if (port->flags & UPF_FOURPORT) { ^ drivers/tty/serial/8250/8250_port.c:1416:14: note: Calling 'inb_p' save_ICP = inb_p(ICP); ^ arch/x86/include/asm/io.h:325:15: note: expanded from macro 'inb_p' #define inb_p inb_p ^ arch/x86/include/asm/io.h:318:1: note: Calling 'slow_down_io' BUILDIO(b, b, char) ^ arch/x86/include/asm/io.h:282:2: note: expanded from macro 'BUILDIO' slow_down_io(); \ ^~~~~~~~~~~~~~ arch/x86/include/asm/paravirt.h:55:2: note: Assigned value is garbage or undefined PVOP_VCALL0(cpu.io_delay); ^ arch/x86/include/asm/paravirt_types.h:511:2: note: expanded from macro 'PVOP_VCALL0' __PVOP_VCALL(op) ^~~~~~~~~~~~~~~~ arch/x86/include/asm/paravirt_types.h:491:8: note: expanded from macro '__PVOP_VCALL' (void)____PVOP_CALL(, op, CLBR_ANY, PVOP_VCALL_CLOBBERS, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/include/asm/paravirt_types.h:446:3: note: expanded from macro '____PVOP_CALL' PVOP_CALL_ARGS; \ ^~~~~~~~~~~~~~ arch/x86/include/asm/paravirt_types.h:404:16: note: expanded from macro 'PVOP_CALL_ARGS' unsigned long __edi = __edi, __esi = __esi, \ ^ ~~~~~ drivers/tty/serial/8250/8250_port.c:695:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(rs485->padding, 0, sizeof(rs485->padding)); ^ include/linux/fortify-string.h:272:25: note: expanded from macro 'memset' #define memset(p, c, s) __fortify_memset_chk(p, c, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk' __underlying_memset(p, c, __fortify_size); \ ^~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset' #define __underlying_memset __builtin_memset ^~~~~~~~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:695:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(rs485->padding, 0, sizeof(rs485->padding)); ^ include/linux/fortify-string.h:272:25: note: expanded from macro 'memset' #define memset(p, c, s) __fortify_memset_chk(p, c, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk' __underlying_memset(p, c, __fortify_size); \ ^~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset' #define __underlying_memset __builtin_memset ^~~~~~~~~~~~~~~~ >> drivers/tty/serial/8250/8250_port.c:1047:20: warning: Value stored to 'port' >> during its initialization is never read [clang-analyzer-deadcode.DeadStores] struct uart_port *port = &up->port; ^~~~ ~~~~~~~~~ drivers/tty/serial/8250/8250_port.c:1047:20: note: Value stored to 'port' during its initialization is never read struct uart_port *port = &up->port; ^~~~ ~~~~~~~~~ Suppressed 37 warnings (37 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 27 warnings generated. fs/dlm/lockspace.c:75:9: warning: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id); ^~~~~~~~ fs/dlm/lockspace.c:75:9: note: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id); ^~~~~~~~ fs/dlm/lockspace.c:89:9: warning: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] return snprintf(buf, PAGE_SIZE, "%u\n", dlm_no_directory(ls)); ^~~~~~~~ fs/dlm/lockspace.c:89:9: note: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 return snprintf(buf, PAGE_SIZE, "%u\n", dlm_no_directory(ls)); ^~~~~~~~ fs/dlm/lockspace.c:107:9: warning: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] return snprintf(buf, PAGE_SIZE, "%x\n", status); ^~~~~~~~ fs/dlm/lockspace.c:107:9: note: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 return snprintf(buf, PAGE_SIZE, "%x\n", status); ^~~~~~~~ fs/dlm/lockspace.c:112:9: warning: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid); ^~~~~~~~ fs/dlm/lockspace.c:112:9: note: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid); ^~~~~~~~ fs/dlm/lockspace.c:480:2: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memcpy(ls->ls_name, name, namelen); ^ include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy' #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:362:2: note: expanded from macro '__fortify_memcpy_chk' __underlying_##op(p, q, __fortify_size); \ ^~~~~~~~~~~~~~~~~ note: expanded from here include/linux/fortify-string.h:45:29: note: expanded from macro '__underlying_memcpy' #define __underlying_memcpy __builtin_memcpy ^~~~~~~~~~~~~~~~ fs/dlm/lockspace.c:480:2: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 memcpy(ls->ls_name, name, namelen); ^ include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy' #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:362:2: note: expanded from macro '__fortify_memcpy_chk' __underlying_##op(p, q, __fortify_size); \ ^~~~~~~~~~~~~~~~~ note: expanded from here include/linux/fortify-string.h:45:29: note: expanded from macro '__underlying_memcpy' #define __underlying_memcpy __builtin_memcpy ^~~~~~~~~~~~~~~~ fs/dlm/lockspace.c:543:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(&ls->ls_stub_rsb, 0, sizeof(struct dlm_rsb)); ^ include/linux/fortify-string.h:272:25: note: expanded from macro 'memset' #define memset(p, c, s) __fortify_memset_chk(p, c, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk' __underlying_memset(p, c, __fortify_size); \ ^~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset' #define __underlying_memset __builtin_memset ^~~~~~~~~~~~~~~~ fs/dlm/lockspace.c:543:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(&ls->ls_stub_rsb, 0, sizeof(struct dlm_rsb)); ^ include/linux/fortify-string.h:272:25: note: expanded from macro 'memset' #define memset(p, c, s) __fortify_memset_chk(p, c, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:265:2: note: expanded from macro '__fortify_memset_chk' __underlying_memset(p, c, __fortify_size); \ ^~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:47:29: note: expanded from macro '__underlying_memset' #define __underlying_memset __builtin_memset ^~~~~~~~~~~~~~~~ Suppressed 21 warnings (21 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 22 warnings generated. arch/x86/crypto/cast6_avx_glue.c:53:2: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] CBC_ENC_BLOCK(__cast6_encrypt); ^ arch/x86/crypto/ecb_cbc_helpers.h:52:2: note: expanded from macro 'CBC_ENC_BLOCK' memcpy(walk.iv, __iv, __bsize); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:369:26: note: expanded from macro 'memcpy' #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/fortify-string.h:362:2: note: expanded from macro '__fortify_memcpy_chk' __underlying_##op(p, q, __fortify_size); \ ^~~~~~~~~~~~~~~~~ note: expanded from here include/linux/fortify-string.h:45:29: note: expanded from macro '__underlying_memcpy' #define __underlying_memcpy __builtin_memcpy vim +/port +1047 drivers/tty/serial/8250/8250_port.c b6830f6df8914f Peter Hurley 2015-06-27 1038 b6830f6df8914f Peter Hurley 2015-06-27 1039 /* b6830f6df8914f Peter Hurley 2015-06-27 1040 * We know that the chip has FIFOs. Does it have an EFR? The b6830f6df8914f Peter Hurley 2015-06-27 1041 * EFR is located in the same register position as the IIR and b6830f6df8914f Peter Hurley 2015-06-27 1042 * we know the top two bits of the IIR are currently set. The b6830f6df8914f Peter Hurley 2015-06-27 1043 * EFR should contain zero. Try to read the EFR. b6830f6df8914f Peter Hurley 2015-06-27 1044 */ b6830f6df8914f Peter Hurley 2015-06-27 1045 static void autoconfig_16550a(struct uart_8250_port *up) b6830f6df8914f Peter Hurley 2015-06-27 1046 { 4a3bd8aca2d6d6 John Ogness 2022-02-04 @1047 struct uart_port *port = &up->port; b6830f6df8914f Peter Hurley 2015-06-27 1048 unsigned char status1, status2; b6830f6df8914f Peter Hurley 2015-06-27 1049 unsigned int iersave; 4a3bd8aca2d6d6 John Ogness 2022-02-04 1050 unsigned long flags; 4a3bd8aca2d6d6 John Ogness 2022-02-04 1051 bool is_console; b6830f6df8914f Peter Hurley 2015-06-27 1052 b6830f6df8914f Peter Hurley 2015-06-27 1053 up->port.type = PORT_16550A; b6830f6df8914f Peter Hurley 2015-06-27 1054 up->capabilities |= UART_CAP_FIFO; b6830f6df8914f Peter Hurley 2015-06-27 1055 dc56ecb81a0aa4 Josh Triplett 2020-01-10 1056 if (!IS_ENABLED(CONFIG_SERIAL_8250_16550A_VARIANTS)) dc56ecb81a0aa4 Josh Triplett 2020-01-10 1057 return; dc56ecb81a0aa4 Josh Triplett 2020-01-10 1058 b6830f6df8914f Peter Hurley 2015-06-27 1059 /* b6830f6df8914f Peter Hurley 2015-06-27 1060 * Check for presence of the EFR when DLAB is set. b6830f6df8914f Peter Hurley 2015-06-27 1061 * Only ST16C650V1 UARTs pass this test. b6830f6df8914f Peter Hurley 2015-06-27 1062 */ b6830f6df8914f Peter Hurley 2015-06-27 1063 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); b6830f6df8914f Peter Hurley 2015-06-27 1064 if (serial_in(up, UART_EFR) == 0) { b6830f6df8914f Peter Hurley 2015-06-27 1065 serial_out(up, UART_EFR, 0xA8); b6830f6df8914f Peter Hurley 2015-06-27 1066 if (serial_in(up, UART_EFR) != 0) { b6830f6df8914f Peter Hurley 2015-06-27 1067 DEBUG_AUTOCONF("EFRv1 "); b6830f6df8914f Peter Hurley 2015-06-27 1068 up->port.type = PORT_16650; b6830f6df8914f Peter Hurley 2015-06-27 1069 up->capabilities |= UART_CAP_EFR | UART_CAP_SLEEP; b6830f6df8914f Peter Hurley 2015-06-27 1070 } else { b6830f6df8914f Peter Hurley 2015-06-27 1071 serial_out(up, UART_LCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1072 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | b6830f6df8914f Peter Hurley 2015-06-27 1073 UART_FCR7_64BYTE); b6830f6df8914f Peter Hurley 2015-06-27 1074 status1 = serial_in(up, UART_IIR) >> 5; b6830f6df8914f Peter Hurley 2015-06-27 1075 serial_out(up, UART_FCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1076 serial_out(up, UART_LCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1077 b6830f6df8914f Peter Hurley 2015-06-27 1078 if (status1 == 7) b6830f6df8914f Peter Hurley 2015-06-27 1079 up->port.type = PORT_16550A_FSL64; b6830f6df8914f Peter Hurley 2015-06-27 1080 else b6830f6df8914f Peter Hurley 2015-06-27 1081 DEBUG_AUTOCONF("Motorola 8xxx DUART "); b6830f6df8914f Peter Hurley 2015-06-27 1082 } b6830f6df8914f Peter Hurley 2015-06-27 1083 serial_out(up, UART_EFR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1084 return; b6830f6df8914f Peter Hurley 2015-06-27 1085 } b6830f6df8914f Peter Hurley 2015-06-27 1086 b6830f6df8914f Peter Hurley 2015-06-27 1087 /* b6830f6df8914f Peter Hurley 2015-06-27 1088 * Maybe it requires 0xbf to be written to the LCR. b6830f6df8914f Peter Hurley 2015-06-27 1089 * (other ST16C650V2 UARTs, TI16C752A, etc) b6830f6df8914f Peter Hurley 2015-06-27 1090 */ b6830f6df8914f Peter Hurley 2015-06-27 1091 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); b6830f6df8914f Peter Hurley 2015-06-27 1092 if (serial_in(up, UART_EFR) == 0 && !broken_efr(up)) { b6830f6df8914f Peter Hurley 2015-06-27 1093 DEBUG_AUTOCONF("EFRv2 "); b6830f6df8914f Peter Hurley 2015-06-27 1094 autoconfig_has_efr(up); b6830f6df8914f Peter Hurley 2015-06-27 1095 return; b6830f6df8914f Peter Hurley 2015-06-27 1096 } b6830f6df8914f Peter Hurley 2015-06-27 1097 b6830f6df8914f Peter Hurley 2015-06-27 1098 /* b6830f6df8914f Peter Hurley 2015-06-27 1099 * Check for a National Semiconductor SuperIO chip. b6830f6df8914f Peter Hurley 2015-06-27 1100 * Attempt to switch to bank 2, read the value of the LOOP bit b6830f6df8914f Peter Hurley 2015-06-27 1101 * from EXCR1. Switch back to bank 0, change it in MCR. Then b6830f6df8914f Peter Hurley 2015-06-27 1102 * switch back to bank 2, read it from EXCR1 again and check b6830f6df8914f Peter Hurley 2015-06-27 1103 * it's changed. If so, set baud_base in EXCR2 to 921600. -- dwmw2 b6830f6df8914f Peter Hurley 2015-06-27 1104 */ b6830f6df8914f Peter Hurley 2015-06-27 1105 serial_out(up, UART_LCR, 0); 36fd95b17e9c1c Yegor Yefremov 2016-05-31 1106 status1 = serial8250_in_MCR(up); b6830f6df8914f Peter Hurley 2015-06-27 1107 serial_out(up, UART_LCR, 0xE0); b6830f6df8914f Peter Hurley 2015-06-27 1108 status2 = serial_in(up, 0x02); /* EXCR1 */ b6830f6df8914f Peter Hurley 2015-06-27 1109 b6830f6df8914f Peter Hurley 2015-06-27 1110 if (!((status2 ^ status1) & UART_MCR_LOOP)) { b6830f6df8914f Peter Hurley 2015-06-27 1111 serial_out(up, UART_LCR, 0); 36fd95b17e9c1c Yegor Yefremov 2016-05-31 1112 serial8250_out_MCR(up, status1 ^ UART_MCR_LOOP); b6830f6df8914f Peter Hurley 2015-06-27 1113 serial_out(up, UART_LCR, 0xE0); b6830f6df8914f Peter Hurley 2015-06-27 1114 status2 = serial_in(up, 0x02); /* EXCR1 */ b6830f6df8914f Peter Hurley 2015-06-27 1115 serial_out(up, UART_LCR, 0); 36fd95b17e9c1c Yegor Yefremov 2016-05-31 1116 serial8250_out_MCR(up, status1); b6830f6df8914f Peter Hurley 2015-06-27 1117 b6830f6df8914f Peter Hurley 2015-06-27 1118 if ((status2 ^ status1) & UART_MCR_LOOP) { b6830f6df8914f Peter Hurley 2015-06-27 1119 unsigned short quot; b6830f6df8914f Peter Hurley 2015-06-27 1120 b6830f6df8914f Peter Hurley 2015-06-27 1121 serial_out(up, UART_LCR, 0xE0); b6830f6df8914f Peter Hurley 2015-06-27 1122 b6830f6df8914f Peter Hurley 2015-06-27 1123 quot = serial_dl_read(up); b6830f6df8914f Peter Hurley 2015-06-27 1124 quot <<= 3; b6830f6df8914f Peter Hurley 2015-06-27 1125 b6830f6df8914f Peter Hurley 2015-06-27 1126 if (ns16550a_goto_highspeed(up)) b6830f6df8914f Peter Hurley 2015-06-27 1127 serial_dl_write(up, quot); b6830f6df8914f Peter Hurley 2015-06-27 1128 b6830f6df8914f Peter Hurley 2015-06-27 1129 serial_out(up, UART_LCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1130 b6830f6df8914f Peter Hurley 2015-06-27 1131 up->port.uartclk = 921600*16; b6830f6df8914f Peter Hurley 2015-06-27 1132 up->port.type = PORT_NS16550A; b6830f6df8914f Peter Hurley 2015-06-27 1133 up->capabilities |= UART_NATSEMI; b6830f6df8914f Peter Hurley 2015-06-27 1134 return; b6830f6df8914f Peter Hurley 2015-06-27 1135 } b6830f6df8914f Peter Hurley 2015-06-27 1136 } b6830f6df8914f Peter Hurley 2015-06-27 1137 b6830f6df8914f Peter Hurley 2015-06-27 1138 /* b6830f6df8914f Peter Hurley 2015-06-27 1139 * No EFR. Try to detect a TI16750, which only sets bit 5 of b6830f6df8914f Peter Hurley 2015-06-27 1140 * the IIR when 64 byte FIFO mode is enabled when DLAB is set. b6830f6df8914f Peter Hurley 2015-06-27 1141 * Try setting it with and without DLAB set. Cheap clones b6830f6df8914f Peter Hurley 2015-06-27 1142 * set bit 5 without DLAB set. b6830f6df8914f Peter Hurley 2015-06-27 1143 */ b6830f6df8914f Peter Hurley 2015-06-27 1144 serial_out(up, UART_LCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1145 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); b6830f6df8914f Peter Hurley 2015-06-27 1146 status1 = serial_in(up, UART_IIR) >> 5; b6830f6df8914f Peter Hurley 2015-06-27 1147 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); b6830f6df8914f Peter Hurley 2015-06-27 1148 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); b6830f6df8914f Peter Hurley 2015-06-27 1149 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE); b6830f6df8914f Peter Hurley 2015-06-27 1150 status2 = serial_in(up, UART_IIR) >> 5; b6830f6df8914f Peter Hurley 2015-06-27 1151 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); b6830f6df8914f Peter Hurley 2015-06-27 1152 serial_out(up, UART_LCR, 0); b6830f6df8914f Peter Hurley 2015-06-27 1153 b6830f6df8914f Peter Hurley 2015-06-27 1154 DEBUG_AUTOCONF("iir1=%d iir2=%d ", status1, status2); b6830f6df8914f Peter Hurley 2015-06-27 1155 b6830f6df8914f Peter Hurley 2015-06-27 1156 if (status1 == 6 && status2 == 7) { b6830f6df8914f Peter Hurley 2015-06-27 1157 up->port.type = PORT_16750; b6830f6df8914f Peter Hurley 2015-06-27 1158 up->capabilities |= UART_CAP_AFE | UART_CAP_SLEEP; b6830f6df8914f Peter Hurley 2015-06-27 1159 return; b6830f6df8914f Peter Hurley 2015-06-27 1160 } b6830f6df8914f Peter Hurley 2015-06-27 1161 4a3bd8aca2d6d6 John Ogness 2022-02-04 1162 is_console = uart_console(port); 4a3bd8aca2d6d6 John Ogness 2022-02-04 1163 4a3bd8aca2d6d6 John Ogness 2022-02-04 1164 if (is_console) 4a3bd8aca2d6d6 John Ogness 2022-02-04 1165 printk_cpu_sync_get_irqsave(flags); 4a3bd8aca2d6d6 John Ogness 2022-02-04 1166 b6830f6df8914f Peter Hurley 2015-06-27 1167 /* b6830f6df8914f Peter Hurley 2015-06-27 1168 * Try writing and reading the UART_IER_UUE bit (b6). b6830f6df8914f Peter Hurley 2015-06-27 1169 * If it works, this is probably one of the Xscale platform's b6830f6df8914f Peter Hurley 2015-06-27 1170 * internal UARTs. b6830f6df8914f Peter Hurley 2015-06-27 1171 * We're going to explicitly set the UUE bit to 0 before b6830f6df8914f Peter Hurley 2015-06-27 1172 * trying to write and read a 1 just to make sure it's not b6830f6df8914f Peter Hurley 2015-06-27 1173 * already a 1 and maybe locked there before we even start start. b6830f6df8914f Peter Hurley 2015-06-27 1174 */ b6830f6df8914f Peter Hurley 2015-06-27 1175 iersave = serial_in(up, UART_IER); b6830f6df8914f Peter Hurley 2015-06-27 1176 serial_out(up, UART_IER, iersave & ~UART_IER_UUE); b6830f6df8914f Peter Hurley 2015-06-27 1177 if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { b6830f6df8914f Peter Hurley 2015-06-27 1178 /* b6830f6df8914f Peter Hurley 2015-06-27 1179 * OK it's in a known zero state, try writing and reading b6830f6df8914f Peter Hurley 2015-06-27 1180 * without disturbing the current state of the other bits. b6830f6df8914f Peter Hurley 2015-06-27 1181 */ b6830f6df8914f Peter Hurley 2015-06-27 1182 serial_out(up, UART_IER, iersave | UART_IER_UUE); b6830f6df8914f Peter Hurley 2015-06-27 1183 if (serial_in(up, UART_IER) & UART_IER_UUE) { b6830f6df8914f Peter Hurley 2015-06-27 1184 /* b6830f6df8914f Peter Hurley 2015-06-27 1185 * It's an Xscale. b6830f6df8914f Peter Hurley 2015-06-27 1186 * We'll leave the UART_IER_UUE bit set to 1 (enabled). b6830f6df8914f Peter Hurley 2015-06-27 1187 */ b6830f6df8914f Peter Hurley 2015-06-27 1188 DEBUG_AUTOCONF("Xscale "); b6830f6df8914f Peter Hurley 2015-06-27 1189 up->port.type = PORT_XSCALE; b6830f6df8914f Peter Hurley 2015-06-27 1190 up->capabilities |= UART_CAP_UUE | UART_CAP_RTOIE; b6830f6df8914f Peter Hurley 2015-06-27 1191 return; b6830f6df8914f Peter Hurley 2015-06-27 1192 } b6830f6df8914f Peter Hurley 2015-06-27 1193 } else { b6830f6df8914f Peter Hurley 2015-06-27 1194 /* b6830f6df8914f Peter Hurley 2015-06-27 1195 * If we got here we couldn't force the IER_UUE bit to 0. b6830f6df8914f Peter Hurley 2015-06-27 1196 * Log it and continue. b6830f6df8914f Peter Hurley 2015-06-27 1197 */ b6830f6df8914f Peter Hurley 2015-06-27 1198 DEBUG_AUTOCONF("Couldn't force IER_UUE to 0 "); b6830f6df8914f Peter Hurley 2015-06-27 1199 } b6830f6df8914f Peter Hurley 2015-06-27 1200 serial_out(up, UART_IER, iersave); b6830f6df8914f Peter Hurley 2015-06-27 1201 4a3bd8aca2d6d6 John Ogness 2022-02-04 1202 if (is_console) 4a3bd8aca2d6d6 John Ogness 2022-02-04 1203 printk_cpu_sync_put_irqrestore(flags); 4a3bd8aca2d6d6 John Ogness 2022-02-04 1204 b6830f6df8914f Peter Hurley 2015-06-27 1205 /* b6830f6df8914f Peter Hurley 2015-06-27 1206 * We distinguish between 16550A and U6 16550A by counting b6830f6df8914f Peter Hurley 2015-06-27 1207 * how many bytes are in the FIFO. b6830f6df8914f Peter Hurley 2015-06-27 1208 */ b6830f6df8914f Peter Hurley 2015-06-27 1209 if (up->port.type == PORT_16550A && size_fifo(up) == 64) { b6830f6df8914f Peter Hurley 2015-06-27 1210 up->port.type = PORT_U6_16550A; b6830f6df8914f Peter Hurley 2015-06-27 1211 up->capabilities |= UART_CAP_AFE; b6830f6df8914f Peter Hurley 2015-06-27 1212 } b6830f6df8914f Peter Hurley 2015-06-27 1213 } b6830f6df8914f Peter Hurley 2015-06-27 1214 -- 0-DAY CI Kernel Test Service https://01.org/lkp _______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
