From owner-svn-src-all@freebsd.org Fri Oct 30 01:19:06 2015 Return-Path: Delivered-To: svn-src-all@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 0CBDCA20A5E; Fri, 30 Oct 2015 01:19:06 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B274F1CCD; Fri, 30 Oct 2015 01:19:05 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9U1J4Lj012883; Fri, 30 Oct 2015 01:19:04 GMT (envelope-from gonzo@FreeBSD.org) Received: (from gonzo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9U1J482012882; Fri, 30 Oct 2015 01:19:04 GMT (envelope-from gonzo@FreeBSD.org) Message-Id: <201510300119.t9U1J482012882@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gonzo set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko Date: Fri, 30 Oct 2015 01:19:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290176 - head/sys/contrib/vchiq/interface/vchiq_arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2015 01:19:06 -0000 Author: gonzo Date: Fri Oct 30 01:19:04 2015 New Revision: 290176 URL: https://svnweb.freebsd.org/changeset/base/290176 Log: Fix BULK read transfer if destination buffer is not cache line-aligned. We can't use copyout because destination memory is userland address in another process but we have reference to respective page so map the page into kernel address space and copy fragments there Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c ============================================================================== --- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c Fri Oct 30 01:18:07 2015 (r290175) +++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c Fri Oct 30 01:19:04 2015 (r290176) @@ -109,6 +109,22 @@ vchiq_dmamap_cb(void *arg, bus_dma_segme *addr = PHYS_TO_VCBUS(segs[0].ds_addr); } +static int +copyout_page(vm_page_t p, size_t offset, void *kaddr, size_t size) +{ + uint8_t *dst; + + dst = pmap_mapdev(VM_PAGE_TO_PHYS(p), PAGE_SIZE); + if (!dst) + return ENOMEM; + + memcpy(dst + offset, kaddr, size); + + pmap_unmapdev((vm_offset_t)dst, PAGE_SIZE); + + return 0; +} + int __init vchiq_platform_init(VCHIQ_STATE_T *state) { @@ -560,15 +576,19 @@ free_pagelist(BULKINFO_T *bi, int actual if (head_bytes > actual) head_bytes = actual; - memcpy((char *)bi->buf, + copyout_page(pages[0], + pagelist->offset, fragments->headbuf, head_bytes); } if ((actual >= 0) && (head_bytes < actual) && (tail_bytes != 0)) { - memcpy((char *)bi->buf + actual - tail_bytes, - fragments->tailbuf, tail_bytes); + + copyout_page(pages[num_pages-1], + (((vm_offset_t)bi->buf + actual) % PAGE_SIZE) - tail_bytes, + fragments->tailbuf, + tail_bytes); } down(&g_free_fragments_mutex);