From 0085280722421d27a8f86dc9bf58d5281343c366 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 6 Mar 2020 09:20:52 -0500 Subject: [PATCH] fixes for 5.5 Signed-off-by: Sasha Levin --- ...da-export-number-of-digital-micropho.patch | 73 ++++++++++++++++ ...-insert-oom-queue-into-position-tree.patch | 49 +++++++++++ ...ref-to-a-group-when-adding-it-to-a-s.patch | 87 +++++++++++++++++++ ...tra-ref-to-prevent-a-queue-from-bein.patch | 58 +++++++++++++ queue-5.5/series | 4 + 5 files changed, 271 insertions(+) create mode 100644 queue-5.5/asoc-intel-skl-hda-export-number-of-digital-micropho.patch create mode 100644 queue-5.5/block-bfq-do-not-insert-oom-queue-into-position-tree.patch create mode 100644 queue-5.5/block-bfq-get-a-ref-to-a-group-when-adding-it-to-a-s.patch create mode 100644 queue-5.5/block-bfq-get-extra-ref-to-prevent-a-queue-from-bein.patch create mode 100644 queue-5.5/series diff --git a/queue-5.5/asoc-intel-skl-hda-export-number-of-digital-micropho.patch b/queue-5.5/asoc-intel-skl-hda-export-number-of-digital-micropho.patch new file mode 100644 index 00000000000..63e444bc18f --- /dev/null +++ b/queue-5.5/asoc-intel-skl-hda-export-number-of-digital-micropho.patch @@ -0,0 +1,73 @@ +From c57eab21de2325196a42f698fef5a290106a7580 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 4 Dec 2019 15:15:44 -0600 +Subject: ASoC: intel/skl/hda - export number of digital microphones via + control components + +From: Jaroslav Kysela + +[ Upstream commit 8cd9956f61c65022209ce6d1e55ed12aea12357d ] + +It is required for the auto-detection in the user space (for UCM). + +Signed-off-by: Jaroslav Kysela +Signed-off-by: Pierre-Louis Bossart +Cc: Mark Brown +Link: https://lore.kernel.org/r/20191204211556.12671-2-pierre-louis.bossart@linux.intel.com +Signed-off-by: Mark Brown +Signed-off-by: Sasha Levin +--- + sound/soc/intel/boards/skl_hda_dsp_generic.c | 8 ++++++++ + sound/soc/sof/intel/hda.c | 3 ++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c +index 4e45901e3a2f1..11eaee9ae41f7 100644 +--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c ++++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c +@@ -100,6 +100,8 @@ static struct snd_soc_card hda_soc_card = { + .late_probe = skl_hda_card_late_probe, + }; + ++static char hda_soc_components[30]; ++ + #define IDISP_DAI_COUNT 3 + #define HDAC_DAI_COUNT 2 + #define DMIC_DAI_COUNT 2 +@@ -183,6 +185,12 @@ static int skl_hda_audio_probe(struct platform_device *pdev) + hda_soc_card.dev = &pdev->dev; + snd_soc_card_set_drvdata(&hda_soc_card, ctx); + ++ if (mach->mach_params.dmic_num > 0) { ++ snprintf(hda_soc_components, sizeof(hda_soc_components), ++ "cfg-dmics:%d", mach->mach_params.dmic_num); ++ hda_soc_card.components = hda_soc_components; ++ } ++ + return devm_snd_soc_register_card(&pdev->dev, &hda_soc_card); + } + +diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c +index 82ecadda886c6..a1780259292fa 100644 +--- a/sound/soc/sof/intel/hda.c ++++ b/sound/soc/sof/intel/hda.c +@@ -351,7 +351,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) + const char *tplg_filename; + const char *idisp_str; + const char *dmic_str; +- int dmic_num; ++ int dmic_num = 0; + int codec_num = 0; + int i; + #endif +@@ -472,6 +472,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) + mach_params->codec_mask = bus->codec_mask; + mach_params->platform = dev_name(sdev->dev); + mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; ++ mach_params->dmic_num = dmic_num; + } + + /* create codec instances */ +-- +2.20.1 + diff --git a/queue-5.5/block-bfq-do-not-insert-oom-queue-into-position-tree.patch b/queue-5.5/block-bfq-do-not-insert-oom-queue-into-position-tree.patch new file mode 100644 index 00000000000..1f98903bce8 --- /dev/null +++ b/queue-5.5/block-bfq-do-not-insert-oom-queue-into-position-tree.patch @@ -0,0 +1,49 @@ +From 26c2b0426f2bbb2d2c49e274be96aa901c9ce5e4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 3 Feb 2020 11:40:55 +0100 +Subject: block, bfq: do not insert oom queue into position tree + +From: Paolo Valente + +[ Upstream commit 32c59e3a9a5a0b180dd015755d6d18ca31e55935 ] + +BFQ maintains an ordered list, implemented with an RB tree, of +head-request positions of non-empty bfq_queues. This position tree, +inherited from CFQ, is used to find bfq_queues that contain I/O close +to each other. BFQ merges these bfq_queues into a single shared queue, +if this boosts throughput on the device at hand. + +There is however a special-purpose bfq_queue that does not participate +in queue merging, the oom bfq_queue. Yet, also this bfq_queue could be +wrongly added to the position tree. So bfqq_find_close() could return +the oom bfq_queue, which is a source of further troubles in an +out-of-memory situation. This commit prevents the oom bfq_queue from +being inserted into the position tree. + +Tested-by: Patrick Dung +Tested-by: Oleksandr Natalenko +Signed-off-by: Paolo Valente +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/bfq-iosched.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c +index 5c239c540c47a..3dbd0666fec1b 100644 +--- a/block/bfq-iosched.c ++++ b/block/bfq-iosched.c +@@ -614,6 +614,10 @@ bfq_pos_tree_add_move(struct bfq_data *bfqd, struct bfq_queue *bfqq) + bfqq->pos_root = NULL; + } + ++ /* oom_bfqq does not participate in queue merging */ ++ if (bfqq == &bfqd->oom_bfqq) ++ return; ++ + /* + * bfqq cannot be merged any longer (see comments in + * bfq_setup_cooperator): no point in adding bfqq into the +-- +2.20.1 + diff --git a/queue-5.5/block-bfq-get-a-ref-to-a-group-when-adding-it-to-a-s.patch b/queue-5.5/block-bfq-get-a-ref-to-a-group-when-adding-it-to-a-s.patch new file mode 100644 index 00000000000..5dcd1c8bc8d --- /dev/null +++ b/queue-5.5/block-bfq-get-a-ref-to-a-group-when-adding-it-to-a-s.patch @@ -0,0 +1,87 @@ +From d1cf53b6e526b97efc55ce9dfa6a50b91ef7f164 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 3 Feb 2020 11:40:59 +0100 +Subject: block, bfq: get a ref to a group when adding it to a service tree + +From: Paolo Valente + +[ Upstream commit db37a34c563bf4692b36990ae89005c031385e52 ] + +BFQ schedules generic entities, which may represent either bfq_queues +or groups of bfq_queues. When an entity is inserted into a service +tree, a reference must be taken, to make sure that the entity does not +disappear while still referred in the tree. Unfortunately, such a +reference is mistakenly taken only if the entity represents a +bfq_queue. This commit takes a reference also in case the entity +represents a group. + +Tested-by: Oleksandr Natalenko +Tested-by: Chris Evich +Signed-off-by: Paolo Valente +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/bfq-cgroup.c | 2 +- + block/bfq-iosched.h | 1 + + block/bfq-wf2q.c | 12 ++++++++++-- + 3 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c +index e1419edde2ec5..e7919e76a27c2 100644 +--- a/block/bfq-cgroup.c ++++ b/block/bfq-cgroup.c +@@ -332,7 +332,7 @@ static void bfqg_put(struct bfq_group *bfqg) + kfree(bfqg); + } + +-static void bfqg_and_blkg_get(struct bfq_group *bfqg) ++void bfqg_and_blkg_get(struct bfq_group *bfqg) + { + /* see comments in bfq_bic_update_cgroup for why refcounting bfqg */ + bfqg_get(bfqg); +diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h +index 8526f20c53bc1..144bc544be568 100644 +--- a/block/bfq-iosched.h ++++ b/block/bfq-iosched.h +@@ -984,6 +984,7 @@ struct bfq_group *bfq_find_set_group(struct bfq_data *bfqd, + struct blkcg_gq *bfqg_to_blkg(struct bfq_group *bfqg); + struct bfq_group *bfqq_group(struct bfq_queue *bfqq); + struct bfq_group *bfq_create_group_hierarchy(struct bfq_data *bfqd, int node); ++void bfqg_and_blkg_get(struct bfq_group *bfqg); + void bfqg_and_blkg_put(struct bfq_group *bfqg); + + #ifdef CONFIG_BFQ_GROUP_IOSCHED +diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c +index 05f0bf4a1144d..44079147e396e 100644 +--- a/block/bfq-wf2q.c ++++ b/block/bfq-wf2q.c +@@ -536,7 +536,9 @@ static void bfq_get_entity(struct bfq_entity *entity) + bfqq->ref++; + bfq_log_bfqq(bfqq->bfqd, bfqq, "get_entity: %p %d", + bfqq, bfqq->ref); +- } ++ } else ++ bfqg_and_blkg_get(container_of(entity, struct bfq_group, ++ entity)); + } + + /** +@@ -650,8 +652,14 @@ static void bfq_forget_entity(struct bfq_service_tree *st, + + entity->on_st = false; + st->wsum -= entity->weight; +- if (bfqq && !is_in_service) ++ if (is_in_service) ++ return; ++ ++ if (bfqq) + bfq_put_queue(bfqq); ++ else ++ bfqg_and_blkg_put(container_of(entity, struct bfq_group, ++ entity)); + } + + /** +-- +2.20.1 + diff --git a/queue-5.5/block-bfq-get-extra-ref-to-prevent-a-queue-from-bein.patch b/queue-5.5/block-bfq-get-extra-ref-to-prevent-a-queue-from-bein.patch new file mode 100644 index 00000000000..daee459bfbe --- /dev/null +++ b/queue-5.5/block-bfq-get-extra-ref-to-prevent-a-queue-from-bein.patch @@ -0,0 +1,58 @@ +From 8fb186cacbb4f5ae75270a021429cbb6a97c2b1b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 3 Feb 2020 11:40:56 +0100 +Subject: block, bfq: get extra ref to prevent a queue from being freed during + a group move + +From: Paolo Valente + +[ Upstream commit ecedd3d7e19911ab8fe42f17b77c0a30fe7f4db3 ] + +In bfq_bfqq_move(), the bfq_queue, say Q, to be moved to a new group +may happen to be deactivated in the scheduling data structures of the +source group (and then activated in the destination group). If Q is +referred only by the data structures in the source group when the +deactivation happens, then Q is freed upon the deactivation. + +This commit addresses this issue by getting an extra reference before +the possible deactivation, and releasing this extra reference after Q +has been moved. + +Tested-by: Chris Evich +Tested-by: Oleksandr Natalenko +Signed-off-by: Paolo Valente +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + block/bfq-cgroup.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c +index e7919e76a27c2..db2a14215aeea 100644 +--- a/block/bfq-cgroup.c ++++ b/block/bfq-cgroup.c +@@ -651,6 +651,12 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, + bfq_bfqq_expire(bfqd, bfqd->in_service_queue, + false, BFQQE_PREEMPTED); + ++ /* ++ * get extra reference to prevent bfqq from being freed in ++ * next possible deactivate ++ */ ++ bfqq->ref++; ++ + if (bfq_bfqq_busy(bfqq)) + bfq_deactivate_bfqq(bfqd, bfqq, false, false); + else if (entity->on_st) +@@ -670,6 +676,8 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq, + + if (!bfqd->in_service_queue && !bfqd->rq_in_driver) + bfq_schedule_dispatch(bfqd); ++ /* release extra ref taken above */ ++ bfq_put_queue(bfqq); + } + + /** +-- +2.20.1 + diff --git a/queue-5.5/series b/queue-5.5/series new file mode 100644 index 00000000000..bd64ed7df6e --- /dev/null +++ b/queue-5.5/series @@ -0,0 +1,4 @@ +asoc-intel-skl-hda-export-number-of-digital-micropho.patch +block-bfq-get-a-ref-to-a-group-when-adding-it-to-a-s.patch +block-bfq-get-extra-ref-to-prevent-a-queue-from-bein.patch +block-bfq-do-not-insert-oom-queue-into-position-tree.patch -- 2.47.3