Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5664755ybn; Sun, 29 Sep 2019 03:14:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTQVWz0Gnf1wE9eOcrLdy0l+F/AFuBx2JhEqABGmwEfZvpMXK1sgy5U2s3Ec1mu380/d5F X-Received: by 2002:aa7:c743:: with SMTP id c3mr14099908eds.241.1569752070806; Sun, 29 Sep 2019 03:14:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569752070; cv=none; d=google.com; s=arc-20160816; b=ltFxcVRsOw3KkfpFoof2cNEjv7ZIeNmcZ/vlin4BowJyqfJAw2t+LNFz++QU5cfMMO 1Oo4GGtmRtudkuCwyEY7yJ1SMgBs/O91xz9nC3a7Vko5E0Ud8rVOlpfaNhkwys/DyA5j fiwfe+0jEZet7qJ+CkeuolsXEGqy2KmssKS2RNB5Tmso+E3IIdUxdS6CVmisv7bEilq5 usWsXpy57R3srJQjuODmkcIIVFW7/1rezC8jhbuC9X0CrfHb+65/2TxzLlC1jg2ifEVB FSgeXcFN36GhVmuvsnkvVXYGGUc+gqt8A7heXKYWxnH84sauz5gJyhIxnmjfb/bBRL1l 3b+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fzz1vU8mGE8FmPTvtRGscJAFxkifmyeCm2r3TAVRE80=; b=eASl+UL3lZyyzGbcr8Luk+r8HTr8sbYfaIYNN23GxUxN/KBmy0oGEWmR2cCepB9zpE IC+6h23lQKBflXtXOGUeRNVdSuDm5aoM0WsRE7yAJXZyBOvTUNFGKDNDJGY+WuCDs5UJ NCHTpF9XNuSwy3HFdciREcRVIoDoIp9IV/RD9VwDGNphdN9eQygfiHN3uKsevjGLsIoe PYT/yXuly168i1vAfAF+lYtuIs05lswNnZH/LzdjBV8GXd9q63DoLMbtajmLqYmr5azj oOUbAYuP+XuuCS4mmfR9YhRvvRoP7jNI8jnLWYQF8KE9jWyGADeqBikq+UpFh/m8v6+l 4/cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UsimsHhg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x25si4819389edr.128.2019.09.29.03.14.06; Sun, 29 Sep 2019 03:14:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UsimsHhg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728962AbfI2KM6 (ORCPT + 99 others); Sun, 29 Sep 2019 06:12:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:48956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbfI2KM6 (ORCPT ); Sun, 29 Sep 2019 06:12:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91A76207FA; Sun, 29 Sep 2019 10:12:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569751977; bh=iA59w1NaMEWbdMwVd9RqjRIthDIUAHLMrP7xRK9GzCM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UsimsHhgmGlkho9Zjk2InZF3otI2sYSWm269oaYYRMVvh3u8CR0xguJunZyBa0UxB 3FDThahbn9TSTlk93/fEXsvg5XkBgKbbrKkyd/dSytBUu+/o7a4kEhQuuI/jL3Vztg 6VPLj7yBmwHhmYUr0BBy+/qBPnRldE5+7QGDRu8U= Date: Sun, 29 Sep 2019 12:12:54 +0200 From: Greg KH To: jun.zhang@intel.com Cc: labbott@redhat.com, sumit.semwal@linaro.org, arve@android.com, tkjos@android.com, maco@android.com, joel@joelfernandes.org, christian@brauner.io, devel@driverdev.osuosl.org, Jie A , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, he@osuosl.org, Bai@osuosl.org, bo Subject: Re: [PATCH] ion_system_heap: support X86 archtecture Message-ID: <20190929101254.GA1907778@kroah.com> References: <20190929072841.14848-1-jun.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190929072841.14848-1-jun.zhang@intel.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 29, 2019 at 03:28:41PM +0800, jun.zhang@intel.com wrote: > From: zhang jun > > we see tons of warning like: > [ 45.846872] x86/PAT: NDK MediaCodec_:3753 map pfn RAM range req > write-combining for [mem 0x1e7a80000-0x1e7a87fff], got write-back > [ 45.848827] x86/PAT: .vorbis.decoder:4088 map pfn RAM range req > write-combining for [mem 0x1e7a58000-0x1e7a58fff], got write-back > [ 45.848875] x86/PAT: NDK MediaCodec_:3753 map pfn RAM range req > write-combining for [mem 0x1e7a48000-0x1e7a4ffff], got write-back > [ 45.849403] x86/PAT: .vorbis.decoder:4088 map pfn RAM range > req write-combining for [mem 0x1e7a70000-0x1e7a70fff], got write-back > > check the kernel Documentation/x86/pat.txt, it says: > A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range, > vm_insert_pfn > Drivers wanting to export some pages to userspace do it by using > mmap interface and a combination of > 1) pgprot_noncached() > 2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn() > With PAT support, a new API pgprot_writecombine is being added. > So, drivers can continue to use the above sequence, with either > pgprot_noncached() or pgprot_writecombine() in step 1, followed by step 2. > > In addition, step 2 internally tracks the region as UC or WC in > memtype list in order to ensure no conflicting mapping. > > Note that this set of APIs only works with IO (non RAM) regions. > If driver ants to export a RAM region, it has to do set_memory_uc() or > set_memory_wc() as step 0 above and also track the usage of those pages > and use set_memory_wb() before the page is freed to free pool. > > the fix follow the pat document, do set_memory_wc() as step 0 and > use the set_memory_wb() before the page is freed. > > Signed-off-by: he, bo > Signed-off-by: zhang jun > Signed-off-by: Bai, Jie A > --- > drivers/staging/android/ion/ion_system_heap.c | 28 ++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c > index b83a1d16bd89..d298b8194820 100644 > --- a/drivers/staging/android/ion/ion_system_heap.c > +++ b/drivers/staging/android/ion/ion_system_heap.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #include "ion.h" > > @@ -134,6 +135,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap, > sg = table->sgl; > list_for_each_entry_safe(page, tmp_page, &pages, lru) { > sg_set_page(sg, page, page_size(page), 0); > + > +#ifdef CONFIG_X86 > + if (!(buffer->flags & ION_FLAG_CACHED)) > + set_memory_wc((unsigned long)page_address(sg_page(sg)), > + PAGE_ALIGN(sg->length) >> PAGE_SHIFT); > +#endif There is no way to do this without these #ifdefs? That feels odd, why can't you just always test for this? thanks, greg k-h