Received: by 10.213.65.68 with SMTP id h4csp1095611imn; Wed, 21 Mar 2018 02:28:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELs/Ul99gfBu1f9xXb9q9/PdwkJG1M0CAeT23q/rhSudzpynw3LTZgA+rPwUS+IevZwAhPaU X-Received: by 2002:a17:902:9009:: with SMTP id a9-v6mr19511772plp.272.1521624497859; Wed, 21 Mar 2018 02:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521624497; cv=none; d=google.com; s=arc-20160816; b=RvoiHyYRyrCXBvKFkOk/vA687BOJVEx7D3iXoPt1Gjwr2ano/GTnVLxwTbK5Sav3vd YMUzweYy1N9XnVLxlrQ0qhF6NSUopRPfn05zUhqqvQKP2egylR1DvNlOkFygdagfF61e NN8o7xRh5iuvZlZGCrg96EtApPvjmmCVkNcoy3ihoWBryqqksgZkVOVllkKfJRBpWZiM 8m50DRzMFBJLm/qBeT4NVM5gkZVKAwGHNx6ifVA2T9jtinWeHmh0R1zTg9+RgnfYSnhr eHPBNEbT5OYkaof9wbe+uPlSNq0hre4M+uQDJEO4j/83nmcw9JmaWUlBX9ZvrT0ifkjn FXaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=hIfWkr3rPuhQthz4gbc5Z31SlehuREO+uuYHx+gFqmk=; b=Gqdxjy1uzgoRnfDW8aJDV2bzDk42OD7ldKLNeEgx9mM5FtWmJuveHuCrlJeMxuSJK/ suQHX9urmXx/JYHzZbpx8zLQFtX66ZEZo4TjGa4LDYlNWGBquDfm5mxGregWOXvTrcPp 3TM/XQhb/FO2eyJQp5H1ud/gGUvVWJXrg50TGPjPUuhAZyKxbYVAKPybtnW5fzWQ+iHX PdVh6wpuEtsyXt6PUsxGieeFUZSXCqbsuQx9VHSOJrscTzwjXa5WKMSPuDDJ/2PRxQtB 8Vm/vFP9Us+FpmbKqvGcJUCkkbE0ugq7GQiRgkFvLl8zW5StV/V5ukngEVNb+7TeoDQo vHcw== 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 v13si2750088pfm.83.2018.03.21.02.28.03; Wed, 21 Mar 2018 02:28:17 -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 S1751728AbeCUJ1G (ORCPT + 99 others); Wed, 21 Mar 2018 05:27:06 -0400 Received: from verein.lst.de ([213.95.11.211]:41249 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbeCUJ1E (ORCPT ); Wed, 21 Mar 2018 05:27:04 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 2674EDE403; Wed, 21 Mar 2018 10:27:02 +0100 (CET) Date: Wed, 21 Mar 2018 10:27:02 +0100 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-nvdimm@lists.01.org, linux-block@vger.kernel.org, Stephen Bates , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?iso-8859-1?B?Suly9G1l?= Glisse , Benjamin Herrenschmidt , Alex Williamson , Steve Wise Subject: Re: [PATCH v3 11/11] nvmet: Optionally use PCI P2P memory Message-ID: <20180321092702.GC7098@lst.de> References: <20180312193525.2855-1-logang@deltatee.com> <20180312193525.2855-12-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180312193525.2855-12-logang@deltatee.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + const char *page, size_t count) > +{ > + struct nvmet_port *port = to_nvmet_port(item); > + struct device *dev; > + struct pci_dev *p2p_dev = NULL; > + bool use_p2pmem; > + > + switch (page[0]) { > + case 'y': > + case 'Y': > + case 'a': > + case 'A': > + use_p2pmem = true; > + break; > + case 'n': > + case 'N': > + use_p2pmem = false; > + break; > + default: > + dev = bus_find_device_by_name(&pci_bus_type, NULL, page); > + if (!dev) { > + pr_err("No such PCI device: %s\n", page); > + return -ENODEV; > + } > + > + use_p2pmem = true; > + p2p_dev = to_pci_dev(dev); > + > + if (!pci_has_p2pmem(p2p_dev)) { > + pr_err("PCI device has no peer-to-peer memory: %s\n", > + page); > + pci_dev_put(p2p_dev); > + return -ENODEV; > + } > + } Yikes. Shouldn't auto just be the normal yes case instead of this string parsing mess? > + if (rsp->req.sg != &rsp->cmd->inline_sg) { > + if (rsp->req.p2p_dev) > + pci_p2pmem_free_sgl(rsp->req.p2p_dev, rsp->req.sg, > + rsp->req.sg_cnt); > + else > + sgl_free(rsp->req.sg); > + } Can we factor this into a helper, as the other target drivers (fc for now, tcp soon) using sgl allocatins should share the code? (same for the alloc side)