Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp519545ybb; Wed, 25 Mar 2020 04:35:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuR3t/wmFr8C0jpzgYK/dAf5R7x4ic5mqRRtGy6YmKhqtP4eslY5TOY2QYng2XJeToE/CxZ X-Received: by 2002:aca:4286:: with SMTP id p128mr2041525oia.29.1585136115115; Wed, 25 Mar 2020 04:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585136115; cv=none; d=google.com; s=arc-20160816; b=NZmzdv+XAZ4NycM1zMAtOQ7CvnlE/iSG1l57u6UwmGBl3WEvrtokykPrc+vf8F9aRh sL3Rl9imLwpG5knEKSZ9HwtHkIiG6KBC0jGgOSBR31fc2Pn+9iPb06kLgNkHanYCxBlB iAkyjP0nObwMBZHSKpdb7pi7ikQCzAMR6RR6NBfnbyhF77rPhdfjlUoekEfTEIztZbfL 6hATAL3mr+7GSQynf8VIw/MrSu4rxp0DfQAa2mnmxDUfV+PNbUQInF0C3yOgzSRcXfID OFi+jJn/mOjbvANSL9kvdNnVJvTzutzEvmcgZEyWOGKnPNzLCwaL5CjwiyYDbZBS+Np4 B28Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O7KffvUQLvEtuKLuleQeJ202vBQLqQy9HV1Fxk0tNOM=; b=qZXrTmyWx8Umtel+qBwrsaY1KZDlxj09T9ia5J6+9LdrfXu85JqTBmWf5mpYoTPmI6 FZxFjKVbnhvwfHKmeBtiY8VAOiUqwKGz8gxsYaLT6K/PlSc0FKK2RQwhZeXaqjI+Vy1/ Kl341uiufd7ApmtvFVMhqddRblwlkThMFiw8iromKwlERaj6deZanWyGNSqYhefAWBP1 oDC0Mgj/Y4FgtJqEb+HeFCDhskCPD0x+a1qEUY2FHNZCa22enfOQ7IeLyxQCmvt9MoX4 n93Bx9cC6b04D40C28DomsFJm1CzbWDWMV3LkJWvzLCSsGIJcJ7+OgljIeFa+oAT5OXH RlHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDfdSaRD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r29si11477174oth.324.2020.03.25.04.35.01; Wed, 25 Mar 2020 04:35:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=HDfdSaRD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727394AbgCYLed (ORCPT + 99 others); Wed, 25 Mar 2020 07:34:33 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:47081 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgCYLec (ORCPT ); Wed, 25 Mar 2020 07:34:32 -0400 Received: by mail-lf1-f66.google.com with SMTP id q5so1437010lfb.13 for ; Wed, 25 Mar 2020 04:34:31 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=O7KffvUQLvEtuKLuleQeJ202vBQLqQy9HV1Fxk0tNOM=; b=HDfdSaRDnAglhBGm1Inpp4+PGlm69FgGVABJzD28TMp6tqeNsKiHMI777YCormOPzd uObNsIFHV1Npk5ziYCXZ0cQLBNe4T8aZZKrc3tZBoKsfGViR+Ix/mqOLR4JsgIMcm9t1 vFdk3jktgqFH4Z/+GU/IydPzWVGMjeoANomk1rbXDkBKfC1ZsDPJLBW8K0DcZwll9C24 tp+m/Jzg8CN8lYauf5ETMIUTJ1rrRQ1tXDrgUnt6dLpzH8GpssHm3HOsSizAit60PbjS Q/2MXBDO8MYvbDm058vsshlEfxsxUgbcDLCNaTtOnWlyOVawtVI6kXoNhDLMsh67bsk+ papQ== 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:mime-version:content-transfer-encoding; bh=O7KffvUQLvEtuKLuleQeJ202vBQLqQy9HV1Fxk0tNOM=; b=dSP+krgJhi3rFZRpIxS4f2vq7h5USndeoQ67Xpafl4MeRLivF4SZO/RuE6xpWOlz05 9XzDga9QWdbrSaOwHIAeT1m0dKPzPqFIIbkDxzRUhgtW2o90nfIYw3aLDCGrHvo4ywsU QvTPuPiyITiRj+q7IDAc79K63/pydTYQqaTCRdEqRgUBltMOmZ+B6u+xCMrA0XasD/1Q zR988hQI92hN6jWD1r3pV+lhjsO/zSxyfyTEE2txdKPDtLQUQAU3jmzcQILEalcUEIvr oqrrrKfazrYEgV+fH00BbJtjf9qSM9rWrHQGLPesftevmnxn1+AwhPtUICluVK2vkeYl dY6Q== X-Gm-Message-State: ANhLgQ3TwJ8blOF8ns3ZJiB3lrqGpezx03qvbavsVqFN6lrzcz+sjeCC L40CEsSbHh8hJhKs439c3ZbBFA== X-Received: by 2002:ac2:4116:: with SMTP id b22mr1933177lfi.172.1585136070290; Wed, 25 Mar 2020 04:34:30 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id v22sm3920009ljc.79.2020.03.25.04.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 04:34:29 -0700 (PDT) From: Ulf Hansson To: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Christoph Hellwig , Russell King , Linus Walleij , Vinod Koul , Haibo Chen , Ludovic Barre , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Ulf Hansson , stable@vger.kernel.org Subject: [PATCH 2/2] amba: Initialize dma_parms for amba devices Date: Wed, 25 Mar 2020 12:34:07 +0100 Message-Id: <20200325113407.26996-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325113407.26996-1-ulf.hansson@linaro.org> References: <20200325113407.26996-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's currently the amba driver's responsibility to initialize the pointer, dma_parms, for its corresponding struct device. The benefit with this approach allows us to avoid the initialization and to not waste memory for the struct device_dma_parameters, as this can be decided on a case by case basis. However, it has turned out that this approach is not very practical. Not only does it lead to open coding, but also to real errors. In principle callers of dma_set_max_seg_size() doesn't check the error code, but just assumes it succeeds. For these reasons, let's do the initialization from the common amba bus at the device registration point. This also follows the way the PCI devices are being managed, see pci_device_add(). Suggested-by: Christoph Hellwig Cc: Russell King Cc: Signed-off-by: Ulf Hansson --- drivers/amba/bus.c | 2 ++ include/linux/amba/bus.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index fe1523664816..5e61783ce92d 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -374,6 +374,8 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent) WARN_ON(dev->irq[0] == (unsigned int)-1); WARN_ON(dev->irq[1] == (unsigned int)-1); + dev->dev.dma_parms = &dev->dma_parms; + ret = request_resource(parent, &dev->res); if (ret) goto err_out; diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h index 26f0ecf401ea..0bbfd647f5c6 100644 --- a/include/linux/amba/bus.h +++ b/include/linux/amba/bus.h @@ -65,6 +65,7 @@ struct amba_device { struct device dev; struct resource res; struct clk *pclk; + struct device_dma_parameters dma_parms; unsigned int periphid; unsigned int cid; struct amba_cs_uci_id uci; -- 2.20.1