From patchwork Thu Jan 24 20:24:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10780085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AB0814E5 for ; Thu, 24 Jan 2019 20:24:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 792132EF27 for ; Thu, 24 Jan 2019 20:24:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC072EF8A; Thu, 24 Jan 2019 20:24:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 026ED2EF27 for ; Thu, 24 Jan 2019 20:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728816AbfAXUYi (ORCPT ); Thu, 24 Jan 2019 15:24:38 -0500 Received: from mail-pg1-f174.google.com ([209.85.215.174]:42368 "EHLO mail-pg1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728220AbfAXUYg (ORCPT ); Thu, 24 Jan 2019 15:24:36 -0500 Received: by mail-pg1-f174.google.com with SMTP id d72so3149753pga.9 for ; Thu, 24 Jan 2019 12:24:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B0f8amiCLjyli23I/W3zmD+C1Sb7tBAJSig2UQnjOwY=; b=gB0ZszgYj5x8jhbNMvIZcXlWOR1JWYlYbwLDXLU4cskG8A97BO+WzW5FZ7LelxxtIR /p9ppRHWPpPWeC7jJJchOrVJqwJeE5+0SNOZHKWFIhtk9f3n3LxW8P0LvcwdNZRXaKgo lzFu6Rf+aPTnZtMhPUudVyz8KKbzuabo5P2GQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B0f8amiCLjyli23I/W3zmD+C1Sb7tBAJSig2UQnjOwY=; b=aCjc+qe/B4/lB8ONPMw4C3n5FJlWYarhFMcza0nDU5i5qslZ50HZjXUvlmZhvyV9ai FP4wCBu2RbKJSYQpDgWAMAr5apyREaa08ifyaIPeVbHoTfBlxDAWyoW5F+74ydtcyh/g lytsclwnL9dnYSAzhzSiBLiMZ7ugKVI2aFQ9NP2KZvLGH8IlORxKGSLEtJ0Z1pyp3yUo 5lGjY1kHQ5/MgX7JqSsB9F+4s5gRXNG6n0x7Y9lyPJ6CFa3M7hznipkcZTvXq7ZW3FDD Zi8zDUUxfscDKMPGbR91pmvCTmTAzGMnsgaviwShX9YrKg9k102CrA9xXWPAjo+1gY7x YMXg== X-Gm-Message-State: AJcUukf+CPj9DJoZZrpt36FUC2abJF4QQ0Ok87x/slmWcKmnfqx6rREs irwffjfTAWriSU1NVPS8JzOCOg== X-Google-Smtp-Source: ALg8bN4Dwb3JzI5lW/2vt0Yp5oNUZHY8h6sdUI1wJTzstKxnpgqTE9glCXrxX130Sm4sTN55K9ANxw== X-Received: by 2002:a62:de06:: with SMTP id h6mr8198941pfg.158.1548361476070; Thu, 24 Jan 2019 12:24:36 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id c72sm45263309pfb.107.2019.01.24.12.24.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Jan 2019 12:24:35 -0800 (PST) From: John Stultz To: lkml Cc: Li Yu , Dan Williams , Vinod Koul , Tanglei Han , Zhuangluan Su , Ryan Grachek , Manivannan Sadhasivam , Guodong Xu , dmaengine@vger.kernel.org, John Stultz Subject: [PATCH 5/8 v5] dma: k3dma: Add support for dma-channel-mask Date: Thu, 24 Jan 2019 12:24:20 -0800 Message-Id: <1548361463-28372-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548361463-28372-1-git-send-email-john.stultz@linaro.org> References: <1548361463-28372-1-git-send-email-john.stultz@linaro.org> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Li Yu Add dma-channel-mask as a property for k3dma, it defines available dma channels which a non-secure mode driver can use. One sample usage of this is in Hi3660 SoC. DMA channel 0 is reserved to lpm3, which is a coprocessor for power management. So as a result, any request in kernel (which runs on main processor and in non-secure mode) should start from at least channel 1. Cc: Dan Williams Cc: Vinod Koul Cc: Tanglei Han Cc: Zhuangluan Su Cc: Ryan Grachek Cc: Manivannan Sadhasivam Cc: Guodong Xu Cc: dmaengine@vger.kernel.org Signed-off-by: Li Yu [jstultz: Reworked to use a channel mask] Signed-off-by: John Stultz --- v3: Rename to hisi-dma-avail-chan v4: Rename to dma-channel-mask v5: Use BIT(i) instead of (1<chan_pending */ spin_lock_irq(&d->lock); for (pch = 0; pch < d->dma_channels; pch++) { + if (!(d->dma_channel_mask & (1<phy[pch]; if (p->vchan == NULL && !list_empty(&d->chan_pending)) { @@ -336,6 +340,9 @@ static void k3_dma_tasklet(unsigned long arg) spin_unlock_irq(&d->lock); for (pch = 0; pch < d->dma_channels; pch++) { + if (!(d->dma_channel_mask & (1<phy[pch]; c = p->vchan; @@ -856,6 +863,13 @@ static int k3_dma_probe(struct platform_device *op) "dma-channels", &d->dma_channels); of_property_read_u32((&op->dev)->of_node, "dma-requests", &d->dma_requests); + ret = of_property_read_u32((&op->dev)->of_node, + "dma-channel-mask", &d->dma_channel_mask); + if (ret) { + dev_warn(&op->dev, + "dma-channel-mask doesn't exist, considering all as available.\n"); + d->dma_channel_mask = (u32)~0UL; + } } if (!(soc_data->flags & K3_FLAG_NOCLK)) { @@ -887,8 +901,12 @@ static int k3_dma_probe(struct platform_device *op) return -ENOMEM; for (i = 0; i < d->dma_channels; i++) { - struct k3_dma_phy *p = &d->phy[i]; + struct k3_dma_phy *p; + + if (!(d->dma_channel_mask & BIT(i))) + continue; + p = &d->phy[i]; p->idx = i; p->base = d->base + i * 0x40; }