linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Stephen Boyd <stephen.boyd@linaro.org>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Mark Brown <broonie@kernel.org>,
	Ming Lei <ming.lei@canonical.com>,
	Vikram Mulukutla <markivx@codeaurora.org>
Subject: Re: [RESEND/PATCHv4 v4 1/3] firmware: Consolidate kmap/read/write logic
Date: Tue, 7 Jun 2016 13:21:00 -0700	[thread overview]
Message-ID: <20160607132100.dcc052bdf5affaab7cdc29ce@linux-foundation.org> (raw)
In-Reply-To: <20160607164741.31849-2-stephen.boyd@linaro.org>

On Tue,  7 Jun 2016 09:47:39 -0700 Stephen Boyd <stephen.boyd@linaro.org> wrote:

> We use similar structured code to read and write the kmapped
> firmware pages. The only difference is read copies from the kmap
> region and write copies to it. Consolidate this into one function
> to reduce duplication.
> 
> ...
>
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -691,6 +691,29 @@ out:
>  
>  static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
>  
> +static void firmware_rw(struct firmware_buf *buf, char *buffer,
> +			loff_t offset, size_t count, bool read)
> +{
> +	while (count) {
> +		void *page_data;
> +		int page_nr = offset >> PAGE_SHIFT;
> +		int page_ofs = offset & (PAGE_SIZE-1);
> +		int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
> +
> +		page_data = kmap(buf->pages[page_nr]);

fwiw, we could switch the code to kmap_atomic() here.  It is faster.

> +		if (read)
> +			memcpy(buffer, page_data + page_ofs, page_cnt);
> +		else
> +			memcpy(page_data + page_ofs, buffer, page_cnt);
> +
> +		kunmap(buf->pages[page_nr]);
> +		buffer += page_cnt;
> +		offset += page_cnt;
> +		count -= page_cnt;
> +	}
> +}

  reply	other threads:[~2016-06-07 20:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07 16:47 [RESEND/PATCHv4 v4 0/3] request_firmware() into pre-allocated buffers Stephen Boyd
2016-06-07 16:47 ` [RESEND/PATCHv4 v4 1/3] firmware: Consolidate kmap/read/write logic Stephen Boyd
2016-06-07 20:21   ` Andrew Morton [this message]
2016-06-07 16:47 ` [RESEND/PATCHv4 v4 2/3] firmware: Provide infrastructure to make fw caching optional Stephen Boyd
2016-06-14  1:53   ` Luis R. Rodriguez
2016-06-07 16:47 ` [RESEND/PATCHv4 v4 3/3] firmware: Support loading into a pre-allocated buffer Stephen Boyd
2016-06-12  9:28   ` kbuild test robot

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=20160607132100.dcc052bdf5affaab7cdc29ce@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=broonie@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markivx@codeaurora.org \
    --cc=ming.lei@canonical.com \
    --cc=stephen.boyd@linaro.org \
    --cc=zohar@linux.vnet.ibm.com \
    /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).