All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] mmc: tegra: use bounce buffer APIs
Date: Tue, 06 Nov 2012 11:50:22 -0700	[thread overview]
Message-ID: <50995BEE.7020108@wwwdotorg.org> (raw)
In-Reply-To: <CAPnjgZ0LU_FTxyf4cEFeySadmukC3BeTw34qDr916+AUaTyV-A@mail.gmail.com>

On 11/05/2012 05:00 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Mon, Nov 5, 2012 at 3:04 PM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> Tegra's MMC driver does DMA, and hence needs cache-aligned buffers. In
>> some cases (e.g. user load commands) this cannot be guaranteed by callers
>> of the MMC APIs. To solve this, modify the Tegra MMC driver to use the
>> new bounce_buffer_*() APIs.

>> diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c

>>  #include <asm/arch-tegra/clk_rst.h>
>>  #include <asm/arch-tegra/tegra_mmc.h>
>>  #include <mmc.h>
>> +#include <bouncebuf.h>
> 
> The order seems wrong here - I think bouncebuf and mmc should go above
> the asm/ ones, and bouncebuf should be first.

Is there a defined order for header files? I suppose I should try and
read and remember more documentation!

>> @@ -180,8 +196,10 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
>>         if (data)
>>                 mmc_set_transfer_mode(host, data);
>>
>> -       if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY))
>> -               return -1;
>> +       if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY)) {
>> +               ret = -1;
>> +               goto cleanup;
>> +       }
> 
> You might consider putting this body in a function so you don't need
> these two lines everywhere below.

I'm not quite sure how a function would work here; a function can't
really goto. Do you mean a macro? I'd tend to this a macro would
obfuscate the pretty simple code.

Oh, perhaps you mean having a new top-level function that does:

bounce_buffer_start();
calls a function to do all the work
bounce_buffer_stop();

That would certainly simplify the patch.

>> diff --git a/include/configs/tegra-common-post.h b/include/configs/tegra-common-post.h

>> +#ifdef CONFIG_TEGRA_MMC
>> +#define CONFIG_BOUNCE_BUFFER
>> +#endif
> 
> Is there really any harm in just defining this always (say in the
> tegra20-common.h)? The functions should be dropped if not used.

I suppose it'd be fine to always enable this since the linker should
drop the functions when not referenced. Of course, that relies on
bouncebuf.o not having any global side-effects (e.g. registering things
via custom linker segments that are always pulled in). The code above
represents the actual dependency too; hopefully one day U-Boot will
sprout Kconfig, and that logic can be replaced by:

config TEGRA_MMC
    select BOUNCE_BUFFER

  reply	other threads:[~2012-11-06 18:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-05 23:04 [U-Boot] [PATCH 1/3] common: add ifdefs around bouncebuf.c body Stephen Warren
2012-11-05 23:04 ` [U-Boot] [PATCH 2/3] common: rework bouncebuf implementation Stephen Warren
2012-11-05 23:54   ` Simon Glass
2012-11-06 18:44     ` Stephen Warren
2012-11-06 19:30     ` Stephen Warren
2012-11-05 23:04 ` [U-Boot] [PATCH 3/3] mmc: tegra: use bounce buffer APIs Stephen Warren
2012-11-06  0:00   ` Simon Glass
2012-11-06 18:50     ` Stephen Warren [this message]
2012-11-06 19:03       ` Simon Glass
2012-11-05 23:47 ` [U-Boot] [PATCH 1/3] common: add ifdefs around bouncebuf.c body Simon Glass
2012-11-06 18:04   ` Stephen Warren
2012-11-06  0:54 ` Marek Vasut
2012-11-06 18:07   ` Stephen Warren
2012-11-06 22:43     ` Marek Vasut
2012-11-06 22:49       ` Stephen Warren
2012-11-06 22:57         ` Marek Vasut
2012-11-06 23:13           ` Stephen Warren
2012-11-07 13:21             ` Marek Vasut
2012-11-07 17:00               ` Stephen Warren
2012-11-08  1:20                 ` Marek Vasut

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=50995BEE.7020108@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.