From patchwork Thu Dec 3 13:50:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 11948823 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97DFFC001D8 for ; Thu, 3 Dec 2020 13:51:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51039207A2 for ; Thu, 3 Dec 2020 13:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387913AbgLCNvk (ORCPT ); Thu, 3 Dec 2020 08:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727555AbgLCNvk (ORCPT ); Thu, 3 Dec 2020 08:51:40 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DD2DC061A53 for ; Thu, 3 Dec 2020 05:50:54 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id d18so2136407edt.7 for ; Thu, 03 Dec 2020 05:50:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hu9KgoIfbByheWddhHSVotGIyHUSFkyJms4K0ds5aD0=; b=Oi/n0knrwImSI4CEBam8QT0IbtCLWeBEXgD68WJD64bfEHTfoDlB8EpgWv0XH6nEsK nkjOZTH8z65mXjMBxj4+B1ZLT39XcmQSqukqiJO5LpFkA42FAmn6ONe12WmoIYtmE7OI cbbND+9GCGcsc1gROCFrVQDtR0uvr4FKJHjmQJpQW7r1y3EdE82JuM0aEGqS7L8/sT0V pI+pLVfESdFmIO3EfayPzGX+CLQFAJZ6j2ilqTY+ZVoVWtjPnugrPG9y9VoEzCCpoyrS rBnOdvCq++y3Ic1sroxeIb1VvwkITEIM4vPsKFVREboCNxurFjgkiC2ahHY9BCk59vYh zYIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hu9KgoIfbByheWddhHSVotGIyHUSFkyJms4K0ds5aD0=; b=maKPXsty9pexwtXTtwp58KamL3925Zz4XR8EbAmNQ+EEhK4rcqZApYUC/s/PDNZ1+f MIwymQNtRXo/m+ScBHzkQ/kxMhmN9Mm2/2f0w7UvaoOcFBLaXTcY3VTJogew+bSrBtss ThsuzkFoeiDVtj58cl2BM0vuvsmjRxUImSTQi2RVZFMBL3XSs+JnS3HAPoWqaQDBBxdy rPYddhjofusNjCB13sJgZL/63zXRC2ndR/N9bqLI6tuf96nF5srfu++A5xQQxK9SKuQK tOsDDrhZ1oEPMd04uriCE4NUs7X35egnhiCx1mzDF1/fk5F/2c2T/hfrpAySFY20Aa+K TZqg== X-Gm-Message-State: AOAM533fNnGo4xOQC4OwQvT8yRNwuvbFmgpIoaqG19pccVOh8AcafxW+ EPYUh217mofydfrImjfpY883QA== X-Google-Smtp-Source: ABdhPJwBmWi7KNWvH8FypVlA0zQ0mVIrxylTLr76VUWW3/nnN6q4QcfqhToxcbVBPavllXn7a1Rd2Q== X-Received: by 2002:a50:8a8b:: with SMTP id j11mr3015431edj.19.1607003452929; Thu, 03 Dec 2020 05:50:52 -0800 (PST) Received: from belels006.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id t19sm903192eje.86.2020.12.03.05.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 05:50:52 -0800 (PST) From: Patrick Havelange To: Madalin Bucur , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Patrick Havelange Subject: [PATCH net 1/4] net: freescale/fman: Split the main resource region reservation Date: Thu, 3 Dec 2020 14:50:36 +0100 Message-Id: <20201203135039.31474-2-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201203135039.31474-1-patrick.havelange@essensium.com> References: <20201203135039.31474-1-patrick.havelange@essensium.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The main fman driver is only using some parts of the fman memory region. Split the reservation of the main region in 2, so that the other regions that will be used by fman-port and fman-mac drivers can be reserved properly and not be in conflict with the main fman reservation. Signed-off-by: Patrick Havelange --- drivers/net/ethernet/freescale/fman/fman.c | 103 +++++++++++++-------- drivers/net/ethernet/freescale/fman/fman.h | 9 +- 2 files changed, 69 insertions(+), 43 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c index ce0a121580f6..2e85209d560d 100644 --- a/drivers/net/ethernet/freescale/fman/fman.c +++ b/drivers/net/ethernet/freescale/fman/fman.c @@ -58,12 +58,15 @@ /* Modules registers offsets */ #define BMI_OFFSET 0x00080000 #define QMI_OFFSET 0x00080400 -#define KG_OFFSET 0x000C1000 -#define DMA_OFFSET 0x000C2000 -#define FPM_OFFSET 0x000C3000 -#define IMEM_OFFSET 0x000C4000 -#define HWP_OFFSET 0x000C7000 -#define CGP_OFFSET 0x000DB000 +#define SIZE_REGION_0 0x00081000 +#define POL_OFFSET 0x000C0000 +#define KG_OFFSET_FROM_POL 0x00001000 +#define DMA_OFFSET_FROM_POL 0x00002000 +#define FPM_OFFSET_FROM_POL 0x00003000 +#define IMEM_OFFSET_FROM_POL 0x00004000 +#define HWP_OFFSET_FROM_POL 0x00007000 +#define CGP_OFFSET_FROM_POL 0x0001B000 +#define SIZE_REGION_FROM_POL 0x00020000 /* Exceptions bit map */ #define EX_DMA_BUS_ERROR 0x80000000 @@ -1433,7 +1436,7 @@ static int clear_iram(struct fman *fman) struct fman_iram_regs __iomem *iram; int i, count; - iram = fman->base_addr + IMEM_OFFSET; + iram = fman->base_addr_pol + IMEM_OFFSET_FROM_POL; /* Enable the auto-increment */ iowrite32be(IRAM_IADD_AIE, &iram->iadd); @@ -1710,11 +1713,8 @@ static int set_num_of_open_dmas(struct fman *fman, u8 port_id, static int fman_config(struct fman *fman) { - void __iomem *base_addr; int err; - base_addr = fman->dts_params.base_addr; - fman->state = kzalloc(sizeof(*fman->state), GFP_KERNEL); if (!fman->state) goto err_fm_state; @@ -1740,13 +1740,14 @@ static int fman_config(struct fman *fman) fman->state->res = fman->dts_params.res; fman->exception_cb = fman_exceptions; fman->bus_error_cb = fman_bus_error; - fman->fpm_regs = base_addr + FPM_OFFSET; - fman->bmi_regs = base_addr + BMI_OFFSET; - fman->qmi_regs = base_addr + QMI_OFFSET; - fman->dma_regs = base_addr + DMA_OFFSET; - fman->hwp_regs = base_addr + HWP_OFFSET; - fman->kg_regs = base_addr + KG_OFFSET; - fman->base_addr = base_addr; + fman->fpm_regs = fman->dts_params.base_addr_pol + FPM_OFFSET_FROM_POL; + fman->bmi_regs = fman->dts_params.base_addr_0 + BMI_OFFSET; + fman->qmi_regs = fman->dts_params.base_addr_0 + QMI_OFFSET; + fman->dma_regs = fman->dts_params.base_addr_pol + DMA_OFFSET_FROM_POL; + fman->hwp_regs = fman->dts_params.base_addr_pol + HWP_OFFSET_FROM_POL; + fman->kg_regs = fman->dts_params.base_addr_pol + KG_OFFSET_FROM_POL; + fman->base_addr_0 = fman->dts_params.base_addr_0; + fman->base_addr_pol = fman->dts_params.base_addr_pol; spin_lock_init(&fman->spinlock); fman_defconfig(fman->cfg); @@ -1937,8 +1938,8 @@ static int fman_init(struct fman *fman) fman->state->exceptions &= ~FMAN_EX_QMI_SINGLE_ECC; /* clear CPG */ - memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0, - fman->state->fm_port_num_of_cg); + memset_io((void __iomem *)(fman->base_addr_pol + CGP_OFFSET_FROM_POL), + 0, fman->state->fm_port_num_of_cg); /* Save LIODN info before FMan reset * Skipping non-existent port 0 (i = 1) @@ -2717,13 +2718,11 @@ static struct fman *read_dts_node(struct platform_device *of_dev) { struct fman *fman; struct device_node *fm_node, *muram_node; - struct resource *res; + struct resource *tmp_res, *main_res; u32 val, range[2]; int err, irq; struct clk *clk; u32 clk_rate; - phys_addr_t phys_base_addr; - resource_size_t mem_size; fman = kzalloc(sizeof(*fman), GFP_KERNEL); if (!fman) @@ -2740,34 +2739,31 @@ static struct fman *read_dts_node(struct platform_device *of_dev) fman->dts_params.id = (u8)val; /* Get the FM interrupt */ - res = platform_get_resource(of_dev, IORESOURCE_IRQ, 0); - if (!res) { + tmp_res = platform_get_resource(of_dev, IORESOURCE_IRQ, 0); + if (!tmp_res) { dev_err(&of_dev->dev, "%s: Can't get FMan IRQ resource\n", __func__); goto fman_node_put; } - irq = res->start; + irq = tmp_res->start; /* Get the FM error interrupt */ - res = platform_get_resource(of_dev, IORESOURCE_IRQ, 1); - if (!res) { + tmp_res = platform_get_resource(of_dev, IORESOURCE_IRQ, 1); + if (!tmp_res) { dev_err(&of_dev->dev, "%s: Can't get FMan Error IRQ resource\n", __func__); goto fman_node_put; } - fman->dts_params.err_irq = res->start; + fman->dts_params.err_irq = tmp_res->start; /* Get the FM address */ - res = platform_get_resource(of_dev, IORESOURCE_MEM, 0); - if (!res) { + main_res = platform_get_resource(of_dev, IORESOURCE_MEM, 0); + if (!main_res) { dev_err(&of_dev->dev, "%s: Can't get FMan memory resource\n", __func__); goto fman_node_put; } - phys_base_addr = res->start; - mem_size = resource_size(res); - clk = of_clk_get(fm_node, 0); if (IS_ERR(clk)) { dev_err(&of_dev->dev, "%s: Failed to get FM%d clock structure\n", @@ -2832,22 +2828,47 @@ static struct fman *read_dts_node(struct platform_device *of_dev) } } - fman->dts_params.res = - devm_request_mem_region(&of_dev->dev, phys_base_addr, - mem_size, "fman"); - if (!fman->dts_params.res) { - dev_err(&of_dev->dev, "%s: request_mem_region() failed\n", + err = devm_request_resource(&of_dev->dev, &iomem_resource, main_res); + if (err) { + dev_err(&of_dev->dev, "%s: devm_request_resource() failed\n", + __func__); + goto fman_free; + } + + fman->dts_params.res = main_res; + + tmp_res = devm_request_mem_region(&of_dev->dev, main_res->start, + SIZE_REGION_0, "fman"); + if (!tmp_res) { + dev_err(&of_dev->dev, "%s: devm_request_mem_region() failed\n", __func__); goto fman_free; } - fman->dts_params.base_addr = - devm_ioremap(&of_dev->dev, phys_base_addr, mem_size); - if (!fman->dts_params.base_addr) { + fman->dts_params.base_addr_0 = + devm_ioremap(&of_dev->dev, tmp_res->start, + resource_size(tmp_res)); + if (!fman->dts_params.base_addr_0) { dev_err(&of_dev->dev, "%s: devm_ioremap() failed\n", __func__); goto fman_free; } + tmp_res = devm_request_mem_region(&of_dev->dev, + main_res->start + POL_OFFSET, + SIZE_REGION_FROM_POL, "fman"); + if (!tmp_res) { + dev_err(&of_dev->dev, "%s: devm_request_mem_region() failed\n", + __func__); + goto fman_free; + } + + fman->dts_params.base_addr_pol = + devm_ioremap(&of_dev->dev, tmp_res->start, + resource_size(tmp_res)); + if (!fman->dts_params.base_addr_pol) { + dev_err(&of_dev->dev, "%s: devm_ioremap() failed\n", __func__); + goto fman_free; + } fman->dev = &of_dev->dev; err = of_platform_populate(fm_node, NULL, NULL, &of_dev->dev); diff --git a/drivers/net/ethernet/freescale/fman/fman.h b/drivers/net/ethernet/freescale/fman/fman.h index f2ede1360f03..e6b339c57230 100644 --- a/drivers/net/ethernet/freescale/fman/fman.h +++ b/drivers/net/ethernet/freescale/fman/fman.h @@ -306,7 +306,11 @@ typedef irqreturn_t (fman_bus_error_cb)(struct fman *fman, u8 port_id, /* Structure that holds information received from device tree */ struct fman_dts_params { - void __iomem *base_addr; /* FMan virtual address */ + void __iomem *base_addr_0; /* FMan virtual address */ + void __iomem *base_addr_pol; /* FMan virtual address + * second region starting at + * policer offset + */ struct resource *res; /* FMan memory resource */ u8 id; /* FMan ID */ @@ -322,7 +326,8 @@ struct fman_dts_params { struct fman { struct device *dev; - void __iomem *base_addr; + void __iomem *base_addr_0; + void __iomem *base_addr_pol; struct fman_intr_src intr_mng[FMAN_EV_CNT]; struct fman_fpm_regs __iomem *fpm_regs; From patchwork Thu Dec 3 13:50:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 11948825 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF33FC001D7 for ; Thu, 3 Dec 2020 13:51:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FAB4206F6 for ; Thu, 3 Dec 2020 13:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730544AbgLCNvt (ORCPT ); Thu, 3 Dec 2020 08:51:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728877AbgLCNvs (ORCPT ); Thu, 3 Dec 2020 08:51:48 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23B96C061A54 for ; Thu, 3 Dec 2020 05:50:55 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id k4so2179490edl.0 for ; Thu, 03 Dec 2020 05:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=32wijpVRZam48n6WcEbTQm6X2gRK0yzC2hG6Y0Y2+Lk=; b=Y8z/8EuFA6ejo6uNXN3hvgjf2bBiWOtpkVqtVbJc39AD0hDdwCfH7jMRp0Fqviek6h vzoeCESVCdFOLPy01jeD5p3DY2c7O7hvTDdciTZNvNTLnu+Z296xanf6RLanEfDF8a/0 Y2xXyJPGoOsQHcUYyvelkmMu5Xnsyott645gcYSbEILzmnOxCYQclATF4tm4k8LPgpLE Dfuo5mjL9/dN7rNxpUuURAUIKJYARMYl8XJEQu681tZ2PlKQCof4/AcC7n7xUjMW88nW Mc9bL/oaRgFotODx9ppFbGNV/34SIE87WOGwAluESGyCfL0kD7hUYCseosyvp/V6J7LK WoSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=32wijpVRZam48n6WcEbTQm6X2gRK0yzC2hG6Y0Y2+Lk=; b=JDTIyOGKNOgXahSJWivbvj4/cOa+fp7YV6pa5sZcx7UyuEC8SHlFFXF07jUiyUAbxj anL37c1+lUwyf4gd/ZFwco9bCl0G1phpR74CVjVzsbJHE22eeL/SqK1T+3CqwGDO/+cH 6k1m/U54CkPhDXOeEfZ06r7V98CHYgV1rdzC7NZUDrCgBLExV056OZifFuQvagyaOZbl yLPkvk/0FArQeuxNH8yGhRP6k3VfV9FaT9GrjvPIYjmYFwznZvzXey5qo03Y8Wz9akh8 xIFzNH7v6Rr88ItSQWkFR3xpe7h2siTfELkpl4KJuUNUBgbtAToMC61qbDFYp4GP5E0G 5sJQ== X-Gm-Message-State: AOAM531yl7f3WRjeZ4mWNmDQLu/0+FIfWOfjAnrptWuNLe83x+kExBzA 7w0zNP1xkU9Kq0MSYy5lfVYqYQ== X-Google-Smtp-Source: ABdhPJxK7ivMeqHmdO88xAdb7S2f1m58nWZyi58XtU2CWRWbeB6CiptUNSInd2qvBfrMu6IC5Ar5Lg== X-Received: by 2002:a05:6402:17ad:: with SMTP id j13mr2937991edy.347.1607003453896; Thu, 03 Dec 2020 05:50:53 -0800 (PST) Received: from belels006.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id t19sm903192eje.86.2020.12.03.05.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 05:50:53 -0800 (PST) From: Patrick Havelange To: Madalin Bucur , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Patrick Havelange Subject: [PATCH net 2/4] net: freescale/fman-port: remove direct use of __devm_request_region Date: Thu, 3 Dec 2020 14:50:37 +0100 Message-Id: <20201203135039.31474-3-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201203135039.31474-1-patrick.havelange@essensium.com> References: <20201203135039.31474-1-patrick.havelange@essensium.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This driver was directly calling __devm_request_region with a specific resource on the stack as parameter. This is invalid as __devm_request_region expects the given resource passed as parameter to live longer than the call itself, as the pointer to the resource will be stored inside the internal struct used by the devres management. In addition to this issue, a related bug has been found by kmemleak with this trace : unreferenced object 0xc0000001efc01880 (size 64): comm "swapper/0", pid 1, jiffies 4294669078 (age 3620.536s) hex dump (first 32 bytes): 00 00 00 0f fe 4a c0 00 00 00 00 0f fe 4a cf ff .....J.......J.. c0 00 00 00 00 ee 9d 98 00 00 00 00 80 00 02 00 ................ backtrace: [] .alloc_resource+0xb8/0xe0 [] .__request_region+0x70/0x1c4 [] .__devm_request_region+0x8c/0x138 [] .fman_port_probe+0x170/0x420 [] .platform_drv_probe+0x84/0x108 [] .driver_probe_device+0x2c4/0x394 [] .__driver_attach+0x124/0x128 [] .bus_for_each_dev+0xb4/0x110 [] .driver_attach+0x34/0x4c [] .bus_add_driver+0x264/0x2a4 [] .driver_register+0x94/0x160 [] .__platform_driver_register+0x60/0x7c [] .fman_port_load+0x28/0x64 [] .do_one_initcall+0xd4/0x1a8 [] .kernel_init_freeable+0x1bc/0x2a4 [] .kernel_init+0x24/0x138 Indeed, the new resource (created in __request_region) will be linked to the given resource living on the stack, which will end its lifetime after the function calling __devm_request_region has finished. Meaning the new resource allocated is no longer reachable. Now that the main fman driver is no longer reserving the region used by fman-port, this previous hack is no longer needed and we can use the regular call to devm_request_mem_region instead, solving those bugs at the same time. Signed-off-by: Patrick Havelange --- drivers/net/ethernet/freescale/fman/fman_port.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c index d9baac0dbc7d..354974939d9d 100644 --- a/drivers/net/ethernet/freescale/fman/fman_port.c +++ b/drivers/net/ethernet/freescale/fman/fman_port.c @@ -1878,10 +1878,10 @@ static int fman_port_probe(struct platform_device *of_dev) of_node_put(port_node); - dev_res = __devm_request_region(port->dev, &res, res.start, - resource_size(&res), "fman-port"); + dev_res = devm_request_mem_region(port->dev, res.start, + resource_size(&res), "fman-port"); if (!dev_res) { - dev_err(port->dev, "%s: __devm_request_region() failed\n", + dev_err(port->dev, "%s: devm_request_mem_region() failed\n", __func__); err = -EINVAL; goto free_port; From patchwork Thu Dec 3 13:50:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 11948829 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E952CC04FC7 for ; Thu, 3 Dec 2020 13:52:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACC1120709 for ; Thu, 3 Dec 2020 13:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730742AbgLCNwP (ORCPT ); Thu, 3 Dec 2020 08:52:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726956AbgLCNwO (ORCPT ); Thu, 3 Dec 2020 08:52:14 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13969C061A56 for ; Thu, 3 Dec 2020 05:50:56 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id u19so2158623edx.2 for ; Thu, 03 Dec 2020 05:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7cVseWE6MIn0vIOshUQxsts71GrP62tJMM0vJ2mEO6M=; b=dSHcHuRESYLtlZtJIQdqGBUk0OZD2FHTCPmivLVjMLany23ElrfmjTJ5QNuXbr51/t FAxaJiOYERb1JckT6NM6S5qBJkYfbIUgnWBr4SIUckpOfvLa6FerK5Gy+XHNksXuEhji IRB+aPMkqGj4Xfr1m7rQx/u/2zCNvktGFS/Ziayy1AUQy0ExZC5TFSmTaPIsCIyW30Lf XE48qB6V1B8IltXD7ldz7T/LZ3qND7n05B7pijClTcATNDO4+hbMCCP6baNAIgZHbMRk afbgWtuUmLykXV0VbY4D2uJSS5hMGsoU3b5VKHHBMsFEuuqFAw96/D3jEBv5b4MBHdUL osgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7cVseWE6MIn0vIOshUQxsts71GrP62tJMM0vJ2mEO6M=; b=DgnYD41wgIy/y4VOp4HzgR96abGl/jkFVdiqoxXw89Ggl3X2QHN6SvAVzBq7z68yKt yqOVZhLeNjxS3WFMW5mN26T6DKTBL2+6ZBH/39NVufXeWam5oBqCwGaDSaJl9VrMcKFP OoZGefj7nY8EbdYl7hk2R2lchK7k0kylirKF82Nzc5bJWodWpLkzr9zP+haxDFmCS4Tn D6j8C6Xb2MqPSJ5IEhxtreCHs2if1uFYVFjERnHRzh3oimSMTKcAQsFBFnmMBVxGH3au Wb9U8pXNO/TvjfY0wqLjDscslI0b1hXoxLyQVhsDoqIrYyzEn5URRz7SfpE0UZnBSPMp oXVA== X-Gm-Message-State: AOAM531qDFlOhSGTrFZ8FtwURDjWjJgVu6IOeUZgQI+W0Wy4ZuB35hK5 5V8BxByMioR8yeLwGhdHJkilPw== X-Google-Smtp-Source: ABdhPJz1lQsVMRY0JLAQ4IxHktkgOk18n2IR9qX57KDkm0D+iuVmWR4/8SHNzfogWx+ZyolX8rkCcA== X-Received: by 2002:a50:b404:: with SMTP id b4mr2873495edh.369.1607003454809; Thu, 03 Dec 2020 05:50:54 -0800 (PST) Received: from belels006.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id t19sm903192eje.86.2020.12.03.05.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 05:50:54 -0800 (PST) From: Patrick Havelange To: Madalin Bucur , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Patrick Havelange Subject: [PATCH net 3/4] net: freescale/fman-mac: remove direct use of __devm_request_region Date: Thu, 3 Dec 2020 14:50:38 +0100 Message-Id: <20201203135039.31474-4-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201203135039.31474-1-patrick.havelange@essensium.com> References: <20201203135039.31474-1-patrick.havelange@essensium.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since the main fman driver is no longer reserving the complete fman memory region, it is no longer needed to use a custom call to __devm_request_region, so replace it with devm_request_mem_region Signed-off-by: Patrick Havelange --- drivers/net/ethernet/freescale/fman/mac.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/mac.c b/drivers/net/ethernet/freescale/fman/mac.c index 901749a7a318..35ca33335aed 100644 --- a/drivers/net/ethernet/freescale/fman/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac.c @@ -690,12 +690,10 @@ static int mac_probe(struct platform_device *_of_dev) goto _return_of_get_parent; } - mac_dev->res = __devm_request_region(dev, - fman_get_mem_region(priv->fman), - res.start, resource_size(&res), - "mac"); + mac_dev->res = devm_request_mem_region(dev, res.start, + resource_size(&res), "mac"); if (!mac_dev->res) { - dev_err(dev, "__devm_request_mem_region(mac) failed\n"); + dev_err(dev, "devm_request_mem_region(mac) failed\n"); err = -EBUSY; goto _return_of_get_parent; } From patchwork Thu Dec 3 13:50:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 11948827 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14C1EC04FC8 for ; Thu, 3 Dec 2020 13:52:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D980220754 for ; Thu, 3 Dec 2020 13:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730798AbgLCNwU (ORCPT ); Thu, 3 Dec 2020 08:52:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728754AbgLCNwT (ORCPT ); Thu, 3 Dec 2020 08:52:19 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 175FCC08E85E for ; Thu, 3 Dec 2020 05:50:57 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id cw27so2155772edb.5 for ; Thu, 03 Dec 2020 05:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n6zxn0ciPWvecDtaO/9pXlIMYf7CJlzucbFrKBsiNoc=; b=QLZNuPrT5uf1X88NBcbBw2nY6+Q00yCrLLHBNqUgkv+bq7RHQycBWM+naJgy8x5d+I fO/O3DGJ6aa4jNOuR7IPbqGFVBBUv6yWbLnkr6s83m38BJFWQoMPRrSBLfBtUAiQgAyS J2zojUQpHvSTYTLRNgRnYvIKSxbscuGTkiG1+yM4+U3RDroUu2aKmjJjQWW3pFhYDrXg cbBB0enNCrFwbqPUTfBoTKzO0pqWiHdUHarykVYjoFXLZZwrwholGYK3buFMdyD9LDOe hAw7mBp2li26EuEbKgQbcAan1JzNyB1j3GEUJ/bj6Jq7jv41V1E15I4lH7/CJ3Mi2eq1 g92w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n6zxn0ciPWvecDtaO/9pXlIMYf7CJlzucbFrKBsiNoc=; b=bo+T6vULh/jNCalg0J4C3FBukZeZcO9Wg7GjWuKUWN65pipvgLH+flfb10fM/zr+x1 2wydeDRTbpV8m/TkS2AzJZCQIuYNwX7vqK/f0u8CVzMXHAqOCoa4+IOtYNzGZ0N9pz9J UZNSZLIOhHPxOXGhntmhArvZnQvINcP0xRO4Elolj/gAexnODFUKCCYGvTyuqp6lmVEA 6GZucgAmmomNNmr4DUghQHl2Oe/IjIspjEXlQ1W4rL2y3Uyhvu6GpkfA03PYf7lwQ7pv 4Ola19MN2MrcnAt5V5ZPh85DYhzj6FQ9Qrt/gTUkceUMS3KmHVLc8rSU+OCDBSWRmiqo M+TQ== X-Gm-Message-State: AOAM532eiNts847JABDDLdDCb54ZxJV6cKRoRzzJ1T6b8n0xVwgHluFb fvqn2gvz3g5QKVx1zqyr/ntPSg== X-Google-Smtp-Source: ABdhPJxEcPSsd9iZKtjM08Y/ZJsM6IA2escx5T41We/67gAoepdb9+qZzLph0YcUATXd/mVcw6PZ5g== X-Received: by 2002:aa7:c3c2:: with SMTP id l2mr2861713edr.15.1607003455814; Thu, 03 Dec 2020 05:50:55 -0800 (PST) Received: from belels006.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id t19sm903192eje.86.2020.12.03.05.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 05:50:55 -0800 (PST) From: Patrick Havelange To: Madalin Bucur , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Patrick Havelange Subject: [PATCH net 4/4] net: freescale/fman: remove fman_get_mem_region Date: Thu, 3 Dec 2020 14:50:39 +0100 Message-Id: <20201203135039.31474-5-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201203135039.31474-1-patrick.havelange@essensium.com> References: <20201203135039.31474-1-patrick.havelange@essensium.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This function is no longer used, so we can remove it. The pointer to the resource that was kept inside struct fman_state_struct can also be removed for the same reason. Signed-off-by: Patrick Havelange --- drivers/net/ethernet/freescale/fman/fman.c | 17 ----------------- drivers/net/ethernet/freescale/fman/fman.h | 2 -- 2 files changed, 19 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c index 2e85209d560d..bf78e12a1683 100644 --- a/drivers/net/ethernet/freescale/fman/fman.c +++ b/drivers/net/ethernet/freescale/fman/fman.c @@ -531,8 +531,6 @@ struct fman_state_struct { u32 qman_channel_base; u32 num_of_qman_channels; - - struct resource *res; }; /* Structure that holds FMan initial configuration */ @@ -1737,7 +1735,6 @@ static int fman_config(struct fman *fman) fman->state->qman_channel_base = fman->dts_params.qman_channel_base; fman->state->num_of_qman_channels = fman->dts_params.num_of_qman_channels; - fman->state->res = fman->dts_params.res; fman->exception_cb = fman_exceptions; fman->bus_error_cb = fman_bus_error; fman->fpm_regs = fman->dts_params.base_addr_pol + FPM_OFFSET_FROM_POL; @@ -2405,20 +2402,6 @@ u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id) } EXPORT_SYMBOL(fman_get_qman_channel_id); -/** - * fman_get_mem_region - * @fman: A Pointer to FMan device - * - * Get FMan memory region - * - * Return: A structure with FMan memory region information - */ -struct resource *fman_get_mem_region(struct fman *fman) -{ - return fman->state->res; -} -EXPORT_SYMBOL(fman_get_mem_region); - /* Bootargs defines */ /* Extra headroom for RX buffers - Default, min and max */ #define FSL_FM_RX_EXTRA_HEADROOM 64 diff --git a/drivers/net/ethernet/freescale/fman/fman.h b/drivers/net/ethernet/freescale/fman/fman.h index e6b339c57230..e326aa37b8b2 100644 --- a/drivers/net/ethernet/freescale/fman/fman.h +++ b/drivers/net/ethernet/freescale/fman/fman.h @@ -398,8 +398,6 @@ int fman_set_mac_max_frame(struct fman *fman, u8 mac_id, u16 mfl); u32 fman_get_qman_channel_id(struct fman *fman, u32 port_id); -struct resource *fman_get_mem_region(struct fman *fman); - u16 fman_get_max_frm(void); int fman_get_rx_extra_headroom(void);