From patchwork Thu Nov 2 08:10:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 117756 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1745030edm; Thu, 2 Nov 2017 01:10:43 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RjrMDQQZl001TfHYxFgKgn2sfG/6GxkTCt18sqh4EylOQIyIjrREG12cMPEuy7ci6zqo5t X-Received: by 10.99.56.19 with SMTP id f19mr2707410pga.328.1509610243479; Thu, 02 Nov 2017 01:10:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509610243; cv=none; d=google.com; s=arc-20160816; b=hv+2t0ZYPhO/NjWOe7sqnrIWrcL4GdBR18M+5iZoC7ywzlyFG7De71o/dw/syvjwrc 7qHFN40Dhd4jO19mgzCFJDodQ1jGxHOGvKi4SrAno0QoCOom6W7vWHZSN8W9rmSzM/J8 dCaHjtQqGDvzEO0cyc9ehMvk9aeU1b7YBgs1Ra51TQR2U8Evcoc2UO7k5qPGtcI26m2v ZGD/tGR4aw0A5bRShpiY4Eak2iHifh+sw158bcjX+bwd+XhhZww77o36EqcBTmAJ7to+ LKI6KB05O0oHbfpvfveWxTINOpdNlVLnKnEtLtVnOFwfVYw14M46AoBOO4Gkpbq5pYVx toFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=RhWSaA8jTxGH+KheblKatZKgv1CT5z7MrX9RS6thXGs=; b=AT8yEr6vspx+jxas2RsZFM/B1Y3PgzoCu2GNnA/Umh8KaDcB1Is7hbC6tkb93jLSme b01pt44uwiVnKPOTwU1BKmuODWdpxSO9hjpiZ/mQ9GB2srJBjDo/0SFeRGcO62d+f7dw vMOE1BCoYtg7+mKZquZvOVlmQyhMmOMuDD4fUJ/nbmZk6pDqpEaWqlfML0WfyjrEwGHt HTQnm+ygzhCMdv48vkLxFbg3Djq1yLNk4KdXWmkmHGVKVxDnqjU0oNmkw1krXYs0iMie aALR2aulJGRgKPmjsE8yCJb9nUHEqxCZdIfyPsRzgA9dZ5qHmCzTuVNbTphwmawx1U8B bMmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o15si2908503pgf.485.2017.11.02.01.10.43; Thu, 02 Nov 2017 01:10:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755501AbdKBIKk (ORCPT + 26 others); Thu, 2 Nov 2017 04:10:40 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752759AbdKBIKh (ORCPT ); Thu, 2 Nov 2017 04:10:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 488EB1529; Thu, 2 Nov 2017 01:10:37 -0700 (PDT) Received: from sugar.kfn.arm.com (unknown [10.45.48.167]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A61F93F483; Thu, 2 Nov 2017 01:10:35 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] staging: ccree: handle limiting of DMA masks Date: Thu, 2 Nov 2017 08:10:22 +0000 Message-Id: <1509610224-14708-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509610224-14708-1-git-send-email-gilad@benyossef.com> References: <1509610224-14708-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Properly handle limiting of DMA masks based on device and bus capabilities. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 5f03c25..1d4c7bb 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -208,6 +208,7 @@ static int init_cc_resources(struct platform_device *plat_dev) struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; + dma_addr_t dma_mask; int rc = 0; new_drvdata = devm_kzalloc(dev, sizeof(*new_drvdata), GFP_KERNEL); @@ -256,15 +257,29 @@ static int init_cc_resources(struct platform_device *plat_dev) } dev_dbg(dev, "Registered to IRQ: %d\n", new_drvdata->irq); + if (!plat_dev->dev.dma_mask) + plat_dev->dev.dma_mask = &plat_dev->dev.coherent_dma_mask; + + dma_mask = (dma_addr_t)(DMA_BIT_MASK(DMA_BIT_MASK_LEN)); + while (dma_mask > 0x7fffffffUL) { + if (dma_supported(&plat_dev->dev, dma_mask)) { + rc = dma_set_coherent_mask(&plat_dev->dev, dma_mask); + if (!rc) + break; + } + dma_mask >>= 1; + } + + if (rc) { + dev_err(dev, "Error: failed in dma_set_mask, mask=%par\n", + &dma_mask); + goto post_drvdata_err; + } + rc = cc_clk_on(new_drvdata); if (rc) goto post_drvdata_err; - if (!dev->dma_mask) - dev->dma_mask = &dev->coherent_dma_mask; - - if (!dev->coherent_dma_mask) - dev->coherent_dma_mask = DMA_BIT_MASK(DMA_BIT_MASK_LEN); /* Verify correct mapping */ signature_val = CC_HAL_READ_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_SIGNATURE));