Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752596AbdCOSjW (ORCPT ); Wed, 15 Mar 2017 14:39:22 -0400 Received: from mail-bl2nam02on0061.outbound.protection.outlook.com ([104.47.38.61]:42912 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751014AbdCOShr (ORCPT ); Wed, 15 Mar 2017 14:37:47 -0400 Authentication-Results: codeaurora.org; dkim=none (message not signed) header.d=none;codeaurora.org; dmarc=none action=none header.from=cavium.com; Date: Wed, 15 Mar 2017 19:37:34 +0100 From: Robert Richter To: Shanker Donthineni Cc: Marc Zyngier , Thomas Gleixner , Jason Cooper , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 8/8] irqchip, gicv3-its, cma: Use CMA for allocation of large device tables Message-ID: <20170315183734.GW16822@rric.localdomain> References: <20170306125739.19445-1-rrichter@cavium.com> <20170306125739.19445-9-rrichter@cavium.com> <3c462655-fb2c-ede7-1dc0-ca5c7f64904f@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3c462655-fb2c-ede7-1dc0-ca5c7f64904f@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.224.60.118] X-ClientProxiedBy: AM4P190CA0013.EURP190.PROD.OUTLOOK.COM (10.172.213.151) To BL2PR07MB2337.namprd07.prod.outlook.com (10.167.101.15) X-MS-Office365-Filtering-Correlation-Id: 0e98a251-f3d8-4b0b-e63b-08d46bd25e80 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BL2PR07MB2337; X-Microsoft-Exchange-Diagnostics: 1;BL2PR07MB2337;3:FoAlIY67mM/QajoAjvxjlE67U9bMPaKB6pBW4h8dUy5uxhFl5z6MxRUbS/gMFAt4fykZm9AyU2GjxF6bqU68u7NDSbjX+5w9tgmtzyfg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MMw2PvQyQCMANKvGQ6VTlaWK5xyzleZyyJbrMytNX5V7vIqZ933B39Z0R6ZF5fSoOVmkJjO799VEbz+N9qJpJtzl5AgIPJAQRBt32NxrcP5pmCIVyuFyslLKX3/4w0RY49WeCcknO3KDHCU59aYZyNdFSZhkLz7/ol4Lgy82fxH4lrSSHjkQfDf/yVHXurldZqnwQ+TNqLIvhi4vSAfAzw0Tt6ZTGLfZe8djhejNXnlOY3vboyWqybLX2BixSTy5m6GY3D/BnuY+GUK2isuddzts4xbq2Cwqpvzh9BrzH1mDFirywVHXQ/rHqotFPfOXg6MjrbqcQoNF3NduBWal35NKicegjuPKu4T0tfyezQ7qtm4/XlnOE0YQXDGh+4QfWPuhsH+Vi7ehwbzGJur2AtV6Qp9NFvP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123560025)(20161123564025)(20161123558025)(20161123562025)(20161123555025)(6072148);SRVR:BL2PR07MB2337;BCL:0;PCL:0;RULEID:;SRVR:BL2PR07MB2337; X-Microsoft-Exchange-Diagnostics: 1;BL2PR07MB2337;4:75RVRDBum5gC0B8aGPb9F3jvQH2lVXFEbuap2V5PBsYUS9S5VtRJhaD2cV5r5r3jyHVwdQROUcSxMeKsmqux5sZZfhVHVi0O3DzuHuryZmuql9CrXxef93iBr/MH2FctBWcHrKvGTA0fntAFIgQN/3Jl07G4Dgs5vQKbbCuFa3JS+9krk8t38Kwzon3bOXBE/h1+wTe5O81V3dn8ymRWytbGCJS3o7EooNKrrt1T0HQnjF5Ck8a6NMCAzGwMUH6pWKElySsw46Wx/z3DzsaF4wJqrpTnM/Dz+0Ds+j++DpITq7cRr0f1ccstfD75rHz3f5NDr99Eu/+Y7Zwaea2bmEZbiwU9qVEshjItrdKSYLHj9QstVoW+W/Db1VJyagzyOSzF8h8mV3+LD3yyqBPR7Tl5cgpdhW8uI81rIO7GJeDBKbCxqeDFpk7QvrUODCMOiBuS89MP8KCWa7ZSMjsU/P0k3SVs6TI0Qr8OBgwSR1zJE91zmJ8CuKTHlgYW6/0CBRjMlDdrmxqnnvUITLTPieKBFajgbccK1b5wdeqwSpxf8AxBygeESfNcUzqi/gizL1jyEm1k3DW9S9VseU6MFs6R8bniQYkc1uk8fmfVt48sApYegH+kUG9p5ubOirVSVzWs1BU8Hzapj9kzWKXJGw== X-Forefront-PRVS: 02475B2A01 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(39410400002)(39450400003)(39830400002)(377454003)(24454002)(81166006)(25786008)(4001350100001)(83506001)(50466002)(23726003)(6916009)(2950100002)(6666003)(53546007)(110136004)(8676002)(305945005)(38730400002)(86362001)(189998001)(1076002)(4326008)(47776003)(66066001)(55016002)(54906002)(2906002)(76176999)(54356999)(50986999)(9686003)(6246003)(5660300001)(6506006)(229853002)(53936002)(33656002)(6116002)(3846002)(7736002)(42186005)(18370500001);DIR:OUT;SFP:1101;SCL:1;SRVR:BL2PR07MB2337;H:rric.localdomain;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR07MB2337;23:2MzIMsH1n7wFRI6bTMHv5toFgOGduyMBl7XIiaEMW?= =?us-ascii?Q?83OH1tzkL/VC5QxtBbxDT6ebRPgxHGUtrHyHC5v/4I3w27ecBI3giPYJRfyx?= =?us-ascii?Q?AwBmp3f6aQzZLWTANPQfCdfsaNXrAoc/XJrMJ0vYNCxjpz+8sQP7yMdj5TRw?= =?us-ascii?Q?V+Y1u+6uOTrED4mC9nf8qtBqtJRxhWwbXBKQGRZEgdlRvurYbZMyYg6mimnk?= =?us-ascii?Q?KaShMIXRo4+HRKDPa9QAJoB7mYDsGKB2bJ1XbDQE/DG/nTpL+1VThRnZ6Kvb?= =?us-ascii?Q?WzyBSLS++azrCXj/FXZ0GfP2w5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NQex7LdqM2VDmUHHLng== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2017 18:37:42.8736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR07MB2337 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2866 Lines: 81 On 14.03.17 12:40:45, Shanker Donthineni wrote: > I don't see anywhere in this patch, code calls explicitly CMA API to > allocate memory for device table. The CMA feature is an optional in > kernel, and will be handled transparently inside the the DMA > layer. It would be nicer to not mention CMA word in the commit > subject. Still CMA is *essential* and used for large tables. IMO this needs to be emphasized. That's the reason for using devm_alloc_coherent(). > On 03/06/2017 06:57 AM, Robert Richter wrote: > > The gicv3-its device table may have a size of up to 16MB. With 4k > > pagesize the maximum size of memory allocation is 4MB. Use CMA for > > allocation of large tables. > Just say use devm_alloc_coherent() to allocate memory. > > > We use the device managed version of dma_alloc_coherent(). Thus, we > > don't need to release it manually on device removal. > > > > Signed-off-by: Robert Richter > > --- > > drivers/irqchip/irq-gic-v3-its.c | 69 +++++++++++++++++++++++----------------- > > 1 file changed, 40 insertions(+), 29 deletions(-) > > > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > > index 6625b3a505f0..6d293a0165b0 100644 > > --- a/drivers/irqchip/irq-gic-v3-its.c > > +++ b/drivers/irqchip/irq-gic-v3-its.c > > @@ -876,13 +878,26 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser, > > order = get_order(GITS_BASER_PAGES_MAX * psz); > > } > > > > - base = (void *)devm_get_free_pages(&its->dev, GFP_KERNEL | __GFP_ZERO, > > - order); > > - if (!base) > > + base = dmam_alloc_coherent(&its->dev, > > + PAGE_ORDER_TO_SIZE(order), > > + &dma_handle, > > + GFP_KERNEL | __GFP_ZERO); > Not just for 1st level device table, you have do a similar code > change when allocating memory for 2nd level device table. The 2nd level tables are much smaller, so no need for dmam_alloc_coherent() there. Though, we could use device managed devm_get_free_pages() there too. > > + > > + if (!base && order >= MAX_ORDER) { > > + order = MAX_ORDER - 1; > > + dev_warn(&its->dev, "Device Table too large, reduce ids %u->%u, no CMA memory available\n", > > + its->device_ids, > > + ilog2(PAGE_ORDER_TO_SIZE(order) / (int)esz)); > > + goto retry_alloc_baser; > > + } > > + > > + if (!base) { > > + dev_err(&its->dev, "Failed to allocate device table\n"); > > return -ENOMEM; > > + } > > @@ -1698,6 +1706,9 @@ static int __init its_init_one(struct its_node *its) > > return err; > > } > > > > + /* Setup dma_ops for dmam_alloc_coherent() */ > > + arch_setup_dma_ops(&its->dev, 0, 0, NULL, true); > > + > Why you are hard-coding DMA coherent property to true here ? It > breaks the MSI(x) functionally on systems where ITS hardware doesn't > support coherency. Aren't current ITS tables coherent only? Thanks, -Robert