From patchwork Wed Apr 22 10:10:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185688 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp566282ilf; Wed, 22 Apr 2020 03:10:17 -0700 (PDT) X-Received: by 2002:ac2:498d:: with SMTP id f13mr16583147lfl.75.1587550216978; Wed, 22 Apr 2020 03:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587550216; cv=none; d=google.com; s=arc-20160816; b=RdCwxsxKGMU4QItnb2akY2jQOJ2PljUtNA0CW+fW20I2kR84SLDMFP4QILpEgOq+g/ CQMHNShVC1/nA7MDycdcLBZVLihlShRX9RpEIOHpUyzIqR0Txez0m/hKkFZ+ij6ctDOU ezqx5epBN/hGEVT0h9ji10szyBQRb9Ex9InxEcHo/qLsuRgO0ZWzGtdnZNrU+NiXEppi A7ibw8UFFl0RP37CZ5R24n7PnjZPIihqlYa2QiOcOZZYOa8M3WA9fyg3kMCszVJHd6uA mFCBmzoAUu+O6wF2+9IN0jTWBqhGyOItyZRqH5AD0Q82K2xGqQCg2aY6s2HzzcS/gLGx +ryw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=C6DnVKRB6NIRjwPWAXMLQ0NJgkEo62OoeU3KPTioqDw=; b=Kk58VjEsEKWtGiIaceKoqHoKA2G4fMnrV/+lhFavrWQUVhvcGSD39eC3DtGwn3ZK/g pjPZZQh/48LZEUoZSw8We6CB9dMgC9EGlZXoiuWG8kByHSZpFhoGOOX3Xo1YeDrEKUbL r599Qd1Oh80GjT9AlwfVt05ub4rpJpXj9DLsrUz+YPpvJfjJn7kgz+za33NEKd0y5za2 iV568dDePSoLe2mrp5RHfjWa39NXDzDkdkimMRqttvrvdEXcwMw2ruAQNoXGm2keB6s1 mO8Zp9kKenusvC0M3DwCtr21SuKaSft6FVKgARBfDxpmOu1tKLjbRioHW6fs6TFSODjh y1OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KObRodab; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id 143sor2144946lfk.32.2020.04.22.03.10.16 for (Google Transport Security); Wed, 22 Apr 2020 03:10:16 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KObRodab; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@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:mime-version :content-transfer-encoding; bh=C6DnVKRB6NIRjwPWAXMLQ0NJgkEo62OoeU3KPTioqDw=; b=KObRodabLDVnh1RpbkhyXvi3gbBuwT9PIEfxCQHFdpvCFUN4d+kPA4VAHcRZ0RmfVZ 4wIxqA6/QeN4pIEGPxiruC+Wizaj1UgClk2twBJwLYA2KBkeFCQVRwwAjmdMB/BoSkB6 r0AGQiT09nh4MdZh/BYj9bHL+W2gJtzl2/Z/wSMvMN7E0k10z4EmkCrpKMeu3+5jfc98 JQsmBEmWCQqQBBzMEAC9wIQz0e2+Tu9TzKVjO/TR1zp3LnZK8eP8DzkVpWzZzZeasvxE +Ex9E8rxacadZ+yRRA/FMveBBk1RwMPUPgpDv6wlQi9J/i9v18jGoBlxjLEMNJRwtqTs wGPw== 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:mime-version :content-transfer-encoding; bh=C6DnVKRB6NIRjwPWAXMLQ0NJgkEo62OoeU3KPTioqDw=; b=IINcgtFMOWgB8pbiF2Sch3WeguWutrf7X3frmxeAz1E3hUMnYatqPviBZ6orhz8638 t3U/N37Nk5+aChveoNBRHHRrK2v2dOKySQiPnJCFygeguDvPymzN1zlkRlJVRpwfUFxq uparxZosLhhU9SgAj8Rk9iLeNUahtXTWtxkPF0GCSP10Cmp6AsKAQhltaYdEMPbx02xw G4fvUnrKBXCkGLz9Qn5/ztWo1TrBuRGhV8TvGWQuntOPvoW20Y8nAz8/+eemaLYEt1Td 6c2tNUPbPG5KlvcodQzGkRQoq51Ydk3FaTpYSGnCrnEqMuc1QJcx3VnMiEwoghyjaiTq z87w== X-Gm-Message-State: AGi0PuYKB74RBUlc7ODxBH2svf4yOlbYHO0pzIAXmKsRsdxUwzvt8vEk yYPW57u+qIqor6GFcXBMyxwMXGhE X-Google-Smtp-Source: APiQypLiEWMoI272TzvgNnpPzocl0qlAVahabYTkLZn37KAuy/71WeWwggv4+DDRNoenNgGXkegsaw== X-Received: by 2002:a19:ee11:: with SMTP id g17mr16425495lfb.42.1587550216225; Wed, 22 Apr 2020 03:10:16 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-98-128-181-7.NA.cust.bahnhof.se. [98.128.181.7]) by smtp.gmail.com with ESMTPSA id s6sm4246018lfs.74.2020.04.22.03.10.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 03:10:15 -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 , Robin Murphy , Vinod Koul , Haibo Chen , Ludovic Barre , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Ulf Hansson , stable@vger.kernel.org Subject: [RESEND PATCH v2 2/2] amba: Initialize dma_parms for amba devices Date: Wed, 22 Apr 2020 12:10:13 +0200 Message-Id: <20200422101013.31267-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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: Tested-by: Haibo Chen Reviewed-by: Arnd Bergmann Signed-off-by: Ulf Hansson --- drivers/amba/bus.c | 1 + include/linux/amba/bus.h | 1 + 2 files changed, 2 insertions(+) -- 2.20.1 diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index fe1523664816..8558b629880b 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -645,6 +645,7 @@ static void amba_device_initialize(struct amba_device *dev, const char *name) dev->dev.release = amba_device_release; dev->dev.bus = &amba_bustype; dev->dev.dma_mask = &dev->dev.coherent_dma_mask; + dev->dev.dma_parms = &dev->dma_parms; dev->res.name = dev_name(&dev->dev); } 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;