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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <983e943b-30f2-7d80-294a-df29bca11738@cern.ch>
Date:   Mon, 13 Mar 2017 18:25:53 +0100
From:   Adrian Fiergolski <Adrian.Fiergolski@...n.ch>
To:     Mark Brown <broonie@...nel.org>
CC:     <linux-spi@...r.kernel.org>, <robh+dt@...nel.org>,
        <mark.rutland@....com>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <miguel.ojeda.sandonis@...il.com>
Subject: Re: [PATCH] spi: Add spi-bits-per-word binding.

Hi Mark,

I think, we misunderstand. Any line of spidev (or device driver in
general) is called, if master, setting its bit_per_word_mask, doesn't
cover 8 bits per word. Thus, in such a case, any device driver has a
possibility to be registered and handle the "limited capabilities of the
controller". IMHO, the problem is in the spi core itself. I will try to
be more clear.

In my case, xilinx_spi_probe function (of spi-xilinx controller) sets
bits_per_word_mask of spi_master struct only to 16 bits support. Later,
xilinx_spi_probe calls of_register_spi_devices, which calls
of_register_spi_devices. The last one allocates an empty spi_device
struct and configures different options of the spi_device according to a
device tree. bits_per_word are not covered here (why?), thus it is left
0 (value after allocation), which, by convention, means 8 bits support.
At the end, the same function (of_register_spi_device) calls
spi_add_device which finally calls spi_setup. The last call, according
to convention, changes bits_per_word to 8 and calls
__spi_validate_bits_per_word which fails, as master doesn't support 8
bit transmission. This fails registration sequence of a device driver.
As you see, the device driver doesn't have possibility to modify
bits_per_word during the registration process, thus it can't provide
support for such limited controllers.

Regards,
Adrian


On 21.02.2017 at 20:08, Mark Brown wrote:
> On Mon, Feb 20, 2017 at 04:35:12PM +0100, Adrian Fiergolski wrote:
>> If an SPI controller doesn't support 8 bit transfers
>> (master->bits_per_word_mask), it will be never registered (tested with
>> spidev):
>> of_register_spi_device calls spi_add_device which calls spi_setup. The last
>> takes as an argument spi_device struct, which, in case of spidev, has
>> bits_per_word set to 0. Thus, the spi_setup function will set it to default
>> 8. Further, the same function will call __spi_validate_bits_per_word which
>> will fail the whole registration for controllers not supporting 8 bit
>> transfers (i.e. xilinx-spi).
> This doens't make much sense, if a device driver requires a given number
> of bits per word forcing a different value via device tree is not going
> to result in the driver actually working.  If you want to use a device
> with a controller with restricted bits per word support you need to
> change the device driver to support the limited capabilities of the
> controller.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ