Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bus: fsl-mc: add autorescan sysfs

Add the autorescan sysfs in order to enable/disable the DPRC IRQs on
which automatic rescan of the bus is performed. This is important when
dynamic creation of objects is needed to happen in a timely manner because
object creation can be bundled together.

Acked-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Link: https://lore.kernel.org/r/20210114170752.2927915-6-ciorneiioana@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ioana Ciornei and committed by
Greg Kroah-Hartman
296c6264 3f609943

+85 -2
+10
Documentation/ABI/stable/sysfs-bus-fsl-mc
··· 7 7 synchronize the objects under fsl-mc bus and the 8 8 Management Complex firmware. 9 9 Users: Userspace drivers and management tools 10 + 11 + What: /sys/bus/fsl-mc/autorescan 12 + Date: January 2021 13 + KernelVersion: 5.12 14 + Contact: Ioana Ciornei <ioana.ciornei@nxp.com> 15 + Description: Writing a zero value to this attribute will 16 + disable the DPRC IRQs on which automatic rescan 17 + of the fsl-mc bus is performed. A non-zero value 18 + will enable the DPRC IRQs. 19 + Users: Userspace drivers and management tools
+15 -2
drivers/bus/fsl-mc/dprc-driver.c
··· 458 458 /* 459 459 * Disable and clear interrupt for a given DPRC object 460 460 */ 461 - static int disable_dprc_irq(struct fsl_mc_device *mc_dev) 461 + int disable_dprc_irq(struct fsl_mc_device *mc_dev) 462 462 { 463 + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); 463 464 int error; 464 465 struct fsl_mc_io *mc_io = mc_dev->mc_io; 465 466 ··· 497 496 return error; 498 497 } 499 498 499 + mc_bus->irq_enabled = 0; 500 + 500 501 return 0; 502 + } 503 + 504 + int get_dprc_irq_state(struct fsl_mc_device *mc_dev) 505 + { 506 + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); 507 + 508 + return mc_bus->irq_enabled; 501 509 } 502 510 503 511 static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev) ··· 535 525 return 0; 536 526 } 537 527 538 - static int enable_dprc_irq(struct fsl_mc_device *mc_dev) 528 + int enable_dprc_irq(struct fsl_mc_device *mc_dev) 539 529 { 530 + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); 540 531 int error; 541 532 542 533 /* ··· 564 553 565 554 return error; 566 555 } 556 + 557 + mc_bus->irq_enabled = 1; 567 558 568 559 return 0; 569 560 }
+55
drivers/bus/fsl-mc/fsl-mc-bus.c
··· 241 241 } 242 242 static BUS_ATTR_WO(rescan); 243 243 244 + static int fsl_mc_bus_set_autorescan(struct device *dev, void *data) 245 + { 246 + struct fsl_mc_device *root_mc_dev; 247 + unsigned long val; 248 + char *buf = data; 249 + 250 + if (!fsl_mc_is_root_dprc(dev)) 251 + goto exit; 252 + 253 + root_mc_dev = to_fsl_mc_device(dev); 254 + 255 + if (kstrtoul(buf, 0, &val) < 0) 256 + return -EINVAL; 257 + 258 + if (val) 259 + enable_dprc_irq(root_mc_dev); 260 + else 261 + disable_dprc_irq(root_mc_dev); 262 + 263 + exit: 264 + return 0; 265 + } 266 + 267 + static int fsl_mc_bus_get_autorescan(struct device *dev, void *data) 268 + { 269 + struct fsl_mc_device *root_mc_dev; 270 + char *buf = data; 271 + 272 + if (!fsl_mc_is_root_dprc(dev)) 273 + goto exit; 274 + 275 + root_mc_dev = to_fsl_mc_device(dev); 276 + 277 + sprintf(buf, "%d\n", get_dprc_irq_state(root_mc_dev)); 278 + exit: 279 + return 0; 280 + } 281 + 282 + static ssize_t autorescan_store(struct bus_type *bus, 283 + const char *buf, size_t count) 284 + { 285 + bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_set_autorescan); 286 + 287 + return count; 288 + } 289 + 290 + static ssize_t autorescan_show(struct bus_type *bus, char *buf) 291 + { 292 + bus_for_each_dev(bus, NULL, (void *)buf, fsl_mc_bus_get_autorescan); 293 + return strlen(buf); 294 + } 295 + 296 + static BUS_ATTR_RW(autorescan); 297 + 244 298 static struct attribute *fsl_mc_bus_attrs[] = { 245 299 &bus_attr_rescan.attr, 300 + &bus_attr_autorescan.attr, 246 301 NULL, 247 302 }; 248 303
+5
drivers/bus/fsl-mc/fsl-mc-private.h
··· 578 578 struct mutex scan_mutex; /* serializes bus scanning */ 579 579 struct dprc_attributes dprc_attr; 580 580 struct fsl_mc_uapi uapi_misc; 581 + int irq_enabled; 581 582 }; 582 583 583 584 #define to_fsl_mc_bus(_mc_dev) \ ··· 656 655 } 657 656 658 657 #endif 658 + 659 + int disable_dprc_irq(struct fsl_mc_device *mc_dev); 660 + int enable_dprc_irq(struct fsl_mc_device *mc_dev); 661 + int get_dprc_irq_state(struct fsl_mc_device *mc_dev); 659 662 660 663 #endif /* _FSL_MC_PRIVATE_H_ */