Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp348861lqs; Thu, 13 Jun 2024 11:45:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUG8YsdXEoYxQuw9FK1axI1iOBC1lQ4SoYqvtG4dz/xHI3g4rxqG45PED+hugvzUeLrEIwdWjUM1CI5Uw2uS6efs/DykEf4Uva2H1j1CA== X-Google-Smtp-Source: AGHT+IGjxl1kEp79YLHW2sMM0soe4+/lTnG8nSsU8Frs1P3KMnT/OdHJEBnFHwBFwubXYOTTcFng X-Received: by 2002:a2e:8eda:0:b0:2eb:dd0b:b9ec with SMTP id 38308e7fff4ca-2ec0e5c6c2fmr4083211fa.20.1718304326950; Thu, 13 Jun 2024 11:45:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718304326; cv=pass; d=google.com; s=arc-20160816; b=O3XAyH8g0EukIh5fZ+9/gvd8E33lwd2YrYJDStzU7Jp9VsKjGoiyARkGhFsye0w4+u V1NvW4UrM8nY6iQZFX7I1FYtKAd4OlDOek3XC/pzdx7UU5318AiBwm/N525QdWM5UHOO 3IJXkUkjC2vUwPqxFMQUvWGzk2BBvTJJeRXgmnubnn0axiaTljwxRmJk0YIAWeh2OWaO ta/zszTcAXxwTbgB41cqFzBhi9G1hBbtG5z/OqkqPE59TN4lzVT7Kx/3L3rFDS7O1wBn ucYTNQqFqeLw72jb4JVnFYf+T/kL8gyRBAaLZ3WL43OHh7ITc5UD46oVfMwdbfzg5lw2 dhlQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:subject:cc:to:from:date:dkim-signature; bh=i3nokdg5pg6y3YsIGD/sdN/I74TlVQfkhMBr+UDV+uA=; fh=WL74A0nlWntJcVE8Y03tvrHV2tpFaVgRG1nYxGs+SN4=; b=F4gXrb5RKfsh9rA7RaTrajGCpfYO1Ki06GzBCmndgbe38wz8ll9wVp/scl2ITCvLB2 Ejy8Bp6/AxP8Ye/WZlj1ZDtuq1YuDyn209g+FgIdNftoHeReNB71WK+v/VgdRRtvt4O8 jGpgSU9oaEPB5cX7Ucic0vWOB8h04KuCvRHzgnvi2sp3xITVBdCb2h4BWlzj5CUiSSU2 ZtKi8VmqgHIZJ7u992iOziYfOtxBcYNhtc4rLP+S+j7jmbT5tVpXNBRXUqMDHAvcNMdf ZMzDNIdwoQxgF05uwCXp3R7IUavGogyRLzd5k6SNPa5BMCYL36xv2xhup7ud0wufZTAL AP8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R3XGyyGF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213856-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57cb7477c67si1029785a12.635.2024.06.13.11.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 11:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213856-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R3XGyyGF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-213856-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213856-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A64B31F21593 for ; Thu, 13 Jun 2024 18:45:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0350814B95B; Thu, 13 Jun 2024 18:45:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R3XGyyGF" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28B5214AD2C; Thu, 13 Jun 2024 18:45:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718304317; cv=none; b=BWjgA/6Cms/oo41bcGkoUd/Pbl3ws2Ka3Rblpk2mQjPr+raAqlVGwW8Mrgx+i9FP6/kznZOpb2XSqO3SP4h1LVOh8MgTMka8dqsV9LTvMio2xFigVj4C8o7O4XCwwAa0Lw5xEN1dfnFSdcAWk1ktzqArIF4CN9WYG00UAVmREOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718304317; c=relaxed/simple; bh=SaYK7xDVIVPlSht74HhNqclsX16Ie88uGUDzvreWhC4=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=n396HNQ/gjzH/DyEoJeh4vwn2HirmG8pP0pcvItDX8ah4GPNVsBfgNf0HRyAUcSczkVUN1sBlEDH0BfjQBRFdH0El71B5VB6yOk6RZvOTILlQGHt49gvA8jTfmE2W7PGYBxwJPQEQH+yiMBmmxaWsmp177WHWFdaXfsHnTay+k4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=R3XGyyGF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54CA4C2BBFC; Thu, 13 Jun 2024 18:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718304316; bh=SaYK7xDVIVPlSht74HhNqclsX16Ie88uGUDzvreWhC4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=R3XGyyGFzwjza+YIqcLz1yLluC+7EBBbxz+bjk3bINlUnfF3fBo0vxvRZJE5rfezX IdtqN5Ji664TSC9q1zDKWqteUv+wYuC1Nj5D/qWFhIxfv8aJHOsOlVa+YlyfZXwTbw q8YhThE/zwkuHoY0Gow1P3nfPb7g0HDwiVmv6lBgHboXDBhEInoNST0x9kr7XAcZST 7l5nAMqy+jilTniLJNCAATJ9/PnOsT2mV1J+v0mG6Iq95VwyFrsc8mUvCjaBHL5hu4 1iFHa0yZKD8X3mVu1QH6PyWqatlTDDPlcJHDN/wiinR13NnQmlbKLPuT6KqVIHBrt1 ehn9BXQozHTbg== Date: Thu, 13 Jun 2024 13:45:14 -0500 From: Bjorn Helgaas To: Ilpo =?utf-8?B?SsOkcnZpbmVu?= Cc: Philipp Stanner , Hans de Goede , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Bjorn Helgaas , Sam Ravnborg , dakr@redhat.com, dri-devel@lists.freedesktop.org, LKML , linux-pci@vger.kernel.org Subject: Re: [PATCH v7 03/13] PCI: Reimplement plural devres functions Message-ID: <20240613184514.GA1071919@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Thu, Jun 13, 2024 at 07:54:38PM +0300, Ilpo Järvinen wrote: > On Wed, 5 Jun 2024, Philipp Stanner wrote: > > > When the original PCI devres API was implemented, priority was given to > > the creation of a set of "plural functions" such as > > pcim_request_regions(). These functions have bit masks as parameters to > > specify which BARs shall get mapped. Most users, however, only use those > > to map 1-3 BARs. > > +static int __pcim_request_region_range(struct pci_dev *pdev, int bar, > > + unsigned long offset, unsigned long maxlen, > > + const char *name, int req_flags) > > +{ > > + resource_size_t start = pci_resource_start(pdev, bar); > > + resource_size_t len = pci_resource_len(pdev, bar); > > + unsigned long dev_flags = pci_resource_flags(pdev, bar); > > + > > + if (start == 0 || len == 0) /* That's an unused BAR. */ > > + return 0; > > + if (len <= offset) > > + return -EINVAL; > > Extra space. Thanks for reviewing this. I dropped the space locally in the v9 series. > > void pcim_iounmap_regions(struct pci_dev *pdev, int mask) > > { > > - void __iomem * const *iomap; > > - int i; > > - > > - iomap = pcim_iomap_table(pdev); > > - if (!iomap) > > - return; > > + short bar; > > The current best practice is to use unsigned for loop vars that will never > be negative. > > I don't entirely follow what is reasoning behind making it short instead > of unsigned int? Existing interfaces like pcim_iomap() take "int bar". I locally changed all the BAR indices to "int". We can make everything unsigned later if worthwhile. > > - for (i = 0; i < PCIM_IOMAP_MAX; i++) { > > - if (!mask_contains_bar(mask, i)) > > + for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { > > Is this change minimal if it contains variable renames like this? > Was "i" not "bar" even if it was given as a parameter to > mask_contains_bar()? Replaced locally with "i". Bjorn