From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by dpdk.org (Postfix) with ESMTP id 60B181BE35 for ; Tue, 3 Jul 2018 12:01:10 +0200 (CEST) Received: by mail-ed1-f67.google.com with SMTP id d3-v6so1194849edi.1 for ; Tue, 03 Jul 2018 03:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=j5+vupsw/ULpehZb8353aWwz9hfUeRuCVImA4Rkvcrc=; b=DDK9AYWaBo7TblW6PxLPqj817YR1+lwDJKe4z5bgMRZMdVZ58DIT9P4d+UplVvtChJ hBX+lCLK4c/LkMQ3lBkTofBEAM4Cnb4mV3xd11mPcY+vaF2M67BU4XIbkC49LLJm0FGn B+am+j57cl0PZagTaW3889R3Oc8oAFNamoVsW7CB0OJ5sbrv5I3j2Ckk5M1zaQjjoosm rKz5g7AkrxDGfYiHkFKC5g02VnoFxIWB3HRgwIbQZX9yqTKiBwJWyT/QtdGh41eVsqi9 Qd2ebhbmhwb/NgkCOIkDUzpeGp1Z24cLLND0jq88Z2zE34sw/gX60hdHG5PkvP49abmu /r+g== 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=j5+vupsw/ULpehZb8353aWwz9hfUeRuCVImA4Rkvcrc=; b=fZnVGhEatpcc9e1f3uS0j0iGg8lEMrNQepiQViO1d/Gw8deY4PjT/tOktsZvpr+mME iwUJvuItD/DFdfHq7rlMQ0YbwcX1aFvEp1tEwgEJdQySeyl83UCCelbyPuRNNwvauSrQ Ys+dqDf9s97zrfiOCh1b8I4OAWdeHq4D/UJ/ZZTwslTnW6YjuWAxtm6r3hxsbG91VUy7 wJY/i/Gwz8BKmuTPtrPhFyBMhFAOSjnMAXy+UJPp1obVocrp2nbblm+2699kVHO5zj6P B9/z0Dqz5p/D5gaCHo3/dvrcyMJ+NAHXvOPjWl5D4/XR9l+sO/EPk+hguaTcSQgfP79Y I+Rg== X-Gm-Message-State: APt69E2MgzUjOv6eMVqpckUyqkp4Te954UCSe06nHhrkQ9RRpFMiM9wJ 34oAa4ijbWgACQzo0WiSL6vJP9oVYDYywe/FRADUhw== X-Google-Smtp-Source: AAOMgpegIT0EwgL5I4akRqRuaKUcE5glmdZh3ClnJ0g6Sh1Wh+5azAVEX9nZdgEDxUsUDgXj6URBKnufGr3HQbosSBQ= X-Received: by 2002:a50:adfd:: with SMTP id b58-v6mr28143864edd.168.1530612070107; Tue, 03 Jul 2018 03:01:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a50:b194:0:0:0:0:0 with HTTP; Tue, 3 Jul 2018 03:01:09 -0700 (PDT) In-Reply-To: References: <1530552423-32301-1-git-send-email-alejandro.lucero@netronome.com> <1530552423-32301-2-git-send-email-alejandro.lucero@netronome.com> From: Alejandro Lucero Date: Tue, 3 Jul 2018 11:01:09 +0100 Message-ID: To: "Burakov, Anatoly" Cc: dev , stable@dpdk.org, Maxime Coquelin Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-stable] [PATCH 1/6] mem: add function for checking memsegs IOVAs addresses X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2018 10:01:10 -0000 On Tue, Jul 3, 2018 at 10:07 AM, Burakov, Anatoly wrote: > On 02-Jul-18 6:26 PM, Alejandro Lucero wrote: > >> A device can suffer addressing limitations. This functions checks >> memsegs have iovas within the supported range based on dma mask. >> >> PMD should use this during initialization if supported devices >> suffer addressing limitations, returning an error if this function >> returns memsegs out of range. >> >> Another potential usage is for emulated IOMMU hardware with addressing >> limitations. >> >> Signed-off-by: Alejandro Lucero >> --- >> > > > > + const struct rte_mem_config *mcfg; >> + uint64_t mask; >> + int i; >> + int ret = 0; >> + >> + /* create dma mask */ >> + mask = 1ULL << maskbits; >> + mask -= 1; >> > > mask = ~((1ULL << maskbits) - 1); > > ? IMO this makes it much more clear what you're trying to do. > > Sure. I will change it. > + >> + /* get pointer to global configuration */ >> + mcfg = rte_eal_get_configuration()->mem_config; >> + >> + for (i = 0; i < RTE_MAX_MEMSEG; i++) { >> + if (mcfg->memseg[i].addr == NULL) >> + break; >> + >> + if (mcfg->memseg[i].iova & ~mask) { >> + ret = -1; >> + break; >> + } >> + } >> + >> + if (!ret) >> + return ret; >> + >> + RTE_LOG(INFO, EAL, "memseg[%d] iova %"PRIx64" out of range:\n", >> + i, mcfg->memseg[i].iova); >> + RTE_LOG(INFO, EAL, "\tusing dma mask %"PRIx64"\n", mask); >> + >> + return -1; >> > > The control flow looks weird to me. You break if iova has any bits that > are in the mask, then you display log messages and return -1. How about > just logging error and returning -1, and simply returning 0 after the loop? > > I agree. The truth is I did that initially, but the log lines were too long with the indent. I will go back to the original. Thanks > -- > Thanks, > Anatoly >