Received: by 10.213.65.68 with SMTP id h4csp1406634imn; Wed, 21 Mar 2018 09:55:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELtCg7jmG0/xcSmwzmujSGBW3M2TrrgMkQnK8jQjSBacrEB5ue0N0Vcq4H+xOLVoLOam4CJc X-Received: by 2002:a17:902:8685:: with SMTP id g5-v6mr17239198plo.133.1521651308462; Wed, 21 Mar 2018 09:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521651308; cv=none; d=google.com; s=arc-20160816; b=D7H7fYuvca5vz+XVEFHhpYY9pjcnwuUe3YR7MVSyqyfhD7+eEka+oiCrTaSgQs4hHW 1QEvpjzXwLsshqZqLoGmtw/5qVMRveqt6fQpi/Eqg5I5FFyLhhLZqJsZM/WDpHMp3N6d IetmoNE/vrZOuhBrIg1FsBgWB2tXytX0DNAQWPXXQputCLnqpOFTSRDiZGPomspfqnk0 Ejh5I1HaVeZ/4HrT4zOEuUGGL0wycXUnF7AJtUczcTSNlQv2GaTjQt6u4BKfsOqJvaZ9 S9XfE5M83ThCV5YXeBiiJvcWnUW8IlI4/LlqF4O1/VE6u9fireya0YDj5eLO81ty5W+6 zI6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:arc-authentication-results; bh=SmYkeRDMJh5AhEnpRs5/FoDILI+9tgEQh5ONiRrCXYM=; b=BrOCeeV5/1lR5h76j6txIWqpzbfbnIh+Ie7Rp9kMEEWpLdRjjgTEG39vugypVXBhxK Zn/NyXNOPBKs9AzZQc3wPAdc0uZMnzLdAykMqeD2UZgNieeXDInsX31GGK8scxQQkbYB g9ava2Nd6pRSy1JNWubJ9u8rdTCtj7qwyzuoZzQk0Ol8q6t4JKgp7ETpYsr8bE4qXU3F MdYhpOZ06h5ew9S7S0ZAuUHXGnPQZ1rXnNTzbb1Yh/bKlkH+kRhmnSBMcPJ2UG1qBUGc mNM5Hu/e1Axyaq5DJwrnoq8BsJZVndGAgyW7+alUgdSxH4BviWt7h/9EZZNFtFUyfe+9 XlMg== 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 o33-v6si4255384plb.369.2018.03.21.09.54.53; Wed, 21 Mar 2018 09:55:08 -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 S1753007AbeCUQxs (ORCPT + 99 others); Wed, 21 Mar 2018 12:53:48 -0400 Received: from ale.deltatee.com ([207.54.116.67]:56936 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbeCUQxq (ORCPT ); Wed, 21 Mar 2018 12:53:46 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1eygyZ-0007iW-MK; Wed, 21 Mar 2018 10:52:36 -0600 To: Christoph Hellwig 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 , Jens Axboe , Keith Busch , Sagi Grimberg , Bjorn Helgaas , Jason Gunthorpe , Max Gurtovoy , Dan Williams , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Benjamin Herrenschmidt , Alex Williamson , Steve Wise References: <20180312193525.2855-1-logang@deltatee.com> <20180312193525.2855-12-logang@deltatee.com> <20180321092702.GC7098@lst.de> From: Logan Gunthorpe Message-ID: Date: Wed, 21 Mar 2018 10:52:25 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180321092702.GC7098@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: swise@opengridcomputing.com, alex.williamson@redhat.com, benh@kernel.crashing.org, jglisse@redhat.com, dan.j.williams@intel.com, maxg@mellanox.com, jgg@mellanox.com, bhelgaas@google.com, sagi@grimberg.me, keith.busch@intel.com, axboe@kernel.dk, sbates@raithlin.com, linux-block@vger.kernel.org, linux-nvdimm@lists.01.org, linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 Subject: Re: [PATCH v3 11/11] nvmet: Optionally use PCI P2P memory X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/03/18 03:27 AM, Christoph Hellwig wrote: >> + 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? Sorry, I don't follow. The code, as is, should automatically select the device if the user sets it to "yes" or "auto" or "y" or similar. (Roughly similar to how kstrtobool() works, except '0' or '1' are not accepted seeing they could overlap with PCI device names). In other cases, it looks for the specific PCI device name to use exactly. Are you saying it shouldn't work this way or are you saying the code to implement it is too messy? >> + 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) Sure. Would the helpers belong in core.c? Thanks, Logan