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: 156513 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2399026jaa; Thu, 24 Jan 2019 12:24:36 -0800 (PST) X-Received: by 2002:a17:902:20c6:: with SMTP id v6mr8062069plg.156.1548361476456; Thu, 24 Jan 2019 12:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548361476; cv=none; d=google.com; s=arc-20160816; b=pjdd3HIBVi26HNoAYWWf36moIU2OwqsnpB3Fzi1xmsUKcjpBoz7+96m79EkuFh5NWQ AziA/ufx6/y9ZtlFn2gaxBhDJKBke61YH0PkK7iMkjh6DXYk0Vp5jSx7eD+acWurx0uD tXRiwA8Yp1ug9Ufi8+T+fBptg/Lt3TW1ZTw+xr76QtWwUiznjfsCRdUaSzO2l6UdAT/Z b8j8DCUGNCILM+Np3txkpUho3Q9bIxyvwrIul4D7j4QtsAQ6dT9IQXSZx3+tiCECcvvv CLQBJv+6Z81NwvQ7PYu1UzsQQXxVMzh3QG2+taMaamPTyMBfUQ3t3SvmI+d6RqIRGN7h DZ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=B0f8amiCLjyli23I/W3zmD+C1Sb7tBAJSig2UQnjOwY=; b=h9yaGhsjFR1UF5eIQVMZS5n7gnVUGM8EtWzbOvNaAUXRFN2EJlmsBdWqLxEdvojf3C 7tGA5AqNLE1G9gztWl5m0cbNzleXSDDjfTbfIOy9+lEHSnAqAPOia1eEeb6oDcvHSr1L sN1j550arXl8iR8MKKWP2m5i3o4H1mGWFEVI0qv1+9m1bcpH5omMr0YE/qB7wxD3ZDfE s2YyDCmD4wMH0146Op3+4kSCdsBGCe+PR3OA61UvN5NbjP4+3RIpo4VlFImQd9vxNWzu +V4hWUdp6bZ85feVPoCs+1M5bG2kdtajwT0jxAP7g3Hi7lgpwCU/Qxep4Xc9K33yuYGR Je8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gB0ZszgY; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id c84sor33867590pfe.49.2019.01.24.12.24.36 for (Google Transport Security); Thu, 24 Jan 2019 12:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gB0ZszgY; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=rSDsECOyQvvPTY/UNynuB6EWg92yaKoz3aq2xriwhibV09UHcnCg/O94+vCZc+DhL0 h6g7/2BssUaEQi32uhTFODTPlEYGEYidXfMbApNTfl8+o+JN6rktvuXz5ve0mQQh3NFg QzvDIPdBffuzmBKPS1VTwJ931SYScgTaAdmgU33tV0TyqB+A0ajnlwmmg3IoZMjAT4MT cFwEdZeeun/YzQbR5t+w3w4Hu6kEZT3PZxzBQDIDToYT0jxBtcYu7cxxClY52rvCr9UR nb5DwagGZORjWX7eOKtmqiBaROHIOaIZsqDcvf7Pv/IWMJ2biaX+1SKGCI8/3RxA6eaW nbYQ== X-Gm-Message-State: AJcUuke/qEJ8L4M+tYP4gjuZoY3R3142qly+thmU+K7KUZsV9hkNzqQq 3HQRIUMmeFBSIGfK1MbhnrcGsDhB 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) Return-Path: 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> 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; }