From patchwork Wed Apr 22 10:09:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 185687 Delivered-To: patches@linaro.org Received: by 2002:a92:3d9a:0:0:0:0:0 with SMTP id k26csp566173ilf; Wed, 22 Apr 2020 03:10:08 -0700 (PDT) X-Received: by 2002:a2e:96c2:: with SMTP id d2mr16364930ljj.214.1587550208632; Wed, 22 Apr 2020 03:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587550208; cv=none; d=google.com; s=arc-20160816; b=eOKaZ8bWPXAkJCly/kkXleUpObsSUxdLZScrTnnEi/yR13FfQCPcJHR9oLxOVQwUi4 mZ1f8UubjjPbySRNifnJ1ixP343YAv+mO8dQUnA7AbPmGhPR2cVhigrOqZoglJTyhuPG ir4Ft114MeXuWTaMazUMPrQzf6gKAg+KBFYU5LsBOyJoyNYtVGm+f09miyk9aQUc51+M XeQ0MhD2DPdzP7lSTbq3+mxUciQgECgoke//BoI15/MHhy3ni7HjsnqfIgzNFkQsYIe3 QpOgXQpeQgJWwKuTNWRKwSgT/D7zVl2tj0c2i1wcDBGPbiWbRbpgdGyDdbM4drjQx7j3 5OkQ== 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=eVpuV9906kTdH8kjynNF6G4cMp3xW329yIZR2pMpgr4=; b=zkYdIap4pzf6IwZUtImh1/Klfnrmx5VNS+EV25PH+MmE7Pg2nSENgAP6LHUdhwE9dt lx8mUvur9mwtIMjg8nxRdcPROSiA8Ra4XkFP4nPLvnWEZOtrhSnLVRnKlUqTPy6EmKgn 4ozVlf2j6PS9/9EpJkrcRnBQrXLOI6pTvSGVuvKEy3uMIhZn5N71Nlfzq6xLivV2lQD6 W/Qk4KcqMYpqIujFeFnVGz9JkFNKWPHLpz8bCV4gf+WdLjbURbs+kVPn7I2d5vulVjJu 0IGD4ktN+gy/YbY6EPZO1W4JDPhwjX0W4yObN5toFvcpj6iROHJs/MFgLZwe4ZNN2Exw /cIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gz85oKII; 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 l15sor3128629lje.5.2020.04.22.03.10.08 for (Google Transport Security); Wed, 22 Apr 2020 03:10:08 -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=gz85oKII; 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=eVpuV9906kTdH8kjynNF6G4cMp3xW329yIZR2pMpgr4=; b=gz85oKIIWH5onOAX7yHN644ZgaDeGOH22z4QW3dFCjsQm4l+4JWTJo7PfmpPjDGFft XxBdaYeN7nKECc8t3WmGqFz9zW/uu77kGEPXIXhk0gE8OGEr3yOg7k2tIG7VHqppeC0z dHqFUUbvhKyF4nocekpBRtF9JXkOquUcuduNq/gUnjyNc9NYUb2P7lBZJQNoMuUijcTA piOcMylf1fKLEnNbPRvbYVUxvcQ58xJqizUGxJ6eTO5JPsQWZqYBk+gmA21gbh8J3Fys r0+fdE782jU5LP9EtKfg3RXEWGWp8RrxcyqN1KHxk+RmZ0rKSpm1/5LITPymBGkcKBFb U+fA== 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=eVpuV9906kTdH8kjynNF6G4cMp3xW329yIZR2pMpgr4=; b=WTA5nBEb7F5RVPgD/VrmVcoyPmY3arXNnluAOvYv47Z2pVrCFrkP6zrASXFjoVU3nT dSdAlptVQqIhV99M9hUI4BgzMFJdO6YlVLaUCLshYuBQdaRQCyGPd1HtCcrHThMo7jKf dvL9USi6XZMIJooKNeIRXCa6CuOi+tUR2rulEIONo+FUK834kQLG5BkBD/PKb+u3BSB7 h6oNDVvffhepZpIMN+kppdqjWWPpuPUzJZupks3xGXL2GJjEe4Msz/z2sOK44hw5cgyT K/t+JHyQ52/lW/INUGNXkyjtDKasxLVVtYUYxeS6oQ43kWlUd3DtwFw1lz96xWnFzkV2 JaMw== X-Gm-Message-State: AGi0PuZ5hM+A1kA3FlPmOdQkG7PZb6g48Vl6+JNLouSoBj64PCUr2ES1 sCyilxy/lmibyPD69cvDmAllNEtI X-Google-Smtp-Source: APiQypLzg0y5Fg8LOd4XLWjOORnygZbpUDG7xZWJc87sQhB/LR5OrVVWb/3kGnX6Jb5WRwXKr//wGQ== X-Received: by 2002:a2e:5746:: with SMTP id r6mr15361642ljd.15.1587550208106; Wed, 22 Apr 2020 03:10:08 -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 v18sm4649962lfd.0.2020.04.22.03.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 03:10:07 -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 1/2] driver core: platform: Initialize dma_parms for platform devices Date: Wed, 22 Apr 2020 12:09:54 +0200 Message-Id: <20200422100954.31211-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 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: Tested-by: Haibo Chen Reviewed-by: Arnd Bergmann Signed-off-by: Ulf Hansson --- 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 5255550b7c34..b27d0f6c18c9 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -380,6 +380,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 bdc35753ef7c..77a2aada106d 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;