Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2800003ybb; Fri, 27 Mar 2020 12:16:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv0W0KMJ0dUlV5VqTr9DjxzFQPC2joCCuJ9DLXR6teVGZ1y7N3tmMUDsnjm4d3vJxHO3qbS X-Received: by 2002:a9d:69ca:: with SMTP id v10mr185511oto.64.1585336602982; Fri, 27 Mar 2020 12:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585336602; cv=none; d=google.com; s=arc-20160816; b=bIVVzfHPRMpCOg0PJbVJW9aryw5L5NAZp+e75ge+chY5wLbxrzNht9ULbqFqdUnSQq 92TBWbE8o6kY1fjvb4Ke4zsZbKXJwz5CdJztV/4xSIemhAsaQPxEZwi1AfbG7pZRpEZ0 /hbV1h2hLyLO4u9DvY7BdqUghU//0zYCkfTWSANsMgp15gevMle8PefkZ4bnGos5Xmxh Bsa6zl5l/QLz0+NtVPqb0O/1euG6lYa94jrlzeRPZr4a861U3jDnnPfLyyFZXH1VjU6l KVDvm6P7Kbc6F1Ystm5HfspsUKWYDXVwalj3NBmB3SmdZUe/abheKoQTPpEiOIr4vbbR z0IA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JojxBaxIDzTPqLLX+PgkII6wbrVmpWYiWGKItzvfdbI=; b=qPSvypBoBvXKvTvLMsikW4ibeBTYmOiFiWzdk+bhtN3prZcWDn3chpcVfa9jgeUfIU oAbBK64WhxvjZ4zCaZOtWLbVKCKxMV7raaBeL5NgLgNSdUF4lK8XKwsybAObI72qmkW9 9I0Dtht4bJ7k5ka9armb6+epq3bTsnTWtU6PgdoOULEzHtg9h9EQ2CfkO9II4hSZwhcE PkT4A3xRIJIHsxOINQ7Brkon/tyaQHiiIjodxdRLtdwJu/a0Tvq/NO8itkQ7nYw13oCX RPmtuRNLzQcGHHWONGY6WqjC/xG0YGqfjXYwMd3SFm7FajiTbOH9o3q0W2JaGk2+dhcF idPw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k62si1942157oif.247.2020.03.27.12.16.29; Fri, 27 Mar 2020 12:16:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbgC0TPl (ORCPT + 99 others); Fri, 27 Mar 2020 15:15:41 -0400 Received: from foss.arm.com ([217.140.110.172]:51708 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbgC0TPl (ORCPT ); Fri, 27 Mar 2020 15:15:41 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A8A9430E; Fri, 27 Mar 2020 12:15:40 -0700 (PDT) Received: from [10.57.60.204] (unknown [10.57.60.204]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AF4563F71E; Fri, 27 Mar 2020 12:15:38 -0700 (PDT) Subject: Re: [PATCH 0/2] amba/platform: Initialize dma_parms at the bus level To: Ulf Hansson , BOUGH CHEN Cc: Arnd Bergmann , "Rafael J . Wysocki" , Greg Kroah-Hartman , Linus Walleij , Russell King , "linux-kernel@vger.kernel.org" , Vinod Koul , "linux-arm-kernel@lists.infradead.org" , "dmaengine@vger.kernel.org" , Christoph Hellwig , Ludovic Barre References: <20200325113407.26996-1-ulf.hansson@linaro.org> From: Robin Murphy Message-ID: <2b2f1b1e-d186-e60f-baa9-3223ad4101f0@arm.com> Date: Fri, 27 Mar 2020 19:15:37 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-27 3:34 pm, Ulf Hansson wrote: > On Fri, 27 Mar 2020 at 04:02, BOUGH CHEN wrote: >> >> >>> -----Original Message----- >>> From: BOUGH CHEN >>> Sent: 2020年3月26日 12:41 >>> To: Ulf Hansson ; Greg Kroah-Hartman >>> ; Rafael J . Wysocki ; >>> linux-kernel@vger.kernel.org >>> Cc: Arnd Bergmann ; Christoph Hellwig ; >>> Russell King ; Linus Walleij ; >>> Vinod Koul ; Ludovic Barre ; >>> linux-arm-kernel@lists.infradead.org; dmaengine@vger.kernel.org >>> Subject: RE: [PATCH 0/2] amba/platform: Initialize dma_parms at the bus level >>> >>>> -----Original Message----- >>>> From: Ulf Hansson >>>> Sent: 2020年3月25日 19:34 >>>> To: Greg Kroah-Hartman ; Rafael J . >>>> Wysocki ; linux-kernel@vger.kernel.org >>>> Cc: Arnd Bergmann ; Christoph Hellwig ; >>>> Russell King ; Linus Walleij >>>> ; Vinod Koul ; BOUGH CHEN >>>> ; Ludovic Barre ; >>>> linux-arm-kernel@lists.infradead.org; dmaengine@vger.kernel.org; Ulf >>>> Hansson >>>> Subject: [PATCH 0/2] amba/platform: Initialize dma_parms at the bus >>>> level >>>> >>>> It's currently the amba/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, this series initializes the dma_parms from the >>>> amba/platform bus at the device registration point. This also follows >>>> the way the PCI devices are being managed, see pci_device_add(). >>>> >>>> If it turns out that this is an acceptable solution, we probably also >>>> want the changes for stable, but I am not sure if it applies without conflicts. >>>> >>>> The series is based on v5.6-rc7. >>>> >>> >>> Hi Ulf, >>> >>> Since i.MXQM SMMU related code still not upstream yet, so I apply your >>> patches on our internal Linux branch based on v5.4.24, and find it do not work >>> on my side. Maybe for platform core drivers, there is a gap between v5.4.24 >>> and v5.6-rc7 which has the impact. >>> I will try to put our SMMU related code into v5.6-rc7, then do the test again. >>> >>> >> >> Hi Ulf, >> >> On the latest Linux-next branch, the top commit 89295c59c1f063b533d071ca49d0fa0c0783ca6f (tag: next-20200326), after add your two patches, I just add the simple debug code as following in the /driver/mmc/core/queue.c, but seems still not work as our expect, logically, it should work, so can you or anyone test on other platform? This seems weird. > > You are right, this doesn't work for platform devices being added > through the OF path. > > In other words, of_platform_device_create_pdata() manually allocates > the platform device and assigns it the &platform_bus_type, but without > calling platform_device_add(). > > For amba, it works fine, as in that OF path, amba_device_add() is called. Hmm. > > I re-spin this, to address the problem. Perhaps we simply need to use > the ->probe() path. FWIW we already have setup_pdev_dma_masks(), so it might be logical to include dma_parms in there too. Robin. > > Kind regards > Uffe > >> >> diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c >> index 25bee3daf9e2..f091280f7ffb 100644 >> --- a/drivers/mmc/core/queue.c >> +++ b/drivers/mmc/core/queue.c >> @@ -403,6 +403,13 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) >> blk_queue_max_segment_size(mq->queue, >> round_down(host->max_seg_size, block_size)); >> >> + pr_err("###### the max segment size is %d\n", queue_max_segment_size(mq->queue)); >> + if (host->parent->dma_parms) { >> + pr_err("######### the dma parms has value\n"); >> + } else if (!(host->parent->dma_parms)) { >> + pr_err("######## the dma parms is zero!!\n"); >> + } >> + >> dma_set_max_seg_size(mmc_dev(host), queue_max_segment_size(mq->queue)); >> >> INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); >> >> Here is the log I got when system run, even after your patch, the dev->dma_parms is still NULL. >> [ 0.989853] mmc0: new HS400 MMC card at address 0001 >> [ 0.995708] sdhci-esdhc-imx 30b50000.mmc: Got CD GPIO >> [ 0.999374] ###### the max segment size is 65024 >> [ 1.008594] ######## the dma parms is zero!! >> [ 1.012875] mmcblk0: mmc0:0001 IB2932 29.2 GiB >> [ 1.017569] ###### the max segment size is 65024 >> [ 1.022195] ######## the dma parms is zero!! >> [ 1.026479] mmcblk0boot0: mmc0:0001 IB2932 partition 1 4.00 MiB >> [ 1.032541] ###### the max segment size is 65024 >> [ 1.035198] mmc1: SDHCI controller on 30b50000.mmc [30b50000.mmc] using ADMA >> [ 1.037169] ######## the dma parms is zero!! >> [ 1.048493] mmcblk0boot1: mmc0:0001 IB2932 partition 2 4.00 MiB >> [ 1.054531] mmcblk0rpmb: mmc0:0001 IB2932 partition 3 4.00 MiB, chardev (234:0) >> >> >> Regards >> Haibo Chen >>> Best Regards >>> Haibo Chen >>> >>>> Kind regards >>>> Ulf Hansson >>>> >>>> Ulf Hansson (2): >>>> driver core: platform: Initialize dma_parms for platform devices >>>> amba: Initialize dma_parms for amba devices >>>> >>>> drivers/amba/bus.c | 2 ++ >>>> drivers/base/platform.c | 1 + >>>> include/linux/amba/bus.h | 1 + >>>> include/linux/platform_device.h | 1 + >>>> 4 files changed, 5 insertions(+) >>>> >>>> -- >>>> 2.20.1 >> > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >