From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752920AbbJMMV2 (ORCPT ); Tue, 13 Oct 2015 08:21:28 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:58176 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbbJMMV0 (ORCPT ); Tue, 13 Oct 2015 08:21:26 -0400 From: Arnd Bergmann To: zhangfei Cc: John Garry , James.Bottomley@hansenpartnership.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linuxarm@huawei.com, linux-scsi@vger.kernel.org, xuwei5@hisilicon.com, john.garry2@mail.dcu.ie, hare@suse.de Subject: Re: [PATCH 07/25] scsi: hisi_sas: add ioremap for device HW Date: Tue, 13 Oct 2015 14:20:59 +0200 Message-ID: <5074860.NRYCq0Qjjh@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <561CD316.6040406@linaro.org> References: <1444663237-238302-1-git-send-email-john.garry@huawei.com> <5285087.C8umupFr76@wuerfel> <561CD316.6040406@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:IWuMUIg13sXikPQyKnjNaHw/vWEDk3Hzlw8dz0Q2pardi2Ho9Kl PcdG2UPlwWivQfvBX2snIrJpsjAMrPFS6gOrCdJ5I1N/KpIyqfCQtWh/AY1f0pPvlG2n5rk O22c11QYdd67eIvG1QHin5joim7pMN/MUXHoXxGRG2BtdfhS8neJqlv1mnNVONPwyf7rSP6 ACWPfiINAEZmFQzU0zxbg== X-UI-Out-Filterresults: notjunk:1;V01:K0:kdlrCkDWgoE=:I/SDDqeebeNvyKdEuiqNqq wqv25IYRKNvaXscxntlDCyuetY7SXPBKXKBbXW5Tj+hY2fYVw5JU1Li6ZduJpRf/0h3biZlkt TSWN/WsJv6KCCBTsHGMVxrWrrAAf5J65hDbUdk51iCGRf4YZwQF+fnrLG1aZtkgMbL2m0Eh8F 771929VX3CbZRBFSRvKC12i0rRtfW9vQoOXf7UeD0E6oTD1KjBcNZl9f03gi/c6RfgC0tmYad b3ytMI5ritkikvGzPtpUfsZloOHjVeLKgq4hCI1uEmmXg3Xm5lK2HrcVAqO0/LSZ/wFPx2dTh rNEQOI3BpoyOD4NMvGbTIxsAGGyjHRM4p9JE1JjOOwxS2sUCXoxRtcID76pvxjzv8zZtnLFxJ Mb4UPaRYMVwAKV+JwuJwQMeNHrVQVPdDAEWTTI6RhIE3UrQMLVW9l9AfHNe26VSIeHmuNQnJ6 Rp9+Frjpr7w+Sv7SbpsBbWXR8CSphVd2wT0pVCQPZBWLG7Z7y8YgRQJpY63uunj47ultzOB/9 i+Gsneeui81u6SJhsnVODlb+IqpRZ4MKOx18lNIv7NMzmjXMyQ8QHYpL9iaRnGMeMp9kxupMI vFutZ8UHAHgpKNsiAPYnLixD2dbE6hly2TcAc0DXtbCvQmUGsvIG8eWEzXDSA4sQjxfzco7aY y9/8rTLD8JXx7f95WRj92pjecz94+aWiCpBU6ck2ktfY3NPMRNqD97N5mN+EHJjD/6duHZhR6 7tDFwbUA3ruHAM5m Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 13 October 2015 17:47:02 zhangfei wrote: > On 10/12/2015 11:21 PM, Arnd Bergmann wrote: > > On Monday 12 October 2015 23:20:19 John Garry wrote: > >> +int hisi_sas_ioremap(struct hisi_hba *hisi_hba) > >> +{ > >> + struct platform_device *pdev = hisi_hba->pdev; > >> + struct device *dev = &pdev->dev; > >> + struct resource *res; > >> + > >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > >> + hisi_hba->regs = devm_ioremap(dev, > >> + res->start, > >> + resource_size(res)); > >> + if (!hisi_hba->regs) > >> + return -ENOMEM; > >> + > >> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > >> + hisi_hba->ctrl_regs = devm_ioremap(dev, > >> + res->start, > >> + resource_size(res)); > >> + if (!hisi_hba->ctrl_regs) > >> + return -ENOMEM; > >> + > >> + return 0; > >> +} > >> > >> static const struct of_device_id sas_of_match[] = { > >> > > > > Better use devm_ioremap_resource() here, which registers the resource so they > > are checked for conflicts and listed in /proc/iomem. > > > > Yes, hisi_hba->regs can use devm_ioremap_resource. > > However ctrl_regs have to use devm_ioremap, since the address are > sharing among different nodes, unfortunately, and devm_ioremap_resource > will fail. This sounds like it should be fixed in the DT binding then, to ensure that the ranges don't overlap. Mapping the same register region multiple times is generally considered a bad idea because the drivers that map them often don't have global locks that serialize the access, so it's better to have code in place that ensures that they are distinct. What is the purpose of the ctrl_regs region, and why is it shared across multiple devices? Are all users of these registers in the same driver? Arnd