Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp669706pxb; Tue, 9 Feb 2021 09:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWrScYR2rbids9XhcKwzE27FwnSX4VSh294s1YaP5QVimiRnnh3RRKevAJKRWyLJsbrJ3p X-Received: by 2002:a17:906:40f:: with SMTP id d15mr23769472eja.522.1612891753753; Tue, 09 Feb 2021 09:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612891753; cv=none; d=google.com; s=arc-20160816; b=KqYwpMVFZI5HyLBoJXZKY+gm2CcXDwe9MkR3hbVj63+8rzoSmmsZL1foNPB3VPbUKy kbH/JP0RwcY4FDDZ0I4OIg5DltrRemUAtqVoUsqz/sk3cLNS/RwYOV1I5uSUDiTRLjYf 1j2efVpOOeP4aUxiuskqT2pUINqoVp4YZUu0NUi3YFbSLsZmLmdWCVIAG8fQ4ppEALwj 91jjYeiIH98q2FZc7UAaVOvSkjUez++/9PEKgQaymblkmIllodbY1C9kcGUGL15+aMzB 6i7B0iJKqdQIhMFdLAvF1N/6sooVkjw0gJWzmwpioE/kD6wsvbC28Hvf2I1Yidx1v/kl V2rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=4UpteF9FRAi4Lict6Jo0G0PAyOOY1t7OFU8ICZLlrWU=; b=wO2YQbG2Nk1ct6L9GY31l1bacV53CA4R9gobTu2Uc+cmHb1WJnuF8Sev6+iWpTBanP yfWSNKxsQ2wdLCBzlRyQUHG4KJBD7NkSBvJ8WiQWZZjLFmBgAYF5F6pul+S/l3NMhLbs byuBmal8msT5rwLtCQvaIT1SfhbuF1VhO4V04UAPwCqlmntk/PBqvgBNsTjUeh0uFPOO iarIaEQW9Om6PgpB1jG9iTnurKh2J8+w5cFIve4cw76RP2f+kvOufFgAgMHZQC/WDfcL mWaAmHMa7dz5u7StauYlHIBFaEK6kOFJ0eFdW82FayEM7ZIaL7eVA0mnl+RPyBx9Ha1W hwNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z92si15717615ede.291.2021.02.09.09.28.46; Tue, 09 Feb 2021 09:29:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232909AbhBIR0j (ORCPT + 99 others); Tue, 9 Feb 2021 12:26:39 -0500 Received: from mail-wr1-f49.google.com ([209.85.221.49]:43676 "EHLO mail-wr1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233092AbhBIRZ0 (ORCPT ); Tue, 9 Feb 2021 12:25:26 -0500 Received: by mail-wr1-f49.google.com with SMTP id z6so22873870wrq.10; Tue, 09 Feb 2021 09:24:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4UpteF9FRAi4Lict6Jo0G0PAyOOY1t7OFU8ICZLlrWU=; b=X6w+jZ6IVwm+MyxEorO/YZsBoyZ4chJtCj5bbN97NGzycXs31OcvfNcZuaQeVRWzUU 0C5TRrRJUVHE6hzS37sekMWBreP+8FoBVsxGg7cP8tQCc3fl/3LIKxsR4n1gxRPts7ik 3fcaprYWX0XV+pqrffXCOtpGdo/ydyUTenAWq9ycfTqCgc92uxE+HWtp7K6BbezsxR9M HSwmdDnsbZgYVH20vAOgM1w0jfj3oD5fuyqm0fd1FKIWojzhF3iJct3pHZZoe7HgdBJ1 h5MvDd2GaGZiAqbpkSJnpUSwcjk+jKFocWwodf4kw9/BePMRb/Ktxmoaa5eSXnWmnqUg lc7w== X-Gm-Message-State: AOAM5310ZVlokOhn1QSq5aUEEAP08BNsp0F63a5rJgBS1FnsKig6oWvd 4Ji+ACu1wjMqLYnu7UZyEJpBNBF2zMC4S4W1 X-Received: by 2002:adf:a501:: with SMTP id i1mr13852390wrb.149.1612891473332; Tue, 09 Feb 2021 09:24:33 -0800 (PST) Received: from rocinante ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id l10sm38463537wro.4.2021.02.09.09.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 09:24:32 -0800 (PST) Date: Tue, 9 Feb 2021 18:24:30 +0100 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: Gustavo Pimentel Cc: "linux-doc@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Andrew Morton , Greg Kroah-Hartman , Jonathan Corbet , Bjorn Helgaas Subject: Re: [RESEND v4 1/6] misc: Add Synopsys DesignWare xData IP driver Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gustavo, [...] > > The code in question would be (exceprt from the patch): > > > > [...] > > +static int dw_xdata_pcie_probe(struct pci_dev *pdev, > > + const struct pci_device_id *pid) > > +{ > > + const struct dw_xdata_pcie_data *pdata = (void *)pid->driver_data; > > + struct dw_xdata *dw; > > [...] > > + dw->rg_region.vaddr = pcim_iomap_table(pdev)[pdata->rg_bar]; > > + if (!dw->rg_region.vaddr) > > + return -ENOMEM; > > [...] > > > > Perhaps something like the following would would? > > > > void __iomem * const *iomap_table; > > > > iomap_table = pcim_iomap_table(pdev); > > if (!iomap_table) > > return -ENOMEM; > > > > dw->rg_region.vaddr = iomap_table[pdata->rg_bar]; > > if (!dw->rg_region.vaddr) > > return -ENOMEM; > > > > With sensible error messages added, of course. What do you think? > > I think all the improvements are welcome. I will do that. > My only doubt is if Bjorn recommends removing the > iomap_table[pdata->rg_bar] check, after adding the verification on the > pcim_iomap_table, because all other drivers doesn't do that. Good point. I only found two drivers that do this extra check: https://elixir.bootlin.com/linux/v5.11-rc7/source/drivers/crypto/ccp/sp-pci.c#L203 https://elixir.bootlin.com/linux/v5.11-rc7/source/drivers/net/ethernet/amd/xgbe/xgbe-pci.c#L252 Bjorn, do you think that there is some likelihood that the table might be missing a mapped address for a given BAR? I don't think that is the case, but should it be the case, then perhaps adding a small wrapper that would take a BAR and do all the verification internally might be a good idea. Krzysztof