From: "Hunter, Adrian" <adrian.hunter@intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "stable@vger.kernel.org" <stable@vger.kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: RE: [PATCH 5.10 83/83] scsi: ufs: core: Fix task management completion
Date: Mon, 11 Oct 2021 15:03:59 +0000 [thread overview]
Message-ID: <8dc0e077af3f4fd5a0887784f65bd722@intel.com> (raw)
In-Reply-To: <20211011134511.235071707@linuxfoundation.org>
Hi
This doesn't work. Please drop. Sorry, no idea why I sent it before testing.
Specifically, in v5.10, ufshcd_tmc_handler() can be called under the same spinlock
it is using, which deadlocks.
Regards
Adrian
> -----Original Message-----
> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Sent: Monday, October 11, 2021 4:47 PM
> To: linux-kernel@vger.kernel.org
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>;
> stable@vger.kernel.org; Bart Van Assche <bvanassche@acm.org>; Hunter,
> Adrian <adrian.hunter@intel.com>; Martin K. Petersen
> <martin.petersen@oracle.com>
> Subject: [PATCH 5.10 83/83] scsi: ufs: core: Fix task management completion
>
> From: Adrian Hunter <adrian.hunter@intel.com>
>
> commit f5ef336fd2e4c36dedae4e7ca66cf5349d6fda62 upstream.
>
> The UFS driver uses blk_mq_tagset_busy_iter() when identifying task
> management requests to complete, however blk_mq_tagset_busy_iter()
> doesn't
> work.
>
> blk_mq_tagset_busy_iter() only iterates requests dispatched by the block
> layer. That appears as if it might have started since commit 37f4a24c2469
> ("blk-mq: centralise related handling into blk_mq_get_driver_tag") which
> removed 'data->hctx->tags->rqs[rq->tag] = rq' from blk_mq_rq_ctx_init()
> which gets called:
>
> blk_get_request
> blk_mq_alloc_request
> __blk_mq_alloc_request
> blk_mq_rq_ctx_init
>
> Since UFS task management requests are not dispatched by the block layer,
> hctx->tags->rqs[rq->tag] remains NULL, and since
> blk_mq_tagset_busy_iter()
> relies on finding requests using hctx->tags->rqs[rq->tag], UFS task
> management requests are never found by blk_mq_tagset_busy_iter().
>
> By using blk_mq_tagset_busy_iter(), the UFS driver was relying on internal
> details of the block layer, which was fragile and subsequently got
> broken. Fix by removing the use of blk_mq_tagset_busy_iter() and having
> the
> driver keep track of task management requests.
>
> Link: https://lore.kernel.org/r/20210922091059.4040-1-
> adrian.hunter@intel.com
> Fixes: 1235fc569e0b ("scsi: ufs: core: Fix task management request
> completion timeout")
> Fixes: 69a6c269c097 ("scsi: ufs: Use blk_{get,put}_request() to allocate and
> free TMFs")
> Cc: stable@vger.kernel.org
> Tested-by: Bart Van Assche <bvanassche@acm.org>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> ---
> drivers/scsi/ufs/ufshcd.c | 54 +++++++++++++++++++++----------------------
> ---
> drivers/scsi/ufs/ufshcd.h | 1
> 2 files changed, 26 insertions(+), 29 deletions(-)
>
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -6105,27 +6105,6 @@ static irqreturn_t ufshcd_check_errors(s
> return retval;
> }
>
> -struct ctm_info {
> - struct ufs_hba *hba;
> - unsigned long pending;
> - unsigned int ncpl;
> -};
> -
> -static bool ufshcd_compl_tm(struct request *req, void *priv, bool reserved)
> -{
> - struct ctm_info *const ci = priv;
> - struct completion *c;
> -
> - WARN_ON_ONCE(reserved);
> - if (test_bit(req->tag, &ci->pending))
> - return true;
> - ci->ncpl++;
> - c = req->end_io_data;
> - if (c)
> - complete(c);
> - return true;
> -}
> -
> /**
> * ufshcd_tmc_handler - handle task management function completion
> * @hba: per adapter instance
> @@ -6136,14 +6115,24 @@ static bool ufshcd_compl_tm(struct reque
> */
> static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba)
> {
> - struct request_queue *q = hba->tmf_queue;
> - struct ctm_info ci = {
> - .hba = hba,
> - .pending = ufshcd_readl(hba,
> REG_UTP_TASK_REQ_DOOR_BELL),
> - };
> + unsigned long flags, pending, issued;
> + irqreturn_t ret = IRQ_NONE;
> + int tag;
>
> - blk_mq_tagset_busy_iter(q->tag_set, ufshcd_compl_tm, &ci);
> - return ci.ncpl ? IRQ_HANDLED : IRQ_NONE;
> + pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
> +
> + spin_lock_irqsave(hba->host->host_lock, flags);
> + issued = hba->outstanding_tasks & ~pending;
> + for_each_set_bit(tag, &issued, hba->nutmrs) {
> + struct request *req = hba->tmf_rqs[tag];
> + struct completion *c = req->end_io_data;
> +
> + complete(c);
> + ret = IRQ_HANDLED;
> + }
> + spin_unlock_irqrestore(hba->host->host_lock, flags);
> +
> + return ret;
> }
>
> /**
> @@ -6273,9 +6262,9 @@ static int __ufshcd_issue_tm_cmd(struct
> ufshcd_hold(hba, false);
>
> spin_lock_irqsave(host->host_lock, flags);
> - blk_mq_start_request(req);
>
> task_tag = req->tag;
> + hba->tmf_rqs[req->tag] = req;
> treq->req_header.dword_0 |= cpu_to_be32(task_tag);
>
> memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq));
> @@ -6319,6 +6308,7 @@ static int __ufshcd_issue_tm_cmd(struct
> }
>
> spin_lock_irqsave(hba->host->host_lock, flags);
> + hba->tmf_rqs[req->tag] = NULL;
> __clear_bit(task_tag, &hba->outstanding_tasks);
> spin_unlock_irqrestore(hba->host->host_lock, flags);
>
> @@ -9246,6 +9236,12 @@ int ufshcd_init(struct ufs_hba *hba, voi
> err = PTR_ERR(hba->tmf_queue);
> goto free_tmf_tag_set;
> }
> + hba->tmf_rqs = devm_kcalloc(hba->dev, hba->nutmrs,
> + sizeof(*hba->tmf_rqs), GFP_KERNEL);
> + if (!hba->tmf_rqs) {
> + err = -ENOMEM;
> + goto free_tmf_queue;
> + }
>
> /* Reset the attached device */
> ufshcd_vops_device_reset(hba);
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -731,6 +731,7 @@ struct ufs_hba {
>
> struct blk_mq_tag_set tmf_tag_set;
> struct request_queue *tmf_queue;
> + struct request **tmf_rqs;
>
> struct uic_command *active_uic_cmd;
> struct mutex uic_cmd_mutex;
>
next prev parent reply other threads:[~2021-10-11 15:15 UTC|newest]
Thread overview: 89+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 13:45 [PATCH 5.10 00/83] 5.10.73-rc1 review Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 01/83] Partially revert "usb: Kconfig: using select for USB_COMMON dependency" Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 02/83] usb: chipidea: ci_hdrc_imx: Also search for phys phandle Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 03/83] USB: cdc-acm: fix racy tty buffer accesses Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 04/83] USB: cdc-acm: fix break reporting Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 05/83] usb: typec: tcpm: handle SRC_STARTUP state if cc changes Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 06/83] drm/nouveau/kms/tu102-: delay enabling cursor until after assign_windows Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 07/83] xen/privcmd: fix error handling in mmap-resource processing Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 08/83] mmc: meson-gx: do not use memcpy_to/fromio for dram-access-quirk Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 09/83] mmc: sdhci-of-at91: wait for calibration done before proceed Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 10/83] mmc: sdhci-of-at91: replace while loop with read_poll_timeout Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 11/83] ovl: fix missing negative dentry check in ovl_rename() Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 12/83] ovl: fix IOCB_DIRECT if underlying fs doesnt support direct IO Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 13/83] nfsd: fix error handling of register_pernet_subsys() in init_nfsd() Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 14/83] nfsd4: Handle the NFSv4 READDIR dircount hint being zero Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 15/83] SUNRPC: fix sign error causing rpcsec_gss drops Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 16/83] xen/balloon: fix cancelled balloon action Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 17/83] ARM: dts: omap3430-sdp: Fix NAND device node Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 18/83] ARM: dts: imx6dl-yapp4: Fix lp5562 LED driver probe Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 19/83] ARM: dts: qcom: apq8064: use compatible which contains chipid Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 20/83] riscv: Flush current cpu icache before other cpus Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 21/83] bus: ti-sysc: Add break in switch statement in sysc_init_soc() Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 22/83] soc: qcom: socinfo: Fixed argument passed to platform_set_data() Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 23/83] ARM: dts: qcom: apq8064: Use 27MHz PXO clock as DSI PLL reference Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 24/83] ARM: at91: pm: do not panic if ram controllers are not enabled Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 25/83] soc: qcom: mdt_loader: Drop PT_LOAD check on hash segment Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 26/83] ARM: dts: imx: Add missing pinctrl-names for panel on M53Menlo Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 27/83] ARM: dts: imx: Fix USB host power regulator polarity " Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 28/83] ARM: dts: imx6qdl-pico: Fix Ethernet support Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 29/83] PCI: hv: Fix sleep while in non-sleep context when removing child devices from the bus Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 30/83] ath5k: fix building with LEDS=m Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 31/83] arm64: dts: qcom: pm8150: use qcom,pm8998-pon binding Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 32/83] xtensa: use CONFIG_USE_OF instead of CONFIG_OF Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 33/83] xtensa: call irqchip_init only when CONFIG_USE_OF is selected Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 34/83] iwlwifi: pcie: add configuration of a Wi-Fi adapter on Dell XPS 15 Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 35/83] bpf, arm: Fix register clobbering in div/mod implementation Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 36/83] soc: ti: omap-prm: Fix external abort for am335x pruss Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 37/83] bpf: Fix integer overflow in prealloc_elems_and_freelist() Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 38/83] net/mlx5e: IPSEC RX, enable checksum complete Greg Kroah-Hartman
2021-10-11 13:45 ` [PATCH 5.10 39/83] net/mlx5: E-Switch, Fix double allocation of acl flow counter Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 40/83] phy: mdio: fix memory leak Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 41/83] net_sched: fix NULL deref in fifo_set_limit() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 42/83] powerpc/fsl/dts: Fix phy-connection-type for fm1mac3 Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 43/83] ptp_pch: Load module automatically if ID matches Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 44/83] arm64: dts: ls1028a: add missing CAN nodes Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 45/83] dt-bindings: drm/bridge: ti-sn65dsi86: Fix reg value Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 46/83] ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 47/83] net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 48/83] net: bridge: fix under estimation " Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 49/83] net/sched: sch_taprio: properly cancel timer from taprio_destroy() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 50/83] net: sfp: Fix typo in state machine debug string Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 51/83] netlink: annotate data races around nlk->bound Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 52/83] perf jevents: Tidy error handling Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 53/83] bus: ti-sysc: Use CLKDM_NOAUTO for dra7 dcan1 for errata i893 Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 54/83] drm/sun4i: dw-hdmi: Fix HDMI PHY clock setup Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 55/83] video: fbdev: gbefb: Only instantiate device when built for IP32 Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 56/83] drm/nouveau: avoid a use-after-free when BO init fails Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 57/83] drm/nouveau/kms/nv50-: fix file release memory leak Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 58/83] drm/nouveau/debugfs: " Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 59/83] gve: Correct available tx qpl check Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 60/83] gve: Avoid freeing NULL pointer Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 61/83] rtnetlink: fix if_nlmsg_stats_size() under estimation Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 62/83] gve: fix gve_get_stats() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 63/83] gve: report 64bit tx_bytes counter from gve_handle_report_stats() Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 64/83] i40e: fix endless loop under rtnl Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 65/83] i40e: Fix freeing of uninitialized misc IRQ vector Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 66/83] net: prefer socket bound to interface when not in VRF Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 67/83] powerpc/iommu: Report the correct most efficient DMA mask for PCI devices Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 68/83] i2c: acpi: fix resource leak in reconfiguration device addition Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 69/83] i2c: mediatek: Add OFFSET_EXT_CONF setting back Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 70/83] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 71/83] bpf, s390: Fix potential memory leak about jit_data Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 72/83] RISC-V: Include clone3() on rv32 Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 73/83] powerpc/bpf: Fix BPF_MOD when imm == 1 Greg Kroah-Hartman
2021-10-11 17:29 ` Naresh Kamboju
2021-10-11 17:34 ` Naresh Kamboju
2021-10-11 13:46 ` [PATCH 5.10 74/83] powerpc/bpf: Fix BPF_SUB when imm == 0x80000000 Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 75/83] powerpc/64s: fix program check interrupt emergency stack path Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 76/83] pseries/eeh: Fix the kdump kernel crash during eeh_pseries_init Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 77/83] x86/platform/olpc: Correct ifdef symbol to intended CONFIG_OLPC_XO15_SCI Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 78/83] x86/Kconfig: Correct reference to MWINCHIP3D Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 79/83] x86/sev: Return an error on a returned non-zero SW_EXITINFO1[31:0] Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 80/83] x86/entry: Correct reference to intended CONFIG_64_BIT Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 81/83] x86/entry: Clear X86_FEATURE_SMAP when CONFIG_X86_SMAP=n Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 82/83] x86/hpet: Use another crystalball to evaluate HPET usability Greg Kroah-Hartman
2021-10-11 13:46 ` [PATCH 5.10 83/83] scsi: ufs: core: Fix task management completion Greg Kroah-Hartman
2021-10-11 15:03 ` Hunter, Adrian [this message]
2021-10-11 15:30 ` Greg Kroah-Hartman
2021-10-11 16:16 ` [PATCH 5.10 00/83] 5.10.73-rc1 review Florian Fainelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8dc0e077af3f4fd5a0887784f65bd722@intel.com \
--to=adrian.hunter@intel.com \
--cc=bvanassche@acm.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox