Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp558906ybh; Tue, 10 Mar 2020 04:06:34 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs2M830kQgas9XleP4lvHLhZJFRopdQkcaBKcLg1tL5ShXCkwj7wyrcH52Q/Hdlp6jwbNiC X-Received: by 2002:aca:2303:: with SMTP id e3mr728473oie.74.1583838394687; Tue, 10 Mar 2020 04:06:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583838394; cv=none; d=google.com; s=arc-20160816; b=ENIdoeTtubrBnEPAa9mRKoYsO9ZfNpflO8rILMcBCQCTfkuxuBmaUjqhCCLMfMHTwc ZZx0xB+KrTwQbc6dqfeE+yfNb0SH0kWs47vtKfeYYF0iyn+dJpDiGjntyyDxNxdi4OAO gHTJj3gyu0m/SYc9BJCBz/tEFUglcaKkx6+QBqVXiwwsKh/MQd9EGrVJs9+ICeOShURj rBNtSvi9jQRZNEEWbKCXQ8ofmy3iMPzRXZheDusE6tWxjt9Q0AUcjkwUvwrVUcCT3kIJ nmYROItKcaRw3r/aUjUf3DMBRfOYLF9YPHILBlkU7D1tLlwtORr97OErMqc9enQ5zSJ5 Rk1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:in-reply-to :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CzkrWAmBf2oqqeq6nmGCN0dfk2xPizcnlNYu+9BCd+8=; b=kkYZyh10+sSYSj/yblRExcVpeV1ZdZACige3GI2F7KF/r/Rrc4ipD4QbBEXDmbwRHT pxiUc4rPdejVKpn6SNEhBlm/7KYoCv9hJfGjvyj2wq66k8egV+u+F1e7i87AVD3NkyGB upD4tWPaUdxadzZcqOVzq+g22mIyY+EDP5t3HTdGAeOQbcABhaWHl1ffzF9TiCaTiE5w cno15mdoBBiovQRnahku9DJNIKy8072+ti4ueEZ4ghGS64s9RGhpLVhjBstydM/cFInl aGjYU8Sf3zCQ+rC16uxJFhPSVAx/98Ty/BuQypDCR1uyuVzjBQP76/t8EQBWozWhMkgh 7/Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhdHJtbB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f17si5335976oij.64.2020.03.10.04.06.17; Tue, 10 Mar 2020 04:06:34 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhdHJtbB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbgCJLEv (ORCPT + 99 others); Tue, 10 Mar 2020 07:04:51 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:38888 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726252AbgCJLEv (ORCPT ); Tue, 10 Mar 2020 07:04:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583838290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=CzkrWAmBf2oqqeq6nmGCN0dfk2xPizcnlNYu+9BCd+8=; b=VhdHJtbBM2UJ7wihHh7agbQKfcNldICQy9XKaRmv2cRQ/9Yvg7O8UzTF7KnJdgqedblf1o 8T2uFMLwxn0xt8VWMSnBXdmoopO770O471tecm9eoVfZKbLAltFO8l+ZF4FxiFdyxCEJx+ P6fX73BFRDYRi2Gui1uczpHTzizjygY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-389--FRRzkK1NtS5nisEDRQ31g-1; Tue, 10 Mar 2020 07:04:45 -0400 X-MC-Unique: -FRRzkK1NtS5nisEDRQ31g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7AB9218B5FAA; Tue, 10 Mar 2020 11:04:44 +0000 (UTC) Received: from localhost (unknown [10.36.118.73]) by smtp.corp.redhat.com (Postfix) with ESMTP id B404B5C28E; Tue, 10 Mar 2020 11:04:38 +0000 (UTC) Date: Tue, 10 Mar 2020 11:04:37 +0000 From: Stefan Hajnoczi To: Vivek Goyal Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, virtio-fs@redhat.com, miklos@szeredi.hu, dgilbert@redhat.com, mst@redhat.com, Sebastien Boeuf , kbuild test robot Subject: Re: [PATCH 04/20] virtio: Implement get_shm_region for PCI transport Message-ID: <20200310110437.GI140737@stefanha-x1.localdomain> References: <20200304165845.3081-1-vgoyal@redhat.com> <20200304165845.3081-5-vgoyal@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200304165845.3081-5-vgoyal@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zgY/UHCnsaNnNXRx" Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --zgY/UHCnsaNnNXRx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Mar 04, 2020 at 11:58:29AM -0500, Vivek Goyal wrote: > diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_p= ci_modern.c > index 7abcc50838b8..52f179411015 100644 > --- a/drivers/virtio/virtio_pci_modern.c > +++ b/drivers/virtio/virtio_pci_modern.c > @@ -443,6 +443,111 @@ static void del_vq(struct virtio_pci_vq_info *info) > =09vring_del_virtqueue(vq); > } > =20 > +static int virtio_pci_find_shm_cap(struct pci_dev *dev, > + u8 required_id, > + u8 *bar, u64 *offset, u64 *len) > +{ > +=09int pos; > + > + for (pos =3D pci_find_capability(dev, PCI_CAP_ID_VNDR); Please fix the mixed tabs vs space indentation in this patch. > +static bool vp_get_shm_region(struct virtio_device *vdev, > +=09=09=09 struct virtio_shm_region *region, u8 id) > +{ > +=09struct virtio_pci_device *vp_dev =3D to_vp_device(vdev); > +=09struct pci_dev *pci_dev =3D vp_dev->pci_dev; > +=09u8 bar; > +=09u64 offset, len; > +=09phys_addr_t phys_addr; > +=09size_t bar_len; > +=09int ret; > + > +=09if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len)) { > +=09=09return false; > +=09} > + > +=09ret =3D pci_request_region(pci_dev, bar, "virtio-pci-shm"); > +=09if (ret < 0) { > +=09=09dev_err(&pci_dev->dev, "%s: failed to request BAR\n", > +=09=09=09__func__); > +=09=09return false; > +=09} > + > +=09phys_addr =3D pci_resource_start(pci_dev, bar); > +=09bar_len =3D pci_resource_len(pci_dev, bar); > + > + if (offset + len > bar_len) { > + dev_err(&pci_dev->dev, > + "%s: bar shorter than cap offset+len\n", > + __func__); > + return false; > + } > + > +=09region->len =3D len; > +=09region->addr =3D (u64) phys_addr + offset; > + > +=09return true; > +} Missing pci_release_region()? --zgY/UHCnsaNnNXRx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAl5ndEUACgkQnKSrs4Gr c8jLYwf/exeUl3WphEdcCDBZB1FzUfCmswGzkwrT92YXIdpwgJZrl688mmhjXloi GJqsnE3BX20JSmDOw3KlRiByhAEaz2HwKpdjT62Xq3CBRMLDemAymoDsGtjlanVK fdmw17AJzX01wpcPW2ek87jGaHwygYHt4GFrE9NH+TiB7WVU0EfXmaF1fbVREkT1 VGzPZqY0xpWl3g12g9P0BCrftqa0PyLG29aHHG5NFs7kbTNaej5NcBOUjxEvk9jB 3mS+w/vUz7cdZPyj0BxxVjNN6udpyi83i4QdTzgLKilwD9x1VhvtnVVJiOdXOdvm h4bns2UcpEqEvyaSsVzo3jlYx+OeRw== =74o7 -----END PGP SIGNATURE----- --zgY/UHCnsaNnNXRx--