Re: nvme: use I/O submission queue entry size reported by controller

joshua stein <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <20260529160316.6171759809@106b4e529f446cd>
On Thu, 28 May 2026 at 23:48:27 +0200, Mark Kettenis wrote:
> > Date: Sun, 17 May 2026 12:25:57 -0500
> > From: joshua stein <[email protected]>
> > 
> > On at least the Apple T2 NVMe, 128-byte submission queue entries on
> > I/O queues are required instead of the standard 64 bytes.
> > 
> > This gets NVMe working on the 2018 Mac Mini.  Also tested on a 
> > non-Apple NVMe but more tests would be helpful.
> 
> Unfortunately this breaks the NVMe on my 2023 Mac mini.  It advertises
> 128-byte submission queue entries, but only works with 64-byte ones.

Because of course it does.  Well done, Apple.

ok


> Index: dev/ic/nvme.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ic/nvme.c,v
> diff -u -p -r1.127 nvme.c
> --- dev/ic/nvme.c	27 May 2026 15:04:14 -0000	1.127
> +++ dev/ic/nvme.c	28 May 2026 21:37:35 -0000
> @@ -1288,10 +1288,12 @@ nvme_identify(struct nvme_softc *sc, u_i
>  
>  	sc->sc_nn = lemtoh32(&identify->nn);
>  
> -	/* use maximum I/O SQE size reported */
> -	sc->sc_sqe_size = 1 << (identify->sqes >> 4);
> -	if (sc->sc_sqe_size < sizeof(struct nvme_sqe))
> -		sc->sc_sqe_size = sizeof(struct nvme_sqe);
> +	if (sc->sc_sqe_size == 0) {
> +		/* use maximum I/O SQE size reported */
> +		sc->sc_sqe_size = 1 << (identify->sqes >> 4);
> +		if (sc->sc_sqe_size < sizeof(struct nvme_sqe))
> +			sc->sc_sqe_size = sizeof(struct nvme_sqe);
> +	}
>  
>  	/*
>  	 * At least one Apple NVMe device presents a second, bogus disk that is
> Index: arch/arm64/dev/aplns.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/arm64/dev/aplns.c,v
> diff -u -p -r1.17 aplns.c
> --- arch/arm64/dev/aplns.c	11 Jan 2026 12:47:48 -0000	1.17
> +++ arch/arm64/dev/aplns.c	28 May 2026 21:37:35 -0000
> @@ -234,6 +234,7 @@ nvme_ans_attach(struct device *parent, s
>  	sc->sc_ios = faa->fa_reg[0].size;
>  	sc->sc_ops = &nvme_ans_ops;
>  	sc->sc_openings = 1;
> +	sc->sc_sqe_size = sizeof(struct nvme_sqe);
>  
>  	if (nvme_attach(sc) != 0) {
>  		/* error printed by nvme_attach() */
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.