linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Eduard Hasenleithner <eduard@hasenleithner.at>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [RFC PATCH v2] Workaround for discard on non-conformant nvme devices
Date: Tue, 12 Nov 2019 03:58:30 +0900	[thread overview]
Message-ID: <20191111185830.GD10851@redsun51.ssa.fujisawa.hgst.com> (raw)
In-Reply-To: <216cfad5-b724-f69d-9a8c-c5ee2ec13212@hasenleithner.at>

On Sun, Nov 10, 2019 at 07:27:08PM +0100, Eduard Hasenleithner wrote:
> +++ linux-5.3.7/drivers/nvme/host/core.c	2019-11-10 19:11:49.419372363 +0100
> @@ -562,8 +562,13 @@ static blk_status_t nvme_setup_discard(s
>  	struct nvme_dsm_range *range;
>  	struct bio *bio;
> 
> -	range = kmalloc_array(segments, sizeof(*range),
> -				GFP_ATOMIC | __GFP_NOWARN);
> +	if (!(ns->ctrl->quirks & NVME_QUIRK_DSM_PAGEALIGN)) {
> +		range = kmalloc_array(segments, sizeof(*range),
> +					GFP_ATOMIC | __GFP_NOWARN);
> +	} else {
> +		/* Device with quirk: use (page aligned) discard_page */
> +		range = NULL;
> +	}

Please initialize 'range' to NULL so we don't need the 'else' case.

> @@ -97,6 +97,11 @@ enum nvme_quirks {
>  	 * Force simple suspend/resume path.
>  	 */
>  	NVME_QUIRK_SIMPLE_SUSPEND		= (1 << 10),
> +
> +	/*
> +	 * Workaround for devices reading DSM beyond end of page.
> +	 */
> +	NVME_QUIRK_DSM_PAGEALIGN		= (1 << 11),

Let's get a better description of this. My recommendation:

	For devices that do not consider the DSM 'Number of Ranges'
	field when determining how much data to DMA. Page aligned and
	sized is always sufficient as that is the largest a DSM range
	list can be.

And let's add the known devices to the nvme pci_driver that require
this.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2019-11-11 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-10 18:27 [RFC PATCH v2] Workaround for discard on non-conformant nvme devices Eduard Hasenleithner
2019-11-11 10:28 ` Christoph Hellwig
2019-11-11 18:58 ` Keith Busch [this message]
2019-11-11 22:10   ` Eduard Hasenleithner

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=20191111185830.GD10851@redsun51.ssa.fujisawa.hgst.com \
    --to=kbusch@kernel.org \
    --cc=eduard@hasenleithner.at \
    --cc=linux-nvme@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).