From c8492ee2082c28c70064cfda59cf29ab44a6efe3 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Tue, 1 Oct 2019 21:08:44 -0400 Subject: [PATCH] fixes for 5.2 Signed-off-by: Sasha Levin --- ...a-realtek-pci-quirk-for-medion-e4254.patch | 84 ++++++++++++++++ .../blk-mq-add-callback-of-.cleanup_rq.patch | 98 +++++++++++++++++++ .../scsi-implement-.cleanup_rq-callback.patch | 62 ++++++++++++ queue-5.2/series | 3 + 4 files changed, 247 insertions(+) create mode 100644 queue-5.2/alsa-hda-realtek-pci-quirk-for-medion-e4254.patch create mode 100644 queue-5.2/blk-mq-add-callback-of-.cleanup_rq.patch create mode 100644 queue-5.2/scsi-implement-.cleanup_rq-callback.patch diff --git a/queue-5.2/alsa-hda-realtek-pci-quirk-for-medion-e4254.patch b/queue-5.2/alsa-hda-realtek-pci-quirk-for-medion-e4254.patch new file mode 100644 index 00000000000..e665bf91b55 --- /dev/null +++ b/queue-5.2/alsa-hda-realtek-pci-quirk-for-medion-e4254.patch @@ -0,0 +1,84 @@ +From dccb2403749305b592eebcb0e04a448473fdd2c2 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 15 Sep 2019 16:57:28 +0200 +Subject: ALSA: hda/realtek - PCI quirk for Medion E4254 + +From: Jan-Marek Glogowski + +[ Upstream commit bd9c10bc663dd2eaac8fe39dad0f18cd21527446 ] + +The laptop has a combined jack to attach headsets on the right. +The BIOS encodes them as two different colored jacks at the front, +but otherwise it seems to be configured ok. But any adaption of +the pins config on its own doesn't fix the jack detection to work +in Linux. Still Windows works correct. + +This is somehow fixed by chaining ALC256_FIXUP_ASUS_HEADSET_MODE, +which seems to register the microphone jack as a headset part and +also results in fixing jack sensing, visible in dmesg as: + +-snd_hda_codec_realtek hdaudioC0D0: Mic=0x19 ++snd_hda_codec_realtek hdaudioC0D0: Headset Mic=0x19 + +[ Actually the essential change is the location of the jack; the + driver created "Front Mic Jack" without the matching volume / mute + control element due to its jack location, which confused PA. + -- tiwai ] + +Signed-off-by: Jan-Marek Glogowski +Cc: +Link: https://lore.kernel.org/r/8f4f9b20-0aeb-f8f1-c02f-fd53c09679f1@fbihome.de +Signed-off-by: Takashi Iwai +Signed-off-by: Sasha Levin +--- + sound/pci/hda/patch_realtek.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index d223a79ac934f..36aee8ad20547 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -5870,6 +5870,7 @@ enum { + ALC256_FIXUP_ASUS_MIC_NO_PRESENCE, + ALC299_FIXUP_PREDATOR_SPK, + ALC294_FIXUP_ASUS_INTSPK_HEADSET_MIC, ++ ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -6926,6 +6927,16 @@ static const struct hda_fixup alc269_fixups[] = { + .chained = true, + .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC + }, ++ [ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE] = { ++ .type = HDA_FIXUP_PINS, ++ .v.pins = (const struct hda_pintbl[]) { ++ { 0x19, 0x04a11040 }, ++ { 0x21, 0x04211020 }, ++ { } ++ }, ++ .chained = true, ++ .chain_id = ALC256_FIXUP_ASUS_HEADSET_MODE ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -7189,6 +7200,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), + SND_PCI_QUIRK(0x19e5, 0x3204, "Huawei MACH-WX9", ALC256_FIXUP_HUAWEI_MACH_WX9_PINS), + SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ ++ SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), + + #if 0 + /* Below is a quirk table taken from the old code. +@@ -7357,6 +7369,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { + {.id = ALC295_FIXUP_CHROME_BOOK, .name = "alc-chrome-book"}, + {.id = ALC299_FIXUP_PREDATOR_SPK, .name = "predator-spk"}, + {.id = ALC298_FIXUP_HUAWEI_MBX_STEREO, .name = "huawei-mbx-stereo"}, ++ {.id = ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE, .name = "alc256-medion-headset"}, + {} + }; + #define ALC225_STANDARD_PINS \ +-- +2.20.1 + diff --git a/queue-5.2/blk-mq-add-callback-of-.cleanup_rq.patch b/queue-5.2/blk-mq-add-callback-of-.cleanup_rq.patch new file mode 100644 index 00000000000..699207170d2 --- /dev/null +++ b/queue-5.2/blk-mq-add-callback-of-.cleanup_rq.patch @@ -0,0 +1,98 @@ +From f3b6bf5654e4636e069beb2b13636a1e98783d94 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 Jul 2019 10:04:59 +0800 +Subject: blk-mq: add callback of .cleanup_rq + +From: Ming Lei + +[ Upstream commit 226b4fc75c78f9c497c5182d939101b260cfb9f3 ] + +SCSI maintains its own driver private data hooked off of each SCSI +request, and the pridate data won't be freed after scsi_queue_rq() +returns BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE. An upper layer driver +(e.g. dm-rq) may need to retry these SCSI requests, before SCSI has +fully dispatched them, due to a lower level SCSI driver's resource +limitation identified in scsi_queue_rq(). Currently SCSI's per-request +private data is leaked when the upper layer driver (dm-rq) frees and +then retries these requests in response to BLK_STS_RESOURCE or +BLK_STS_DEV_RESOURCE returns from scsi_queue_rq(). + +This usecase is so specialized that it doesn't warrant training an +existing blk-mq interface (e.g. blk_mq_free_request) to allow SCSI to +account for freeing its driver private data -- doing so would add an +extra branch for handling a special case that all other consumers of +SCSI (and blk-mq) won't ever need to worry about. + +So the most pragmatic way forward is to delegate freeing SCSI driver +private data to the upper layer driver (dm-rq). Do so by adding +new .cleanup_rq callback and calling a new blk_mq_cleanup_rq() method +from dm-rq. A following commit will implement the .cleanup_rq() hook +in scsi_mq_ops. + +Cc: Ewan D. Milne +Cc: Bart Van Assche +Cc: Hannes Reinecke +Cc: Christoph Hellwig +Cc: Mike Snitzer +Cc: dm-devel@redhat.com +Cc: +Fixes: 396eaf21ee17 ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback") +Signed-off-by: Ming Lei +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + drivers/md/dm-rq.c | 1 + + include/linux/blk-mq.h | 13 +++++++++++++ + 2 files changed, 14 insertions(+) + +diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c +index 5f7063f05ae07..b41ecb451c784 100644 +--- a/drivers/md/dm-rq.c ++++ b/drivers/md/dm-rq.c +@@ -408,6 +408,7 @@ static int map_request(struct dm_rq_target_io *tio) + ret = dm_dispatch_clone_request(clone, rq); + if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) { + blk_rq_unprep_clone(clone); ++ blk_mq_cleanup_rq(clone); + tio->ti->type->release_clone_rq(clone, &tio->info); + tio->clone = NULL; + return DM_MAPIO_REQUEUE; +diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h +index 15d1aa53d96c4..a5a99b43f68e8 100644 +--- a/include/linux/blk-mq.h ++++ b/include/linux/blk-mq.h +@@ -140,6 +140,7 @@ typedef int (poll_fn)(struct blk_mq_hw_ctx *); + typedef int (map_queues_fn)(struct blk_mq_tag_set *set); + typedef bool (busy_fn)(struct request_queue *); + typedef void (complete_fn)(struct request *); ++typedef void (cleanup_rq_fn)(struct request *); + + + struct blk_mq_ops { +@@ -200,6 +201,12 @@ struct blk_mq_ops { + /* Called from inside blk_get_request() */ + void (*initialize_rq_fn)(struct request *rq); + ++ /* ++ * Called before freeing one request which isn't completed yet, ++ * and usually for freeing the driver private data ++ */ ++ cleanup_rq_fn *cleanup_rq; ++ + /* + * If set, returns whether or not this queue currently is busy + */ +@@ -366,4 +373,10 @@ static inline blk_qc_t request_to_qc_t(struct blk_mq_hw_ctx *hctx, + BLK_QC_T_INTERNAL; + } + ++static inline void blk_mq_cleanup_rq(struct request *rq) ++{ ++ if (rq->q->mq_ops->cleanup_rq) ++ rq->q->mq_ops->cleanup_rq(rq); ++} ++ + #endif +-- +2.20.1 + diff --git a/queue-5.2/scsi-implement-.cleanup_rq-callback.patch b/queue-5.2/scsi-implement-.cleanup_rq-callback.patch new file mode 100644 index 00000000000..49d05547981 --- /dev/null +++ b/queue-5.2/scsi-implement-.cleanup_rq-callback.patch @@ -0,0 +1,62 @@ +From 3829df0de3943f15601d161dfb04d10d8da30c6c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 25 Jul 2019 10:05:00 +0800 +Subject: scsi: implement .cleanup_rq callback + +From: Ming Lei + +[ Upstream commit b7e9e1fb7a9227be34ad4a5e778022c3164494cf ] + +Implement .cleanup_rq() callback for freeing driver private part +of the request. Then we can avoid to leak this part if the request isn't +completed by SCSI, and freed by blk-mq or upper layer(such as dm-rq) finally. + +Cc: Ewan D. Milne +Cc: Bart Van Assche +Cc: Hannes Reinecke +Cc: Christoph Hellwig +Cc: Mike Snitzer +Cc: dm-devel@redhat.com +Cc: +Fixes: 396eaf21ee17 ("blk-mq: improve DM's blk-mq IO merging via blk_insert_cloned_request feedback") +Signed-off-by: Ming Lei +Signed-off-by: Jens Axboe +Signed-off-by: Sasha Levin +--- + drivers/scsi/scsi_lib.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c +index 40f392569664b..506062081d8e2 100644 +--- a/drivers/scsi/scsi_lib.c ++++ b/drivers/scsi/scsi_lib.c +@@ -1073,6 +1073,18 @@ static void scsi_initialize_rq(struct request *rq) + cmd->retries = 0; + } + ++/* ++ * Only called when the request isn't completed by SCSI, and not freed by ++ * SCSI ++ */ ++static void scsi_cleanup_rq(struct request *rq) ++{ ++ if (rq->rq_flags & RQF_DONTPREP) { ++ scsi_mq_uninit_cmd(blk_mq_rq_to_pdu(rq)); ++ rq->rq_flags &= ~RQF_DONTPREP; ++ } ++} ++ + /* Add a command to the list used by the aacraid and dpt_i2o drivers */ + void scsi_add_cmd_to_list(struct scsi_cmnd *cmd) + { +@@ -1800,6 +1812,7 @@ static const struct blk_mq_ops scsi_mq_ops = { + .init_request = scsi_mq_init_request, + .exit_request = scsi_mq_exit_request, + .initialize_rq_fn = scsi_initialize_rq, ++ .cleanup_rq = scsi_cleanup_rq, + .busy = scsi_mq_lld_busy, + .map_queues = scsi_map_queues, + }; +-- +2.20.1 + diff --git a/queue-5.2/series b/queue-5.2/series index 2647cf8728b..e315894c54b 100644 --- a/queue-5.2/series +++ b/queue-5.2/series @@ -226,3 +226,6 @@ rdma-fix-double-free-in-srq-creation-error-flow.patch randstruct-check-member-structs-in-is_pure_ops_struct.patch arm-dts-am3517-evm-fix-missing-video.patch rcu-tree-fix-sched_fifo-params.patch +alsa-hda-realtek-pci-quirk-for-medion-e4254.patch +blk-mq-add-callback-of-.cleanup_rq.patch +scsi-implement-.cleanup_rq-callback.patch -- 2.47.3