All of lore.kernel.org
 help / color / mirror / Atom feed
From: andre.przywara@linaro.org (Andre Przywara)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] DMA: fix AMBA PL08x driver issue with 64bit DMA address type
Date: Thu, 15 Aug 2013 23:07:26 +0200	[thread overview]
Message-ID: <520D430E.2050803@linaro.org> (raw)
In-Reply-To: <CAL_JsqLRtRvPyFagLLaRAjciiur=qVKmt2v7q5MPtEGuDske4Q@mail.gmail.com>

On 08/14/2013 09:13 PM, Rob Herring wrote:
> On Wed, Aug 14, 2013 at 8:00 AM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
>> NAK.
>
> This patch has nothing to do with dma masks or your dma mask series.
> The code deals with bus alignment and cleans up the code to do
> alignment operations in a sane way compared to modulo operator. The
> only thing 64-bit dma_addr_t did was expose crap code.

I agree. Actually I'd see the DMA mask thing just as an opportunity to 
fix this code, not as the reason. I guess there are gazillions of 
drivers in the ARM world which have problems with any address related 
variable being bigger than 32bit, and those should all be fixed eventually.

> Perhaps bus_addr_offset needs a better name to indicate it is dealing
> with bus alignment rather than bus address offset.

Actually my first patch version called this function 
unaligned_bus_addr(), but this was rather odd with the one non-boolean 
usage of it - where it actually wants to know the offset.

Regards,
Andre.

>> On Wed, Aug 14, 2013 at 02:52:08PM +0200, Andre Przywara wrote:
>>> In Rob's recent pull request the patch
>>>        ARM: highbank: select ARCH_DMA_ADDR_T_64BIT for LPAE
>>> promotes dma_addr_t to 64bit, which breaks compilation of the
>>> AMBA PL08x DMA driver.
>>> GCC has no function for the 64bit/8bit modulo operation.
>>> Looking more closely the divisor can only be 1, 2 or 4, so the full
>>> featured '%' modulo operation is overkill and can be replaced by
>>> simple bit masking.
>>>
>>> Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
>>> ---
>>>   drivers/dma/amba-pl08x.c | 16 ++++++++++------
>>>   1 file changed, 10 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
>>> index 06fe45c..29e1cf9 100644
>>> --- a/drivers/dma/amba-pl08x.c
>>> +++ b/drivers/dma/amba-pl08x.c
>>> @@ -286,6 +286,11 @@ static inline struct pl08x_txd *to_pl08x_txd(struct dma_async_tx_descriptor *tx)
>>>        return container_of(tx, struct pl08x_txd, vd.tx);
>>>   }
>>>
>>> +static int bus_addr_offset(struct pl08x_bus_data *bus)
>>> +{
>>> +     return bus->addr & (bus->buswidth - 1);
>>> +}
>>> +
>>>   /*
>>>    * Mux handling.
>>>    *
>>> @@ -886,8 +891,8 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
>>>                                return 0;
>>>                        }
>>>
>>> -                     if ((bd.srcbus.addr % bd.srcbus.buswidth) ||
>>> -                                     (bd.dstbus.addr % bd.dstbus.buswidth)) {
>>> +                     if (bus_addr_offset(&bd.srcbus) ||
>>> +                                     bus_addr_offset(&bd.dstbus)) {
>>>                                dev_err(&pl08x->adev->dev,
>>>                                        "%s src & dst address must be aligned to src"
>>>                                        " & dst width if peripheral is flow controller",
>>> @@ -908,9 +913,8 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
>>>                 */
>>>                if (bd.remainder < mbus->buswidth)
>>>                        early_bytes = bd.remainder;
>>> -             else if ((mbus->addr) % (mbus->buswidth)) {
>>> -                     early_bytes = mbus->buswidth - (mbus->addr) %
>>> -                             (mbus->buswidth);
>>> +             else if (bus_addr_offset(mbus)) {
>>> +                     early_bytes = mbus->buswidth - bus_addr_offset(mbus);
>>>                        if ((bd.remainder - early_bytes) < mbus->buswidth)
>>>                                early_bytes = bd.remainder;
>>>                }
>>> @@ -928,7 +932,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x,
>>>                         * Master now aligned
>>>                         * - if slave is not then we must set its width down
>>>                         */
>>> -                     if (sbus->addr % sbus->buswidth) {
>>> +                     if (bus_addr_offset(sbus)) {
>>>                                dev_dbg(&pl08x->adev->dev,
>>>                                        "%s set down bus width to one byte\n",
>>>                                        __func__);
>>> --
>>> 1.7.12.1
>>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2013-08-15 21:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 12:52 [PATCH 0/2] DMA: AMBA PL08x DMA driver fixes due to ARCH_DMA_ADDR_T_64BIT Andre Przywara
2013-08-14 12:52 ` [PATCH 1/2] DMA: fix AMBA PL08x driver issue with 64bit DMA address type Andre Przywara
2013-08-14 13:00   ` Russell King - ARM Linux
2013-08-14 19:13     ` Rob Herring
2013-08-15 21:07       ` Andre Przywara [this message]
2013-08-15 21:15         ` Russell King - ARM Linux
2013-08-19 10:19           ` [PATCH v2] DMA: fix AMBA PL08x compilation " Andre Przywara
2013-08-19 13:26             ` Rob Herring
2013-08-21  6:17             ` Vinod Koul
2013-08-21 21:01   ` [PATCH 1/2] DMA: fix AMBA PL08x driver " Linus Walleij
2013-08-21 21:22     ` Andre Przywara
2013-08-21 21:49     ` Matt Sealey
2013-08-14 12:52 ` [PATCH 2/2] DMA: fix printk warning in AMBA PL08x DMA driver Andre Przywara
2013-08-14 13:00   ` Russell King - ARM Linux
2013-08-14 13:00 ` [PATCH 0/2] DMA: AMBA PL08x DMA driver fixes due to ARCH_DMA_ADDR_T_64BIT Russell King - ARM Linux
2013-08-14 14:05   ` Rob Herring

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=520D430E.2050803@linaro.org \
    --to=andre.przywara@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.