From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-io0-f171.google.com (mail-io0-f171.google.com [209.85.223.171]) by dpdk.org (Postfix) with ESMTP id 5ED9E2C57; Fri, 12 Jan 2018 23:46:26 +0100 (CET) Received: by mail-io0-f171.google.com with SMTP id 25so7468822ioj.9; Fri, 12 Jan 2018 14:46:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3T1kXyhY1KJS9UR1JIH6fiqatrFDtATjqOjo1tadjMU=; b=odDEYQye/eg5IYjJUCjzhULuRZwv+qb/1sJ44Oa0+fTeDZpKFrCzGIeuN5T+INpAGj 5DSx72tNR7GEHqjB9htYjf5W9yy6DzSc4V6qfjay5h/8qZRe95TkvDEF+S1MeTpZxBAV qHFRNtTJ/qcsIIlMkXdPAb/kiJJ1yaRPNf5A+0TBRqsPGA4jipYd5UlK6Kun/2XCFTQc EhXiMfwhqzyglKk5NeXHUnWp5ovivKuF4TzdGdg0sYVUamf05wP9g7oQBiZCaKZpD92T rf/psxb1i8EvNrxanGLH9B3UMe1WNKpalmHTX7jg70jyRu4ieBwZeBYCUlUH8UqTvg9t SNPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3T1kXyhY1KJS9UR1JIH6fiqatrFDtATjqOjo1tadjMU=; b=Z/h8m6ssv1zqJ1kCduvhQA2+bUHt6ex0s8i3Vfom7/oNMvl+h7ZNf08z8HBm6tWw6l /WaBbeKaHFdrDwkIYBOF+hgcLVcPNm08LtQUBESKBhVBg2jzVqUl/P7BGii3KzhdDL3h HmbKwRUYqjtbRMYiTQ1g1w5cnZh9fWl7POax6xFo5eI+CBQ2w7y8TGSQ5RlZroDrVYoi BQiLWQaj2ASg9o2LAoaO9N/Y4Cimt2iXM2twhDO78NpsZSs511wE7STYTmmf9fY2xbmc /Dh3C7kL7oBcsxh/PzTzfbuXN4QdZeXbfZDgSNe6/aIWaYwc0RivOS6xSuwKk48wqojo 7ohw== X-Gm-Message-State: AKGB3mLderMFvgbLUEsjtlMj9fSySzc4FH9f2KXQDA2PT9zfCWszDqWS DHe3Bhsm4GzDhTpf70bKOzdeuNoOGGQ1Cuy+80s= X-Google-Smtp-Source: ACJfBotVKzkJc50i2cMSaMZzIuj6SbwDyTJ884LuOrnAGr2vfiSqItgQ0BFajGRUWF8RwvXpQaLoqr/qADYu5Rz1n5k= X-Received: by 10.107.40.134 with SMTP id o128mr28149279ioo.57.1515797185721; Fri, 12 Jan 2018 14:46:25 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.69.9 with HTTP; Fri, 12 Jan 2018 14:46:25 -0800 (PST) In-Reply-To: References: <20180112102220.20061-1-maxime.coquelin@redhat.com> <89c16dd0-3938-f9ae-cc9f-189388abc0a9@intel.com> From: Chas Williams <3chas3@gmail.com> Date: Fri, 12 Jan 2018 17:46:25 -0500 Message-ID: To: Maxime Coquelin Cc: "Burakov, Anatoly" , dev@dpdk.org, stable@dpdk.org, Jianfeng Tan , "Zhang, Qi Z" , Stephen Hemminger , santosh.shukla@caviumnetworks.com, Thomas Monjalon , peterx@redhat.com Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v3] bus/pci: forbid VA as IOVA mode if IOMMU address width too small X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 22:46:26 -0000 Tested-by: Chas Williams On Fri, Jan 12, 2018 at 8:18 AM, Maxime Coquelin wrote: > Hi Anatoly, > > > On 01/12/2018 12:10 PM, Burakov, Anatoly wrote: > >> >> >> +#if defined(RTE_ARCH_X86) >>> +static bool >>> +pci_one_device_iommu_support_va(struct rte_pci_device *dev) >>> +{ >>> +#define VTD_CAP_MGAW_SHIFT 16 >>> +#define VTD_CAP_MGAW_MASK (0x3fULL << VTD_CAP_MGAW_SHIFT) >>> +#define X86_VA_WIDTH 47 /* From Documentation/x86/x86_64/mm.txt */ >>> + struct rte_pci_addr *addr = &dev->addr; >>> + char filename[PATH_MAX]; >>> + FILE *fp; >>> + uint64_t mgaw, vtd_cap_reg = 0; >>> + >>> + snprintf(filename, sizeof(filename), >>> + "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", >>> + rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, >>> + addr->function); >>> + if (access(filename, F_OK) == -1) { >>> + /* We don't have an Intel IOMMU, assume VA supported*/ >>> + return true; >>> + } >>> + >>> + /* We have an intel IOMMU */ >>> + fp = fopen(filename, "r"); >>> + if (fp == NULL) { >>> + RTE_LOG(ERR, EAL, "%s(): can't open %s\n", __func__, filename); >>> + return false; >>> + } >>> + >>> + if (fscanf(fp, "%lx", &vtd_cap_reg) != 1) { >>> + RTE_LOG(ERR, EAL, "%s(): can't read %s\n", __func__, filename); >>> + fclose(fp); >>> + return false; >>> + } >>> + >>> + fclose(fp); >>> >> >> Hi Maxime, >> >> You probably want to use eal_parse_sysfs_value() for this. >> > > I initially planned to use it, but the sysfs value is hexadecimal, but > not prefixed with "0x". For example: > > # cat /sys/devices/pci0000\:00/0000\:00\:02.0/iommu/intel-iommu/cap > 1c0000c40660462 > > So strtoul() assumes the value is decimal in this case, as explained in > its man page: > > " > DESCRIPTION > > If base is zero or 16, the string may then include a "0x" prefix, and > the number will be read in base 16; otherwise, a zero base is taken as > 10 (decimal) > " > > Thanks, > Maxime >