Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753964AbcKQRdR (ORCPT ); Thu, 17 Nov 2016 12:33:17 -0500 Received: from mail-co1nam03on0054.outbound.protection.outlook.com ([104.47.40.54]:12352 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932308AbcKQRdK (ORCPT ); Thu, 17 Nov 2016 12:33:10 -0500 From: Rafal Ozieblo To: Harini Katakam CC: "harini.katakam@xilinx.com" , "nicolas.ferre@atmel.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [RFC PATCH 2/2] net: macb: Add 64 bit addressing support for GEM Thread-Topic: [RFC PATCH 2/2] net: macb: Add 64 bit addressing support for GEM Thread-Index: AQHSQM0mlMF9RYMdA0O6HcZ/ouUay6DdGzrQ Date: Thu, 17 Nov 2016 12:57:23 +0000 Message-ID: References: In-Reply-To: Accept-Language: pl-PL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=rafalo@cadence.com; x-originating-ip: [213.131.238.28] x-microsoft-exchange-diagnostics: 1;BN3PR07MB2516;7:p5XH4nsuYYoUYktgaXwE0F3bmcCqRKO+Mnm+ZpKhUEnEuOkNj6mEPEexBbuEDJ6VSEZUp74fD0rVuQyPb/zRIWA5Jd1Lyg1xhZgCVfxCM1Te0EmnbokEYTDf7OCIPVY15nYeM/dPtBnqOhzV7VPUZk1Ff62WXexK8GA6Q8GG1V2LJbwMY8gRM2oBelYBYIYQHH4LeDjzCK9Tzve3ZNeiz5+1A0VwLovOmz5lm/61zxvBMNq1yXn6C7bqC4+xOmxLTpXvAZwsZ0A3p86Qle4nxtOuLKZR7bA0yp1N5KEB1jhkqUA/sgGWbIzfec2jbwujJy2MvH6J8SklPWdhWhfXyXMHDhRm33XAQwgUfAbmxUU=;20:4Ib1A+r5VIzBIPhpwhVhzvlnIDnVJ639TQQoCKhr91juv/PrDV6zWdsagA/7FSF8Wx1LJmCdtcupqTmwU+BuMRP+PFUZtCqeuk+bnjG0XEJZE8PCl8uwxt4kXgi27TBLfem1eAlESASXuCqPv7q363F7Wj68plNrX87i6pOalI9ln0Suyy0rDWSy0FtX3ey4OFj6JAIqlG4BdTdby73C4kDRSRC08KVdERwbWK5xkDFT4rQrlUQRoyQlFf7/V83Z x-ms-office365-filtering-correlation-id: 6fe8226a-fc71-40f0-e83e-08d40ee94698 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN3PR07MB2516; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(192813158149592)(72806322054110); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040281)(6060326)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041223)(6061324);SRVR:BN3PR07MB2516;BCL:0;PCL:0;RULEID:;SRVR:BN3PR07MB2516; x-forefront-prvs: 01294F875B x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(24454002)(13464003)(36092001)(377454003)(199003)(189002)(76576001)(68736007)(1411001)(105586002)(99286002)(66066001)(106116001)(106356001)(7696004)(2950100002)(305945005)(8666005)(33656002)(8676002)(86362001)(7846002)(7736002)(74316002)(6916009)(110136003)(5660300001)(87936001)(189998001)(6506003)(50986999)(76176999)(54356999)(3660700001)(3280700002)(9686002)(8936002)(81156014)(101416001)(81166006)(122556002)(77096005)(2900100001)(92566002)(2906002)(229853002)(97736004)(102836003)(6116002)(3846002)(4326007)(7059030)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR07MB2516;H:BN3PR07MB2516.namprd07.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Nov 2016 12:57:23.8745 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR07MB2516 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id uAHHXO34012343 Content-Length: 3197 Lines: 74 -----Original Message----- From: Harini Katakam [mailto:harinikatakamlinux@gmail.com] Sent: 17 listopada 2016 13:22 To: Rafal Ozieblo Cc: harini.katakam@xilinx.com; nicolas.ferre@atmel.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/2] net: macb: Add 64 bit addressing support for GEM > Hi Rafal, > > On Thu, Nov 17, 2016 at 5:20 PM, Rafal Ozieblo wrote: > > Hello, > > I think, there could a bug in your patch. > > > >> + > >> +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT > >> + dmacfg |= GEM_BIT(ADDR64); #endif > > > > You enable 64 bit addressing (64b dma bus width) always when appropriate architecture config option is enabled. > > But there are some legacy controllers which do not support that feature. According Cadence hardware team: > > "64 bit addressing was added in July 2013. Earlier version do not have it. > > This feature was enhanced in release August 2014 to have separate upper address values for transmit and receive." > > > >> /* Bitfields in NSR */ > >> @@ -474,6 +479,10 @@ > >> struct macb_dma_desc { > > > u32 addr; > >> u32 ctrl; > >> +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT > >> + u32 addrh; > >> + u32 resvd; > >> +#endif > >> }; > > > > It will not work for legacy hardware. Old descriptor is 2 words wide, the new one is 4 words wide. > > If you enable CONFIG_ARCH_DMA_ADDR_T_64BIT but hardware doesn't > > support it at all, you will miss every second descriptor. > > > > True, this feature is not available in all of Cadence IP versions. > In fact, the IP version Zynq does not support this. But the one in ZynqMP does. > So, we enable kernel config for 64 bit DMA addressing for this SoC and hence the driver picks it up. My assumption was that if the legacy IP does not support > 64 bit addressing, then this DMA option wouldn't be enabled. What for example with arm64 (which enables CONFIG_ARCH_DMA_ADDR_T_64BIT by default) and legacy IP controller? Or systems with multiple IP, both with and without 64b dma capable? It might result in unpredictable behavio. (explained below) > There is a design config register in Cadence IP which is being read to check for 64 bit address support - DMA mask is set based on that. > But the addition of two descriptor words cannot be based on this runtime check. > For this reason, all the static changes were placed under this check. Are you talking about this? +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + if (GEM_BFEXT(DBWDEF, gem_readl(bp, DCFG1)) > GEM_DBW32) + dma_set_mask(&pdev->dev, DMA_BIT_MASK(44)); +#endif + It only sets the maximum address which can be seen on address bus. (its mask exactly) +static inline void macb_set_addr(struct macb_dma_desc *desc, dma_addr_t addr) +{ + desc->addr = (u32)addr; +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + desc->addrh = (u32)(addr >> 32); +#endif +} + Because addr is 32b wide, (u32)(addr >> 32) equals 0. IP controller uses 2 words for dma descriptor, so desc->addr from second hardware descriptor will be overwritten by desc->addrh from the first software descriptor. (same desc->ctrl from second hardware descriptor will be overwritten by desc->resvd). Regards, Harini