linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Olliver Schinagl <oliver@schinagl.nl>
To: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: Jacek Anaszewski <j.anaszewski@samsung.com>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Richard Purdie <rpurdie@rpsys.net>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux LED Subsystem <linux-leds@vger.kernel.org>,
	Peter Meerwald <pmeerw@pmeerw.net>
Subject: Re: [PATCHv1 0/6] leds: pca9653x: support inverted outputs and cleanups
Date: Wed, 20 Apr 2016 09:21:30 +0200	[thread overview]
Message-ID: <57172DFA.9030107@schinagl.nl> (raw)
In-Reply-To: <CAPybu_2uZqR4exnS08taVYyr=ziK+EzuJy+_FxhbtqSiOE_=mw@mail.gmail.com>

Hey Ricardo,

On 19-04-16 15:42, Ricardo Ribalda Delgado wrote:
> Hi again
>
> On Tue, Apr 19, 2016 at 3:27 PM, Olliver Schinagl <oliver@schinagl.nl> wrote:
>> Hey Ricardo,
>> Without actually looking at the code right now, but the driver does a
>> read/modify/write on the register, and a register is shared among several
>> leds. So in that regard, it makes sense and I don't think it's very
>> expensive to move the lock, since we have to lock for the write a few lines
>> down anyway.
> Actually, the code is only making sure that PCA963X_MODE2_DMBLNK is
> on. It is never cleared afterwards.
i do not think this can work at all actually.

While trying to move those lines to probe and thinking about the 
consequences, I noticed blink is now never enabled again.
E.g. the probe reads the blink bit at probe, updates its internal 
trigger to timer etc and now during probe, if there is no 
default-trigger, we now have the correct trigger set.

However, when we enable blink via the timer trigger for example, the 
blink_set() gets executed and it writes the blink bit.

mode2 = i2c_smbus_read_byte_data(pca963x->chip->client, PCA963X_MODE2);
  	if (!(mode2 & PCA963X_MODE2_DMBLNK))
  		i2c_smbus_write_byte_data(pca963x->chip->client, PCA963X_MODE2,
  			mode2 | PCA963X_MODE2_DMBLNK);


so after the read, we immediatly do a write.

Now I understand your concern, the i2c operations are slow and time 
consuming making the mutex very expensive.

The thing is, to be able to write the blink bit, we need to read the 
whole mode2 register, to do a proper read-modify-write. We don't know 
what's in the mode2 register and we only want to write the bit if it is 
actually not set to begin with, to save a i2c write operation.

We start this function already however with with two write calls of 
sequential registers, the grp and pwm enable registers. There is even a 
call to automatically update these registers, which I think we'd use 
i2c_master_send() to set the address via the auto-increment register and 
enable auto increment of these two registers. Now we reduced the 2 
seperate calls into one bigger 'faster' call. So 1 win there. But! it 
will require us however to change the other calls to disable auto 
increment via de mode1 register. Since this is an extra i2c_write 
operation, it makes the other i2c writes more expensive, which may 
happen much more often (enable blink only happens occasionally, changing 
the brightness may change a lot (fade in fade out).

So unless i'm totally misunderstanding something, I don't think we can 
safe much here at all.

The only win would be by not reading the mode2 in the mutex, but what if 
we read the register, someone else modifies it, and we write to it again?

olliver

>
> It will be great if you could set that bit on probe and remove those
> two lines and verify that it works on real hardware.
>
>
> The move of the lock can be a bit expensive. i2c writes can take a
> while to be performed, this is why only ledout was protected
> initially.
>
> Best regards

  reply	other threads:[~2016-04-20  7:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-19  7:40 [PATCHv1 0/6] leds: pca9653x: support inverted outputs and cleanups Olliver Schinagl
2016-04-19  7:40 ` [PATCH 1/6] leds: pca963x: Alphabetize headers Olliver Schinagl
2016-04-19  7:40 ` [PATCH 2/6] leds: pca963x: Lock i2c r/w access Olliver Schinagl
2016-04-19  7:40 ` [PATCH 3/6] leds: pca963x: Add defines and remove some magic values Olliver Schinagl
2016-04-19  8:16   ` kbuild test robot
2016-04-19  7:40 ` [PATCH 4/6] leds: pca963x: Reduce " Olliver Schinagl
2016-04-19  7:40 ` [PATCH 5/6] leds: pca963x: Inform the output that it is inverted Olliver Schinagl
2016-04-21 15:07   ` Rob Herring
2016-04-22 12:38     ` Olliver Schinagl
2016-04-22 13:09       ` Rob Herring
2016-04-22 15:44         ` Olliver Schinagl
2016-04-19  7:40 ` [PATCH 6/6] leds: pca963x: Remove whitespace and checkpatch problems Olliver Schinagl
2016-04-19  9:23 ` [PATCHv1 0/6] leds: pca9653x: support inverted outputs and cleanups Jacek Anaszewski
2016-04-19  9:39   ` Olliver Schinagl
2016-04-19 11:18     ` Ricardo Ribalda Delgado
2016-04-19 13:27       ` Olliver Schinagl
2016-04-19 13:42         ` Ricardo Ribalda Delgado
2016-04-20  7:21           ` Olliver Schinagl [this message]
2016-04-20  8:01             ` Ricardo Ribalda Delgado
2016-04-20  8:51               ` Olliver Schinagl
2016-04-20  8:56                 ` Ricardo Ribalda Delgado
2016-04-20  9:06                   ` Olliver Schinagl
2016-04-20  9:17                     ` Ricardo Ribalda Delgado
2016-04-20 10:12                       ` Olliver Schinagl
2016-04-22  7:21                       ` Olliver Schinagl
2016-05-12  9:04                       ` Olliver Schinagl
2016-05-12  9:07                   ` Olliver Schinagl

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=57172DFA.9030107@schinagl.nl \
    --to=oliver@schinagl.nl \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=pmeerw@pmeerw.net \
    --cc=ricardo.ribalda@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=rpurdie@rpsys.net \
    /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).