tree: https://gitee.com/openeuler/kernel.git OLK-6.6 head: b2b8512ca97108929f3aca5405875d91577b8c80 commit: 0f0c155e2bb76b55e447e83da0226561c7f397b1 [3075/3075] ub:ubus: Support device level and port level reset config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20251106/202511060146.GOM8mybD-lkp@i...) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251106/202511060146.GOM8mybD-lkp@i...) 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 <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202511060146.GOM8mybD-lkp@intel.com/ All warnings (new ones prefixed by >>):
drivers/ub/ubus/reset.c:33:5: warning: no previous prototype for function 'ub_elr' [-Wmissing-prototypes] 33 | int ub_elr(struct ub_entity *dev) | ^ drivers/ub/ubus/reset.c:33:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 33 | int ub_elr(struct ub_entity *dev) | ^ | static drivers/ub/ubus/reset.c:231:5: warning: no previous prototype for function 'ub_port_reset_check' [-Wmissing-prototypes] 231 | int ub_port_reset_check(struct ub_entity *dev, int port_id) | ^ drivers/ub/ubus/reset.c:231:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 231 | int ub_port_reset_check(struct ub_entity *dev, int port_id) | ^ | static drivers/ub/ubus/reset.c:277:5: warning: no previous prototype for function 'ub_port_reset' [-Wmissing-prototypes] 277 | int ub_port_reset(struct ub_entity *dev, int port_id) | ^ drivers/ub/ubus/reset.c:277:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 277 | int ub_port_reset(struct ub_entity *dev, int port_id) | ^ | static drivers/ub/ubus/reset.c:323:5: warning: no previous prototype for function 'ub_port_reset_function' [-Wmissing-prototypes] 323 | int ub_port_reset_function(struct ub_port *port) | ^ drivers/ub/ubus/reset.c:323:1: note: declare 'static' if the function is not intended to be used outside of this translation unit 323 | int ub_port_reset_function(struct ub_port *port) | ^ | static 4 warnings generated.
vim +/ub_elr +33 drivers/ub/ubus/reset.c 28 29 /** 30 * ub_elr - Initiate an UB entity level reset 31 * @dev: UB entity to reset 32 */
33 int ub_elr(struct ub_entity *dev) 34 { 35 u8 command; 36 u8 val = 0; 37 int ret; 38 39 /* enable ELR */ 40 command = 0x01; 41 ret = ub_cfg_write_byte(dev, UB_ELR, command); 42 if (ret) { 43 ub_err(dev, "dev elr failed, write byte error, ret=%d", ret); 44 return ret; 45 } 46 47 /* 48 * ub entity must complete an ELR within 100ms, 49 * but may silently discard requests while the ELR is in 50 * progress. Wait 100ms before trying to access the device. 51 */ 52 msleep(100); 53 54 ret = ub_cfg_read_byte(dev, UB_ELR_DONE, &val); 55 if (ret || !val) { 56 ub_err(dev, "dev elr failed, ret=%d, ELR_DONE=%u\n", ret, val); 57 return -EINVAL; 58 } 59 60 ub_info(dev, "dev elr success\n"); 61 62 return 0; 63 } 64 65 /** 66 * ub_device_reset - Initiate a UB entity reset 67 * @ent: UB entity. 68 */ 69 int ub_device_reset(struct ub_entity *ent) 70 { 71 u16 command; 72 int ret; 73 74 if (!ent) { 75 pr_err("device which will be reset is NULL\n"); 76 return -EINVAL; 77 } 78 79 if (is_ibus_controller(ent)) { 80 ub_warn(ent, "ub bus controller do not support reset.\n"); 81 return -EINVAL; 82 } 83 84 /* device reset only support Entity0 */ 85 if (ent->entity_idx) { 86 ub_err(ent, "device is not entity0, entity_idx=%u\n", ent->entity_idx); 87 return -EINVAL; 88 } 89 90 device_lock(&ent->dev); 91 92 /* enable device reset */ 93 command = 0x01; 94 ret = ub_send_cfg(ent, (u8)sizeof(u16), UB_ENTITY_RST, (u32 *)&command); 95 if (ret) { 96 ub_err(ent, "device reset failed, ret=%d\n", ret); 97 device_unlock(&ent->dev); 98 return -EIO; 99 } 100 101 device_unlock(&ent->dev); 102 ub_info(ent, "device reset success\n"); 103 104 return 0; 105 } 106 EXPORT_SYMBOL_GPL(ub_device_reset); 107 108 static void ub_save_token_state(struct ub_entity *dev) 109 { 110 int ret; 111 int i; 112 113 for (i = DEV_TOKEN_ID; i <= DEV_TOKEN_ID; i++) { 114 ret = ub_cfg_read_dword(dev, saved_cfg_offset[i], 115 &dev->saved_config_space[i]); 116 if (ret) { 117 ub_err(dev, "ub cfg read dword failed, save cfg offset: %#x.\n", 118 saved_cfg_offset[i]); 119 continue; 120 } 121 ub_info(dev, "saving config space at address %#x (reading %#x)\n", 122 saved_cfg_offset[i], dev->saved_config_space[i]); 123 } 124 } 125 126 static int ub_save_state(struct ub_entity *dev) 127 { 128 const struct ub_error_handlers *err_handler = 129 dev->driver ? dev->driver->err_handler : NULL; 130 131 if (err_handler && err_handler->ub_reset_prepare) 132 err_handler->ub_reset_prepare(dev); 133 134 ub_save_token_state(dev); 135 136 dev->state_saved = true; 137 138 return 0; 139 } 140 141 static void ub_restore_config_dword(struct ub_entity *dev, u32 pos, u32 saved_val) 142 { 143 int retry = 10; 144 u32 val; 145 int ret; 146 147 ret = ub_cfg_read_dword(dev, pos, &val); 148 if (ret || val == saved_val) 149 return; 150 while (retry-- > 0) { 151 ub_info(dev, "restoring config space at address %#x (was %#x, writing %#x)\n", 152 pos, val, saved_val); 153 ub_cfg_write_dword(dev, pos, saved_val); 154 155 if (ub_cfg_read_dword(dev, pos, &val)) 156 continue; 157 158 if (val == saved_val) 159 return; 160 161 #define RESTORE_RETRY_SLEEP_MS 1 162 msleep(RESTORE_RETRY_SLEEP_MS); 163 } 164 } 165 166 static void ub_restore_state(struct ub_entity *dev) 167 { 168 const struct ub_error_handlers *err_handler = 169 dev->driver ? dev->driver->err_handler : NULL; 170 int i; 171 172 if (!dev->state_saved) 173 return; 174 175 for (i = DEV_TOKEN_ID; i <= DEV_TOKEN_ID; i++) { 176 ub_restore_config_dword(dev, saved_cfg_offset[i], 177 dev->saved_config_space[i]); 178 } 179 180 dev->state_saved = false; 181 182 if (err_handler && err_handler->ub_reset_done) 183 err_handler->ub_reset_done(dev); 184 } 185 186 static int ub_reset_check(struct ub_entity *dev) 187 { 188 if (is_ibus_controller(dev)) { 189 ub_err(dev, "UB Bus Controller does not support ELR!\n"); 190 return -EINVAL; 191 } 192 193 if (!dev->reset_fn) 194 return -ENOTTY; 195 196 return 0; 197 } 198 199 int ub_reset_entity(struct ub_entity *dev) 200 { 201 int ret, rc; 202 203 if (!dev) { 204 pr_err("device is NULL\n"); 205 return -EINVAL; 206 } 207 208 rc = ub_reset_check(dev); 209 if (rc) 210 return rc; 211 212 if (!device_trylock(&dev->dev)) 213 return -EBUSY; 214 215 ret = ub_save_state(dev); 216 if (ret) { 217 device_unlock(&dev->dev); 218 return ret; 219 } 220 221 rc = ub_elr(dev); 222 223 ub_restore_state(dev); 224 225 device_unlock(&dev->dev); 226 227 return rc; 228 } 229 EXPORT_SYMBOL_GPL(ub_reset_entity); 230 231 int ub_port_reset_check(struct ub_entity *dev, int port_id) 232 { 233 struct ub_port *port = NULL; 234 235 if (!dev) 236 return -EINVAL; 237 238 if (is_idev(dev)) { 239 ub_err(dev, "IDEV does not support port reset!\n"); 240 return -EINVAL; 241 } 242 243 if (port_id >= dev->port_nums) { 244 ub_err(dev, "Can't reset port because port(%d) is over port_nums(%u)!\n", 245 port_id, dev->port_nums); 246 return -EINVAL; 247 } 248 249 port = dev->ports + port_id; 250 251 if (port->type == VIRTUAL) { 252 ub_err(dev, "vport reset is not supported now!\n"); 253 return -EINVAL; 254 } 255 256 return 0; 257 } 258
-- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki