linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: "Michał Kępień" <kernel@kempniu.pl>
Cc: Darren Hart <dvhart@infradead.org>,
	Matthew Garrett <mjg59@srcf.ucam.org>,
	Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <j.anaszewski@samsung.com>,
	Alex Hung <alex.hung@canonical.com>,
	platform-driver-x86@vger.kernel.org, linux-leds@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/14] dell-laptop: extract SMBIOS-related code to a separate module
Date: Thu, 21 Jan 2016 14:14:50 +0100	[thread overview]
Message-ID: <20160121131450.GE7192@pali> (raw)
In-Reply-To: <20160121130603.GA4360@eudyptula.hq.kempniu.pl>

On Thursday 21 January 2016 14:06:03 Michał Kępień wrote:
> > > A total of four functions have something to do with the SMBIOS buffer:
> > > 
> > >   * get_buffer()
> > >   * clear_buffer()
> > >   * release_buffer()
> > >   * dell_send_request()
> > > 
> > > This rework is a chance to make them all consistent, i.e. remove the
> > > SMBIOS buffer from their argument lists.  This way we can "signal" this
> > > API's users that there is only one SMBIOS buffer ever involved while
> > > still removing the extern and EXPORT_SYMBOL_GPL for the buffer.  BTW, I
> > > also see little point in returning the buffer from dell_send_request()
> > > as none of its callers in dell-laptop assign its return value to
> > > anything (i.e. there is no "buffer = dell_send_request(buffer, ...)" in
> > > the code).
> > > 
> > > To sum up, I'd suggest that function prototypes could look like this:
> > > 
> > >     struct calling_interface_buffer *dell_smbios_get_buffer(void);
> > >     void dell_smbios_clear_buffer(void);
> > >     void dell_smbios_release_buffer(void);
> > >     void dell_smbios_send_request(int class, int select);
> > > 
> > > What do you think?
> > > 
> > 
> > In other scenario functions should do something like this:
> > 
> > struct buf *buf_alloc(void);
> > buf_clear(struct buf *buf);
> > buf_free(struct buf *buf);
> > buf_do_something(struct buf *buf, ...);
> > 
> > But here I do not know how hard is to create alloc/free functions and
> > what is cost for creating that buffer in first 4GB memory...
> 
> I'm guessing the cost is negligible, given that SMBIOS calls are not
> present in any hot path.  Writing these functions is also pretty
> straightforward, but the inconvenience of this approach is that it
> forces the callers to do the error-checking for each buf_alloc() call.
> It also seems pretty inefficient - notice we only need 36 bytes for the
> calling interface buffer, yet we would be allocating a whole page in
> each buf_alloc() call.
> 
> On the other hand, I believe returning a separate buffer for each
> buf_alloc() caller makes it possible to drop buffer_mutex altogether.
> Yet, the approach I suggested is more similar to what the Dell-supplied
> dcdbas driver does internally (it manages a single, resizable buffer,
> which is protected by a mutex and controllable from userspace through
> sysfs), which is why I think it's a good idea to stick to that concept
> for consistency.
> 
> As this patch series already touches a lot of code, I would like to
> avoid changing the underlying concepts as much as possible.  If that's
> okay with you, I'll post a v2 which includes your suggestion to make the
> buffer pointer static while keeping the interface similar to the
> original one.  If you would really like me to take a different path,
> please let me know and I'll comply.
> 

Another idea:

What about passing struct calling_interface_buffer from caller allocated
memory (either from stack or kernel alloc) to dell-smbios which will
copy it into own buffer under 4GB and then pass it to dcdbas?

This will avoid to use that get/release function and there will be only
one send_request.

But I will let decision for API to other people as I do not know what
the best API to use here...

-- 
Pali Rohár
pali.rohar@gmail.com

  reply	other threads:[~2016-01-21 13:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12 14:02 [PATCH 00/14] Common Dell SMBIOS API Michał Kępień
2016-01-12 14:02 ` [PATCH 01/14] dell-laptop: extract SMBIOS-related code to a separate module Michał Kępień
2016-01-16 15:19   ` Pali Rohár
2016-01-18 10:34     ` Michał Kępień
2016-01-20  9:21     ` Michał Kępień
2016-01-21  8:35       ` Pali Rohár
2016-01-21 13:06         ` Michał Kępień
2016-01-21 13:14           ` Pali Rohár [this message]
2016-01-21 13:39             ` Michał Kępień
2016-02-08 21:42               ` Darren Hart
2016-02-09  8:33                 ` Pali Rohár
2016-02-09 13:58                   ` Michał Kępień
2016-02-09 16:51                   ` Darren Hart
2016-02-09 19:12                     ` Pali Rohár
2016-02-10 23:03                       ` Darren Hart
2016-01-12 14:02 ` [PATCH 02/14] dell-smbios: don't pass a buffer to dell_send_request() Michał Kępień
2016-01-12 14:02 ` [PATCH 03/14] dell-smbios: rename buffer to dell_smbios_buffer Michał Kępień
2016-01-12 14:02 ` [PATCH 04/14] dell-smbios: rename clear_buffer() to dell_smbios_clear_buffer() Michał Kępień
2016-01-12 14:02 ` [PATCH 05/14] dell-smbios: rename get_buffer() to dell_smbios_get_buffer() Michał Kępień
2016-01-12 14:02 ` [PATCH 06/14] dell-smbios: rename release_buffer() to dell_smbios_release_buffer() Michał Kępień
2016-01-12 14:02 ` [PATCH 07/14] dell-smbios: rename dell_send_request() to dell_smbios_send_request() Michał Kępień
2016-01-12 14:02 ` [PATCH 08/14] dell-smbios: implement new function for finding DMI table 0xDA tokens Michał Kępień
2016-01-12 14:02 ` [PATCH 09/14] dell-laptop: use dell_smbios_find_token() instead of find_token_id() Michał Kępień
2016-01-12 14:02 ` [PATCH 10/14] dell-laptop: use dell_smbios_find_token() instead of find_token_location() Michał Kępień
2016-01-12 14:02 ` [PATCH 11/14] dell-smbios: remove find_token_{id,location}() Michał Kępień
2016-01-12 14:02 ` [PATCH 12/14] dell-smbios: make da_tokens static Michał Kępień
2016-01-12 14:02 ` [PATCH 13/14] dell-led: use dell_smbios_find_token() for finding mic DMI tokens Michał Kępień
2016-01-21 10:52   ` Jacek Anaszewski
2016-01-21 15:00     ` Michał Kępień
2016-01-21 15:42       ` Jacek Anaszewski
2016-01-12 14:03 ` [PATCH 14/14] dell-led: use dell_smbios_send_request() for SMBIOS requests Michał Kępień
2016-01-14 22:43 ` [PATCH 00/14] Common Dell SMBIOS API Darren Hart

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=20160121131450.GE7192@pali \
    --to=pali.rohar@gmail.com \
    --cc=alex.hung@canonical.com \
    --cc=dvhart@infradead.org \
    --cc=j.anaszewski@samsung.com \
    --cc=kernel@kempniu.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=platform-driver-x86@vger.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).