From patchwork Mon Apr 17 07:55:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1951146vqo; Mon, 17 Apr 2023 00:58:49 -0700 (PDT) X-Google-Smtp-Source: AKy350YR5LGy8HTLSu5a2SHjpie8BPR3/R45bG42ONe6fzufpUXzWeonJaqJBF/6Jya5fA2RAZ78 X-Received: by 2002:a17:902:8684:b0:1a6:6a7c:9fde with SMTP id g4-20020a170902868400b001a66a7c9fdemr10383863plo.14.1681718328892; Mon, 17 Apr 2023 00:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681718328; cv=none; d=google.com; s=arc-20160816; b=MV57+AUflU8hZsZ9PUDK/bALTqtglWnZwsyXbecOxbL0cJHFh/kWc8d2Y5pb6AhvCI J74Oj/xteqeZlBVEOdauY0eTWbwgOXEhAw/YCNl6oIZRBRp44EysFnVBpU2ZV4x/lKQZ 0G8eNW2Nn4aVcCLXpnJoEF8hBQ5yH/lNVSVGh12q0XEQAsFZ3MLUQCxgELMioqXHL4pO ypVxyUKWHJfOgtnlBKMdWxUX3yNhcLhB5BMAA/gl9PuObj5vjgwZx+pli1reLjYAqqd2 RuhlTuwwYyBXgjyFhnJT0A9Q7YBz4ihs7CaLi2zJjOS/wDpiLS9BFgnkmAOb8pNEr95A Jc5A== 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=o2kEZXqS3DdorsV7KBvalbCQQT9rGiidMVD8f+P+zW8=; b=sJyTzzwyaXDIT40ZLjucQiFj+dyROjnV9Ts28MWNdI3yEE0M+T5E4Uq4bVSJ25eyLw pNkN+MnNKiiUAyn5V8jW5mqnqY9C6OgCG8lQ2CGIskkik6CJftXEnErDhMXqg0paFjbO XyAYWMU3qGnNdNOovinifuhW/0FTuPNw8twJha4Ocn30x+TFwAHBYnlVo8ebogWF/Qbs DVFSrhHKVYSlqv+OgQOUHpnuI6gcsyv5G/iAWt8YpzgnTQKjzYf8Maf45nB5f5vYP+7m yTCrrcN6LM5W13Ukjj6Rv/SUyrCmTB+d48Nt/1FCq0OvVIa5Z7BY68xK4VDCPcnShXCG AOpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cszasHJq; 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 l13-20020a170903244d00b001a68986a3d6si11266046pls.408.2023.04.17.00.58.34; Mon, 17 Apr 2023 00:58:48 -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=cszasHJq; 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 S230516AbjDQH4H (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbjDQHz6 (ORCPT ); Mon, 17 Apr 2023 03:55:58 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052FE2D53 for ; Mon, 17 Apr 2023 00:55:56 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4ec816c9b62so1187411e87.2 for ; Mon, 17 Apr 2023 00:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718154; x=1684310154; 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=o2kEZXqS3DdorsV7KBvalbCQQT9rGiidMVD8f+P+zW8=; b=cszasHJqTYYYiVgMtunipV+yzyUhFzSLNhUSkwJDjzdL7jFJrC3sW5CWMmi297UZuk icxBUMV5s1ZlZ3lqmVzkwG02nMxJ6IXkEO26lhcMrSMSIQTM71BrUKYMkURHWrY6ZnKI bAVlqFHdMatGCfWMnFwelhVbkjVURlAIXTqiWVJhGu8myBWN+i9tHfHpmFR0NSKQGGud rkycl4wBZ3xdjEtnSM+p7sCoqwxTUDCrsMvfS03lNPgWMM9FCJlAe6K70IrzW+VLH3DA Xj6hQQfit2+FZiMRguB3LIuZ9asqaQCfhECdLQI7rljKFlEP08FJMzEBr2y1RJOH1FNS HyiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718154; x=1684310154; 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=o2kEZXqS3DdorsV7KBvalbCQQT9rGiidMVD8f+P+zW8=; b=lqtWnQ/A16JjT3qFBMZYYhHoPeJV9pgSmB1eDdczF1+GGLMnPAV7YP7A9g8wo+nTeJ s3BrnwzQhx0ALaYhp5kQd1ZTt69YNqbmHwspRU1E4rnuy1168+U/hE3VHTvzgLPSXZRe 4Dneg5swpCOqCONvWDpqpoAjn3pTktoWlVy9L5rGeOSMA4ZwnD56nwumT5aO6VaOEWfD RdozQKiJfbPPDtoFTXxwnnV7cFEDB0/7dZgqLPvq0M8mGCUtyDI7MQcfqW9brS4ooFs0 Sf/1SnGZKShLNtlE/0UU+B6d4rnN0mAfqie1Wb5JfAUUzUD7YYeot77O23W9eliiaBXs sRVw== X-Gm-Message-State: AAQBX9drLPa7JUM4tLwydtcIk/kykFDJSc2X6SrgW0MDPoyrqOIyDlCo hOCYVGqlmuJ4uDoupIaEq56qoQ== X-Received: by 2002:a19:c502:0:b0:4ec:8087:88bb with SMTP id w2-20020a19c502000000b004ec808788bbmr1805886lfe.3.1681718154207; Mon, 17 Apr 2023 00:55:54 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:53 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:46 +0200 Subject: [PATCH 1/7] dt-bindings: dma: dma40: Prefer to pass sram through phandle MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-1-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763409478628837322?= X-GMAIL-MSGID: =?utf-8?q?1763409478628837322?= 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. Signed-off-by: Linus Walleij --- .../devicetree/bindings/dma/stericsson,dma40.yaml | 35 +++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml b/Documentation/devicetree/bindings/dma/stericsson,dma40.yaml index 64845347f44d..4fe0df937171 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,14 @@ properties: clocks: maxItems: 1 + sram: + $ref: '/schemas/types.yaml#/definitions/phandle-array' + items: + maxItems: 2 + description: + List of phandles for the SRAM used by the DMA40 block, the first + phandle is the LCPA memory, the second is the LCLA memory. + memcpy-channels: $ref: /schemas/types.yaml#/definitions/uint32-array description: Array of u32 elements indicating which channels on the DMA @@ -138,6 +155,7 @@ required: - reg - interrupts - clocks + - sram - memcpy-channels additionalProperties: false @@ -149,8 +167,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 Mon Apr 17 07:55:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84039 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1955899vqo; Mon, 17 Apr 2023 01:08:27 -0700 (PDT) X-Google-Smtp-Source: AKy350aXXxJt2SwW9s2lLK/u5LEKdwweVBtkiBN0AP0CdtMake5ledmgR+7vOQWGwIX4y8y0qaGF X-Received: by 2002:a05:6a20:9389:b0:ef:44da:9418 with SMTP id x9-20020a056a20938900b000ef44da9418mr6186790pzh.17.1681718907205; Mon, 17 Apr 2023 01:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681718907; cv=none; d=google.com; s=arc-20160816; b=Fj51t46NKn8smSJCvk/jXrwCUdgq8FSyARQVgpkPSbRA8bNiUcaWb2DB63tG1BjwTP o3QAYOs51yhq1A1Ss2qW/DWgBuWU3VppJ3PcRNZUAd6NpdZAbMEucrsquQLQsgaq/Dw3 SSelD/9ZsLJMItLeoBGAeECSG+080UCwpa04prUBEmj4hs0HmIl4okjdRb7XrtoBJNEH UrcFUZfuDRflPUeyu197xD95A8noKbKF2WJ6Ssb3CVexQgsQXmH9xtQTAowPFrxAEQEr W4J19TaHNMgfPW/D8hTjOLA83EQwbl8xafo8imLD0/l3h6zwZqkavI21Y+aKJA9qm00J grzg== 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=wDtAHFkACNF4Fh0e1ECtMlpIQkwRfUIlYaCT74L7zJo=; b=F+U2hv0Ia4D3jCYi/EIhwhacrJVbMQ2MkV/VPiQGkGagG4N3BK/vpsDOru5BjCcgGG v8SwU1Mv+BMWmDBqNbgfYdgBVtfu/JVNSNlqn+e6T0lcuhBAGodfJZq076SjG7nYQX/v zVFv8ieBr05mYQASckf/w0+P55jh4/1VIJwOKu3Ohw6i12t2chavObYysXOsWR8m3YtK 6JZryenmuwci5iVyTYD3fqObAE9oO5NhxdCmIThbS/A+UCWObymYPzQhPHUpJJbgkmGo zej25C8bC/FQOQPev2gct0MZ8s+Y3usW5w9zEKr6vPRSFgpJjcpLiiNNP2XUjbyx27SJ RTfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q7WCF1N+; 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 q21-20020a63f955000000b0051397d1ae3csi9244944pgk.168.2023.04.17.01.08.15; Mon, 17 Apr 2023 01:08:27 -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=q7WCF1N+; 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 S229883AbjDQH4L (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbjDQHz6 (ORCPT ); Mon, 17 Apr 2023 03:55:58 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEECA2D62 for ; Mon, 17 Apr 2023 00:55:56 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4ec8148f73eso1202980e87.1 for ; Mon, 17 Apr 2023 00:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718155; x=1684310155; 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=wDtAHFkACNF4Fh0e1ECtMlpIQkwRfUIlYaCT74L7zJo=; b=q7WCF1N+CRQkoWPOWi5hetk0qFQtsHK02pWAAiDM91JT2mUoRVoQFvTq0XtekzYjfP aDNyKKUAvU7Zt6SdaYhc00poFYogGvx8fXCB0ZL0R2C+F3RjJbm9lvaJH889C1T9Pwkw 62Q0IQsR7pLMyPOgnyyh/OFIFQLd3HYmxAsAWzUiacTN149pJ8Toi5J7kLBdQ2gD+Hbh 5wxuzji9RIXzVnnHv6TxTd3nZWqc7Gl7eXzfBGHbIHLmY7SpYBoGkzrp7V1Dv7MprKOU AH/ITkbWNpr+A86d56rEn7+lMiMOrtUujLH+uEBAPreyfdRSEh6XeGHc9xfWB7x3OKej bJiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718155; x=1684310155; 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=wDtAHFkACNF4Fh0e1ECtMlpIQkwRfUIlYaCT74L7zJo=; b=C5dZtdMh0OToaDV1v+9Moq4Hk3I+DJ8M2Yv6CNtw3CqSixTVZ9vk2BKCl24mkdlYVo KAnjvf240R4RiqwaBkSk9dCt6aScXmd/T+2Ksr7c1BjNVISFQPqZTl6821VFf8K8M7Ue PFN7+miigX7cOhMnWOtxTg8kr7+Z14wti9a+m18u+F10Qrx9A2IdPiP/haOH/0wcrDlX wFl5nVfI3SnUqIP0aL5mzz4v5pJ86UD4J+fXOF2iZGq3hmDdPscDh9HbuDT0MAPCgGAj r8WaCJmaZCZSkCF1JHZA/s3HTtwr9fsuFmWrO55NKUkSvvHFpnvSJhFhPzMr87YBlG1b POAA== X-Gm-Message-State: AAQBX9cWHbpEUapyPB+9RjM6oYKJ9q7clDCaxZC70diq0co60cl0bMGz r5UjgUsBq9D7s508CJ3+3f8Ngw== X-Received: by 2002:ac2:51b8:0:b0:4ed:bfbf:4486 with SMTP id f24-20020ac251b8000000b004edbfbf4486mr1417102lfk.4.1681718155000; Mon, 17 Apr 2023 00:55:55 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:54 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:47 +0200 Subject: [PATCH 2/7] dmaengine: ste_dma40: Get LCPA SRAM from SRAM node MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-2-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763410084885972939?= X-GMAIL-MSGID: =?utf-8?q?1763410084885972939?= 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 fb7073fc034f..37db3dc9a92a 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..236269d35a53 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", + 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, 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 Mon Apr 17 07:55:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84043 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1956659vqo; Mon, 17 Apr 2023 01:10:11 -0700 (PDT) X-Google-Smtp-Source: AKy350b9KwM05+fhnHZ7DrTyhCnoXJI2s8P+vWejC1BxgYCpfL/6eVu39suyRkOfz95CkkFqujwS X-Received: by 2002:a17:902:e884:b0:1a2:56f4:d369 with SMTP id w4-20020a170902e88400b001a256f4d369mr13656786plg.19.1681719011437; Mon, 17 Apr 2023 01:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719011; cv=none; d=google.com; s=arc-20160816; b=HG6b5nEPL1BIAmEV4+i3qGmS5Hs66Eu0URyrHfj4aOXmf/HZ2rErF3JGq+imOuuP4E cSBulDZ8Ec+69AFGxrcXrWnjJetEVZUMCFhMwX10bxZI5GpTgMtgJQKm+yM+hGfelOO1 ujK2fW3DgfZ5RwYy8tbvnqn1XNl8kDP/8xXgdmBzzPSAnSvJeReLG5DTNEy+ssfBvPdc H38iA3SDMrFND5nt5Ol39708RNHTtGNfDNuIleHAPgBLci28tskHcesZFV3j0Y158plk /ig87V0eOSd77NswLVH8CDc8b1Npja8esDJzxCnxuH0y/VPcUaDPv7y25cc8Z5xpx2KQ 0CeQ== 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=raEcrPxjmvIorgt3QUQP2yO/QZWKTGTiFhKTb/g/MHU=; b=y/LlPG6W8ybF0lTvTnDAxuzV1pQ9ndoFFrg+uXeDwAIXMzBy2wL5g5YezTIcuTVy1Y q3+SVNmwiR7dquVFNgqWhtopo0dF/0atPFnVVdOc4N0g+iQhuiHdKzD5uojENB/ZjzA5 AB9JOac68aoK7h47a+/4K3VQvWiEBGh2fnTJcRgMKqG8Y62M+WyqyHOnMl+DmgzWPCgB YPQPxwR4P9RNInSrlK7fk0Ci6L6WInsyifAWYYHlEVM/OMlWlCIDoGA1sMJ/krYgleRw reqKzda6vP8FwfHyJi13stGnOEtUOqf+D04vODbbTT7Y10nRyg87NMvZAbY5E8x6TGmu dhaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WQvI0XMC; 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 bc7-20020a170902930700b001a637201992si10974468plb.488.2023.04.17.01.09.59; Mon, 17 Apr 2023 01:10:11 -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=WQvI0XMC; 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 S231203AbjDQH4Q (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbjDQH4A (ORCPT ); Mon, 17 Apr 2023 03:56:00 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABFA03595 for ; Mon, 17 Apr 2023 00:55:57 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4ec81773cf7so1189620e87.2 for ; Mon, 17 Apr 2023 00:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718156; x=1684310156; 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=raEcrPxjmvIorgt3QUQP2yO/QZWKTGTiFhKTb/g/MHU=; b=WQvI0XMCf+Pgy2E7m3MhIJQC3jvWr5xauHbQzB7292ATdg6cXkXtPuAFS+s4Ie7sjB EPwa/d0xxX5BgRc8FK3EpWbpN2SZf5NBBYNAnRytTPzvh/a2xYPTrhBb1SKKlCBKM0HC gvbmkLTRu5WHLhhyYkcZgSrF0cPGVPOvorlaggHNa1ZXWnclyTX5Eg56lIvqNXLXYRZ0 pvLz6uaC/yBl0v2aO0tDdqOtIAUNnwutdBGHOwoGLFuUJnFRNKS/V5i6rE+amerWeF7J ZZLGqijPVgcohhB6n80w2flAO5FBGblPDocxELnNvq+JrCHG/Sji/7PKFKbsew6oBTiP Forw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718156; x=1684310156; 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=raEcrPxjmvIorgt3QUQP2yO/QZWKTGTiFhKTb/g/MHU=; b=Q2EKYwP9jxx9dUMCGPJfgTbWgozfN/MyUjPtFyAAnHrUssOHIyhJYOQIrFYS8polXP nPAcIBfXE9NB7I9aglH1OHVAvQMeSAU2LTiKQ5SRg039IOAEV10R8ZVtdjnyqZCUjWm7 WASFITgfLr8Z2n/H0S5N0fEaTYYyZsuDMPXRp9AzjJfNXYq3rsxZZb1spoAAc6T78iXX SbX/YotLFg+PwX7h1ZE+MaH8gHNi0/caZKBuVKiwN76gTDkGo3pISUQe6nRIO5SGrXuC f280VDmSNsFa9w8W3xAWrs/PsSZWOuRR8aUGt3E9Tx/XAaz9bNj7yD/R2nvMgxzOb3vT BgTw== X-Gm-Message-State: AAQBX9cRMJAZZAPuRmKiaMz65cImb7UATzqtqTeakl6dXa36DtBEX9IS 7SM4KJNykvqpkBNgWiOG/inmSQ== X-Received: by 2002:ac2:5dc7:0:b0:4ec:9c2e:7edb with SMTP id x7-20020ac25dc7000000b004ec9c2e7edbmr1554419lfq.42.1681718155874; Mon, 17 Apr 2023 00:55:55 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:55 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:48 +0200 Subject: [PATCH 3/7] dmaengine: ste_dma40: Add dev helper variable MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-3-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763410194337290013?= X-GMAIL-MSGID: =?utf-8?q?1763410194337290013?= 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 236269d35a53..ef2a2fdaa82e 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", 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, 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 Mon Apr 17 07:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1955897vqo; Mon, 17 Apr 2023 01:08:27 -0700 (PDT) X-Google-Smtp-Source: AKy350a20yweClMoo7o8W2jiC3SteBj7BFYCGgEBw5CxxgusNpw5YDwe7jGp6+u5sf+Njq+pIRdQ X-Received: by 2002:a05:6a20:a122:b0:ef:8b50:56b7 with SMTP id q34-20020a056a20a12200b000ef8b5056b7mr4337102pzk.60.1681718907108; Mon, 17 Apr 2023 01:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681718907; cv=none; d=google.com; s=arc-20160816; b=nxxJlDWERs98pKz/zIkNtUcH7n9RXl8YckDDMT0PNlUgSx3MWbZ3iaeU8e2jlxa5bC S9hwW4xLssiZQHpFEM9omrSgx7Vn7wb34ShGg3zn2WiirPq+62h2rFY0+OhyLBcCgsIf K2UdNz/NxYASC7QLU5XGkxXmOU2f0dLZNOVFpsPQJy55hteS1zFgby8T4MkSvOw0c9EL w5+CQFyb6OkEq8XtgRKya2K9JFIRUzgMZvwaB4I6kC150NnL7THoLBOvSDDKDfamRQIc /CWG1/Nn2EGK/LTmypDgeGMO8JY6vCzeW5sA8Wwmn9QcIdp+rvt0gWwrg9myw3OEJ1F8 rjJQ== 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=IPWdg7F3IMdhanRJoUEbtquK6iHGHFOstWq/7/QawoU=; b=ircyn2waUGthBIH2VVq+U02bxWzUQZn8PJmMASfGJttBU9myODAIUxquU56gERjHt2 gKgo4/bBT5+elrvXBBZnY90RWhyH88LeChyRl4UVdb+gL88pd2AoBk8OR1IYYvzximQU IxslwDjjgzFxLHmJxJu2v+FJmFe/B+8LApRx0SLPvW5FV2LabP//7+UMYRmHDGXYKxfY kKPM0aGVKt9/PntdtYs7DCbiWVHY3ubvnXNL26+iXCYhejn6yycDiWH+4DaHBjBhxIEA qlHjJNjQY1KXDk1NQjXsp16RCRJPGO2qiacvliIZYAg6I+F9aij8QeJ7+Sye9BFrNQbb Tn+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LT8FWIuV; 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 k11-20020a634b4b000000b0050be915cebcsi10902126pgl.878.2023.04.17.01.08.15; Mon, 17 Apr 2023 01:08:27 -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=LT8FWIuV; 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 S231211AbjDQH4T (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231161AbjDQH4B (ORCPT ); Mon, 17 Apr 2023 03:56:01 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89E313C2B for ; Mon, 17 Apr 2023 00:55:58 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2a8ad872ea5so11867861fa.2 for ; Mon, 17 Apr 2023 00:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718157; x=1684310157; 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=IPWdg7F3IMdhanRJoUEbtquK6iHGHFOstWq/7/QawoU=; b=LT8FWIuV4QuV5Jxu51E5t0hEDBquZRsX+AYIVo/gFq4FALa3HcErJACinixYKJz0aQ sC3skK7dDYJ9W1DLB/6/wXusRHxiQVe04LDmblPt+9UVD2iKjSHbk0jcctJKr3frLWZp 7KfmyGbcQOCH1ydaWCYEmJRq2+yLTkOXgrNlTZCFV52CAXVxz5CyPaWeM0rSSHFxCm/0 FAziJi89Blw/zsQOn4YbXCX/uBHKyH6Sjq7UA0P89SHJ0MBPZfn+YKVWGiaWbynmsMdp sHCuXJkfwn/pRN4XA2ypjnnw56gQlGYo64HNdTSQuMLgtZDrKLCK/lAddEjjAJQLTOLE ojDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718157; x=1684310157; 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=IPWdg7F3IMdhanRJoUEbtquK6iHGHFOstWq/7/QawoU=; b=ElONPgseDi/cLf75K3qzFb/XMGeBvY2x3BcceB2MYp3q59oOtx2RNGPITqug8Vgy8e 4B8ldtFpB/nVFlIOd+9laBZOdVMDb5baKRvwtzh5S9mqiR9z6jVRRebS5uuW7iDy/LcD 5NEH3qwgfkJEXQGS425rGYan9ZDAdfyFBcpjwqMyw8nKTf65N05cQeesTKgZCD4thlwL +HLrEYSNoBckm3PPd4W4aNfMFH05NP/X638+lvAeJxdbpxlAj06GVw7fbWLVl1j7U99W 0XyM/5CxbX3WLT6pUMsZAp0bPT+UW3+LtR2rd0ZL0vK5I9pDxpaSa57UVf3pBu8bmTcD 8uKQ== X-Gm-Message-State: AAQBX9d4RZO5nOPC5xhuyaxLbW4T7tEoQ7XPCf5KH39wv9dySQ/M1HdG 8QR/JiyZstOERWm0H8YBSIaDnA== X-Received: by 2002:a05:6512:3882:b0:4eb:2b32:feab with SMTP id n2-20020a056512388200b004eb2b32feabmr1673201lft.50.1681718156788; Mon, 17 Apr 2023 00:55:56 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:56 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:49 +0200 Subject: [PATCH 4/7] dmaengine: ste_dma40: Remove platform data MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-4-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763410084959781860?= X-GMAIL-MSGID: =?utf-8?q?1763410084959781860?= 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 ef2a2fdaa82e..e5df28cdc4c8 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 Mon Apr 17 07:55:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1957220vqo; Mon, 17 Apr 2023 01:11:22 -0700 (PDT) X-Google-Smtp-Source: AKy350Zttu19iVTQXGQB6zR8lkk0Ycl5OLpPSR0Vh0BjNL6hl/RMNMkehv7XhC0Oy0UTysuHj0F9 X-Received: by 2002:a05:6a20:69a8:b0:ef:abaa:741b with SMTP id t40-20020a056a2069a800b000efabaa741bmr3602298pzk.7.1681719081857; Mon, 17 Apr 2023 01:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719081; cv=none; d=google.com; s=arc-20160816; b=PHBuikHJPqjKLIKsXK6qYhFChxmrlNWgorKyjmwXWxAOr5MPMXsyxJhp9y85/fLaZw oSjl7VKQ7Wl8+ni8y4KtaV2ZSpW09FnTAZ2bJwQuPGRteAjwHYm2Tk9dhZWzbHF/DoUu KiEehf4AvZ0DJfuKktF9kx00c5wgIapIdaGQM50qH/LeqVafaxpbpVUWO92xsVUv70IX n3l+tdiEPStFxaG8DYA392opAvlgwBw/9srqgsLwJ4JVV3Zd/KcsbqmESKIFSQdqQBUG j1ktetJEzxd95V963WUXbrbAyyybmAP51i2s6aIJwe/jVsq3GOOaljrMiVTzpf+IwoQs fMkg== 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=WctxKpomw5MLFuTazOUJElliLOUHb46B+NNI3oGGJOk=; b=UaTF9YKrUmiYnwWKHbFG9QRhoNrEyJkpL2fZuM8j7nJi8UdSqf5vxLG35eKYJPRMdp UrD3J4pjupEd8ZpprIfQTSsXnG6eP/xNKVZWLhloyOGxbiKuVjeN0Kd4M4psSGicMbyw VIiqMVdE7t7zmOpOzlRIyNRiOZ5T9VAH/ODkTStRpXcTM4DsmKBkXAh5zbleEsH2EZNe 8ACnxPNoHkMPimGb34nApr3VMrUp2CXavwXwbVvUGF4WsrY9K1faLwNezQ89yNmThviv K4mkMKiTZ4Xg1gbhORtBbaVqKDYI+KRfDieddBzXGx9lZ/C7P7bZ9Ayyi7nvAoRvSvQn Ij9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nrm3vCoD; 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 z16-20020a656110000000b00519b9bfd43dsi10287647pgu.480.2023.04.17.01.11.09; Mon, 17 Apr 2023 01:11:21 -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=nrm3vCoD; 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 S231239AbjDQH4a (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbjDQH4C (ORCPT ); Mon, 17 Apr 2023 03:56:02 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B5933C35 for ; Mon, 17 Apr 2023 00:55:59 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4ec9ccab8bbso1203365e87.2 for ; Mon, 17 Apr 2023 00:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718157; x=1684310157; 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=WctxKpomw5MLFuTazOUJElliLOUHb46B+NNI3oGGJOk=; b=nrm3vCoDnCsGk5roNJOkOPJb/qrgzSDL7HZTpjuS0DYFM6k0XGk3ilID4Iatv3LMvT U8XRVJCyLpQPX9QHRfpxzhPr+M0L7uNCX/jXSFPGuAct/7na75uNhvspwNSp+NPOOgy2 c5sf/zmkK6CZ4sSFs4FPA+pTrK5+A6eQfN2XMWFzbyvyf0fKZzzaenFoeKS3LNFBdHez 7Cpjj8F9/dvQDjk24cKykEUjvRQCrPGJwkXmFFL2E04fQ0gOv9h34nIfWleyj3Q+tie1 6lbhupaT40ktTPvKuE2LOCfoE9spvTMDf8WK04iGb50AQ3vq605S/bKk3klAWPhdAT0S muzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718157; x=1684310157; 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=WctxKpomw5MLFuTazOUJElliLOUHb46B+NNI3oGGJOk=; b=AeMrAki204gDmn8vN1n6uOxBRj+ZrujHqPF4t2OP9lXi+YCVyPxfuaxrFN3Ej5NNEa fLOj5OkOGtnoQwidvSdlsFW8Sml9yfMImM9m5l8+4EsdnXd4cMydaJLF8/pu08hEXsMI O6kYf7KPm2IPmgFr25qJlpAz7wsdIOzxwsZb636QRMwZz7FtCbWiX1rprpXF1FcKmTAI GlZHts+tXXNcINRBpki+5gMXVmgNct9P1z7Cmp9MqzjnkIshvuOC7RMDP2QL2BIgjwA2 d5PkLW+tuTb5Q+FLe0X4IK5bCIK6je0CjMxArpgG60570wwpe963BiWk+SNZbdCISiVk I2fQ== X-Gm-Message-State: AAQBX9e/mpuhfOuzcwxVSbRRsA3kQ9uUI2zNazWhoLOeD4axreZXF/Z2 2KaNrP19wHk4DMywRDD5rGlInG+ZhAgavj+fuIo= X-Received: by 2002:a05:6512:924:b0:4eb:274b:a69 with SMTP id f4-20020a056512092400b004eb274b0a69mr2163114lft.26.1681718157639; Mon, 17 Apr 2023 00:55:57 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:57 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:50 +0200 Subject: [PATCH 5/7] dmaengine: ste_dma40: Pass dev to OF function MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-5-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763410267679205777?= X-GMAIL-MSGID: =?utf-8?q?1763410267679205777?= 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 e5df28cdc4c8..fe98f12b8130 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 Mon Apr 17 07:55:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84037 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1951219vqo; Mon, 17 Apr 2023 00:59:06 -0700 (PDT) X-Google-Smtp-Source: AKy350bey2GhCNveHLK+LpZzYz3pYLZZ0bbHj+KNjG1jRnga0H3zTuOCBwzWT72cEtmlBWnimKrE X-Received: by 2002:a17:90a:fd0e:b0:247:6944:2ffc with SMTP id cv14-20020a17090afd0e00b0024769442ffcmr6954897pjb.21.1681718346082; Mon, 17 Apr 2023 00:59:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681718346; cv=none; d=google.com; s=arc-20160816; b=zLpiaeO0ZRmFSTew44TjUnSYCCBcxbq0HXKvlxdb70/KPMOq13m8n1BEEQY7FnTpJJ 2s0A8hjnAd6sQLtgw0ECkaYqGP5MnN862d7YCcTKSJ2GyANDSxItNR+CQyjkCEb981sf Zw76QGT7+duH5a/X6dJ3+yE5zFF2L77+LLWNU/BhVIUkWLo77BFKVUQaUs+jN7dM1G/e uu8piRxbYBnJN2fvvxqsxQyVZ04lPUDLkCc+B/XYMQuaHe6zJtWH7RcpoeALUneIf5Fw MOC0z6HAqD5+VBj4CTRo5Pu7WgJagegCemMuCwUNAKc8k/bKBMDn0pvTVp2iOmkFMMlB NUVQ== 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=6f6IBkBIt739+E7WXx4zldQTdeT9xMqDgSUi25Hzr98=; b=Vwm5it31SAWpFgLFrEWPdrWWEMp2EP0Z1pKyzKKUBfmSGfndEfxSiYVBqyCcIQqrIZ tGETExev2pNaWd6Uxac8aaqcUdoXcVqb2/41M5Lo4vqnTyQy0xESqFcgl/F/njwKzLrf DW6GU8dFQZ782pYJJXBXVLrpRmtLVZOxv5CHjSNSYO0JVhMFrNw5MVdICGCwUYejOdXK 6gVdDXtXnAVBKlx4znlCFAEn2cb4MeqQZgtPYzGYEBCvlL6UFR0//jLG76YAy1M312CX 6CDwVGJFM7rSumiyAvLVaslAy/szi2omSlXssWCHCymxT4wpakj6Rzk+IgqJrmCrRQLD KSlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iJ+BuNWG; 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 oo4-20020a17090b1c8400b00247601c2101si5833173pjb.71.2023.04.17.00.58.51; Mon, 17 Apr 2023 00:59:06 -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=iJ+BuNWG; 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 S231189AbjDQH4d (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231176AbjDQH4D (ORCPT ); Mon, 17 Apr 2023 03:56:03 -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 4E02130C6 for ; Mon, 17 Apr 2023 00:56:00 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2a7ac89b82dso11658411fa.1 for ; Mon, 17 Apr 2023 00:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718158; x=1684310158; 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=6f6IBkBIt739+E7WXx4zldQTdeT9xMqDgSUi25Hzr98=; b=iJ+BuNWG3vRAUZE+T7vEdn54sf368+DJrKBVNkZ2JD+z18ddB1/dgIt5S8eAzQPi4C EpEKGm34ztxZ6UmFEZHxUdBMa/bVCa9w84JR3BpSCUh1wfrJJ80NZWkGKWNJkhlKFVTa YI6qveLXqUu9OhmJCPpnfEn0ItnzC+iJWoVI8R0XQpAgiYdS2LSenrHnvU3JvxW7p4mj 2hJR2AeiA32X6hDX0b5Q3ALrFWjBerlapF54w+o03EcFo/wYDI5ehd1kDvbhLRdqegVb 0TNf8PxiUVkOH+fJGMnHSIYZ3EM9mW210qqPJDQAQ+REw61Sb4r26uON2GbvE+39Hxcz IpdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718158; x=1684310158; 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=6f6IBkBIt739+E7WXx4zldQTdeT9xMqDgSUi25Hzr98=; b=FYK6hfFD17SYkvgcOLizCRA0NLw2E+9YAUD7UfUNKcEdY+eAxxogX/mRUAu9omi4kd qIjct7n0ykYEcRJSQIgJyHjXOzUfInNtbWl5sGKAgt7H3L4hnbKLkNRSlNjSO7Vif8k9 axjdRPapn0uQds6mqm9njs92Kk9tBvhXKhjJpxD0X0nBi0V4mQ6Wl4AorY1lh9Eqlb/L j1uO1g0mYapKWsc/M5ONc6Wlde1Aqj8ttHNSrPAHhxqZm6CV7OhtrJ3xFnVqXztOatWD nEJHuDll1sG+8HjmoKVwDqO77tIlYnJr8FdLTTs/gGlcFgWv/Xpob54I3+XcM53T2cAZ 72lA== X-Gm-Message-State: AAQBX9eZHHDv0KbHYBpeCLa091sDzKbJ5FUEiJOjLSjWCh8WgHaE4chQ fxz14716amcP3YsWAG6KIw4m4A== X-Received: by 2002:ac2:4908:0:b0:4b5:7a91:70f5 with SMTP id n8-20020ac24908000000b004b57a9170f5mr1709749lfi.63.1681718158531; Mon, 17 Apr 2023 00:55:58 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:58 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:51 +0200 Subject: [PATCH 6/7] dmaengine: ste_dma40: Use managed resources MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-6-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763409496556510179?= X-GMAIL-MSGID: =?utf-8?q?1763409496556510179?= 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 fe98f12b8130..c5991009d3e4 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 Mon Apr 17 07:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 84045 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1956681vqo; Mon, 17 Apr 2023 01:10:15 -0700 (PDT) X-Google-Smtp-Source: AKy350ZE0YdC/C1EZWjspFTtMsh5wDsaDbgo7qSS+x4PRTtOdHejATwwtyrEBr//6NWvebXJlGI3 X-Received: by 2002:a05:6a00:1a43:b0:634:657e:546e with SMTP id h3-20020a056a001a4300b00634657e546emr19245635pfv.5.1681719014929; Mon, 17 Apr 2023 01:10:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681719014; cv=none; d=google.com; s=arc-20160816; b=MCvsC/cYGTlOqpNRHAcukaHeBFakx5bH3U6IYDDHNxAjwZAaBb77x2cB+G+WAPiAkj LJbKBEu718sfAZIVL/D2CWQQDeg0ncqxtR3Mae4YNL6QAcCQJIJbpXkyJxvil4fRSJqI kFMXbFaHpJX1UfLkRafS5WvMIncWLvVfVwswdyqw2BqIHBxprO1asj0vtLec0SajxelQ unRO2PmLnLWlLMK9qUZFIoquFfbHZDIkvozA1QETFh2aC1Y6WAwq+onwUKaJizgyl7WI Y8yWVG2ejoM5uLvC5sW0Dv+YyHOb6cZTSaFKh9dI+V0kISejJ8Idc6JoU+TzULP6UnJm H6mQ== 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=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=O1PEWaqImmBnb3WBB6FH/NmE400DGerlhv0wB+spE59hB4OPwAl7XWJ/D0RfZUZDk1 JFsGQDvb1hTlMr/oeEj/lZPPp24ZCEAXJj5Y8gDjrKxS5dU+UD197VSdd4BN/YNwdMuD UImWuaX6iEkXKINrYyKOJuQx9vtg720yDZcfNxnCJzMtG2q8fj/F3IRdlbXi28gZ4j/E cUlAvJGjQ0G9AikA2FjxoBfH0wcl7K7AZnN+tdc/QAolr5TUNMeFwVTHlFZFz9e3bDA6 G4XHaogmNJ6EKluRs5mLu1aeOKCVTClOyyoBIqVBi6yxnw8HkN4LrE4iDx76dIfIPSii 2U9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bKmXKwxI; 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 x189-20020a6263c6000000b0063b86de9d22si4703593pfb.177.2023.04.17.01.10.02; Mon, 17 Apr 2023 01:10:14 -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=bKmXKwxI; 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 S231258AbjDQH4h (ORCPT + 99 others); Mon, 17 Apr 2023 03:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbjDQH4D (ORCPT ); Mon, 17 Apr 2023 03:56:03 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16E2B40F5 for ; Mon, 17 Apr 2023 00:56:01 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4edbd6cc46bso1040574e87.2 for ; Mon, 17 Apr 2023 00:56:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681718159; x=1684310159; 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=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=bKmXKwxI1i5GaBTDoiN8WGb3G7UxJGUxg2INzSxaVMCoaFLx48refXd4Nz5bpaTidd +aJVPhMYK3cl1wy7wA5gA2ITlD3XkS104O9DZZlUQkF/2sYeRwZdKIDF9YkwMDLsEHUa fMknMhAwfXB7I6Abw/8FZI2/Fc6hGYMjSWeHlTqNKpRCbf/nCmmlBfc4HHeSS+DKo7Il Usoh5H71wzm1HaCo6ZsGh01TzozH0JBMsxXAxp8OBvFE1iOe8WNQHfmBGmxmUhPK2InJ InJDp5EKEQvh6O5GYiMLKHqqQqQlbPHOxLZUBQN+wvDF8krGuzw/A27tH1xHHfnQZyT3 0BCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681718159; x=1684310159; 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=6O/2AisgZasdz5TfqSJm6yXze5QCOC8Gd2nntmT4L9I=; b=MCrW5gKpsVXzpnOde6JL5bGgL1YiWNOO6FbTcVBLqaU7JTLX7K6KOpzrIqcLYoMVGo bVrS8soYmTk3Ay2Q1f5XpicoSNr9HIA+IjEWyVXXHZIc/fia4Ua+fTniFVihUl089Ota licdt2oKjNhrcYHKlFI5s6XJqwcrkVauZElf2qrHWwLH/dEqWv7BcWVwN1M7akJakqtF noUkVj4U1UecBnU9Xjam1QWEO1czr7v7ztJtjLCultXfrixIf2lWLegXMSuRyHiKmlL9 Q1Ws+Yd9V2xVjJm0A5D/a/t9VBq8ZdCkd8LiuNDtNfM1R3rVU1lf3f32eaZIccBOPAoI t7rg== X-Gm-Message-State: AAQBX9eECt9qvhv+lzyrSJ15Y8zYjvkNQzXpNI13auSrNwavYpQRKPYC JyUFHs5508+qaH5N0y/1zgD1lg== X-Received: by 2002:a19:f80a:0:b0:4ec:9e01:71e with SMTP id a10-20020a19f80a000000b004ec9e01071emr1697300lff.4.1681718159455; Mon, 17 Apr 2023 00:55:59 -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 p2-20020a19f002000000b004eb274b3a43sm1952547lfc.134.2023.04.17.00.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:55:59 -0700 (PDT) From: Linus Walleij Date: Mon, 17 Apr 2023 09:55:52 +0200 Subject: [PATCH 7/7] dmaengine: ste_dma40: Return error codes properly MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v1-7-b26324956e47@linaro.org> References: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v1-0-b26324956e47@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 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?1763410197959289350?= X-GMAIL-MSGID: =?utf-8?q?1763410197959289350?= 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 c5991009d3e4..2911017265cf 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 */