summaryrefslogtreecommitdiffstats
path: root/block/blk-mq-sysfs.c
AgeCommit message (Expand)Author
2019-11-04blk-mq: make sure that line break can be printedMing Lei
2019-11-02blk-mq: avoid sysfs buffer overflow with too many CPU coresMing Lei
2019-10-07block: Remove "dying" checks from sysfs callbacksBart Van Assche
2019-08-27block: split .sysfs_lock into two locksMing Lei
2019-08-27block: Remove blk_mq_register_dev()Bart Van Assche
2019-05-07Merge tag 'for-5.2/block-20190507' of git://git.kernel.dk/linux-blockLinus Torvalds
2019-05-04blk-mq: move cancel of hctx->run_work into blk_mq_hw_sysfs_releaseMing Lei
2019-05-04blk-mq: free hw queue's resource in hctx's release handlerMing Lei
2019-04-30block: add SPDX tags to block layer files missing licensing informationChristoph Hellwig
2019-04-25block: Replace all ktype default_attrs with groupsKimberly Brown
2018-12-17blk-mq: export hctx->type in debugfs instead of sysfsMing Lei
2018-12-04block: move queues types to the block layerChristoph Hellwig
2018-11-21blk-mq: not embed .mq_kobj and ctx->kobj into queue instanceMing Lei
2018-11-15block: remove a few unused exportsChristoph Hellwig
2018-11-07blk-mq: add 'type' attribute to the sysfs hctx directoryJens Axboe
2018-05-24block drivers/block: Use octal not symbolic permissionsJoe Perches
2018-01-15block: properly protect the 'queue' kobj in blk_unregister_queueMike Snitzer
2017-05-04blk-mq: untangle debugfs and sysfsOmar Sandoval
2017-05-04blk-mq: move debugfs declarations to a separate header fileOmar Sandoval
2017-04-26blk-mq: Only unregister hctxs for which registration succeededBart Van Assche
2017-04-26blk-mq-debugfs: Rename functions for registering and unregistering the mq dir...Bart Van Assche
2017-04-26blk-mq: Let blk_mq_debugfs_register() look up the queue nameBart Van Assche
2017-04-26blk-mq: Register <dev>/queue/mq after having registered <dev>/queueBart Van Assche
2017-03-08blk-mq: free hctx->cpumask in release handler of hctx's kobjectMing Lei
2017-03-08blk-mq: make lifetime consistent between hctx and its kobjectMing Lei
2017-03-08blk-mq: make lifetime consitent between q/ctx and its kobjectMing Lei
2017-03-08blk-mq: initialize mq kobjects in blk_mq_init_allocated_queue()Ming Lei
2017-02-02blk-mq: move debugfs_remove() of disk dir to blk_release_queue()Omar Sandoval
2017-01-27blk-mq: move hctx and ctx counters from sysfs to debugfsOmar Sandoval
2017-01-27blk-mq: move hctx io_poll, stats, and dispatched from sysfs to debugfsOmar Sandoval
2017-01-27blk-mq: move tags and sched_tags info from sysfs to debugfsOmar Sandoval
2017-01-27blk-mq: move hctx->dispatch and ctx->rq_list from sysfs to debugfsOmar Sandoval
2017-01-27blk-mq: create debugfs directory treeOmar Sandoval
2017-01-17blk-mq-sched: add framework for MQ capable IO schedulersJens Axboe
2016-11-10block: add scalable completion tracking of requestsJens Axboe
2016-09-21blk-mq: register device instead of diskMatias Bjørling
2016-09-16blk-mq: account higher order dispatchJens Axboe
2016-09-14block: enable zeroing of io_poll statisticsStephen Bates
2016-09-14block: add poll_considered statisticStephen Bates
2016-08-04blk-mq: fix deadlock in blk_mq_register_disk() error pathJens Axboe
2016-03-20blk-mq: Use proper cpumask iteratorThomas Gleixner
2016-02-09blk-mq: dynamic h/w context countKeith Busch
2015-11-07block: add block polling supportJens Axboe
2015-10-21block: generic request_queue reference countingDan Williams
2015-09-29blk-mq: fix deadlock when reading cpu_listAkinobu Mita
2015-09-29blk-mq: fix sysfs registration/unregistration raceAkinobu Mita
2015-08-15blk-mq: fix buffer overflow when reading sysfs file of 'pending'Ming Lei
2015-03-13blk-mq: add blk_mq_init_allocated_queue and export blk_mq_register_diskMike Snitzer
2015-01-29Revert "blk-mq: fix hctx/ctx kobject use-after-free"Ming Lei
2015-01-20blk-mq: fix hctx/ctx kobject use-after-freeMing Lei
id='n382' href='#n382'>382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
/*
 *  Initialization routines
 *  Copyright (c) by Jaroslav Kysela <perex@perex.cz>
 *
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 */

#include <linux/init.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/file.h>
#include <linux/slab.h>
#include <linux/time.h>
#include <linux/ctype.h>
#include <linux/pm.h>
#include <linux/completion.h>

#include <sound/core.h>
#include <sound/control.h>
#include <sound/info.h>

/* monitor files for graceful shutdown (hotplug) */
struct snd_monitor_file {
	struct file *file;
	const struct file_operations *disconnected_f_op;
	struct list_head shutdown_list;	/* still need to shutdown */
	struct list_head list;	/* link of monitor files */
};

static DEFINE_SPINLOCK(shutdown_lock);
static LIST_HEAD(shutdown_files);

static const struct file_operations snd_shutdown_f_ops;

/* locked for registering/using */
static DECLARE_BITMAP(snd_cards_lock, SNDRV_CARDS);
static struct snd_card *snd_cards[SNDRV_CARDS];

static DEFINE_MUTEX(snd_card_mutex);

static char *slots[SNDRV_CARDS];
module_param_array(slots, charp, NULL, 0444);
MODULE_PARM_DESC(slots, "Module names assigned to the slots.");

/* return non-zero if the given index is reserved for the given
 * module via slots option
 */
static int module_slot_match(struct module *module, int idx)
{
	int match = 1;
#ifdef MODULE
	const char *s1, *s2;

	if (!module || !*module->name || !slots[idx])
		return 0;

	s1 = module->name;
	s2 = slots[idx];
	if (*s2 == '!') {
		match = 0; /* negative match */
		s2++;
	}
	/* compare module name strings
	 * hyphens are handled as equivalent with underscore
	 */
	for (;;) {
		char c1 = *s1++;
		char c2 = *s2++;
		if (c1 == '-')
			c1 = '_';
		if (c2 == '-')
			c2 = '_';
		if (c1 != c2)
			return !match;
		if (!c1)
			break;
	}
#endif /* MODULE */
	return match;
}

#if IS_ENABLED(CONFIG_SND_MIXER_OSS)
int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int free_flag);
EXPORT_SYMBOL(snd_mixer_oss_notify_callback);
#endif

static int check_empty_slot(struct module *module, int slot)
{
	return !slots[slot] || !*slots[slot];
}

/* return an empty slot number (>= 0) found in the given bitmask @mask.
 * @mask == -1 == 0xffffffff means: take any free slot up to 32
 * when no slot is available, return the original @mask as is.
 */
static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int),
				 struct module *module)
{
	int slot;

	for (slot = 0; slot < SNDRV_CARDS; slot++) {
		if (slot < 32 && !(mask & (1U << slot)))
			continue;
		if (!test_bit(slot, snd_cards_lock)) {
			if (check(module, slot))
				return slot; /* found */
		}
	}
	return mask; /* unchanged */
}

/* the default release callback set in snd_device_initialize() below;
 * this is just NOP for now, as almost all jobs are already done in
 * dev_free callback of snd_device chain instead.
 */
static void default_release(struct device *dev)
{
}

/**
 * snd_device_initialize - Initialize struct device for sound devices
 * @dev: device to initialize
 * @card: card to assign, optional
 */
void snd_device_initialize(struct device *dev, struct snd_card *card)
{
	device_initialize(dev);
	if (card)
		dev->parent = &card->card_dev;
	dev->class = sound_class;
	dev->release = default_release;
}
EXPORT_SYMBOL_GPL(snd_device_initialize);

static int snd_card_do_free(struct snd_card *card);
static const struct attribute_group card_dev_attr_group;

static void release_card_device(struct device *dev)
{
	snd_card_do_free(dev_to_snd_card(dev));
}

/**
 *  snd_card_new - create and initialize a soundcard structure
 *  @parent: the parent device object
 *  @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
 *  @xid: card identification (ASCII string)
 *  @module: top level module for locking
 *  @extra_size: allocate this extra size after the main soundcard structure
 *  @card_ret: the pointer