Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5051993ybl; Mon, 9 Dec 2019 22:55:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxkc3eBIKWRzOysKKv8Z2hayarvQXYtm2Av+X19vBtMAK5RKpwJN/eA+CaH/FP71lUy+Hx2 X-Received: by 2002:aca:af54:: with SMTP id y81mr2614438oie.154.1575960944087; Mon, 09 Dec 2019 22:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575960944; cv=none; d=google.com; s=arc-20160816; b=U+tajPrmYFE0nEfRt0oA8FxoGIj6rN/HoZjKICdUC6ouvYbKDnbn1kAi2xFfiwgEUZ 7K2WmUbYO2699AOjIEv/KY++OxexjnUvhfYwwsF2yoGgZL7m63gQtrEqVagwjIt3o9x/ gKd4oYyP0JX1NuC/PvOQOwkTas9MOubfjzx+2mD5n1eLKF+yBfEpek8I7rLswOYdGjrN nyjkb8yQiE4buT8R7nQ4iCyRiris+a/qtXmuSwQ8AN6g+VUNscVi0f+nsUKqmmuY9E+h BAqicU70B0zF/2zOUggJ95h2SuqPKL+YeEZbwRCmq6z0nwpbvRydmj7xhLOGegLRGelb dwDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gu0tI1Ph2fkGTpOQyVLmgqpol4E6X/tEFsGWyYePxFo=; b=rvTWFmWS6qIAYVYuPCt4fdd0TND1I4V+ulC7Fbz5f0vCS5XE+0KE3YsVgosEzb39n0 D4AziFeS0MMqUT86reN2fzLwO5alNIQdaQ5YIZCNcG2VqtiabZhFRV5Gttd15aZWQ0uI EiiuUavMCiFNPWGAHl0fB1LBg2Pg05L+lYEPJowphS160pEkfe8G69c4zvOFB5+DCttK nxiv/HfD/WJZp9hWHr9tOk9TXYmPY0s2ICGfGoZmDY5vv3CG4Ue5wCdXjP09ySYk+GqY aaUNEmm+1ZIOiNPl+ZCOW0AhPcSjefk9MJrGsOJ87IS/2zxIfg9TJPPvpcK4n5mV96O/ P5FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EOSodPBv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12si1454110otm.261.2019.12.09.22.55.31; Mon, 09 Dec 2019 22:55:44 -0800 (PST) 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=@chromium.org header.s=google header.b=EOSodPBv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727272AbfLJGyh (ORCPT + 99 others); Tue, 10 Dec 2019 01:54:37 -0500 Received: from mail-il1-f195.google.com ([209.85.166.195]:38344 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727137AbfLJGyg (ORCPT ); Tue, 10 Dec 2019 01:54:36 -0500 Received: by mail-il1-f195.google.com with SMTP id u17so15190589ilq.5 for ; Mon, 09 Dec 2019 22:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gu0tI1Ph2fkGTpOQyVLmgqpol4E6X/tEFsGWyYePxFo=; b=EOSodPBvj8YO5TUFc/w6bgKtErmFN3IADsXNow5Dn0RDaYlWV7fzSalNujYqj+W7Ea vMcGDUeAqyOAVmkKnYSXWKOxwdUL/+YXgTVZxijs49Qm2F7s93h2rj9jtq2Kg+VQKc5w mYKfcvW9cULBVw3OI8imSJXJMYD/oWIajIlnU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gu0tI1Ph2fkGTpOQyVLmgqpol4E6X/tEFsGWyYePxFo=; b=Jv8ak4yf4ORvD+p4A+n2uZfgJPWK2VKWPTT67KPAWAJvD5oPnnIrijq+xIGy7gbBlc aZWGjxquDXlLPyXPKmv2L1or+aG7IoS++SUXiBo9XyypWlU5ty4tfSWfBB5ybZvzs1DJ vlPRIiEdaNLWWWQf6acSJy2qin5Y8caX4DzUKT7JtTa4eAdy4zEAZMHhdyPWju/b9Ma/ PL1UHmgqtAxaytyCOO8NYRkF301Yg/MzkdSD9iLallZSJJ4tT86/lr3F+dITucSGmWJ/ ZrjSFmX9ZVyoy4aFYUENl+Y67s7ahIxG3bbbGJvkF9CwKXXD7eQEjucJzHc6nw9Kneb8 qkDw== X-Gm-Message-State: APjAAAW4flrI+AbrckR82QispD8w9FeboY9UD0t5Z6guxF9WcoHfj7AP ItOLvGAsrSkUhoYt7ukvFhfTfFxcfX573ap5K1tvdQ== X-Received: by 2002:a92:5c47:: with SMTP id q68mr25325970ilb.41.1575960875769; Mon, 09 Dec 2019 22:54:35 -0800 (PST) MIME-Version: 1.0 References: <20191128125100.14291-1-patrick.rudolph@9elements.com> <20191128125100.14291-2-patrick.rudolph@9elements.com> In-Reply-To: <20191128125100.14291-2-patrick.rudolph@9elements.com> From: Julius Werner Date: Mon, 9 Dec 2019 22:54:23 -0800 Message-ID: Subject: Re: [PATCH v3 1/2] firmware: google: Expose CBMEM over sysfs To: Patrick Rudolph Cc: LKML , Greg Kroah-Hartman , Thomas Gleixner , Allison Randal , Alexios Zavras , Stephen Boyd , Samuel Holland , Julius Werner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +static int cbmem_probe(struct coreboot_device *cdev) > +{ > + struct device *dev = &cdev->dev; > + struct cb_priv *priv; > + int err; > + > + priv = kzalloc(sizeof(*priv), GFP_KERNEL); > + if (!priv) > + return -ENOMEM; > + > + memcpy(&priv->entry, &cdev->cbmem_entry, sizeof(priv->entry)); > + > + priv->remap = memremap(priv->entry.address, > + priv->entry.entry_size, MEMREMAP_WB); We've just been discussing some problems with CBMEM areas and memory mapping types in Chrome OS. CBMEM is not guaranteed to be page-aligned (at least not the "small" entries), but the kernel can only assign memory attributes for a page at a time (and refuses to map the same area twice with two different memory types, for good reason). So if CBMEM entries sharing a page are mapped as writeback by one driver but uncached by the other, things break. There are some CBMEM entries that need to be mapped uncached (e.g. the ACPI UCSI table, which isn't even handled by anything using this CBMEM code) and others for which it would make more sense (e.g. the memory console, where firmware may add more lines at runtime), but I don't think there are any regions that really *need* to be writeback. None of the stuff accessing these areas should access them often enough that caching matters, and I think it's generally more common to map firmware memory areas as uncached anyway. So how about we standardize on mapping it all uncached to avoid any attribute clashes? (That would mean changing the existing VPD and memconsole drivers to use ioremap(), too.)