From patchwork Wed Mar 25 11:34:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 184804 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp505780ile; Wed, 25 Mar 2020 04:34:29 -0700 (PDT) X-Received: by 2002:a2e:3a01:: with SMTP id h1mr1665226lja.161.1585136069044; Wed, 25 Mar 2020 04:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585136069; cv=none; d=google.com; s=arc-20160816; b=b8DM4IEX/cSrVcs051hISu4PNpnfMNLU1xviN6XqMOPN7lFMz9dO0NyyaTI3k0qe1w zxOOxYUDs4QmGmdkXOUiU+Mn5TXNifr/V49Acmp2w22UAo2vYfE5Xnq7cDmlHgImETZx wbGtufBXysTgTTYDaseWC4e+77kEOfmSvUETP57fu888HvvakJhaauw8GVKDIoFZ1qrL jKTCb5VfiEt2mlzCGoJhx1DUTV6Rk7f6m3DmvhvFJVwq/pYNCpf6y9b0k2BFhdvlb+Ht 7L8rFX2esIqIrc8d4Mp9oWTtE8ssvm1ychmqVPx4mGiJevaS0Lk4bjnEnWe2xOW3opBr z9nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QPegYuSfHcA3EBvl8rBN548IrIHva7Siiqx3+i9i/fk=; b=pq/DjHmBPx8JCDp7wl5qTTk6Yh+0fo0GugAAR59Gy/OerUv2XcU88nVl+3/0CRbPbV KyyXbqUDWzxSeE1MokrNa/boTwg+1dnfdKILsttYYeN6UWzXaz+RWK6Fh2wrYEzCLqzR wgh7ZdajRZPgwrbuROJnZfsBfPz1icSfvRuNnaYG1YXiTazLtZ9tbuWqCPRAf3z6kc/q 5roM1b7dz6heot/e5j8caJSzGQblBtYUXemZByYnG8YNpZnxLF1am9S30hAn/bV2HVsK 9z0k5VHZOESaYQTQqigLwOS6AovZ1gCfrHjqNM3iVdD9aYXfz8Y58QT14M/R+jj6foWC tJFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aXIfbdqk; 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 u15sor175647lfq.19.2020.03.25.04.34.28 for (Google Transport Security); Wed, 25 Mar 2020 04:34:29 -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=aXIfbdqk; 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=QPegYuSfHcA3EBvl8rBN548IrIHva7Siiqx3+i9i/fk=; b=aXIfbdqkfrWHNMJxk7rgpfQnHosJstUgv+nPJg8nxRo+9pKouM26WAI5jitlKG5zYm dZx7N6OfzJ8B8lp5AR5Z/nKynJm5BIZo5mfsjpnAouFOVrITTq+MpsKOdTK1TnVZGr6J ZXD2xs25UMtjG5Seqi4Yh5xID9TbudX70og/9CFMxinK3V+PWmxJYgvnCCYaBfOylFDU sGLI80eAP38UiXXmS6eBcqtzZVijLUoii6AuDKzHfZGoxLxCvXIxIjGTYuwjdAwTyjxy RcJsKyFXDpgd4yPdbiI4DwWjQrdAE5T9nhViX9NpC7LDGEGvjepXCx2QLRJr9XWlR41n bh0g== 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=QPegYuSfHcA3EBvl8rBN548IrIHva7Siiqx3+i9i/fk=; b=H7rR5XjH5nSWDUVDOl6d8Tzv+8Y/bVQ/grfKxPE6ycGsz97607qxDgxpGq/agP1JF4 XlVtc9wcumDUjoueOKww6JN/RoSSbOjZD8IxpWt6jaUwX6cqN91UEz5an0brYJNf7lYw +fzkuaNLgHbA7FH7Xr1hV3RoLIhBh4YsYSlia+WQzjC8+jHsDS+g8pqTm4nbqQk6eaX/ CB/ZoUERsik164D1vhCyfYtqv3BmpEjTMocUvn678jj1Xj8o42SCYBR7I4rOYTfT53s6 6r623tvgVdOmqKr0Z0IThWbHqVj6BQwkOP2IgkdP8g1sIW38FyIsT5cI5fVEEEzEwK4B VLyw== X-Gm-Message-State: ANhLgQ2T82T++qLIDO063GRpWCdojW5mQOkE0KWGYUhKeti1M8PC2mZm dTBRWctxc3yDvh7DyCWM+zkzdsfT X-Google-Smtp-Source: ADFU+vuRSm6/etAQz80VrEgGUDZc5VTTv9FpBEJTzRn3gDVEDfDCfTlInPIezeIUpXLoXiDhoHUYOw== X-Received: by 2002:a19:4cc2:: with SMTP id z185mr2098414lfa.0.1585136068643; Wed, 25 Mar 2020 04:34:28 -0700 (PDT) Return-Path: 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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Mar 2020 04:34:28 -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 1/2] driver core: platform: Initialize dma_parms for platform devices Date: Wed, 25 Mar 2020 12:34:06 +0100 Message-Id: <20200325113407.26996-2-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 It's currently the platform 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 platform 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: Signed-off-by: Ulf Hansson --- drivers/base/platform.c | 1 + include/linux/platform_device.h | 1 + 2 files changed, 2 insertions(+) -- 2.20.1 diff --git a/drivers/base/platform.c b/drivers/base/platform.c index b5ce7b085795..46abbfb52655 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -512,6 +512,7 @@ int platform_device_add(struct platform_device *pdev) pdev->dev.parent = &platform_bus; pdev->dev.bus = &platform_bus_type; + pdev->dev.dma_parms = &pdev->dma_parms; switch (pdev->id) { default: diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 041bfa412aa0..81900b3cbe37 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -25,6 +25,7 @@ struct platform_device { bool id_auto; struct device dev; u64 platform_dma_mask; + struct device_dma_parameters dma_parms; u32 num_resources; struct resource *resource; From patchwork Wed Mar 25 11:34:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 184805 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp505801ile; Wed, 25 Mar 2020 04:34:30 -0700 (PDT) X-Received: by 2002:a19:88d4:: with SMTP id k203mr2025898lfd.75.1585136070702; Wed, 25 Mar 2020 04:34:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585136070; cv=none; d=google.com; s=arc-20160816; b=xcuzwMhe2fslM4JqqURXyGZcjTi6QLkclp/YOl9+l8UGSs/qAgFYYcD9A8K4FRgGUS UD8qPPiWFxrgSuQg7f0S7NmKLlLC6ih/w/fuetx+AtI7ockFtyVIAW/HnjpZX0y6h6fE tnRpvZ0E0bgypm7mYcGXNYR50eCmnFZUhRngzU/JmbqbEgC/psdumdwvTMx28JNMYvOj lfWRaUYbHlg7EqV+MvLvIpzs+SFLcxWu79ETn3/6D7+BcexGSLy0RP/KcpP/qJ6CGe5K tF29gf8rlBGLcfDgEtThMNxaBJ9EIGorIvkGFb2GpdIIgfT8Ug5jr8WhHPzSpz6KB1xf o1Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=O7KffvUQLvEtuKLuleQeJ202vBQLqQy9HV1Fxk0tNOM=; b=DwyZU8ah5FaPBQUw2boSwHnZV2CZ1FwKr8eeeel1jI/IIUPE6QM5TqzcbFVpv+TBYt 5QSeUsSB1faNREgpUnh2f2yHDRzu3FEWWeMmi+UQrq70Kp5Ja4vSGXGMQq0NDU7Rvova vLND6BBN8VhcXzeSF/wYWlfE0luCV4kzsCl4K9IlbE3n2HZuojJlAwfKoMSWX9+C6+W4 lHcJ4/kDNUSLPCSYbsmGYnYn8F8m+9YZg20cfwjpr3qZ4rImgH/itCLH6zP/l0hgjYAb HGGzoCXti8nGqjjm8w+lwBV1+juXVhlQujG2/mQWvZBhJ4IBldG/R0xzP8IOjj7EKpnl +PYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HDfdSaRD; 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 t29sor6922252lfg.41.2020.03.25.04.34.30 for (Google Transport Security); Wed, 25 Mar 2020 04:34:30 -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=HDfdSaRD; 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: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=VIGm1CAgbqVtlHXAesl8b76xIwDhtfaNJc19YWVDV21N7qz7fMiD2uKqeJ5JDZVVxm L5ZHs5b8IPsBwczCbuDAolq/k8yLWMwlarv1sO+kO4BLmXe/DYM+xfsHFSvO4G5ZeHTi nOmqf9FutU5y5wJUSnzf1yPEBOMbDkBuQkYzb8v+cnaAUZIhi0fTWueHK+Wz/H80mNQ9 K/CpxPp1pt5KUdeuG74gw6pu7XuR7WHRn50xftg32Qxpu4EJI0UClDgCM1Kh6ePHV+tJ HwlwCL4XGu8ojGSyhwJ/8VLjzQrcloSz5KeM+bqTPUcAwJWs84HtKDxXXRJSCz0jDzCF d3oQ== X-Gm-Message-State: ANhLgQ17w281aorn1QPHp8VAOts9Eurfvl2UW25RkQi+qWvNKaBuADeR ChWW2SZ5sZaTFQwA4vUItQ34+OCJ X-Google-Smtp-Source: ADFU+vtF9WPanLG3a1vSHxs2lc6VyzDOkLrVTfTbQpdbdnZ4basqRFJVF+b7L4EKM0fI2K8g88uVuw== X-Received: by 2002:ac2:4116:: with SMTP id b22mr1933177lfi.172.1585136070290; Wed, 25 Mar 2020 04:34:30 -0700 (PDT) Return-Path: 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 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(+) -- 2.20.1 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;