lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a66e4fe8f7224ea272d68276c7b138b@walle.cc>
Date:   Wed, 06 Jul 2022 23:02:12 +0200
From:   Michael Walle <michael@...le.cc>
To:     haibo.chen@....com
Cc:     ashish.kumar@....com, yogeshgaur.83@...il.com, broonie@...nel.org,
        robh+dt@...nel.org, krzysztof.kozlowski+dt@...aro.org,
        han.xu@....com, singh.kuldeep87k@...il.com,
        tudor.ambarus@...rochip.com, p.yadav@...com,
        miquel.raynal@...tlin.com, richard@....at, vigneshr@...com,
        shawnguo@...nel.org, s.hauer@...gutronix.de, kernel@...gutronix.de,
        linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org,
        devicetree@...r.kernel.org, linux-mtd@...ts.infradead.org,
        festevam@...il.com, linux-imx@....com,
        linux-arm-kernel@...ts.infradead.org, zhengxunli@...c.com.tw
Subject: Re: [PATCH 04/11] spi: spi-nxp-fspi: add function to select sample
 clock source for flash reading

Am 2022-07-05 11:11, schrieb haibo.chen@....com:
> From: Haibo Chen <haibo.chen@....com>
> 
> fspi define four mode for sample clock source selection.
> 
> Here is the list of modes:
> mode 0: Dummy Read strobe generated by FlexSPI Controller and loopback
> internally
> mode 1: Dummy Read strobe generated by FlexSPI Controller and loopback
> from DQS pad
> mode 2: Reserved
> mode 3: Flash provided Read strobe and input from DQS pad
> 
> In default, fspi use mode 0 after reset.
> For 8-8-8-DTR mode, need to use mode 3, otherwise 8-8-8-DTR read always
> get incorrect data.
> 
> Signed-off-by: Haibo Chen <haibo.chen@....com>
> ---
>  drivers/spi/spi-nxp-fspi.c | 47 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index c32a4f53fa2a..34679dc0e1ad 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -380,6 +380,7 @@ struct nxp_fspi {
>  	struct pm_qos_request pm_qos_req;
>  	int selected;
>  #define FSPI_INITILIZED		(1 << 0)
> +#define FSPI_RXCLKSRC_3		(1 << 1)
>  	int flags;
>  };
> 
> @@ -877,6 +878,50 @@ static int nxp_fspi_do_op(struct nxp_fspi *f,
> const struct spi_mem_op *op)
>  	return err;
>  }
> 
> +/*
> + * Sample Clock source selection for Flash Reading
> + * Four modes defined by fspi:
> + * mode 0: Dummy Read strobe generated by FlexSPI Controller
> + *         and loopback internally
> + * mode 1: Dummy Read strobe generated by FlexSPI Controller
> + *         and loopback from DQS pad
> + * mode 2: Reserved
> + * mode 3: Flash provided Read strobe and input from DQS pad
> + *
> + * fspi default use mode 0 after reset
> + */
> +static void nxp_fspi_select_rx_sample_clk_source(struct nxp_fspi *f,
> +						 const struct spi_mem_op *op)
> +{
> +	u32 reg;
> +
> +	/*
> +	 * For 8-8-8-DTR mode, need to use mode 3 (Flash provided Read
> +	 * strobe and input from DQS pad), otherwise read operaton may
> +	 * meet issue.
> +	 * This mode require flash device connect the DQS pad on board.
> +	 * For other modes, still use mode 0, keep align with before.
> +	 * spi_nor_suspend will disable 8-8-8-DTR mode, also need to
> +	 * change the mode back to mode 0.
> +	 */
> +	if (!(f->flags & FSPI_RXCLKSRC_3) &&
> +			op->cmd.dtr && op->addr.dtr &&
> +			op->dummy.dtr && op->data.dtr) {
> +		reg = fspi_readl(f, f->iobase + FSPI_MCR0);
> +		reg |= FSPI_MCR0_RXCLKSRC(3);
> +		fspi_writel(f, reg, f->iobase + FSPI_MCR0);
> +		f->flags |= FSPI_RXCLKSRC_3;
> +	} else if ((f->flags & FSPI_RXCLKSRC_3) &&
> +			!op->cmd.dtr && !op->addr.dtr &&
> +			!op->dummy.dtr && !op->data.dtr) {
> +		reg = fspi_readl(f, f->iobase + FSPI_MCR0);
> +		reg &= ~FSPI_MCR0_RXCLKSRC(3);	/* select mode 0 */
> +		fspi_writel(f, reg, f->iobase + FSPI_MCR0);
> +		f->flags &= ~FSPI_RXCLKSRC_3;
> +	}

How is this supposed to work? Are you unconditionally enable
flash provided read strobes if DTR is used? What if the
flash doesn't provide one or the board haven't DQS connected?

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ