Lines Matching +full:poll +full:- +full:interval

1 // SPDX-License-Identifier: GPL-2.0
3 * Disk events - monitor disk events like media change and eject request.
20 long poll_msecs; /* interval, -1 for default */
38 /* disable in-kernel polling by default */
43 struct disk_events *ev = disk->ev; in disk_events_poll_jiffies()
47 * If device-specific poll interval is set, always use it. If in disk_events_poll_jiffies()
48 * the default is being used, poll if the POLL flag is set. in disk_events_poll_jiffies()
50 if (ev->poll_msecs >= 0) in disk_events_poll_jiffies()
51 intv_msecs = ev->poll_msecs; in disk_events_poll_jiffies()
52 else if (disk->event_flags & DISK_EVENT_FLAG_POLL) in disk_events_poll_jiffies()
59 * disk_block_events - block and flush disk event checking
75 struct disk_events *ev = disk->ev; in disk_block_events()
86 mutex_lock(&ev->block_mutex); in disk_block_events()
88 spin_lock_irqsave(&ev->lock, flags); in disk_block_events()
89 cancel = !ev->block++; in disk_block_events()
90 spin_unlock_irqrestore(&ev->lock, flags); in disk_block_events()
93 cancel_delayed_work_sync(&disk->ev->dwork); in disk_block_events()
95 mutex_unlock(&ev->block_mutex); in disk_block_events()
100 struct disk_events *ev = disk->ev; in __disk_unblock_events()
104 spin_lock_irqsave(&ev->lock, flags); in __disk_unblock_events()
106 if (WARN_ON_ONCE(ev->block <= 0)) in __disk_unblock_events()
109 if (--ev->block) in __disk_unblock_events()
115 &ev->dwork, 0); in __disk_unblock_events()
118 &ev->dwork, intv); in __disk_unblock_events()
120 spin_unlock_irqrestore(&ev->lock, flags); in __disk_unblock_events()
124 * disk_unblock_events - unblock disk event checking
135 if (disk->ev) in disk_unblock_events()
140 * disk_flush_events - schedule immediate event checking and flushing
146 * doesn't clear the events from @disk->ev.
149 * If @mask is non-zero must be called with disk->open_mutex held.
153 struct disk_events *ev = disk->ev; in disk_flush_events()
158 spin_lock_irq(&ev->lock); in disk_flush_events()
159 ev->clearing |= mask; in disk_flush_events()
160 if (!ev->block) in disk_flush_events()
162 &ev->dwork, 0); in disk_flush_events()
163 spin_unlock_irq(&ev->lock); in disk_flush_events()
167 * Tell userland about new events. Only the events listed in @disk->events are
177 if (events & disk->events & (1 << i)) in disk_event_uevent()
181 kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp); in disk_event_uevent()
187 struct gendisk *disk = ev->disk; in disk_check_events()
193 events = disk->fops->check_events(disk, clearing); in disk_check_events()
195 /* accumulate pending events and schedule next poll if necessary */ in disk_check_events()
196 spin_lock_irq(&ev->lock); in disk_check_events()
198 events &= ~ev->pending; in disk_check_events()
199 ev->pending |= events; in disk_check_events()
203 if (!ev->block && intv) in disk_check_events()
205 &ev->dwork, intv); in disk_check_events()
207 spin_unlock_irq(&ev->lock); in disk_check_events()
212 if (disk->event_flags & DISK_EVENT_FLAG_UEVENT) in disk_check_events()
217 * disk_clear_events - synchronously check, clear and return pending events
229 struct disk_events *ev = disk->ev; in disk_clear_events()
239 * store the union of mask and ev->clearing on the stack so that the in disk_clear_events()
240 * race with disk_flush_events does not cause ambiguity (ev->clearing in disk_clear_events()
243 spin_lock_irq(&ev->lock); in disk_clear_events()
244 clearing |= ev->clearing; in disk_clear_events()
245 ev->clearing = 0; in disk_clear_events()
246 spin_unlock_irq(&ev->lock); in disk_clear_events()
250 * if ev->clearing is not 0, the disk_flush_events got called in the in disk_clear_events()
253 __disk_unblock_events(disk, ev->clearing ? true : false); in disk_clear_events()
256 spin_lock_irq(&ev->lock); in disk_clear_events()
257 pending = ev->pending & mask; in disk_clear_events()
258 ev->pending &= ~mask; in disk_clear_events()
259 spin_unlock_irq(&ev->lock); in disk_clear_events()
266 * disk_check_media_change - check if a removable media has been changed
284 bdev_mark_dead(disk->part0, true); in disk_check_media_change()
285 set_bit(GD_NEED_PART_SCAN, &disk->state); in disk_check_media_change()
291 * disk_force_media_change - force a media change event
302 bdev_mark_dead(disk->part0, true); in disk_force_media_change()
303 set_bit(GD_NEED_PART_SCAN, &disk->state); in disk_force_media_change()
316 disk_check_events(ev, &ev->clearing); in disk_events_workfn()
326 * events_poll_msecs : polling interval, 0: disable, -1: system default
350 if (!(disk->event_flags & DISK_EVENT_FLAG_UEVENT)) in disk_events_show()
352 return __disk_events_show(disk->events, buf); in disk_events_show()
367 if (!disk->ev) in disk_events_poll_msecs_show()
368 return sprintf(buf, "-1\n"); in disk_events_poll_msecs_show()
369 return sprintf(buf, "%ld\n", disk->ev->poll_msecs); in disk_events_poll_msecs_show()
380 return -EINVAL; in disk_events_poll_msecs_store()
382 if (intv < 0 && intv != -1) in disk_events_poll_msecs_store()
383 return -EINVAL; in disk_events_poll_msecs_store()
385 if (!disk->ev) in disk_events_poll_msecs_store()
386 return -ENODEV; in disk_events_poll_msecs_store()
389 disk->ev->poll_msecs = intv; in disk_events_poll_msecs_store()
400 * The default polling interval can be specified by the kernel
417 disk_flush_events(ev->disk, 0); in disk_events_set_dfl_poll_msecs()
434 * disk_{alloc|add|del|release}_events - initialize and destroy disk_events.
440 if (!disk->fops->check_events || !disk->events) in disk_alloc_events()
445 pr_warn("%s: failed to initialize events\n", disk->disk_name); in disk_alloc_events()
446 return -ENOMEM; in disk_alloc_events()
449 INIT_LIST_HEAD(&ev->node); in disk_alloc_events()
450 ev->disk = disk; in disk_alloc_events()
451 spin_lock_init(&ev->lock); in disk_alloc_events()
452 mutex_init(&ev->block_mutex); in disk_alloc_events()
453 ev->block = 1; in disk_alloc_events()
454 ev->poll_msecs = -1; in disk_alloc_events()
455 INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn); in disk_alloc_events()
457 disk->ev = ev; in disk_alloc_events()
463 if (!disk->ev) in disk_add_events()
467 list_add_tail(&disk->ev->node, &disk_events); in disk_add_events()
479 if (disk->ev) { in disk_del_events()
483 list_del_init(&disk->ev->node); in disk_del_events()
491 WARN_ON_ONCE(disk->ev && disk->ev->block != 1); in disk_release_events()
492 kfree(disk->ev); in disk_release_events()