From owner-freebsd-drivers@freebsd.org Sun May 29 09:52:43 2016 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 E1DBAB4F0B7 for ; Sun, 29 May 2016 09:52:43 +0000 (UTC) (envelope-from prateekrootkey@gmail.com) Received: from mail-vk0-x241.google.com (mail-vk0-x241.google.com [IPv6:2607:f8b0:400c:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9DB2518B0; Sun, 29 May 2016 09:52:43 +0000 (UTC) (envelope-from prateekrootkey@gmail.com) Received: by mail-vk0-x241.google.com with SMTP id m81so13489755vka.0; Sun, 29 May 2016 02:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=ilkomhO9muKrCGZjNe6dP4bvD6B3SDn+EPQAs2GhTK0=; b=ajSMM5NAlWVlGtcwO7Pdbr9jVeKVay1BHPBaO/knhkoA4LYD8iTNLIOeBSu65PWrND iL9+TZhh177iei+HAuIuOJUj0d/Uy8yBriqSqeMef3JRbHt3o6nxVAVS79tFr7X8M9LA o3H/WApxlumUkOmRtCkjeRYu2Dh6gc4mb/+076+8F9wYevLtY/RvEcjKgvbHQlib7bD/ 6rmox29WihBIthq4m48FVp4/EXaVMD5tv3tper/FcUacJre2v36Q76t3yUpCk94NFb63 AJ9RGFHBtAqoIQajUlnXThzKXkBpo+r+WoNGUz5Y4P7gH0Ne7FauAb3YKxNskBnOBC56 PvKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=ilkomhO9muKrCGZjNe6dP4bvD6B3SDn+EPQAs2GhTK0=; b=fh6e90XexnSbkgQKsSoShMOeU34MWidxKm3fzpAnetmjHH93iatPwPbp+BxsKFQpiv OaPOyzZKf1Q7RMviN9Nn6J08vXhce2FbnatkFU7FHa+rY2dQAXDSib1opQtG8x7YTrud hmAv9ldzkSuXluc7SGVkx2VLUPNw7mNgLGc0Ek2iT1HyzvW+aq13B3+sKqZLMSryCZmW ypWF3f2qbpkMro5096uIsvsDRqqFw7YLufcl08A/wTYysR8xxU6YkVKB6e3T/xmXcPRp 2uIjRbUpKoefBhpPn1o3aNyec14J+wlj9dnAN+35rlBFwTfx1vStJkD13lfBblFa6zn4 Yvqg== X-Gm-Message-State: ALyK8tIVWCNzLQ+jbw6AeGzORyv+g5TZSva+4hFTJ0WDdpwMrOUCQij/0d9aWvJOxsEw9Pe28u0O6EELTeW0Ww== MIME-Version: 1.0 X-Received: by 10.31.167.84 with SMTP id q81mr12679286vke.51.1464515562723; Sun, 29 May 2016 02:52:42 -0700 (PDT) Received: by 10.176.0.148 with HTTP; Sun, 29 May 2016 02:52:42 -0700 (PDT) In-Reply-To: References: Date: Sun, 29 May 2016 15:22:42 +0530 Message-ID: Subject: Re: mps reinitialization triggered system panic From: prateek sethi To: freebsd-drivers@freebsd.org, scottl@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 May 2016 09:52:44 -0000 I have fix this issue by doing multiple retries for mps request sync in case of failure. According to my test results almost 15% changes are there to hit this issue without using this fix. Which is certainly not a good ratio. Please comment if anything is wrong in this. Index: mps.c =================================================================== --- mps.c (revision 2474) +++ mps.c (working copy) @@ -986,8 +985,8 @@ { MPI2_DEFAULT_REPLY *reply; MPI2_IOC_FACTS_REQUEST request; - int error, req_sz, reply_sz; - + int error, req_sz, reply_sz, retry = 0; + MPS_FUNCTRACE(sc); req_sz = sizeof(MPI2_IOC_FACTS_REQUEST); @@ -996,8 +995,13 @@ bzero(&request, req_sz); request.Function = MPI2_FUNCTION_IOC_FACTS; - error = mps_request_sync(sc, &request, reply, req_sz, reply_sz, 5); - + while(retry < 5){ + error = mps_request_sync(sc, &request, reply, req_sz, reply_sz, 5); + if(!error) + break; + mps_dprint(sc, mps_request_sync is failed retry %d\n",retry); + retry++; + } return (error); } @@ -1006,7 +1010,7 @@ { MPI2_IOC_INIT_REQUEST init; MPI2_DEFAULT_REPLY reply; - int req_sz, reply_sz, error; + int req_sz, reply_sz, error, retry = 0; struct timeval now; uint64_t time_in_msec; @@ -1041,11 +1045,16 @@ time_in_msec = (now.tv_sec * 1000 + now.tv_usec/1000); init.TimeStamp.High = htole32((time_in_msec >> 32) & 0xFFFFFFFF); init.TimeStamp.Low = htole32(time_in_msec & 0xFFFFFFFF); + while(retry < 5){ + error = mps_request_sync(sc, &init, &reply, req_sz, reply_sz, 5); + if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS) + error = ENXIO; + if(!error) + break; + mps_dprint(sc, MPS_FAULT, " mps_request_sync is failed retry %d\n",retry); + retry++; + } - error = mps_request_sync(sc, &init, &reply, req_sz, reply_sz, 5); - if ((reply.IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS) - error = ENXIO; - mps_dprint(sc, MPS_INIT, "IOCInit status= 0x%x\n", reply.IOCStatus); return (error); } On Tue, Apr 12, 2016 at 6:43 PM, prateek sethi wrote: > I am using LSI SAS2308 HBA card with freebsd 9.2. My system got panic > during mps reinitialization process. I tried to debug the core and found > that driver was failed to allocate iocfacts, triggered this panic. I also > got "*Doorbell failed to activate*" message in the core file. > > Please help me to find the answers of some questions like:- > > 1. What can be the reasons for Doorbell activation failure? > 2. How I can fix this issue? > 3. If it is a H/w issue, how it can be fixed after reboot? > 4. *Why a driver failure should panic a system?* > > > I think panic is not a good option to get recover from some error. There > should be some another way to handle this failure. > > I am a beginner for the drivers and if I am predicting or asking something > wrong please correct me. > > > Regards > Prateek >