s390/cio: avoid duplicated 'ADD' uevents
authorCornelia Huck <cohuck@redhat.com>
Fri, 27 Mar 2020 12:45:02 +0000 (13:45 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Mon, 6 Apr 2020 12:02:28 +0000 (14:02 +0200)
The common I/O layer delays the ADD uevent for subchannels and
delegates generating this uevent to the individual subchannel
drivers. The io_subchannel driver will do so when the associated
ccw_device has been registered -- but unconditionally, so more
ADD uevents will be generated if a subchannel has been unbound
from the io_subchannel driver and later rebound.

To fix this, only generate the ADD event if uevents were still
suppressed for the device.

Fixes: fa1a8c23eb7d ("s390: cio: Delay uevents for subchannels")
Message-Id: <20200327124503.9794-2-cohuck@redhat.com>
Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/cio/device.c

index 50007cb9be5b881a82741deed6caa6028652ebd3..b29fe8d50baf25677d90b1aed9310abc11a4159f 100644 (file)
@@ -849,8 +849,10 @@ static void io_subchannel_register(struct ccw_device *cdev)
         * Now we know this subchannel will stay, we can throw
         * our delayed uevent.
         */
-       dev_set_uevent_suppress(&sch->dev, 0);
-       kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
+       if (dev_get_uevent_suppress(&sch->dev)) {
+               dev_set_uevent_suppress(&sch->dev, 0);
+               kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
+       }
        /* make it known to the system */
        ret = ccw_device_add(cdev);
        if (ret) {
@@ -1058,8 +1060,11 @@ static int io_subchannel_probe(struct subchannel *sch)
                 * Throw the delayed uevent for the subchannel, register
                 * the ccw_device and exit.
                 */
-               dev_set_uevent_suppress(&sch->dev, 0);
-               kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
+               if (dev_get_uevent_suppress(&sch->dev)) {
+                       /* should always be the case for the console */
+                       dev_set_uevent_suppress(&sch->dev, 0);
+                       kobject_uevent(&sch->dev.kobj, KOBJ_ADD);
+               }
                cdev = sch_get_cdev(sch);
                rc = ccw_device_add(cdev);
                if (rc) {