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>] [day] [month] [year] [list]
Message-ID: <20190410101110.2224eb91@collabora.com>
Date:   Wed, 10 Apr 2019 10:11:10 +0200
From:   Boris Brezillon <boris.brezillon@...labora.com>
To:     masonccyang@...c.com.tw
Cc:     "Marek Vasut" <marek.vasut@...il.com>, bbrezillon@...nel.org,
        broonie@...nel.org, devicetree@...r.kernel.org,
        "Geert Uytterhoeven" <geert+renesas@...der.be>,
        "Simon Horman" <horms@...ge.net.au>, juliensu@...c.com.tw,
        lee.jones@...aro.org, linux-kernel@...r.kernel.org,
        linux-renesas-soc@...r.kernel.org, linux-spi@...r.kernel.org,
        mark.rutland@....com, robh+dt@...nel.org,
        "Sergei Shtylyov" <sergei.shtylyov@...entembedded.com>,
        zhengxunli@...c.com.tw
Subject: Re: [PATCH v9 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI
 controller driver

On Wed, 10 Apr 2019 16:01:02 +0800
masonccyang@...c.com.tw wrote:

> Hi,
>  
> > Re: [PATCH v9 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller   
> driver
> > 
> > On 4/10/19 3:33 AM, masonccyang@...c.com.tw wrote:  
> > > Hi Sergei,
> > >   
> > >> > +static ssize_t rpc_spi_mem_dirmap_write(struct spi_mem_dirmap_desc  
> > > *desc,  
> > >> > +               u64 offs, size_t len, const void *buf)
> > >> > +{
> > >> > +   struct rpc_spi *rpc =
> > >> > +         spi_controller_get_devdata(desc->mem->spi->controller);
> > >> > +   int ret;
> > >> > +
> > >> > +   if (offs + desc->info.offset + len > U32_MAX)
> > >> > +      return -EINVAL;
> > >> > +
> > >> > +   if (len > RPC_WBUF_SIZE)
> > >> > +      len = RPC_WBUF_SIZE;
> > >> > +
> > >> > +   ret = rpc_spi_set_freq(rpc, desc->mem->spi->max_speed_hz);
> > >> > +   if (ret)
> > >> > +      return ret;
> > >> > +
> > >> > +   rpc_spi_mem_set_prep_op_cfg(desc->mem->spi,
> > >> > +                &desc->info.op_tmpl, &offs, &len);
> > >> > +
> > >> > +   regmap_update_bits(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD,  
> > > RPC_CMNCR_MD);  
> > >> > +
> > >> > +   regmap_write(rpc->regmap, RPC_SMDRENR, 0);
> > >> > +
> > >> > +   regmap_update_bits(rpc->regmap, RPC_PHYCNT,   
> RPC_PHYCNT_STRTIM(7) |
> > >> > +            RPC_PHYCNT_WBUF2 | RPC_PHYCNT_WBUF,
> > >> > +            RPC_PHYCNT_WBUF2 | RPC_PHYCNT_WBUF);
> > >> > +
> > >> > +   memcpy_toio(rpc->wbuf, buf, len);  
> > >>
> > >>    Wait, doesn't the manual say that the whole 256-byte buffer should   
> be
> > >> filled?   
> 
> it could be less than 256 bytes, i.e., 128 bytes to rpc->wbuf !
> 
>  I think that short chunks have to be written w/o WBUF (done,
> > > in fact,  
> > >> by the HF driver).
> > >>  
> > > 
> > > From spi-nor.c layer always transfer 256 bytes data with page program
> > > command.  
> > 
> > Does that apply even for flashes with not-256-byte pages ?
> >   
> 
> I think it needs to patch in case of nor->page_size = 512 bytes.

I think the main problem here is that you assume the memory is a
NOR :-). Just do what the spi-mem user asks: if he asks you to write
X bytes, then write no more than X bytes. Use whatever trick you have
to make sure this is always true, and if this requires using a slow
path for non-aligned accesses, then do it, because it's better to have
a slow+working memory than a fast+non-working one :P.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ