From owner-svn-src-head@FreeBSD.ORG Sun Jun 26 16:11:36 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8CA6F106566B; Sun, 26 Jun 2011 16:11:36 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 637D78FC08; Sun, 26 Jun 2011 16:11:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5QGBadc059155; Sun, 26 Jun 2011 16:11:36 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5QGBa2A059153; Sun, 26 Jun 2011 16:11:36 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201106261611.p5QGBa2A059153@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 26 Jun 2011 16:11:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r223571 - head/sys/powerpc/ofw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jun 2011 16:11:36 -0000 Author: nwhitehorn Date: Sun Jun 26 16:11:36 2011 New Revision: 223571 URL: http://svn.freebsd.org/changeset/base/223571 Log: Add better error handling for RTAS calls. These can potentially cause machine checks (e.g. invalid PCI configuration cycles), but these can be caught and recovered from. This change also the RTAS PCI driver to work without modification as a replacement for the Grackle driver on Grackle-based Powermacs. Modified: head/sys/powerpc/ofw/rtas.c Modified: head/sys/powerpc/ofw/rtas.c ============================================================================== --- head/sys/powerpc/ofw/rtas.c Sun Jun 26 15:08:14 2011 (r223570) +++ head/sys/powerpc/ofw/rtas.c Sun Jun 26 16:11:36 2011 (r223571) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -39,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -60,6 +62,8 @@ int rtascall(vm_offset_t callbuffer, uin extern uintptr_t rtas_entry; extern register_t rtasmsr; +int setfault(faultbuf); /* defined in locore.S */ + /* * After the VM is up, allocate RTAS memory and instantiate it */ @@ -188,6 +192,7 @@ int rtas_call_method(cell_t token, int nargs, int nreturns, ...) { vm_offset_t argsptr; + faultbuf env; va_list ap; struct { cell_t token; @@ -213,7 +218,19 @@ rtas_call_method(cell_t token, int nargs args.args_n_results[n] = va_arg(ap, cell_t); argsptr = rtas_real_map(&args, sizeof(args)); - result = rtascall(argsptr, rtas_private_data); + + /* Get rid of any stale machine checks that have been waiting. */ + __asm __volatile ("sync; isync"); + if (!setfault(env)) { + __asm __volatile ("sync"); + result = rtascall(argsptr, rtas_private_data); + __asm __volatile ("sync; isync"); + } else { + result = RTAS_HW_ERROR; + } + curthread->td_pcb->pcb_onfault = 0; + __asm __volatile ("sync"); + rtas_real_unmap(argsptr, &args, sizeof(args)); mtx_unlock(&rtas_mtx);