From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 3EB225A62 for ; Tue, 19 Jan 2016 19:36:08 +0100 (CET) Received: by mail-pf0-f178.google.com with SMTP id 65so179522131pff.2 for ; Tue, 19 Jan 2016 10:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mvista-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=C83960pJZUW7QHH8FUPkA/wStJIZ+caMwxtaiqhddwA=; b=uqcA3QOiVxhH8d012R+wFtPPvDYBtJd1ymFj/5PXjtYgiDN7mieVNU+zmT0sfEBrB9 Y2j6K9Vf9zk1IPcVX3Sz4bf5Ynvbw7bpNKGFIhtvUs5on4W1mX0VwQmPjBPi/yuanc8W G7ZtjN9cJqHwOYGlfmdbi9YBfAi0OjCl7btCwXXaHuMvcFbfzDXQ3uBvhM4unn5XuNhY +hZI1/Xg16Z+f/epY4iGCepb2WOWEcDY4h+6OYsaxSPO9XiC0LxxL4uz5AUHAVVBfsfE vU2OYQ/rN8BhPacSlyt+2/aSAYHzOUVHxK2fgY4g3W6vs4ftefWOpypP+Bc6EzAj723j LKWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=C83960pJZUW7QHH8FUPkA/wStJIZ+caMwxtaiqhddwA=; b=ipsPlNsMfE3J6gDFKrEc9EBqQA6puGTEgSUyk5YoIGZTHbPZmqDm16u5l5DxHWu2YC xR8RrHnNQkZwAaRhyr4zULTV0/s1yy8YJqh+IpwL0zcolXwlUF+AuwwI8fXQ4Q9z6t9E tRnbkz8jWbyDU+70grlmt1Zm43ocNOVQI72Da1zHKI6hARP0GKVNKMd6y4FomJuUtWx4 tBvC4Gf4PRFoqhIaKoJXmr+Kx6FmF9CwthdZsP3+xRgkvxTZkZfgp5sjThhZwYK4AfM1 6OuGIpB/GSV0n9TvPJQSYgyJgTHpOU2AOd1pMXDn2gSwXeqdKZOqA6eQ43ysCifpNA58 k5QQ== X-Gm-Message-State: AG10YOQFj6BPyISrDdekZEnQx4Yf5ylCLW7tK+McHqC2lP6qJT3GDuSdUOrU9gnvhdoCIdO4dx0UfGz1amBeErIr MIME-Version: 1.0 X-Received: by 10.98.14.69 with SMTP id w66mr26177664pfi.144.1453228565931; Tue, 19 Jan 2016 10:36:05 -0800 (PST) Received: by 10.66.196.81 with HTTP; Tue, 19 Jan 2016 10:36:05 -0800 (PST) In-Reply-To: References: <1453203972-24855-1-git-send-email-sshukla@mvista.com> <1453203972-24855-9-git-send-email-sshukla@mvista.com> Date: Wed, 20 Jan 2016 00:06:05 +0530 Message-ID: From: Santosh Shukla To: "Burakov, Anatoly" Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v5 08/11] eal: pci: introduce RTE_KDRV_VFIO_NOIOMMUi driver mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jan 2016 18:36:08 -0000 On Tue, Jan 19, 2016 at 7:48 PM, Burakov, Anatoly wrote: > Hi Santosh, > >> +int >> +pci_vfio_is_noiommu(struct rte_pci_device *pci_dev) { >> + FILE *fp; >> + struct rte_pci_addr *loc; >> + const char *path = >> "/sys/module/vfio/parameters/enable_unsafe_noiommu_mode"; >> + char filename[PATH_MAX] = {0}; >> + char buf[PATH_MAX] = {0}; >> + >> + /* >> + * 1. chk vfio-noiommu mode set in kernel driver >> + * 2. verify pci device attached to vfio-noiommu driver >> + * example: >> + * cd /sys/bus/pci/drivers/vfio-pci//iommu_group >> + * > cat name >> + * > vfio-noiommu --> means virtio_dev attached to vfio-noiommu >> driver >> + */ >> + >> + fp = fopen(path, "r"); >> + if (fp == NULL) { >> + RTE_LOG(ERR, EAL, "can't open %s\n", path); >> + return -1; >> + } >> + >> + if (fread(buf, sizeof(char), 1, fp) != 1) { >> + RTE_LOG(ERR, EAL, "can't read from file %s\n", path); >> + fclose(fp); >> + return -1; >> + } >> + >> + if (strncmp(buf, "Y", 1) != 0) { >> + RTE_LOG(ERR, EAL, "[%s]: vfio: noiommu mode not set\n", >> path); >> + fclose(fp); >> + return -1; >> + } >> + >> + fclose(fp); >> + >> + /* 2. chk whether attached driver is vfio-noiommu or not */ >> + loc = &pci_dev->addr; >> + snprintf(filename, sizeof(filename), >> + SYSFS_PCI_DEVICES "/" PCI_PRI_FMT >> "/iommu_group/name", >> + loc->domain, loc->bus, loc->devid, loc->function); >> + >> + /* check for vfio-noiommu */ >> + fp = fopen(filename, "r"); >> + if (fp == NULL) { >> + RTE_LOG(ERR, EAL, "can't open %s\n", filename); >> + return -1; >> + } >> + >> + if (fread(buf, sizeof(char), sizeof("vfio-noiommu"), fp) != >> + sizeof("vfio-noiommu")) { >> + RTE_LOG(ERR, EAL, "can't read from file %s\n", filename); >> + fclose(fp); >> + return -1; >> + } >> + >> + if (strncmp(buf, "vfio-noiommu", strlen("vfio-noiommu")) != 0) { >> + RTE_LOG(ERR, EAL, "not a vfio-noiommu driver\n"); >> + fclose(fp); >> + return -1; >> + } >> + >> + fclose(fp); >> + >> + return 0; >> +} > > Since this is a public non-performance critical API, shouldn't we check if pci_dev is NULL? Otherwise the patch-set seems fine to me as far as VFIO parts are concerned. > pci_scan_one() uses this api for now and it populate pci_dev before pci_vfio_is_noiommu() could use. So didn't though to add a check, But you are right in case any other module want to use this api. Sending patch now. Thanks. > Thanks, > Anatoly