From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931AbcFGRYd (ORCPT ); Tue, 7 Jun 2016 13:24:33 -0400 Received: from mga11.intel.com ([192.55.52.93]:31471 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755428AbcFGRYb (ORCPT ); Tue, 7 Jun 2016 13:24:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,434,1459839600"; d="scan'208";a="982710217" From: "Jiang, Dave" To: "logang@deltatee.com" , "jdmason@kudzu.us" CC: "Allen.Hubbe@emc.com" , "linux-kernel@vger.kernel.org" , "sudipm.mukherjee@gmail.com" , "arnd@arndb.de" , "john.kading@gd-ms.com" , "linux-ntb@googlegroups.com" Subject: Re: [PATCH v2 2/3] ntb_transport: Check the number of spads the hardware supports Thread-Topic: [PATCH v2 2/3] ntb_transport: Check the number of spads the hardware supports Thread-Index: AQHRwOD/jU1Lclg9gk6rgEZk3LdegZ/etmiA Date: Tue, 7 Jun 2016 17:24:29 +0000 Message-ID: <1465320253.16234.176.camel@intel.com> References: <5757013F.2090401@deltatee.com> <1465320022-4385-1-git-send-email-logang@deltatee.com> In-Reply-To: <1465320022-4385-1-git-send-email-logang@deltatee.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [143.182.137.38] Content-Type: text/plain; charset="utf-8" Content-ID: <18854F9AA3E98D41A40A3B054B6E255C@intel.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u57HObBd032214 On Tue, 2016-06-07 at 11:20 -0600, Logan Gunthorpe wrote: > I'm working on hardware that currently has a limited number of > scratchpad registers and ntb_ndev fails with no clue as to why. I > feel it is better to fail early and provide a reasonable error > message > then to fail later on. > > The same is done to ntb_perf, but it doesn't currently require enough > spads to actually fail. I've also removed the unused SPAD_MSG and > SPAD_ACK enums so that MAX_SPAD accurately reflects the number of > spads used. > > Signed-off-by: Logan Gunthorpe Acked-by: Dave Jiang > --- >  drivers/ntb/ntb_transport.c | 9 +++++++-- >  drivers/ntb/test/ntb_perf.c | 8 ++++++-- >  2 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/drivers/ntb/ntb_transport.c > b/drivers/ntb/ntb_transport.c > index 2ef9d913..6d9940a 100644 > --- a/drivers/ntb/ntb_transport.c > +++ b/drivers/ntb/ntb_transport.c > @@ -1037,6 +1037,13 @@ static int ntb_transport_probe(struct > ntb_client *self, struct ntb_dev *ndev) >   int node; >   int rc, i; >   > + mw_count = ntb_mw_count(ndev); > + if (ntb_spad_count(ndev) < (NUM_MWS + 1 + mw_count * 2)) { > + dev_err(&ndev->dev, "Not enough scratch pad > registers for %s", > + NTB_TRANSPORT_NAME); > + return -EIO; > + } > + >   if (ntb_db_is_unsafe(ndev)) >   dev_dbg(&ndev->dev, >   "doorbell is unsafe, proceed anyway...\n"); > @@ -1052,8 +1059,6 @@ static int ntb_transport_probe(struct > ntb_client *self, struct ntb_dev *ndev) >   >   nt->ndev = ndev; >   > - mw_count = ntb_mw_count(ndev); > - >   nt->mw_count = mw_count; >   >   nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), > diff --git a/drivers/ntb/test/ntb_perf.c > b/drivers/ntb/test/ntb_perf.c > index 30635c8..4368519 100644 > --- a/drivers/ntb/test/ntb_perf.c > +++ b/drivers/ntb/test/ntb_perf.c > @@ -143,8 +143,6 @@ enum { >   VERSION = 0, >   MW_SZ_HIGH, >   MW_SZ_LOW, > - SPAD_MSG, > - SPAD_ACK, >   MAX_SPAD >  }; >   > @@ -696,6 +694,12 @@ static int perf_probe(struct ntb_client *client, > struct ntb_dev *ntb) >   int node; >   int rc = 0; >   > + if (ntb_spad_count(ntb) < MAX_SPAD) { > + dev_err(&ntb->dev, "Not enough scratch pad registers > for %s", > + DRIVER_NAME); > + return -EIO; > + } > + >   node = dev_to_node(&pdev->dev); >   >   perf = kzalloc_node(sizeof(*perf), GFP_KERNEL, node); > --  > 2.1.4 >