[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLinCFmEPHzaQRy0Wq_pjWtA+n_Uu9D63t1oEjtQM=1yMHQ@mail.gmail.com>
Date: Mon, 9 Dec 2019 09:29:46 -0800
From: Michael Chan <michael.chan@...adcom.com>
To: George Spelvin <lkml@....org>
Cc: Netdev <netdev@...r.kernel.org>, Hauke Mehrtens <hauke@...ke-m.de>
Subject: Re: [RFC PATCH 2/4] b44: Fix off-by-one error in acceptable address range
On Sun, Dec 8, 2019 at 12:36 AM George Spelvin <lkml@....org> wrote:
>
> The requirement is dma_addr + size <= 0x40000000, not 0x3fffffff.
>
> In a logically separate but overlapping change, this patch also
> rearranges the logic for detecting failures to use a goto rather
> than testing dma_mapping_error() twice. The latter is expensive if
> CONFIG_DMA_API_DEBUG is set, but also for bug-proofing reasons I try to
> avoid having the same condition in two places that must be kept in sync.
>
> Signed-off-by: George Spelvin <lkml@....org>
> ---
> drivers/net/ethernet/broadcom/b44.c | 42 ++++++++++++++++-------------
> 1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index 394671230c1c..e540d5646aef 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -680,12 +680,13 @@ static int b44_alloc_rx_skb(struct b44 *bp, int src_idx, u32 dest_idx_unmasked)
>
> /* Hardware bug work-around, the chip is unable to do PCI DMA
> to/from anything above 1GB :-( */
> - if (dma_mapping_error(bp->sdev->dma_dev, mapping) ||
> - mapping + RX_PKT_BUF_SZ > DMA_BIT_MASK(30)) {
> + if (dma_mapping_error(bp->sdev->dma_dev, mapping))
> + goto workaround;
> + if (mapping + RX_PKT_BUF_SZ > DMA_BIT_MASK(30)+1) {
The patchset looks ok to me. The only minor suggestion is to define
this (DMA_BIT_MASK(30) + 1) as B44_DMA_ADDR_LIMIT or something like
that so you don't have to repeat it so many times.
Thanks.
Powered by blists - more mailing lists