From patchwork Tue Mar 31 18:38:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185120 Delivered-To: patches@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp4007148ilr; Tue, 31 Mar 2020 11:38:51 -0700 (PDT) X-Received: by 2002:a2e:3c0a:: with SMTP id j10mr10923290lja.205.1585679931170; Tue, 31 Mar 2020 11:38:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585679931; cv=none; d=google.com; s=arc-20160816; b=0C+bcbgml40Zyu5b6Kqvalz0K5PtIKxXsnhGWNLwfrZ4z/Mf979sXX4F/vsDG3s2NK xlyBuq3Abi+F+hFuWyWIYUmMaN+g6jxOiR1d+GcmetibmBC4hSPXHMCPntXNs4Quk/ID XI39fYjQv9pnxm9jmbFS3IWr1JhbP28DLJedojvPQohXSCg9NhZoF4QTCcKy2V1hYFTI RArdbwba0tErHjpBhwc+2a1xXO9bYAHZBsQ7fVH72UTg3giqxaJMbEKB05RUmq+ktnhe 3JLPF2RwwGjo7ggBk2NXXbncl6c0s5UiUNY5U3jBBgxrOiBi3W8Fmxic1wtnGR90am42 /lDg== 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=ef53u72gwX154C7xAMYz+wCT3OMfVTWwHYstmLaCNlc=; b=viMjVLC3wqGaHhHvbKGkKWq6+jT1fdY9ysSqCQfjm2Qs5HNzqZaGtLPIQniZ9FDx3p lvEg6b7z5XOyBxicbTQCJK5BFfX+c3Ve2FVObY87E4LaUj8hZL3f6RLU4SRL6CYYCBXT A8AILzf0plBGKHd2tNc6Ot5GhkDurogJhTaF+/enoaNX6XWG4Z9qEuIcSJa2bw3ccKXs GinMsv719QV6ujr+jL6lASL9Y6fR2jLaCVsnxqWhTvg/+1WPZthpncgv3Rvv18Tc/rlK 5DeNN6Y2XYHn1CltwyAVo5WWebZxIBRSjW5xQL8n/Y6ZmHQ1o1AHBwZ2cFjRYMUktGZI aKuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cW0Tj1W3; 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 t6sor2861062lfq.22.2020.03.31.11.38.50 for (Google Transport Security); Tue, 31 Mar 2020 11:38:51 -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=cW0Tj1W3; 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=ef53u72gwX154C7xAMYz+wCT3OMfVTWwHYstmLaCNlc=; b=cW0Tj1W36bWIKjTQK8D9mJ/96C2vkHPZEcGEzeHzqpZy67M9jPUIyXRV5YA1X2DaHZ Nzpvr5UpM29BGo6lks/pgSsnJES6sPStXAo9uafNp0/NlfHr3bJpYjCISQ8jc5IydKuv iHi7rqNqMiHP+rAsoHJW6SVRpUMNK/RhN1BJmik/agnq4A1zJm38xhfmtxsDxu/c/PYf KNl0mzd8Klq3O9ErQheYvhlwcsAQ4RCIuLEvbAx+wakyHiycLj6pt8B00BtM7cBGB0Ac wuqLoq169V2kl68TDfQyIlc5tkHPXYmP1QNVQrAI2ij9lp2xx6LLurbGqM9Jaes8Dvlv 3IgA== 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=ef53u72gwX154C7xAMYz+wCT3OMfVTWwHYstmLaCNlc=; b=W9XIdI1GW+c0q2M41B1bRqA3DD+wo7cAsq2H4Bme5TvPtSL0aRAv5ThEbKgDV6GGbf wvfMCC639q/t/dPXm4cKaqPX5T5z4eyBhaQVMMdzaPiD//4YkiSMhvaCGzrhR0Ch/U0K /g5eg8QkFJ91e/DMd0ThRNq5mZ1mQdHqbqQ9ja1cb5RGLsf6PhF4xWkK2Ovz8Q41NF+w 4Vpns3rEMxlGpBe0R/wtCm4TLTF2N2ohvVm+CHjmgfSz4RF5irX3Zkf63zuEWy8m9jR4 gVaveJ68vw8X/7iKrE7nzxqCOkozyk18/6qyODt0Pide+x1dWTVOTp9OYfoSrvyyEAlf C/GQ== X-Gm-Message-State: AGi0PuaVmmoXiStD6esL94URYowmwyHCMrtZBEBmOERffMrWcF8FXxGk kveIBVXOYurXBIMwrLrLcRFPXU/l X-Google-Smtp-Source: APiQypJlHBdy85VzPZtpSqUGdPox7hK2Nb2Ow9qHdh0GVGjkZIEzlPooZMXhxhreWPUR3bq6fB+QZA== X-Received: by 2002:a19:c507:: with SMTP id w7mr11146673lfe.131.1585679930697; Tue, 31 Mar 2020 11:38:50 -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 b28sm10331849ljp.90.2020.03.31.11.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 11:38:49 -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: [PATCH v2 1/2] driver core: platform: Initialize dma_parms for platform devices Date: Tue, 31 Mar 2020 20:38:43 +0200 Message-Id: <20200331183844.30488-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200331183844.30488-1-ulf.hansson@linaro.org> References: <20200331183844.30488-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 --- Changes in v2: - Move initialization to setup_pdev_dma_masks(). This means the initialization is done also in the OF path. --- drivers/base/platform.c | 2 ++ include/linux/platform_device.h | 1 + 2 files changed, 3 insertions(+) -- 2.20.1 diff --git a/drivers/base/platform.c b/drivers/base/platform.c index b5ce7b085795..c81b68d5d66d 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -361,6 +361,8 @@ struct platform_object { */ static void setup_pdev_dma_masks(struct platform_device *pdev) { + pdev->dev.dma_parms = &pdev->dma_parms; + if (!pdev->dev.coherent_dma_mask) pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); if (!pdev->dev.dma_mask) { 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 Tue Mar 31 18:38:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185121 Delivered-To: patches@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp4007178ilr; Tue, 31 Mar 2020 11:38:53 -0700 (PDT) X-Received: by 2002:ac2:5ede:: with SMTP id d30mr12140435lfq.157.1585679932827; Tue, 31 Mar 2020 11:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585679932; cv=none; d=google.com; s=arc-20160816; b=MdDvDTcUywZA6htMdV0DYpDdDLfhrOXfVK1TfcTbpctn11YuPI/3OQ/G5AxMO0YOcC Djf0zizEVViuqsxegLt1CY9ucsDslrBHLsEvJjd+QFpvaaVPcDMjAfDKz0FMUFxshs/A /Hh8jkBqeUQ1b3WYk1cR4Ikl+ZCQsLe/UUy4M133YRJVWQg9Q6D7E0fdltD9y6NGyqCb Y5NAwtW+PtBlQ7pVdajrZeEfdGFjw4GaEORVwlTLwvXmmLxCQ5ViiifMclAlANwXHsvq iuH7GjU9Vs6PMsRy+GU0K6WDy7dD88DnbuNx5d7+6aAm4+cfSIDbBqX1csm+RDmp4Pvs D6bg== 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=KW3Lbde0NrLlMFOPBVL9VFr/xqlRRv5C9s8T2uV/EC8=; b=X4iOrolso5PRPX++Eb9jumpUQ+pBGnBh5aRZRcdvSW1MnB7MAE/nOFi4/50mRPbsdH 82Tn4BBwuMtwBqmrJ5LyE/GSWdAQS3vMp3sENLoMmKbDaWgXpJDagIz5c+rZua8lK5m+ n/KTP4OgPexOnOOZJY/k5NwG0c3wpkiEVUCf/VAuFQXZX4uGT7zqHaogr8C9pqKqABfl XlXoOutQblxVZqaKHbumq80sYTAVipS+mShbbO2Ep2p/WhvDyHMo01mcxZh/wY9w0zwd jiPttAoxc8s5ROo8np1UWTCaVE0MD4ndu9qR40i7zXUvbaEn92cv9qXwhFbnuIKRewVU whoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YAzpmToC; 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 t6sor6566841lff.11.2020.03.31.11.38.52 for (Google Transport Security); Tue, 31 Mar 2020 11:38:52 -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=YAzpmToC; 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=KW3Lbde0NrLlMFOPBVL9VFr/xqlRRv5C9s8T2uV/EC8=; b=YAzpmToCHjPKwhVBcWenpASCnFKvzdesYgGqqYMRCP6llJmlm7Y0lj5BXG7cxcVRIl 1fQhsBHrIpdVSutqQJVbpCEti0sA06lsT2dwQTcMRT/nIwMMC4O94hZhauz+WI9GJO6p 12WAtAAApshg2SASKYHsA3S/db71nblcaq3R52IYHCxiGj7rIDzrt1M+tKgLtq7iTSFU aODeaHftNj89LL0xeI0W+Hei2+iJIAT2joCgO2P38SQDfWP6+Ktk5uEgbg+CJVvx4E49 ZrGqhnUVONAeEWgjWrVaZ3BhXiqrh+R/IFaUyAlqH2Zjkgh2qY9Z0AkIAL6AblS6MrhU Y3sQ== 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=KW3Lbde0NrLlMFOPBVL9VFr/xqlRRv5C9s8T2uV/EC8=; b=HoehrEtAenIzppqJgTotgSHXLiCqHocxJS05prcJ4yzj4dZX9E+VZAMAMgTj6QeaWE 5xuJgHz6rL/AMOGtStbRjnnzAVca4Vmd1hDs3AHUWiEi2m7iA0nu0o8b4nT7ZqdvYT0V 1ZmGVPq0w7ONJJT2oYcnoREKJEBDY4rYpyX3us0RchczagdKJobSPvvUuo4ltHyv4LHU JQ5ShNBUyWguJiqZ8rWCUmbPV+aOCaKN1gxinO11OYzCj4/RBTIpHWsUoxTvtFTgAceM 8b3XtPTOTz/I8Jr1FTgMu8rSHwBMl8JIUwG5Jy8OaqCZN9N9UnLUsVIglgVbJgUi3MFm mT0w== X-Gm-Message-State: AGi0PuZFN0aU8qUT2HND41vps0Wq/7d35aPPbftzHUB735jKPeyZ/kvj UhE5X65MH0Lq5d0BMZTSy6zXZlZSm3Yj1A== X-Google-Smtp-Source: APiQypJ8E6I5iZxeoPH0TWIB8ALP7NCLvCUGTgJRpQtCJG/xvf6AdHVA3ceds7R25cl2FPBp6aBIHA== X-Received: by 2002:a05:6512:3091:: with SMTP id z17mr12711035lfd.42.1585679932325; Tue, 31 Mar 2020 11:38:52 -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 b28sm10331849ljp.90.2020.03.31.11.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 11:38:51 -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: [PATCH v2 2/2] amba: Initialize dma_parms for amba devices Date: Tue, 31 Mar 2020 20:38:44 +0200 Message-Id: <20200331183844.30488-3-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200331183844.30488-1-ulf.hansson@linaro.org> References: <20200331183844.30488-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 --- Changes in v2: - Move initialization to amba_device_initialize() to be more consistent with how we manage platform devices. --- 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;