Received: by 10.223.176.46 with SMTP id f43csp99782wra; Thu, 18 Jan 2018 14:31:58 -0800 (PST) X-Google-Smtp-Source: ACJfBouMuMwpTQW4uXu1owBXt1f7QsPy8BMrqNcTjhW3xvUmyiWfZ4Zh8S6E0et6UxfCkPua20ZY X-Received: by 10.98.200.153 with SMTP id i25mr38681376pfk.241.1516314717889; Thu, 18 Jan 2018 14:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516314717; cv=none; d=google.com; s=arc-20160816; b=nq1UO9ZZ7I/jJQVNJIF43Uq588opq6FN+gnb8x2ezI+VRDDZYrDyyi1S/NBOrO4F/P oXGX8/0bNmPys5jwMu5tcgZSMmNCQQAubFdkmVOksKhxeZawMCeYMlODsyIPj7tneSx3 GrYEGCkf7DbGCb2/mhMrvZZeoxypfmCU6xsN3lPleHdCKP0ennBsvrT45VMEJw+uf+IO GIcyze3uDoY5+taoq7KjqsZISPeePqakfWq0eDx6YqQEZYdrkflhPbS418A/tlRw+T+v Cn1igfvwazpK1eVwQKQUSKmSjvg7oFf82I7Frm0I64H9aPd7mTI7cpvG3qu3F5dU79Ri ViKQ== 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:dkim-signature:arc-authentication-results; bh=+NYlb2pRq/r0z2BzMRiCf5ac+8+3CLg70JHV0Tk8BbM=; b=OT+gimfqdFpBq68SIO1VC8E/Y//EGGgK4sT9xMNAq3JGY5gzIfSFIt4b4wcscanOuH m0LgjZJR4QoOCEfu0Pl/nKTjw++FYCwlBlOfHeHGk2/Fmkmagh+GGf3eR/SZgVeMSYp/ Kn3NbdfFoF4wyjPNMXNaYcAL5M3Piy+b72kHWVtfIjZSoG9uuPb8u8NMv0ocOhCyQVLk 9kQK2Q6I2aTy45gsBYZdAtewDDwAbjRM5npB8sYnKSl05ib8KyZMQ3YuN+BKIsxMI1fU gzPA4qv4GYM+EI6qzcwGanvU1LLYI+XxcBkHoTbRqzZhZIk72OrcD/2KD1nEsY2mA4UV Yijw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=EFj04IBi; 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 j14si7088381pgf.695.2018.01.18.14.31.44; Thu, 18 Jan 2018 14:31:57 -0800 (PST) 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; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=EFj04IBi; 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 S1755130AbeARWaT (ORCPT + 99 others); Thu, 18 Jan 2018 17:30:19 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35601 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753822AbeARWaN (ORCPT ); Thu, 18 Jan 2018 17:30:13 -0500 Received: by mail-qt0-f193.google.com with SMTP id u10so34305065qtg.2 for ; Thu, 18 Jan 2018 14:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kudzu-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=+NYlb2pRq/r0z2BzMRiCf5ac+8+3CLg70JHV0Tk8BbM=; b=EFj04IBiFlDZEkLK7HCv5GGv5di5N4R2LCbGPjU1PyAFS/ZXr9Svk+ipf83GDyJMg8 NHN5MMIIwJhZbC9irVv4TmQzOlFzxCIGWCRzIBw50iVokzuLCpXxRUkpgjNQ+wLOwQA5 fH4g9BG5D5BWjcNzxr+UKhc+NEgotWUs4vMyETDrVbwj4QxLiNQX1/vA7nO6lMmdAN9N Ks7z+VTlYkK/4cIVgpCCUfRd/4CLjRcppWC1hSVoqjxaA8/EODSkqcSyyx7DGVrXtClS CFPUFedw0Bc8/SDBlmTiRIrJo4b07jREdLhUu5XljkV58N4YeldOtXrdtcvz3tkFbEv1 3Oxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=+NYlb2pRq/r0z2BzMRiCf5ac+8+3CLg70JHV0Tk8BbM=; b=d9T3NkR53rQR9Hzi8frytQdGdi3iFbEj1zroEQZ9CevM52s4Eyutlsr3tTtk4Zaibv J8StQ7/AygUFWGVesLQCAHpjbq4+Rp+g9AQrqLTXrpbE6QpXu+9p0/TdV9w+OaOwa9Mq eICSHQAHrJjc8OuEwPcqto2EAmA30eKswuxMiURw2DBUgxF7ZL3qJ4RpwBq/98snYs+G HoVONLQW+QjektEPGBHCeOJVUtqqcPZmbmvJrsTCmbAKVpJq7WPkpCvOJrRXphTemDA6 v+nqRYqN9SUYt+vKL1WTfyjSevjYMUbTUYmSayrlyAx9DfgsvWhpCbodumeyxNGQVtyh nAXA== X-Gm-Message-State: AKwxyteuvO0CO1Gb8lvKPLRZJrnxbIyJAcEwBQpN/tp+Ci5V89ALKNpU Yl3hUgPMuvC9vB6FEOCS5Izpbwf9 X-Received: by 10.55.132.5 with SMTP id g5mr24257773qkd.257.1516314612575; Thu, 18 Jan 2018 14:30:12 -0800 (PST) Received: from kudzu.us ([98.122.141.161]) by smtp.gmail.com with ESMTPSA id d123sm5151299qkf.67.2018.01.18.14.30.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 14:30:12 -0800 (PST) Date: Thu, 18 Jan 2018 17:30:10 -0500 From: Jon Mason To: Logan Gunthorpe Cc: linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, Allen.Hubbe@dell.com Subject: Re: [PATCH v2 2/2] ntb_hw_switchtec: Check for alignment of the buffer in mw_set_trans() Message-ID: <20180118223010.GD25893@kudzu.us> References: <20171218182506.5219-1-logang@deltatee.com> <20171218182506.5219-2-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171218182506.5219-2-logang@deltatee.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 18, 2017 at 11:25:06AM -0700, Logan Gunthorpe wrote: > With Switchtec hardware, the buffer used for a memory window must be > aligned to its size (the hardware only replaces the lower bits). In > certain circumstances dma_alloc_coherent() will not provide a buffer > that adheres to this requirement like when using the CMA and > CONFIG_CMA_ALIGNMENT is set lower than the buffer size. > > When we get an unaligned buffer mw_set_trans() should return an error. > We also log an error so we know the cause of the problem. > Applied to ntb-next. Thanks, Jon > Signed-off-by: Logan Gunthorpe > Cc: Jon Mason > --- > > v2: Use IS_ALIGNED macro as suggested by Allen > > drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > index bcd5b6fb3800..6c6f991999b5 100644 > --- a/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > +++ b/drivers/ntb/hw/mscc/ntb_hw_switchtec.c > @@ -320,6 +320,19 @@ static int switchtec_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int widx, > if (xlate_pos < 12) > return -EINVAL; > > + if (!IS_ALIGNED(addr, BIT_ULL(xlate_pos))) { > + /* > + * In certain circumstances we can get a buffer that is > + * not aligned to its size. (Most of the time > + * dma_alloc_coherent ensures this). This can happen when > + * using large buffers allocated by the CMA > + * (see CMA_CONFIG_ALIGNMENT) > + */ > + dev_err(&sndev->stdev->dev, > + "ERROR: Memory window address is not aligned to it's size!\n"); > + return -EINVAL; > + } > + > rc = switchtec_ntb_part_op(sndev, ctl, NTB_CTRL_PART_OP_LOCK, > NTB_CTRL_PART_STATUS_LOCKED); > if (rc) > -- > 2.11.0 > > -- > You received this message because you are subscribed to the Google Groups "linux-ntb" group. > To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com. > To post to this group, send email to linux-ntb@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/20171218182506.5219-2-logang%40deltatee.com. > For more options, visit https://groups.google.com/d/optout.