From patchwork Tue May 16 12:55:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp407448vqo; Tue, 16 May 2023 06:03:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4GP1C15QVeiVP8tWSrdYTEjKCZcyAt0xIX0vvBy/M6AxZzSVkMEsqFJopVBixqeC3DTh7s X-Received: by 2002:a17:90a:d988:b0:24e:20d9:4e5b with SMTP id d8-20020a17090ad98800b0024e20d94e5bmr39026920pjv.9.1684242221343; Tue, 16 May 2023 06:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684242221; cv=none; d=google.com; s=arc-20160816; b=MHziT7qjt9HqRanCXSTH76x2kGOhUj0VcrGZcXoe1UpVlMaPCptmlM2pVWKfxwJZhf MSIeLEBTRUKoT30aW97zCKoUSngApS78v7wejuwB+wUV2dWNjaMdEzL4zzSF33MnKsTx sDtIViZLkoaR8c8ylnzI1Z3+AP1hTucBFNBQ1v+asEkV8t6hKGjCf6646fRg33kArCg+ e0xBvAnLsbsTD5NK5awttjJh6hl+4QHwkcCDunxFBzGC5J5bk2Guqx5zdORVFZqV7eVk QdhEdKlAAcNbS8BE7xeCkG3rbyd2dwYb0Fv9AcisckzkKVRz9HSOKHIiOQQGaJP+tboH f/tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=xYIvv3rYmRWOYRNLYvtYel4ibJsZWh4O4oNdMBTy29c=; b=x2IiLnFr0UkNSPibB7j6wkNUtmyp1zijkCh7BJZCu/3at82RgzkoCA/Eizwscho5S1 31EHdTqYmmaz/NHYzxXt6QcSUjP4gz1LFkhQ7PuJhVOvKDVKzLcjHlnqFmK1UiDtyMPT 7r+aaRjBjALc4Xuk3SUUEnaaBVUA+3uVaeSk5u2oX+kK9TZYDd0HABLLBY/npck7mhEL lgcw3wplXN4j/TuW6sDMF77VBf5AB2yTD/4jiysesIEIZgAaukcToTAa0O8eMlIB9gI4 yT2pYhFPwxCjYIXNEtQe3Xtvx5RRhlhS/G4MVNG4GuKh+ugFpo66n75x5QnwUfJ7SIU9 i1rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RjsBicnm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a17090a4b4400b0024dd8ed1373si1635422pjl.185.2023.05.16.06.03.21; Tue, 16 May 2023 06:03:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RjsBicnm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233189AbjEPM4P (ORCPT + 99 others); Tue, 16 May 2023 08:56:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232763AbjEPM4L (ORCPT ); Tue, 16 May 2023 08:56:11 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBE519AA for ; Tue, 16 May 2023 05:55:45 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ad819ab8a9so119697361fa.0 for ; Tue, 16 May 2023 05:55:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241740; x=1686833740; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=xYIvv3rYmRWOYRNLYvtYel4ibJsZWh4O4oNdMBTy29c=; b=RjsBicnmpolKlYVetZhU3EWldBJY1nHZbNCR0FaY8EKZIlLI8rtgidTMKwlqGM1T4g BWggZAC8K6ZiQaPHvU/M1WYWcf/sxV62Cn6VE+nOaQQAAIbfxLS6ATaODh+7Dg0toJn+ R1SItm3vjtQs3j8LuaByFdui9DkyitLOh+CrXel33+JANKQM82h+KooNCDSh2xU6z0Np kzVzHTEIjxu0d8a6wH7CiX4ToIzEJzZNE1tlj0qjBGWx9SGmuFg9jB+gAdJ9j0trawU7 v3Hm8Ur4xb5/kMORzHniqMCoery5vVKM7f1na/sPQDj5KnX2K3UALZWXVqR3ToPgRsdX FE1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241740; x=1686833740; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xYIvv3rYmRWOYRNLYvtYel4ibJsZWh4O4oNdMBTy29c=; b=auEu1FjqZv0nzafu9bfK3JixXP03OFK+HjpcwnUbXKUnhDysDYDZyXZe4L2SOhoknY NtHC3qE0QfK/Xyd7twMNYZSg0VjBdhJQzz7mfVornxFOEucXDKTYUDfLbwaEurEmHBDR gZkB1JKUDUf/zteUp2ecCwyE9MSmt7JShb+W6O/++MZL+Rxcta+3oU84XzQKNj/iG70T KAzAjodnu1VuWER8gDmETph2xgZW74a8hM0eBVzeFNuZ+0+dS+xtVNA1LxTSGXVU5TAI ucg2DCaHlC27/Zh4/SmEZevPjtYd/GGOoYhswXAbchBedBMIz45aK/4ChJveht2NJear zYbw== X-Gm-Message-State: AC+VfDzHaFjUZPqrW2GoqeiJtBibIAjHHVtYmtyfIwuobT3QBM56cVq7 7cugRNTgKsBbwfSj8fIeFYZ+RQ== X-Received: by 2002:a2e:6812:0:b0:298:aad9:e377 with SMTP id c18-20020a2e6812000000b00298aad9e377mr8354304lja.14.1684241740282; Tue, 16 May 2023 05:55:40 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:39 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:31 +0200 Subject: [PATCH v3 1/7] dt-bindings: dma: dma40: Prefer to pass sram through phandle MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-1-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij , Rob Herring X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766055971622571801?= X-GMAIL-MSGID: =?utf-8?q?1766055971622571801?= Extend the DMA40 bindings so that we can pass two SRAM segments as phandles instead of directly referring to the memory address in the second reg cell. This enables more granular control over the SRAM, and adds the optiona LCLA SRAM segment as well. Deprecate the old way of passing LCPA as a second reg cell, make sram compulsory. Reviewed-by: Rob Herring Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Enumerate phandles using inner and outer maxItems as specified by Rob. - Drop quotes around reference. --- .../devicetree/bindings/dma/stericsson,dma40.yaml | 36 +++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml b/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml index 64845347f44d..1e5752b19a49 100644 --- a/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml +++ b/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml @@ -112,14 +112,23 @@ properties: - const: stericsson,dma40 reg: - items: - - description: DMA40 memory base - - description: LCPA memory base + oneOf: + - items: + - description: DMA40 memory base + - items: + - description: DMA40 memory base + - description: LCPA memory base, deprecated, use eSRAM pool instead + deprecated: true + reg-names: - items: - - const: base - - const: lcpa + oneOf: + - items: + - const: base + - items: + - const: base + - const: lcpa + deprecated: true interrupts: maxItems: 1 @@ -127,6 +136,15 @@ properties: clocks: maxItems: 1 + sram: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: A phandle array with inner size 1 (no arg cells). + First phandle is the LCPA (Logical Channel Parameter Address) memory. + Second phandle is the LCLA (Logical Channel Link base Address) memory. + maxItems: 2 + items: + maxItems: 1 + memcpy-channels: $ref: /schemas/types.yaml#/definitions/uint32-array description: Array of u32 elements indicating which channels on the DMA @@ -138,6 +156,7 @@ required: - reg - interrupts - clocks + - sram - memcpy-channels additionalProperties: false @@ -149,8 +168,9 @@ examples: #include dma-controller@801c0000 { compatible = "stericsson,db8500-dma40", "stericsson,dma40"; - reg = <0x801c0000 0x1000>, <0x40010000 0x800>; - reg-names = "base", "lcpa"; + reg = <0x801c0000 0x1000>; + reg-names = "base"; + sram = <&lcpa>, <&lcla>; interrupts = ; #dma-cells = <3>; memcpy-channels = <56 57 58 59 60>; From patchwork Tue May 16 12:55:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp402542vqo; Tue, 16 May 2023 05:57:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZKnZeA6xjYTdJnwTxWJgRqle4+Y1ROGQdKeYLDMpQ9MhOdiJLSulHmftmWmEkKF676XrD X-Received: by 2002:a05:6a20:3d17:b0:102:5f75:91ea with SMTP id y23-20020a056a203d1700b001025f7591eamr27988223pzi.47.1684241830963; Tue, 16 May 2023 05:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684241830; cv=none; d=google.com; s=arc-20160816; b=RZUQjeor4M7V7kVbHksKlY8GG93N5DmzYDN9+/1XytiWV1SZaLTIJD8tEZOfoqwyzu 1VWZBneGjDYwANXXXP3OyHmJ808gPOR24tUSDBBoZyKbwRIf2MZySp2yymdkoLJ/PMy/ geShWNdbKSQqGVrrI9t9Nu/52BMR6PtKC+uEwANYz0tZiHsZC3a3DzTWzaCRzxOaiYWQ tlDgtOLGb0uTIX2PlvhoWGHg86bTz7ndfRjjVf34Q6AvmkUOrGRSrFT6OG/nKhzrQIBb TlaOH2x0UGSOLZySO1wEK39fjIfLua6vSmuFGFnpKc/7OO8QmH78mgEb0tZn++6aUv+W koxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=qVQkPRqRwG5xBfBm9IYhXXbdgn9DcrnRu4p8iX6QF0c=; b=JY/++ZIpFHhRT905fuLbcHXSuiYIffjNOyE8dFpANjIH/HxzgV6STpnSb2D3MSPGKH /C4h17EImnFNFcSZQVzJCOz/Is2/jBh3sqSJAPtiFLSUxoyLkhZQToSQJPTa+1L/tjE/ xhYO0XDFPZ/zlVVCBOqZ0AzgNLlBUWhFsx/r3ZXrT7AMs63duDRFYRe+BL/UScQDOHuV 8l3KbmcERG2d2h3E4GDXPMx+ArD4d0k33bLEkozjXia/lijeS7j9F3tjKAWI1E1CrYFx 2feZWIv1W3hIx/re4JMwDeUELSd2/8A21gBHwMAwncqLgrdrPlDf7PAAvBeU/YcuPkz7 iFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IyMHltUl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t28-20020a63955c000000b00512fab9493dsi18580933pgn.740.2023.05.16.05.56.56; Tue, 16 May 2023 05:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IyMHltUl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbjEPM4U (ORCPT + 99 others); Tue, 16 May 2023 08:56:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233280AbjEPM4Q (ORCPT ); Tue, 16 May 2023 08:56:16 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DED74C3C for ; Tue, 16 May 2023 05:55:46 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ac7de2b72fso153276831fa.1 for ; Tue, 16 May 2023 05:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241741; x=1686833741; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qVQkPRqRwG5xBfBm9IYhXXbdgn9DcrnRu4p8iX6QF0c=; b=IyMHltUlP9uKObnRhXsIyR5xuvuy5bjKsO1TBpsgEY0lojsUh6azozyNnSwoqRDWgZ Gn8vJavea3cp8JfBWPWuaTPwvTQy/F2fa3VEUu6XXxJpOhZj6RBsqNtJynV9+Mf4pDY0 OBsSQ6/2CyfHkwAlJFgBaGhlWOLk1dmsACou6FFkIX90DCvG6gjXXjg888ssICey6CZX Gw3UjaqfFgr/g/oJxHYAGhekljVkZUgwHhB5b122Lp7GbHvgRnmtUb5eptJzX4S+g8Dz KB42QhcGnkjbEYhaFvz8YXR20ggRESG8cnBpztR//BQCIaoAlLvdgHjlzGql61lrW+uR 3LAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241741; x=1686833741; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qVQkPRqRwG5xBfBm9IYhXXbdgn9DcrnRu4p8iX6QF0c=; b=j+EcgXXIL7u8lhxz7MTplh7FDDkq9u9qLZMQIyES+omWUaoNgQjwmcXT9wF+NkplF5 QiVfCRp268NIQ9zr3dWQSfC9bD8UVsBWXf7TXNXG5Tbmtlx4AJUeVTuxsRoCwJ+tEDBo nYRLaRa/9l8P5p7npxcHZFcaqIG8nqa/Tp5c9K/LZd8Xe4zxOJjY166jh18c53Zr05Ky kwz6/6+WdTFYkVq3edxzRRjbRotvxcvS+muEYaaE7yrOTFoqNbrU8nkgi+rw+ChwD3KN hPvLNLTmfWhflLoDianL5vzbTpgB2yJ3dHFCOKFcUzSnOuD+lnwq5lSHiqeRptpYQjv1 07Ew== X-Gm-Message-State: AC+VfDwjRN6h0t8OtexooSuXCujmrYTOlV1Si0pSEhwm73V2jNGxH4Tl xo1GhjWpNIv6NArUm6BgehnCEg== X-Received: by 2002:a2e:80c6:0:b0:2a6:2444:9892 with SMTP id r6-20020a2e80c6000000b002a624449892mr8100808ljg.25.1684241741373; Tue, 16 May 2023 05:55:41 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:40 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:32 +0200 Subject: [PATCH v3 2/7] dmaengine: ste_dma40: Get LCPA SRAM from SRAM node MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-2-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766055562441842325?= X-GMAIL-MSGID: =?utf-8?q?1766055562441842325?= Instead of passing the reserved SRAM as a "reg" field look for a phandle to the LCPA SRAM memory so we can use the proper SRAM device tree bindings for the SRAM. Signed-off-by: Linus Walleij --- drivers/dma/Kconfig | 1 + drivers/dma/ste_dma40.c | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index f5f422f9b850..644c188d6a11 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -553,6 +553,7 @@ config STE_DMA40 bool "ST-Ericsson DMA40 support" depends on ARCH_U8500 select DMA_ENGINE + select SRAM help Support for ST-Ericsson DMA40 controller diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index f093e08c23b1..7890ccae61f9 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -3506,9 +3507,11 @@ static int __init d40_probe(struct platform_device *pdev) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; + struct device_node *np_lcpa; int ret = -ENOENT; struct d40_base *base; struct resource *res; + struct resource res_lcpa; int num_reserved_chans; u32 val; @@ -3535,37 +3538,37 @@ static int __init d40_probe(struct platform_device *pdev) spin_lock_init(&base->interrupt_lock); spin_lock_init(&base->execmd_lock); - /* Get IO for logical channel parameter address */ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcpa"); - if (!res) { - ret = -ENOENT; - d40_err(&pdev->dev, "No \"lcpa\" memory resource\n"); - goto destroy_cache; + /* Get IO for logical channel parameter address (LCPA) */ + np_lcpa = of_parse_phandle(np, "sram", 0); + if (!np_lcpa) { + dev_err(&pdev->dev, "no LCPA SRAM node\n"); + goto report_failure; } - base->lcpa_size = resource_size(res); - base->phy_lcpa = res->start; - - if (request_mem_region(res->start, resource_size(res), - D40_NAME " I/O lcpa") == NULL) { - ret = -EBUSY; - d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res); - goto destroy_cache; + /* This is no device so read the address directly from the node */ + ret = of_address_to_resource(np_lcpa, 0, &res_lcpa); + if (ret) { + dev_err(&pdev->dev, "no LCPA SRAM resource\n"); + goto report_failure; } + base->lcpa_size = resource_size(&res_lcpa); + base->phy_lcpa = res_lcpa.start; + dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n", + (u32)base->phy_lcpa, base->lcpa_size); /* We make use of ESRAM memory for this. */ val = readl(base->virtbase + D40_DREG_LCPA); - if (res->start != val && val != 0) { + if (base->phy_lcpa != val && val != 0) { dev_warn(&pdev->dev, - "[%s] Mismatch LCPA dma 0x%x, def %pa\n", - __func__, val, &res->start); + "[%s] Mismatch LCPA dma 0x%x, def %08x\n", + __func__, val, (u32)base->phy_lcpa); } else - writel(res->start, base->virtbase + D40_DREG_LCPA); + writel(base->phy_lcpa, base->virtbase + D40_DREG_LCPA); - base->lcpa_base = ioremap(res->start, resource_size(res)); + base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size); if (!base->lcpa_base) { ret = -ENOMEM; d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); - goto destroy_cache; + goto release_base; } /* If lcla has to be located in ESRAM we don't need to allocate */ if (base->plat_data->use_esram_lcla) { @@ -3678,9 +3681,7 @@ static int __init d40_probe(struct platform_device *pdev) if (base->lcpa_base) iounmap(base->lcpa_base); - if (base->phy_lcpa) - release_mem_region(base->phy_lcpa, - base->lcpa_size); +release_base: if (base->phy_start) release_mem_region(base->phy_start, base->phy_size); From patchwork Tue May 16 12:55:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp406317vqo; Tue, 16 May 2023 06:02:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4mpfqmmw7PBqWZOyJ3BVsTGXYSbnvypg4yviec+n2mysX+bg/KjUDXNqz9qXUs+0R0ASkj X-Received: by 2002:a17:902:9a96:b0:1a9:2b7f:a594 with SMTP id w22-20020a1709029a9600b001a92b7fa594mr34016074plp.29.1684242149141; Tue, 16 May 2023 06:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684242149; cv=none; d=google.com; s=arc-20160816; b=Pi0W0lRUDNOBf6xRN7dXZNOJKgMhKYOjRi5fiIlF3eEFTIbrQA5aAtbVsmezDlVe84 +WcmDpDrmKTYbiGCpzfrn9wpCzx3H8vOWQ2IDM+/Xg9d1s3Yixh/U7L63MH0iQMP01iQ tHbmJtpHAfFJYDUfqyYHQTkKSoUJzoBNetC0BXWC1ax7fu/yxuMJiYJ3oFWh2ROowjEn lpoPowB5GqWYe1DkAwb/+bdbqkrEN6hHJw7zU4UdRgyvv95nhSsiFH1yix/j2nqsq4cy HrBN9SGuwXkdPgFvoz9FToqvieW53RK0+9j5lzu2W1CwsS4IqTy3CEtIZR1onY/3qrLD 3Huw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=HXjTKNG/4Q9BqbjF143T/9kpVtT1Frl+2u0I19+j0Tw=; b=VVFXwOCPyuBSZJk40PrcOh44c5zojtZKRyVs1PvcBtJ4ZdxaNpGt7V+fejUVG+gw4E cCkJBsrpV2AFcoODD9eokpKrJNTAnMFJiyiNPJOlNwm3AV9Rh0NOHuKfWoE5LIhofxEf bSxSCvdwUthITlep2gZa8V2khSpHhwzJYN/PjTZ4FGRe9823WG+S1xonzeymiakPC+fV fbB02qp4/ewtvGbWWAWeFYpLx6Tv6BsBjEGL9elibvuIiCnh3IFLbBPr+x4JpP3eFd0Y UAKJ8/yxqY+wIdkKyKw/8bLLcO7ue99Fz3MivXQqYBpvYw97yic5TylUInw7U9ol1T6o 5yRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AD2VueX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a170902654a00b0019f25dae4f5si6755150pln.198.2023.05.16.06.02.04; Tue, 16 May 2023 06:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AD2VueX4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbjEPM4X (ORCPT + 99 others); Tue, 16 May 2023 08:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233204AbjEPM4Q (ORCPT ); Tue, 16 May 2023 08:56:16 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96D4B6A5B for ; Tue, 16 May 2023 05:55:46 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4efe8991b8aso16912673e87.0 for ; Tue, 16 May 2023 05:55:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241743; x=1686833743; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HXjTKNG/4Q9BqbjF143T/9kpVtT1Frl+2u0I19+j0Tw=; b=AD2VueX4Pbraf05ngrY77FYs6FcnQJMuaaRGp77fLkEDQ/aAmrkVFByrKRdfb/26S1 hZRlle0gdGPMXMWaNB/zQ+C+ei2kQI7M6qie0+xcWuLmoR7297GFaS1ivnC9HZIvbvcb rOu/eV7XMd896JpEAiL4uM6qBx7MjEWGlxWnUX+oJzDrH7aUypHS+jcyqhdWqBCOa+Ob AWbWvc835cbYuOMit40ehoaXejghkRWqfhEYTuEspVpRBhUSPZUfxw+LfPBJ62TMLb/N DojPnTARUN5CJ0bOEqKttY/0h8Z1NXRIBzHU6miu1Qf6YqXG17NWDmwooDva+9cUHmzz Qcjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241743; x=1686833743; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HXjTKNG/4Q9BqbjF143T/9kpVtT1Frl+2u0I19+j0Tw=; b=RBuPNgl9AOShdIeeFJIX1dIQktprDP7ZahR3D9WUwno5RnNNRANJ2wR2YYFeq/mzF4 f+H3XRQzFazoumGEZ6j65kz8z+y+qjhC4mB233fGVGE8kQ9wArIbdcgHFhu+W1KaM9Nj z8JSbyfZSX83pYJzQbOSMP/IoOSHJETqGc2YPKTA4Z2Q4P3Wic1CoaEHakHlKRB9n4Ed SNntNNzrywkMTOZjySR76gtFobuREgU5l882xq8NLx1H6uIKR37HfZQNL17P4zNIzmaP JHC+wqYbnhGdHtDdb8KklzqxfwTK88oJe0vrI08gfZre1rbnORbWmLGyRl+18MsE2KFQ GaDg== X-Gm-Message-State: AC+VfDyGb4j8lGgC7PPE/BfBF/08UUramxdRmjWDmC9HTPTQPej02nNn oJqsNQBw04h5HuRhVmqGZwDcIQ== X-Received: by 2002:a2e:9697:0:b0:2a8:aec9:b0ba with SMTP id q23-20020a2e9697000000b002a8aec9b0bamr8495250lji.11.1684241742778; Tue, 16 May 2023 05:55:42 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:41 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:33 +0200 Subject: [PATCH v3 3/7] dmaengine: ste_dma40: Add dev helper variable MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-3-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766055895958034481?= X-GMAIL-MSGID: =?utf-8?q?1766055895958034481?= The &pdev->dev device pointer is used so many times in the probe() and d40_hw_detect_init() functions that a local *dev variable makes the code way easier to read. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 50 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 7890ccae61f9..813de4efced5 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -3104,6 +3104,7 @@ static int __init d40_phy_res_init(struct d40_base *base) static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); + struct device *dev = &pdev->dev; struct clk *clk; void __iomem *virtbase; struct resource *res; @@ -3117,15 +3118,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) u32 cid; u8 rev; - clk = clk_get(&pdev->dev, NULL); + clk = clk_get(dev, NULL); if (IS_ERR(clk)) { - d40_err(&pdev->dev, "No matching clock found\n"); + d40_err(dev, "No matching clock found\n"); goto check_prepare_enabled; } clk_ret = clk_prepare_enable(clk); if (clk_ret) { - d40_err(&pdev->dev, "Failed to prepare/enable clock\n"); + d40_err(dev, "Failed to prepare/enable clock\n"); goto disable_unprepare; } @@ -3151,11 +3152,11 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) & 255) << (i * 8); if (cid != AMBA_CID) { - d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n"); + d40_err(dev, "Unknown hardware! No PrimeCell ID\n"); goto unmap_io; } if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) { - d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n", + d40_err(dev, "Unknown designer! Got %x wanted %x\n", AMBA_MANF_BITS(pid), AMBA_VENDOR_ST); goto unmap_io; @@ -3171,7 +3172,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) */ rev = AMBA_REV_BITS(pid); if (rev < 2) { - d40_err(&pdev->dev, "hardware revision: %d is not supported", rev); + d40_err(dev, "hardware revision: %d is not supported", rev); goto unmap_io; } @@ -3189,7 +3190,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY; - dev_info(&pdev->dev, + dev_info(dev, "hardware rev: %d @ %pa with %d physical and %d logical channels\n", rev, &res->start, num_phy_chans, num_log_chans); @@ -3209,7 +3210,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->phy_size = resource_size(res); base->virtbase = virtbase; base->plat_data = plat_data; - base->dev = &pdev->dev; + base->dev = dev; base->phy_chans = ((void *)base) + ALIGN(sizeof(struct d40_base), 4); base->log_chans = &base->phy_chans[num_phy_chans]; @@ -3505,7 +3506,8 @@ static int __init d40_of_probe(struct platform_device *pdev, static int __init d40_probe(struct platform_device *pdev) { - struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); + struct device *dev = &pdev->dev; + struct stedma40_platform_data *plat_data = dev_get_platdata(dev); struct device_node *np = pdev->dev.of_node; struct device_node *np_lcpa; int ret = -ENOENT; @@ -3522,7 +3524,7 @@ static int __init d40_probe(struct platform_device *pdev) goto report_failure; } } else { - d40_err(&pdev->dev, "No pdata or Device Tree provided\n"); + d40_err(dev, "No pdata or Device Tree provided\n"); goto report_failure; } } @@ -3541,24 +3543,24 @@ static int __init d40_probe(struct platform_device *pdev) /* Get IO for logical channel parameter address (LCPA) */ np_lcpa = of_parse_phandle(np, "sram", 0); if (!np_lcpa) { - dev_err(&pdev->dev, "no LCPA SRAM node\n"); + dev_err(dev, "no LCPA SRAM node\n"); goto report_failure; } /* This is no device so read the address directly from the node */ ret = of_address_to_resource(np_lcpa, 0, &res_lcpa); if (ret) { - dev_err(&pdev->dev, "no LCPA SRAM resource\n"); + dev_err(dev, "no LCPA SRAM resource\n"); goto report_failure; } base->lcpa_size = resource_size(&res_lcpa); base->phy_lcpa = res_lcpa.start; - dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n", + dev_info(dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n", (u32)base->phy_lcpa, base->lcpa_size); /* We make use of ESRAM memory for this. */ val = readl(base->virtbase + D40_DREG_LCPA); if (base->phy_lcpa != val && val != 0) { - dev_warn(&pdev->dev, + dev_warn(dev, "[%s] Mismatch LCPA dma 0x%x, def %08x\n", __func__, val, (u32)base->phy_lcpa); } else @@ -3567,7 +3569,7 @@ static int __init d40_probe(struct platform_device *pdev) base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size); if (!base->lcpa_base) { ret = -ENOMEM; - d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); + d40_err(dev, "Failed to ioremap LCPA region\n"); goto release_base; } /* If lcla has to be located in ESRAM we don't need to allocate */ @@ -3576,7 +3578,7 @@ static int __init d40_probe(struct platform_device *pdev) "lcla_esram"); if (!res) { ret = -ENOENT; - d40_err(&pdev->dev, + d40_err(dev, "No \"lcla_esram\" memory resource\n"); goto destroy_cache; } @@ -3584,7 +3586,7 @@ static int __init d40_probe(struct platform_device *pdev) resource_size(res)); if (!base->lcla_pool.base) { ret = -ENOMEM; - d40_err(&pdev->dev, "Failed to ioremap LCLA region\n"); + d40_err(dev, "Failed to ioremap LCLA region\n"); goto destroy_cache; } writel(res->start, base->virtbase + D40_DREG_LCLA); @@ -3592,7 +3594,7 @@ static int __init d40_probe(struct platform_device *pdev) } else { ret = d40_lcla_allocate(base); if (ret) { - d40_err(&pdev->dev, "Failed to allocate LCLA area\n"); + d40_err(dev, "Failed to allocate LCLA area\n"); goto destroy_cache; } } @@ -3603,7 +3605,7 @@ static int __init d40_probe(struct platform_device *pdev) ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base); if (ret) { - d40_err(&pdev->dev, "No IRQ defined\n"); + d40_err(dev, "No IRQ defined\n"); goto destroy_cache; } @@ -3611,7 +3613,7 @@ static int __init d40_probe(struct platform_device *pdev) base->lcpa_regulator = regulator_get(base->dev, "lcla_esram"); if (IS_ERR(base->lcpa_regulator)) { - d40_err(&pdev->dev, "Failed to get lcpa_regulator\n"); + d40_err(dev, "Failed to get lcpa_regulator\n"); ret = PTR_ERR(base->lcpa_regulator); base->lcpa_regulator = NULL; goto destroy_cache; @@ -3619,7 +3621,7 @@ static int __init d40_probe(struct platform_device *pdev) ret = regulator_enable(base->lcpa_regulator); if (ret) { - d40_err(&pdev->dev, + d40_err(dev, "Failed to enable lcpa_regulator\n"); regulator_put(base->lcpa_regulator); base->lcpa_regulator = NULL; @@ -3642,7 +3644,7 @@ static int __init d40_probe(struct platform_device *pdev) ret = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE); if (ret) { - d40_err(&pdev->dev, "Failed to set dma max seg size\n"); + d40_err(dev, "Failed to set dma max seg size\n"); goto destroy_cache; } @@ -3651,7 +3653,7 @@ static int __init d40_probe(struct platform_device *pdev) if (np) { ret = of_dma_controller_register(np, d40_xlate, NULL); if (ret) - dev_err(&pdev->dev, + dev_err(dev, "could not register of_dma_controller\n"); } @@ -3701,7 +3703,7 @@ static int __init d40_probe(struct platform_device *pdev) kfree(base->phy_res); kfree(base); report_failure: - d40_err(&pdev->dev, "probe failed\n"); + d40_err(dev, "probe failed\n"); return ret; } From patchwork Tue May 16 12:55:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp403510vqo; Tue, 16 May 2023 05:59:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6rx0MTW3iQH/TganMu586OKLta2s6iy1MYjqZoad/PxVyn8WbaEmxqnJ+pZLOEIep7ZziW X-Received: by 2002:a17:902:b197:b0:1aa:f446:d518 with SMTP id s23-20020a170902b19700b001aaf446d518mr35296833plr.16.1684241956382; Tue, 16 May 2023 05:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684241956; cv=none; d=google.com; s=arc-20160816; b=VO5IyU1f/fJGyHQtnRctEItV889rvzT+09kb+AVVPTjZPWWZS5yKYRZlstKu4rxYCL eNl0mTega4FGJ22iIXYC0nplhArXVc14g9tkFDuFD09yORFzC3UWMA3z9uq9qZqDHJvI 0XidwTKTLqfN7daMyGYV0Il6Rcd1TNZ1fmxNqHOYmsPi/SOdQ3RyiZim0xtRQm2QqgFa fvezfe6R6BBJsdzOwZyU2+aeBEXPK0BBUink2k6DSVs+F2NJjVKREHm9UpOGwRXiEWWd Vis/en8GuRXX8bNX2Dy2YKxibjXZ5PYEHc4r3OGv8NIqt8LCzRCQiqGahhGXrQ+Re2mQ Hdxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=OMwKntuZiWZlps+UjnlWk+jBiexFAEwBosD6Wyn0I9A=; b=mC4CeHKyBa+Vgb60igCoBdDEMaI300DMzJwQwB882M7j8Ah1DaRbPimTa+QQMN/2KC KnloAKYeFZJIshvipzPv617AVrgvHsTdDNb09pfFG2qxdecRWFf1D8jdsJDEsgI5Kcjx DAYnk0vxB0Hb2kDb035ewhaVwiL1bKqrQn/4F5+4sqo6cY/0VkwqicZG3lMuVXqpZn7I ZrjQiI43s2DkIrxB7XNgK0fvGniL7YIZDZp9NwIGh12SEwEKK4er7Yvh9FGgcciCOXJx QhZnC/lu3VR2mUKNWU3o+WKa2js0oUQ8LEMFeihvNu3DtDlhsNeMhUpMmaV2unf25wcI qE2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KkBp8x9/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix18-20020a170902f81200b001a6b9ab7025si17944900plb.359.2023.05.16.05.59.02; Tue, 16 May 2023 05:59:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="KkBp8x9/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233332AbjEPM43 (ORCPT + 99 others); Tue, 16 May 2023 08:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233278AbjEPM4S (ORCPT ); Tue, 16 May 2023 08:56:18 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50AE130D1 for ; Tue, 16 May 2023 05:55:48 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ac7462d9f1so151969661fa.2 for ; Tue, 16 May 2023 05:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241744; x=1686833744; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=OMwKntuZiWZlps+UjnlWk+jBiexFAEwBosD6Wyn0I9A=; b=KkBp8x9/KuCNgqi5LqNxZdVhA17gBOVCQVbh48a7pySoiXd5VRWX+Ey96bcLzkoY1S GuNCoYeQPSHYrtGwdT+G0SBGAVSK71Xc1ouBjpz+IIxWH+NJTHW/dWfcl+Hf+XGjazAI /wBYeRcfdVzFRa/9XkbmrY4ulFF5roW3lSsNzZtgOiyXWYDNzn22Ry/KS4WWH/vZvCtr 3iaSL5PwNy+ddiqOAFRsNAR5eH61x3hNuxiP+uCIChYEEX2749PviEMyTwXeGkV7a3mr jLMhx3y1Gmt9K+3C/wEi0v2a+LuT40HS1l7Hn/7HyecjCjSSUKAFG1mfshnej9pZHzP5 MUfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241744; x=1686833744; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OMwKntuZiWZlps+UjnlWk+jBiexFAEwBosD6Wyn0I9A=; b=NfKWqmFw6FulvuZ2pmKt7QPE9Po+5TWRPtTqcEorzyO7yxK832shrashxB/2ODRfup i9DViGzYNydVtmFfFMmi0k6RWiZX/1KZAdMzcbX0Nt959HpEZQOi553ul9crnrFhykaT lvSOIO2r9phiSi/zgEaHqIV4zbRC7ocAjHCmgHEHZVvkerNtIK6nevxq5RlWx0r4oHaf Ga4hlxIN86ynJMMGu+HsObBi1nH8L4AXuqlzqBQ2D6q/ttkDPuvIULwgE5ND4lUTdeBN AmgLBwLuXRPZMy5m8x9nN4dsEkDPt8OfyD3160RfimAk+jWhD6yQzkOteUmr3GtchhK/ Hs/g== X-Gm-Message-State: AC+VfDwd9rntISB5ARX1P1uozc8b/nrhexgqW479hopC3mR0XmeAC7Vk c4xv7FR7jZkbGqVIfHbr0DsxkA== X-Received: by 2002:a2e:b70b:0:b0:2ac:83bb:ab46 with SMTP id j11-20020a2eb70b000000b002ac83bbab46mr7935515ljo.30.1684241743843; Tue, 16 May 2023 05:55:43 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:43 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:34 +0200 Subject: [PATCH v3 4/7] dmaengine: ste_dma40: Remove platform data MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-4-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766055693824180456?= X-GMAIL-MSGID: =?utf-8?q?1766055693824180456?= The Ux500 is device tree-only since ages. Delete the platform data header and push it into or next to the driver instead. Drop the non-DT probe path since this will not happen. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 56 ++++++++---- .../dma-ste-dma40.h => drivers/dma/ste_dma40.h | 101 +-------------------- drivers/dma/ste_dma40_ll.c | 3 +- 3 files changed, 41 insertions(+), 119 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 813de4efced5..48c9606cfd46 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -23,11 +23,39 @@ #include #include #include -#include #include "dmaengine.h" +#include "ste_dma40.h" #include "ste_dma40_ll.h" +/** + * struct stedma40_platform_data - Configuration struct for the dma device. + * + * @dev_tx: mapping between destination event line and io address + * @dev_rx: mapping between source event line and io address + * @disabled_channels: A vector, ending with -1, that marks physical channels + * that are for different reasons not available for the driver. + * @soft_lli_chans: A vector, that marks physical channels will use LLI by SW + * which avoids HW bug that exists in some versions of the controller. + * SoftLLI introduces relink overhead that could impact performace for + * certain use cases. + * @num_of_soft_lli_chans: The number of channels that needs to be configured + * to use SoftLLI. + * @use_esram_lcla: flag for mapping the lcla into esram region + * @num_of_memcpy_chans: The number of channels reserved for memcpy. + * @num_of_phy_chans: The number of physical channels implemented in HW. + * 0 means reading the number of channels from DMA HW but this is only valid + * for 'multiple of 4' channels, like 8. + */ +struct stedma40_platform_data { + int disabled_channels[STEDMA40_MAX_PHYS]; + int *soft_lli_chans; + int num_of_soft_lli_chans; + bool use_esram_lcla; + int num_of_memcpy_chans; + int num_of_phy_chans; +}; + #define D40_NAME "dma40" #define D40_PHY_CHAN -1 @@ -2269,7 +2297,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src, return NULL; } -bool stedma40_filter(struct dma_chan *chan, void *data) +static bool stedma40_filter(struct dma_chan *chan, void *data) { struct stedma40_chan_cfg *info = data; struct d40_chan *d40c = @@ -2288,7 +2316,6 @@ bool stedma40_filter(struct dma_chan *chan, void *data) return err == 0; } -EXPORT_SYMBOL(stedma40_filter); static void __d40_set_prio_rt(struct d40_chan *d40c, int dev_type, bool src) { @@ -3517,16 +3544,9 @@ static int __init d40_probe(struct platform_device *pdev) int num_reserved_chans; u32 val; - if (!plat_data) { - if (np) { - if (d40_of_probe(pdev, np)) { - ret = -ENOMEM; - goto report_failure; - } - } else { - d40_err(dev, "No pdata or Device Tree provided\n"); - goto report_failure; - } + if (d40_of_probe(pdev, np)) { + ret = -ENOMEM; + goto report_failure; } base = d40_hw_detect_init(pdev); @@ -3650,11 +3670,11 @@ static int __init d40_probe(struct platform_device *pdev) d40_hw_init(base); - if (np) { - ret = of_dma_controller_register(np, d40_xlate, NULL); - if (ret) - dev_err(dev, - "could not register of_dma_controller\n"); + ret = of_dma_controller_register(np, d40_xlate, NULL); + if (ret) { + dev_err(dev, + "could not register of_dma_controller\n"); + goto destroy_cache; } dev_info(base->dev, "initialized\n"); diff --git a/include/linux/platform_data/dma-ste-dma40.h b/drivers/dma/ste_dma40.h similarity index 51% rename from include/linux/platform_data/dma-ste-dma40.h rename to drivers/dma/ste_dma40.h index 10641633facc..c697bfe16a01 100644 --- a/include/linux/platform_data/dma-ste-dma40.h +++ b/drivers/dma/ste_dma40.h @@ -1,19 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) ST-Ericsson SA 2007-2010 - * Author: Per Forlin for ST-Ericsson - * Author: Jonas Aaberg for ST-Ericsson - */ - #ifndef STE_DMA40_H #define STE_DMA40_H -#include -#include -#include -#include - /* * Maxium size for a single dma descriptor * Size is limited to 16 bits. @@ -118,92 +107,4 @@ struct stedma40_chan_cfg { int phy_channel; }; -/** - * struct stedma40_platform_data - Configuration struct for the dma device. - * - * @dev_tx: mapping between destination event line and io address - * @dev_rx: mapping between source event line and io address - * @disabled_channels: A vector, ending with -1, that marks physical channels - * that are for different reasons not available for the driver. - * @soft_lli_chans: A vector, that marks physical channels will use LLI by SW - * which avoids HW bug that exists in some versions of the controller. - * SoftLLI introduces relink overhead that could impact performace for - * certain use cases. - * @num_of_soft_lli_chans: The number of channels that needs to be configured - * to use SoftLLI. - * @use_esram_lcla: flag for mapping the lcla into esram region - * @num_of_memcpy_chans: The number of channels reserved for memcpy. - * @num_of_phy_chans: The number of physical channels implemented in HW. - * 0 means reading the number of channels from DMA HW but this is only valid - * for 'multiple of 4' channels, like 8. - */ -struct stedma40_platform_data { - int disabled_channels[STEDMA40_MAX_PHYS]; - int *soft_lli_chans; - int num_of_soft_lli_chans; - bool use_esram_lcla; - int num_of_memcpy_chans; - int num_of_phy_chans; -}; - -#ifdef CONFIG_STE_DMA40 - -/** - * stedma40_filter() - Provides stedma40_chan_cfg to the - * ste_dma40 dma driver via the dmaengine framework. - * does some checking of what's provided. - * - * Never directly called by client. It used by dmaengine. - * @chan: dmaengine handle. - * @data: Must be of type: struct stedma40_chan_cfg and is - * the configuration of the framework. - * - * - */ - -bool stedma40_filter(struct dma_chan *chan, void *data); - -/** - * stedma40_slave_mem() - Transfers a raw data buffer to or from a slave - * (=device) - * - * @chan: dmaengine handle - * @addr: source or destination physicall address. - * @size: bytes to transfer - * @direction: direction of transfer - * @flags: is actually enum dma_ctrl_flags. See dmaengine.h - */ - -static inline struct -dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan, - dma_addr_t addr, - unsigned int size, - enum dma_transfer_direction direction, - unsigned long flags) -{ - struct scatterlist sg; - sg_init_table(&sg, 1); - sg.dma_address = addr; - sg.length = size; - - return dmaengine_prep_slave_sg(chan, &sg, 1, direction, flags); -} - -#else -static inline bool stedma40_filter(struct dma_chan *chan, void *data) -{ - return false; -} - -static inline struct -dma_async_tx_descriptor *stedma40_slave_mem(struct dma_chan *chan, - dma_addr_t addr, - unsigned int size, - enum dma_transfer_direction direction, - unsigned long flags) -{ - return NULL; -} -#endif - -#endif +#endif /* STE_DMA40_H */ diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c index b5287c661eb7..4c489b126cb2 100644 --- a/drivers/dma/ste_dma40_ll.c +++ b/drivers/dma/ste_dma40_ll.c @@ -6,8 +6,9 @@ */ #include -#include +#include +#include "ste_dma40.h" #include "ste_dma40_ll.h" static u8 d40_width_to_bits(enum dma_slave_buswidth width) From patchwork Tue May 16 12:55:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp425188vqo; Tue, 16 May 2023 06:26:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PYPmT2zlyysqBlLi0C+h1seNyODNutlgbmS9iXMQYiJGEr2s8UMsciTiWC/1eMguB8btO X-Received: by 2002:a05:6a20:8f16:b0:103:c059:9371 with SMTP id b22-20020a056a208f1600b00103c0599371mr24479620pzk.38.1684243577018; Tue, 16 May 2023 06:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684243577; cv=none; d=google.com; s=arc-20160816; b=OTe77z4StwLp+tJb1ataYmj9zK8RSbEFN6HV/BujaFFzLeBGfXx284k58/UN5mdfUh UmuAr+DRuMPd32FTAMqc0GPY4MIVwoc5gRDc3m8TExNBJNlI/OZLnxI3IHC5a0HxS0UF mowDFfjmt4/XGIxgGA3Uh3ddnRCmTSgyY5lO3tOHY89KXOXvgKxbCBIPzNk38owr7hhI mfoi4yF2pwKp7rLaqDc2sje2qr3gtJu8xWdeTPWeAW9CHtirlo/ZlrVq2JMSDfXnOuRC uiW68smohZQcGK5dXGbH15n9jpwb5mpJFmZRf6PL4MmzfpAZPL64tJcOQpf5YsZm4kVD 8yyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=CXDujZjOmn14EqjwMZcmym6IEUeRVyRNkVM6UCS7Ld4=; b=kAfnJiV8QziVjYbWx7LRPlhCyZ4Jv270O//hH9t0ik0PPMLf1rXBEzca6tzkHkB5+R MZvR/H4kUIuCCjK6rsCv0/xvcRuDFgL67/g0Pb7tshXjRpMUFdpfur+MFeUGRweOh84N MiWhdht97HGdzQ/A2/cEE/Z5WCuMb1sXkAGtUsvatjKVTemue0Lrxyp8O2mqHMKWBwUM h2MVMBty+F+Akhjwt2Vzv2M+Lw/bvfSSmjvqABtvkFTAMyFzSk9XD3SkHmy6qoP0avyx 5qGrW4wOLA3m4NukVx33I+pol7S0erJBpCuMbPO7kWHStnwFCe8kcPmR2m0QLgvkkUl6 m3lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1m1MrvG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x27-20020aa78f1b000000b0063f13fd6b7esi19412560pfr.207.2023.05.16.06.25.59; Tue, 16 May 2023 06:26:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1m1MrvG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233353AbjEPM4d (ORCPT + 99 others); Tue, 16 May 2023 08:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233299AbjEPM4V (ORCPT ); Tue, 16 May 2023 08:56:21 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6542B6A7C for ; Tue, 16 May 2023 05:55:51 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2ac80da3443so152490821fa.0 for ; Tue, 16 May 2023 05:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241745; x=1686833745; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CXDujZjOmn14EqjwMZcmym6IEUeRVyRNkVM6UCS7Ld4=; b=k1m1MrvGvq5UvjWEb3hZnJWob9bx/nsIVHunAtM9VFyioxd759fGt1mhyGiMgAT+uO 8RVl3mKIdHywmcC6Y4Zlu0h4qDZdBGDXirdUKysfV0bzhpkDDWAEazste7YOqjKF5K+m ytPHrDbprC1nF75ovu23TCFzZPoRjPPlJ8DkBRm53mitT9o9R1LEEEScazLdKcANfhS6 WToWOgO6PaiW/Iz1o7MgDvtS1HYSxsw//7LnsKYXXf+qKABN+gG07o7ZjPSJQscExk3T Ue7jxwAW2vvpkWNh4jjs2nDamyCzkA4z1K2NCSLQSuXTAqB3HgOvW4V8u9eO9KLusiUe PebQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241745; x=1686833745; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CXDujZjOmn14EqjwMZcmym6IEUeRVyRNkVM6UCS7Ld4=; b=W9Bvl4XFsBDUNN2IVUSm8Xk+YeIkBI1Z/9YBvH0T0kXpo8JEKQswE0dn5+RqS8KdMa eE/6Y+dt9JAuur3N7Wq6QbMgGFVvD85XU8UjbnSH93o7arW4iU6Kfv5lpdt1Iy/u04T8 xGXRBOZGfRGoDpRswBqPiJrTkYVq0/yYm/1ZRODqTWK8E+ByPD7/iHAisdNbaltm1c+f Km2mjpLoGvukb9StrEjE2U7xiDWZ0fCQVH/ftxEImzOzxqjkjspcQTeYi7Usxma5b9Ic 6N2Qr9t1EH4m9jfbRNU4oHdVtVTQ+GmSCKE+RvVL6bECLQwCObRo/Wpuyx4RcVVeYpr6 33Aw== X-Gm-Message-State: AC+VfDw086AnQJ5QJDSGy6YeEkQ6NeFctHmCpbtfqb9g4S9KeraHfpkw YOiwcywuRfyXCuMg6FI0gpfiefpjxOg34b76Ozo= X-Received: by 2002:a2e:9d97:0:b0:2ac:d51f:2d60 with SMTP id c23-20020a2e9d97000000b002acd51f2d60mr8540364ljj.33.1684241744893; Tue, 16 May 2023 05:55:44 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:44 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:35 +0200 Subject: [PATCH v3 5/7] dmaengine: ste_dma40: Pass dev to OF function MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-5-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766057393105824526?= X-GMAIL-MSGID: =?utf-8?q?1766057393105824526?= The OF platform data population function only wants to use struct device *dev, so pass that instead. This change makes the compiler realize that the local platform data variable is unused, so drop that too. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 48c9606cfd46..87f57457e4d9 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -3480,14 +3480,14 @@ static int __init d40_lcla_allocate(struct d40_base *base) return ret; } -static int __init d40_of_probe(struct platform_device *pdev, +static int __init d40_of_probe(struct device *dev, struct device_node *np) { struct stedma40_platform_data *pdata; int num_phy = 0, num_memcpy = 0, num_disabled = 0; const __be32 *list; - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; @@ -3500,7 +3500,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_memcpy /= sizeof(*list); if (num_memcpy > D40_MEMCPY_MAX_CHANS || num_memcpy <= 0) { - d40_err(&pdev->dev, + d40_err(dev, "Invalid number of memcpy channels specified (%d)\n", num_memcpy); return -EINVAL; @@ -3515,7 +3515,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_disabled /= sizeof(*list); if (num_disabled >= STEDMA40_MAX_PHYS || num_disabled < 0) { - d40_err(&pdev->dev, + d40_err(dev, "Invalid number of disabled channels specified (%d)\n", num_disabled); return -EINVAL; @@ -3526,7 +3526,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_disabled); pdata->disabled_channels[num_disabled] = -1; - pdev->dev.platform_data = pdata; + dev->platform_data = pdata; return 0; } @@ -3534,7 +3534,6 @@ static int __init d40_of_probe(struct platform_device *pdev, static int __init d40_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct stedma40_platform_data *plat_data = dev_get_platdata(dev); struct device_node *np = pdev->dev.of_node; struct device_node *np_lcpa; int ret = -ENOENT; @@ -3544,7 +3543,7 @@ static int __init d40_probe(struct platform_device *pdev) int num_reserved_chans; u32 val; - if (d40_of_probe(pdev, np)) { + if (d40_of_probe(dev, np)) { ret = -ENOMEM; goto report_failure; } From patchwork Tue May 16 12:55:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp412065vqo; Tue, 16 May 2023 06:08:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ786k9CxW41lX1a3Vv2KwSs9Akk40fP6sdsfc6o6Sl54Pme9fv4fSUNJsTWYhwNf+LMugIt X-Received: by 2002:a17:902:b593:b0:1ad:ea13:1918 with SMTP id a19-20020a170902b59300b001adea131918mr13381882pls.69.1684242514454; Tue, 16 May 2023 06:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684242514; cv=none; d=google.com; s=arc-20160816; b=hrlj3DQGwdii+wEWJ1E1m+w4hK2zZr8qviJAsWtrTerktMGivf4chIxEGXE5JPXFPr RzBEo4vtwQ8W11vegmKJWUQrNiUvK1FN1IoeDH60ryynsB45i97VIrfiAM1eOl8CxOEq admMC3v/xUFLJ6Qk7YXD+Lh2CMWwjvWJy80QSNhOXJ2hPhvTDFHT+pF5Hhec5cmYp9Dh PPZeCgpHFEKu4w6bq7XYGQMZpHLXvggtvlgEhVoizb80J6Czx+BZUhwxvUO+IDZiLQ7A tSFiTundP++m4+LwSmMTG++u1bAKKXQslgVhHuy/zFO2ClOGNP7tvnDbgWdRPkPfdXEH yLtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=mc1Rlsn1GEwCmjCKY/d6Szb0PjVBu+i35jp20ojgCNI=; b=mCHhJPu8TMl5CmevPKIwY3K65pDTm0HP+UCcGbZ/3dEROpVZhq+BV27JLcYNWDgw4u r0/qBFUpfXJB30Ylmwm8n6JMWbU4Mearqv7HnTTXUsGEvaM83wlBQ38CKsJ2sVQcPvUj aO9nelv5sUBf4iAyCnH2yILPxjq7vG++bQd/Htbt4IFkDC+UppcywHp/4DKsNGDrs1Oy KCqIeb/UMUAA5Dl7MTSE0P6HxSn3/cHRpnQNs6HJ+28GhcQ2lUj+OQN+qvcHuvVYKzy+ gHJJPgs+omRqReFPz95JvH9z3reW2mtH5HQ1d3FNKjHWIRzpb2V6R8Yduqp7pLww8qoS Gymw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6I2tWNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a66c2f479asi4665213plr.219.2023.05.16.06.08.16; Tue, 16 May 2023 06:08:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j6I2tWNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233278AbjEPM4s (ORCPT + 99 others); Tue, 16 May 2023 08:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233336AbjEPM4a (ORCPT ); Tue, 16 May 2023 08:56:30 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE3265B5 for ; Tue, 16 May 2023 05:55:57 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ac82912a59so149468851fa.3 for ; Tue, 16 May 2023 05:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241746; x=1686833746; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=mc1Rlsn1GEwCmjCKY/d6Szb0PjVBu+i35jp20ojgCNI=; b=j6I2tWNgl15gXeyPBsLSo0X9lhmiwiWe8q2E/Fu3HKg2ejVWK747D1Xyn/0ALbPrrE VYz8W1Wz3OBCfv4nqhzAeUWAOjUOK3+k92AvV1+9aZ2NAKQTs4LDruUYh811i217Eq5Y g9sVSX+Il015BgYmpmpCgvI3wwASJPtchdi4tV2g1NiFKaIDStLe2o6rAMLkDSFEn8O5 w170P8dofsdpu+8AjEKjYyEyAY7hxl6RUae+855x/XJEaPzlFRwuFYicDFOcMO6RPo8B RI0lKIWc9GdbRJ4XH4Rn8hMxwCDjKGxCarTYgwXvxnkO3RbXHhfFmhmOTBLxxKw23qnh j7lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241746; x=1686833746; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mc1Rlsn1GEwCmjCKY/d6Szb0PjVBu+i35jp20ojgCNI=; b=kkjh+oHWE2L55KMXn425jZzpSEBemdk/JBjq6GPasS7RUccPti7KJS6fgPW/D6uAJD yLPVcohvqsYUbpDi1FKB+CgGiFkVtqgzkMgMxleRKPzKPvNqTPz5PzW5jzZMkXCZ6eVI Ry8nMOZ6X66JEGQCqlRDseFoO9RkWDaoMEulQuqRoWAme9ACdJlReI8l87vNxmI2XASE Qq488o548gMiMmeF8Dp9/Lye/NU2qTOu00GwBhpVeiU5IXTXzHtUsBcbyMN9RIGflTGC 4Lbsus2yKmIi8rNofYIWHDDsn6Qcf6aLikfsrZKsPGL0YtVdgFsp79wTawrngQ0eN7wi cPHg== X-Gm-Message-State: AC+VfDx6VM/haFvxlGNHFDFKeRfPoO56eMF1FqQU2P1u4Xjs/kGAEzM8 Zw2nOnTNmqr04Uu1CoMKxIAt8g== X-Received: by 2002:a2e:8058:0:b0:2a8:bd1f:a377 with SMTP id p24-20020a2e8058000000b002a8bd1fa377mr8160817ljg.20.1684241746275; Tue, 16 May 2023 05:55:46 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:45 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:36 +0200 Subject: [PATCH v3 6/7] dmaengine: ste_dma40: Use managed resources MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-6-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766056278896481484?= X-GMAIL-MSGID: =?utf-8?q?1766056278896481484?= This switches the DMA40 driver to use a bunch of managed resources and strip down the errorpath. The result is pretty neat and makes the driver way more readable. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 180 ++++++++++++++++-------------------------------- 1 file changed, 61 insertions(+), 119 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 87f57457e4d9..313baf316f13 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -554,8 +554,6 @@ struct d40_gen_dmac { * @virtbase: The virtual base address of the DMA's register. * @rev: silicon revision detected. * @clk: Pointer to the DMA clock structure. - * @phy_start: Physical memory start of the DMA registers. - * @phy_size: Size of the DMA register map. * @irq: The IRQ number. * @num_memcpy_chans: The number of channels used for memcpy (mem-to-mem * transfers). @@ -599,8 +597,6 @@ struct d40_base { void __iomem *virtbase; u8 rev:4; struct clk *clk; - phys_addr_t phy_start; - resource_size_t phy_size; int irq; int num_memcpy_chans; int num_phy_chans; @@ -3128,65 +3124,58 @@ static int __init d40_phy_res_init(struct d40_base *base) return num_phy_chans_avail; } +/* Called from the registered devm action */ +static void d40_drop_kmem_cache_action(void *d) +{ + struct kmem_cache *desc_slab = d; + + kmem_cache_destroy(desc_slab); +} + static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device *dev = &pdev->dev; struct clk *clk; void __iomem *virtbase; - struct resource *res; struct d40_base *base; int num_log_chans; int num_phy_chans; int num_memcpy_chans; - int clk_ret = -EINVAL; int i; u32 pid; u32 cid; u8 rev; + int ret; - clk = clk_get(dev, NULL); - if (IS_ERR(clk)) { - d40_err(dev, "No matching clock found\n"); - goto check_prepare_enabled; - } - - clk_ret = clk_prepare_enable(clk); - if (clk_ret) { - d40_err(dev, "Failed to prepare/enable clock\n"); - goto disable_unprepare; - } + clk = devm_clk_get_enabled(dev, NULL); + if (IS_ERR(clk)) + return NULL; /* Get IO for DMAC base address */ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "base"); - if (!res) - goto disable_unprepare; - - if (request_mem_region(res->start, resource_size(res), - D40_NAME " I/O base") == NULL) - goto release_region; - - virtbase = ioremap(res->start, resource_size(res)); - if (!virtbase) - goto release_region; + virtbase = devm_platform_ioremap_resource_byname(pdev, "base"); + if (IS_ERR(virtbase)) { + dev_err(dev, "No IO base defined\n"); + return NULL; + } /* This is just a regular AMBA PrimeCell ID actually */ for (pid = 0, i = 0; i < 4; i++) - pid |= (readl(virtbase + resource_size(res) - 0x20 + 4 * i) + pid |= (readl(virtbase + SZ_4K - 0x20 + 4 * i) & 255) << (i * 8); for (cid = 0, i = 0; i < 4; i++) - cid |= (readl(virtbase + resource_size(res) - 0x10 + 4 * i) + cid |= (readl(virtbase + SZ_4K - 0x10 + 4 * i) & 255) << (i * 8); if (cid != AMBA_CID) { d40_err(dev, "Unknown hardware! No PrimeCell ID\n"); - goto unmap_io; + return NULL; } if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) { d40_err(dev, "Unknown designer! Got %x wanted %x\n", AMBA_MANF_BITS(pid), AMBA_VENDOR_ST); - goto unmap_io; + return NULL; } /* * HW revision: @@ -3200,7 +3189,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) rev = AMBA_REV_BITS(pid); if (rev < 2) { d40_err(dev, "hardware revision: %d is not supported", rev); - goto unmap_io; + return NULL; } /* The number of physical channels on this HW */ @@ -3218,23 +3207,22 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_log_chans = num_phy_chans * D40_MAX_LOG_CHAN_PER_PHY; dev_info(dev, - "hardware rev: %d @ %pa with %d physical and %d logical channels\n", - rev, &res->start, num_phy_chans, num_log_chans); + "hardware rev: %d with %d physical and %d logical channels\n", + rev, num_phy_chans, num_log_chans); - base = kzalloc(ALIGN(sizeof(struct d40_base), 4) + - (num_phy_chans + num_log_chans + num_memcpy_chans) * - sizeof(struct d40_chan), GFP_KERNEL); + base = devm_kzalloc(dev, + ALIGN(sizeof(struct d40_base), 4) + + (num_phy_chans + num_log_chans + num_memcpy_chans) * + sizeof(struct d40_chan), GFP_KERNEL); - if (base == NULL) - goto unmap_io; + if (!base) + return NULL; base->rev = rev; base->clk = clk; base->num_memcpy_chans = num_memcpy_chans; base->num_phy_chans = num_phy_chans; base->num_log_chans = num_log_chans; - base->phy_start = res->start; - base->phy_size = resource_size(res); base->virtbase = virtbase; base->plat_data = plat_data; base->dev = dev; @@ -3271,76 +3259,55 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4a); } - base->phy_res = kcalloc(num_phy_chans, - sizeof(*base->phy_res), - GFP_KERNEL); + base->phy_res = devm_kcalloc(dev, num_phy_chans, + sizeof(*base->phy_res), + GFP_KERNEL); if (!base->phy_res) - goto free_base; + return NULL; - base->lookup_phy_chans = kcalloc(num_phy_chans, - sizeof(*base->lookup_phy_chans), - GFP_KERNEL); + base->lookup_phy_chans = devm_kcalloc(dev, num_phy_chans, + sizeof(*base->lookup_phy_chans), + GFP_KERNEL); if (!base->lookup_phy_chans) - goto free_phy_res; + return NULL; - base->lookup_log_chans = kcalloc(num_log_chans, - sizeof(*base->lookup_log_chans), - GFP_KERNEL); + base->lookup_log_chans = devm_kcalloc(dev, num_log_chans, + sizeof(*base->lookup_log_chans), + GFP_KERNEL); if (!base->lookup_log_chans) - goto free_phy_chans; + return NULL; - base->reg_val_backup_chan = kmalloc_array(base->num_phy_chans, + base->reg_val_backup_chan = devm_kmalloc_array(dev, base->num_phy_chans, sizeof(d40_backup_regs_chan), GFP_KERNEL); if (!base->reg_val_backup_chan) - goto free_log_chans; + return NULL; - base->lcla_pool.alloc_map = kcalloc(num_phy_chans + base->lcla_pool.alloc_map = devm_kcalloc(dev, num_phy_chans * D40_LCLA_LINK_PER_EVENT_GRP, sizeof(*base->lcla_pool.alloc_map), GFP_KERNEL); if (!base->lcla_pool.alloc_map) - goto free_backup_chan; + return NULL; - base->regs_interrupt = kmalloc_array(base->gen_dmac.il_size, + base->regs_interrupt = devm_kmalloc_array(dev, base->gen_dmac.il_size, sizeof(*base->regs_interrupt), GFP_KERNEL); if (!base->regs_interrupt) - goto free_map; + return NULL; base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc), 0, SLAB_HWCACHE_ALIGN, NULL); - if (base->desc_slab == NULL) - goto free_regs; + if (!base->desc_slab) + return NULL; + ret = devm_add_action_or_reset(dev, d40_drop_kmem_cache_action, + base->desc_slab); + if (ret) + return NULL; return base; - free_regs: - kfree(base->regs_interrupt); - free_map: - kfree(base->lcla_pool.alloc_map); - free_backup_chan: - kfree(base->reg_val_backup_chan); - free_log_chans: - kfree(base->lookup_log_chans); - free_phy_chans: - kfree(base->lookup_phy_chans); - free_phy_res: - kfree(base->phy_res); - free_base: - kfree(base); - unmap_io: - iounmap(virtbase); - release_region: - release_mem_region(res->start, resource_size(res)); - check_prepare_enabled: - if (!clk_ret) - disable_unprepare: - clk_disable_unprepare(clk); - if (!IS_ERR(clk)) - clk_put(clk); - return NULL; } static void __init d40_hw_init(struct d40_base *base) @@ -3585,11 +3552,11 @@ static int __init d40_probe(struct platform_device *pdev) } else writel(base->phy_lcpa, base->virtbase + D40_DREG_LCPA); - base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size); + base->lcpa_base = devm_ioremap(dev, base->phy_lcpa, base->lcpa_size); if (!base->lcpa_base) { ret = -ENOMEM; d40_err(dev, "Failed to ioremap LCPA region\n"); - goto release_base; + goto report_failure; } /* If lcla has to be located in ESRAM we don't need to allocate */ if (base->plat_data->use_esram_lcla) { @@ -3599,14 +3566,14 @@ static int __init d40_probe(struct platform_device *pdev) ret = -ENOENT; d40_err(dev, "No \"lcla_esram\" memory resource\n"); - goto destroy_cache; + goto report_failure; } - base->lcla_pool.base = ioremap(res->start, - resource_size(res)); + base->lcla_pool.base = devm_ioremap(dev, res->start, + resource_size(res)); if (!base->lcla_pool.base) { ret = -ENOMEM; d40_err(dev, "Failed to ioremap LCLA region\n"); - goto destroy_cache; + goto report_failure; } writel(res->start, base->virtbase + D40_DREG_LCLA); @@ -3678,16 +3645,8 @@ static int __init d40_probe(struct platform_device *pdev) dev_info(base->dev, "initialized\n"); return 0; - destroy_cache: - kmem_cache_destroy(base->desc_slab); - if (base->virtbase) - iounmap(base->virtbase); - - if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { - iounmap(base->lcla_pool.base); - base->lcla_pool.base = NULL; - } + destroy_cache: if (base->lcla_pool.dma_addr) dma_unmap_single(base->dev, base->lcla_pool.dma_addr, SZ_1K * base->num_phy_chans, @@ -3699,28 +3658,11 @@ static int __init d40_probe(struct platform_device *pdev) kfree(base->lcla_pool.base_unaligned); - if (base->lcpa_base) - iounmap(base->lcpa_base); - -release_base: - if (base->phy_start) - release_mem_region(base->phy_start, - base->phy_size); - if (base->clk) { - clk_disable_unprepare(base->clk); - clk_put(base->clk); - } - if (base->lcpa_regulator) { regulator_disable(base->lcpa_regulator); regulator_put(base->lcpa_regulator); } - kfree(base->lcla_pool.alloc_map); - kfree(base->lookup_log_chans); - kfree(base->lookup_phy_chans); - kfree(base->phy_res); - kfree(base); report_failure: d40_err(dev, "probe failed\n"); return ret; From patchwork Tue May 16 12:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 94697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp413225vqo; Tue, 16 May 2023 06:09:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zcn8VNEcMjk7enjKwo6BmxBQQcDjdGo82UMFYdPKXEaGfGVWhq8eCPgiII4L57tuAHjuf X-Received: by 2002:a05:6a20:3d95:b0:106:57b9:6da1 with SMTP id s21-20020a056a203d9500b0010657b96da1mr6655725pzi.20.1684242596621; Tue, 16 May 2023 06:09:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684242596; cv=none; d=google.com; s=arc-20160816; b=MBNhOQyk7JXxtLOzqK/pEHmXJdSN1A6eReCDSZ4hjxTu5izqchXOcQz+YhaIETrHQk Gr4Sj4a2VkohnGGxopqqvqxEy7SUkoJiskpMTO/cYmcCjpBMqwVdio6cY8Zd0UL82k31 xNN6sSYckSe3+KLe1fE3syOMwx1jKterd8LLO2kOgf3r7UD7XhhQn9bLKWg+reuCVM9o BQlJQoxFb/F4y4KMVew2I1DJujxFR6m6WywXv5Vi+jmgm34wjh4vt+rS30D5KUEr8obB sRGU/69YXDfhpm568qWiv7eXnB4lNK1n2+KGPfsRWgJXguvZBn5UBLFk6hFpPt73VfN6 Y5Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=KThRHpQPHpZPJSTEGZZjIaigcF+AfIhnsyQDOpO+RdU=; b=uHC9OQbHkcxXhcv8svg9Q4+VH8U6jp7ccgyEjoFjHZZzPJF60v8sMs4rgiVR3qoQVV exkMwYvWEKES2nVDpG8oU+HSLayMgbDQiZg1Z3CPMvOpM9fGCKeYxEJ6mEeSc7ZqeKhr VK31PbjwMfxm62mlEkqGgNESf6NbCXEvli2+udy7G3u7j95yV7YN5Y4wWHKKzUNG1rpT yAgTYb3xQkb/e39uHLMN/NUomsHN3XWDe0Z1V20FKH5fOjslxxW2ImZNWdyItByhrRlH 5eao1UKTRgPY21DPXSkazbrRZCUn4W6/f7+LPalcyme4gnR0v/KXfulHkusP/PgtmjVD ANrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kWj3kn1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a633e48000000b0053045acfebbsi17522847pga.48.2023.05.16.06.09.34; Tue, 16 May 2023 06:09:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kWj3kn1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233349AbjEPM4u (ORCPT + 99 others); Tue, 16 May 2023 08:56:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233341AbjEPM4b (ORCPT ); Tue, 16 May 2023 08:56:31 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C74BD4492 for ; Tue, 16 May 2023 05:56:00 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ac8cc8829fso134596561fa.3 for ; Tue, 16 May 2023 05:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684241747; x=1686833747; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KThRHpQPHpZPJSTEGZZjIaigcF+AfIhnsyQDOpO+RdU=; b=kWj3kn1pOuUsl+DepVm/MZsJBwrfldQssLnsjBuMBKxgDM7AD3zgTCSnIAwFDKsRUK 5VfSr66foS5xDfMMdHzg4P7k7JfWWCQGTXKdgVJQySW6SIWyYFk5rvu09MuRVkxlhXcs Uinu873E7zwk1tFIVR+AdaZrnFUum5I2rr5asv0/KlH5Wv5t02H7W+XUmUvQzwS/jmNs OVH1gI5yMtTah1iUfUN7iZIz9Iri9HXhxF0EzF4nEAIZpRIWfL4pYuM3wj5tc7XLYfpz YaxYURTOaUJctn4bjey7TeOkNMZcBiYiTqJeqQioFJ53DZMsyuKqb1xo4zZS9E/4cnq0 +MYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684241747; x=1686833747; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KThRHpQPHpZPJSTEGZZjIaigcF+AfIhnsyQDOpO+RdU=; b=JQklU1k0veVJKqVz05sFblBPARo5ELcy/vM6uXidl7iUAJPNtl/dCPV8Sgck6ilUE3 1YmH7FrottfG1D2ziA+I7rUnAtJzs3VZScZAR8MwDkFLJcg46lQ3tO1LwbcQTnjaIGxY p9aaAitrDNvg05tuMw1nAy28HZpTefLJwHvOZbNtPraMKS/tEyVLC0F8UUgfPxARgqlu ND/hiR4DAUcRHpYWQ9bobdcbZ+MX/wGh2pdIBRPT8SYa33yqGdCKxrgSA3cfxHmI3BsC qvPR5k4tz+ay/Ah+DbKanT8/g9WGfSwWHBSnZZWf1Got+hoW6ECeymvXwtPaYuJERg6T Jwmg== X-Gm-Message-State: AC+VfDzaDDgGBjWsWFT+beTT25K/EskQHLCnTNNi3SHJPNxrHBgOFZ8q GtJNX514lHPpGZmPP7qcQgc2a8WMRwyK3TxQztg= X-Received: by 2002:a2e:9f17:0:b0:2a8:bce1:5cac with SMTP id u23-20020a2e9f17000000b002a8bce15cacmr8101788ljk.37.1684241747533; Tue, 16 May 2023 05:55:47 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id o23-20020a2e7317000000b002add1f4a92asm1647789ljc.113.2023.05.16.05.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 05:55:46 -0700 (PDT) From: Linus Walleij Date: Tue, 16 May 2023 14:55:37 +0200 Subject: [PATCH v3 7/7] dmaengine: ste_dma40: Return error codes properly MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v3-7-60bfa6785968@linaro.org> References: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v3-0-60bfa6785968@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766056364762192921?= X-GMAIL-MSGID: =?utf-8?q?1766056364762192921?= This makes the probe() and its subfunction d40_hw_detect_init() return proper error codes. One effect of this is that deferred probe, e.g from the clock, will start to work, would it happen. Also it is better design. Signed-off-by: Linus Walleij --- drivers/dma/ste_dma40.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 313baf316f13..c30d00a78eed 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -3132,7 +3132,8 @@ static void d40_drop_kmem_cache_action(void *d) kmem_cache_destroy(desc_slab); } -static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) +static int __init d40_hw_detect_init(struct platform_device *pdev, + struct d40_base **retbase) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device *dev = &pdev->dev; @@ -3150,14 +3151,12 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(clk)) - return NULL; + return PTR_ERR(clk); /* Get IO for DMAC base address */ virtbase = devm_platform_ioremap_resource_byname(pdev, "base"); - if (IS_ERR(virtbase)) { - dev_err(dev, "No IO base defined\n"); - return NULL; - } + if (IS_ERR(virtbase)) + return PTR_ERR(virtbase); /* This is just a regular AMBA PrimeCell ID actually */ for (pid = 0, i = 0; i < 4; i++) @@ -3169,13 +3168,13 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) if (cid != AMBA_CID) { d40_err(dev, "Unknown hardware! No PrimeCell ID\n"); - return NULL; + return -EINVAL; } if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) { d40_err(dev, "Unknown designer! Got %x wanted %x\n", AMBA_MANF_BITS(pid), AMBA_VENDOR_ST); - return NULL; + return -EINVAL; } /* * HW revision: @@ -3189,7 +3188,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) rev = AMBA_REV_BITS(pid); if (rev < 2) { d40_err(dev, "hardware revision: %d is not supported", rev); - return NULL; + return -EINVAL; } /* The number of physical channels on this HW */ @@ -3216,7 +3215,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) sizeof(struct d40_chan), GFP_KERNEL); if (!base) - return NULL; + return -ENOMEM; base->rev = rev; base->clk = clk; @@ -3263,51 +3262,53 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) sizeof(*base->phy_res), GFP_KERNEL); if (!base->phy_res) - return NULL; + return -ENOMEM; base->lookup_phy_chans = devm_kcalloc(dev, num_phy_chans, sizeof(*base->lookup_phy_chans), GFP_KERNEL); if (!base->lookup_phy_chans) - return NULL; + return -ENOMEM; base->lookup_log_chans = devm_kcalloc(dev, num_log_chans, sizeof(*base->lookup_log_chans), GFP_KERNEL); if (!base->lookup_log_chans) - return NULL; + return -ENOMEM; base->reg_val_backup_chan = devm_kmalloc_array(dev, base->num_phy_chans, sizeof(d40_backup_regs_chan), GFP_KERNEL); if (!base->reg_val_backup_chan) - return NULL; + return -ENOMEM; base->lcla_pool.alloc_map = devm_kcalloc(dev, num_phy_chans * D40_LCLA_LINK_PER_EVENT_GRP, sizeof(*base->lcla_pool.alloc_map), GFP_KERNEL); if (!base->lcla_pool.alloc_map) - return NULL; + return -ENOMEM; base->regs_interrupt = devm_kmalloc_array(dev, base->gen_dmac.il_size, sizeof(*base->regs_interrupt), GFP_KERNEL); if (!base->regs_interrupt) - return NULL; + return -ENOMEM; base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc), 0, SLAB_HWCACHE_ALIGN, NULL); if (!base->desc_slab) - return NULL; + return -ENOMEM; ret = devm_add_action_or_reset(dev, d40_drop_kmem_cache_action, base->desc_slab); if (ret) - return NULL; + return ret; + + *retbase = base; - return base; + return 0; } static void __init d40_hw_init(struct d40_base *base) @@ -3503,20 +3504,20 @@ static int __init d40_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = pdev->dev.of_node; struct device_node *np_lcpa; - int ret = -ENOENT; struct d40_base *base; struct resource *res; struct resource res_lcpa; int num_reserved_chans; u32 val; + int ret; if (d40_of_probe(dev, np)) { ret = -ENOMEM; goto report_failure; } - base = d40_hw_detect_init(pdev); - if (!base) + ret = d40_hw_detect_init(pdev, &base); + if (ret) goto report_failure; num_reserved_chans = d40_phy_res_init(base); @@ -3530,6 +3531,7 @@ static int __init d40_probe(struct platform_device *pdev) np_lcpa = of_parse_phandle(np, "sram", 0); if (!np_lcpa) { dev_err(dev, "no LCPA SRAM node\n"); + ret = -EINVAL; goto report_failure; } /* This is no device so read the address directly from the node */