From owner-freebsd-drivers@freebsd.org Thu Aug 17 20:54:17 2017 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3C91DD67AA for ; Thu, 17 Aug 2017 20:54:17 +0000 (UTC) (envelope-from Kinjal.Patel@taec.toshiba.com) Received: from mailhost.taec.toshiba.com (mailhost.taec.com [209.243.128.33]) by mx1.freebsd.org (Postfix) with ESMTP id 902CD6443B for ; Thu, 17 Aug 2017 20:54:17 +0000 (UTC) (envelope-from Kinjal.Patel@taec.toshiba.com) Received: from EXMAIL1.taec.toshiba.com (unknown [209.243.133.250]) by mailhost.taec.toshiba.com (Postfix) with ESMTP id 6C32CA0756 for ; Thu, 17 Aug 2017 13:45:39 -0700 (PDT) Received: from EXMAIL2.taec.toshiba.com (209.243.166.31) by EXMAIL1.taec.toshiba.com (209.243.172.198) with Microsoft SMTP Server (TLS) id 14.3.123.3; Thu, 17 Aug 2017 13:45:38 -0700 Received: from EXMAIL1.taec.toshiba.com ([169.254.1.230]) by EXMAIL2.taec.toshiba.com ([169.254.2.30]) with mapi id 14.02.0347.000; Thu, 17 Aug 2017 13:45:39 -0700 From: Kinjal Patel To: "freebsd-drivers@freebsd.org" Subject: NVMe driver init sequence Thread-Topic: NVMe driver init sequence Thread-Index: AdMXlSp3BhHvaAmDQQG9NyRAc27kig== Date: Thu, 17 Aug 2017 20:45:38 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.93.33.62] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Aug 2017 20:54:17 -0000 Hi, I have a query on NVMe driver init sequence in FreeBSD 10.3(stable). The driver init sequence is, 1) Enable controller (CC.EN=3D1) 2) Wait for controller ready (CSTS.RDY=3D1) 3) Set PCI bus master enable (BME=3D1) As per NVMe spec, when NVMe controller becomes ready it has to process comm= and. "Enable (EN): When set to '1', then the controller shall process commands b= ased on Submission Queue Tail doorbell writes" And per PCI Express spec when BME is not set, the PCI Express Function is n= ot allowed to issue any Memory or I/O requests. "Bus Master Enable - Controls the ability of a PCI Express Endpoint to issu= e Memory95 and I/O Read/Write Requests, and the ability of a Root or Switch Port to forward Memory and I/O Read/Write R= equests in the Upstream direction" Enabling controller before setting BME=3D1 is violation of spec, as control= ler has to accept commands but BME is prerequisite for that. The Linux device driver init sequence is, 1) Set PCI bus master enable (BME=3D1) 2) Enable Controller (CC.EN=3D1) 3) Wait for controller ready (CSTS.RDY=3D1) The FreeBSD NVMe driver sequence should be changed to set BME=3D1 before at= tempting to enable controller. Regards, Kinjal Patel