Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4176287pxb; Mon, 1 Feb 2021 14:47:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlOgULVNn1Tl4kiNERtJAVEHhOilY+uicNq9vmDSTWgalD4TKIr9P/QtjJa3EV5e8/WnCl X-Received: by 2002:a17:906:fa18:: with SMTP id lo24mr7497915ejb.221.1612219650520; Mon, 01 Feb 2021 14:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612219650; cv=none; d=google.com; s=arc-20160816; b=tceHncd5HmTqlKHVJ/7DldFQh+egznBkKky03nbQtg2hLLsvo3PQGdMj0W3KIc0NuK WEiCTN3BFvZbUzx+oDFc6eF/w12VjjBjg4GV6+uxTwCiQAmSvwqS6y5lUw7plWiZD8Fu ss3RJnSlj3aUbbYOA+JqcdvzXqAlwFLSbKxzV9hRUWy1kFrOX4yvjDUi710YOp19Fkpp gqfgU4mB4XYx2tmOmuO2dEWUH0zm0IAxjZA40/qKCIweh5AwaVQ4f13SoCQzpYLqQO8C vcPkrUcE//8ZbKfTsrGCfVq9YcHNFJtQ9yaoE0uJBzHRsB+0GNkGp7tIoF/9fH6Jvr4o EtKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=h/+HtgkOHaN53M4LuNqNMv860b//jMIWAHV66x1z8DM=; b=lZr3tKlRMJxfwrcaGJG2fdK0mG/3NFrGWIZBQdbkQgr6VHFwD277mTOGXLmoVqiV+Z Tp2e3ZCbN2gO1SREUoGhB85G4EP9xOWAfKmEDa921IBMq5Y54UMiq1/6aXMIrFMH0+SL dwKYDsAwaHc1e6CpBbOgwjGUYHuF3eni+3dQUuGuL+LkWOM7BuJoukUEgoYo8zh1tV/J TKMA3TRq/BfmMOOkgUucNX998qf+MKlxZ2N8c4+KntpO6JPVe562xlUZ/7X8UK6qQ6gs bSTQHYFBxP/G5eM9KlDMj6ZaeFfEa0xjjoZ7OgjIPIsZrEda0bvd2Yz0RQ6eFLWqXAwQ LjAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GCYQ0iKI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr32si11380113ejc.128.2021.02.01.14.47.06; Mon, 01 Feb 2021 14:47:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GCYQ0iKI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbhBAWps (ORCPT + 99 others); Mon, 1 Feb 2021 17:45:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbhBAWpm (ORCPT ); Mon, 1 Feb 2021 17:45:42 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0D60C061573 for ; Mon, 1 Feb 2021 14:45:02 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id md11so565947pjb.0 for ; Mon, 01 Feb 2021 14:45:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=h/+HtgkOHaN53M4LuNqNMv860b//jMIWAHV66x1z8DM=; b=GCYQ0iKIZ9oD9vYcGpW5ZOQ/O5nsYJSqzH5AGdGh8eOBnUbO6bzHxqCPwFibUMOW5J i/w7oZoci7HhotmzTmg6VKuWbBghTXOATU21p4KFsx3EI2N3eD4xRD0Jaj64e7I5CGgG HZKTkMSvUMXMQt6go7kszGvPeXEy6wyy37gpj80BORjuITag5J5qdaFP9Fwc9O16AcMY axE/+WMqnylWtL9wbd6HcYk8H7xDqgyvn176ixZnqnox96WzBVqZ1ttTU8b3K0KAKTIw a7Uuop8cPXJbIrsFx1taMhJglMPxhVjp7GqGA3mdcEnJCf2euWI3cnmdOAcZDfTLMW/X Wc9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=h/+HtgkOHaN53M4LuNqNMv860b//jMIWAHV66x1z8DM=; b=UX67R4oocATtC+LHG9S6r/7rBHOrBYJ+NBTFyz9NB6/wsJ5pSPKDuc4x0w8FgQwDrS 4q0OWwS9vVk6LlL215fBg5QawVr8lLxD0JrX1sp7ZRqSx91EAZKJm8HvJIs649/uxTHf e2dKeBse7FG4UlrWzmhYtC5Xp0qV7nT3nV0a5xig/wy9vcuWgKi9PnctDwz3tumEjPph so2G2FV/ey8Z4JMBxELpvo3k0wTI1G0CIAjnk1iT72akraVge6tRBD+OBVqtmqPcU47I plZYa4iuxM94+qz9N8DxYlxWx9IKIRgaMkwfTqlbgVt8WqMBkPdsriutipwZkMgcH1UD jKyg== X-Gm-Message-State: AOAM530iaWgGsutJWbF4EphnJnhlY9Pqz0SsVk7LOIfJv2rLUohAwULh ZnW0cxkM3TrmS3uLWvFFY7vsNw== X-Received: by 2002:a17:90a:bf06:: with SMTP id c6mr1053237pjs.220.1612219502048; Mon, 01 Feb 2021 14:45:02 -0800 (PST) Received: from [2620:15c:17:3:4a0f:cfff:fe51:6667] ([2620:15c:17:3:4a0f:cfff:fe51:6667]) by smtp.gmail.com with ESMTPSA id b17sm19787823pfp.167.2021.02.01.14.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 14:45:01 -0800 (PST) Date: Mon, 1 Feb 2021 14:45:00 -0800 (PST) From: David Rientjes To: Ben Widawsky cc: linux-cxl@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Chris Browy , Christoph Hellwig , Dan Williams , Ira Weiny , Jon Masters , Jonathan Cameron , Rafael Wysocki , Randy Dunlap , Vishal Verma , daniel.lll@alibaba-inc.com, "John Groves (jgroves)" , "Kelley, Sean V" Subject: Re: [PATCH 03/14] cxl/mem: Find device capabilities In-Reply-To: <20210201223314.qh24uxd7ajdppgfl@intel.com> Message-ID: References: <20210130002438.1872527-1-ben.widawsky@intel.com> <20210130002438.1872527-4-ben.widawsky@intel.com> <234711bf-c03f-9aca-e0b5-ca677add3ea@google.com> <20210201165352.wi7tzpnd4ymxlms4@intel.com> <32f33dd-97a-8b1c-d488-e5198a3d7748@google.com> <20210201215857.ud5cpg7hbxj2j5bx@intel.com> <20210201222859.lzw3gvxuqebukvr6@intel.com> <20210201223314.qh24uxd7ajdppgfl@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Feb 2021, Ben Widawsky wrote: > > > > > > > > +static int cxl_mem_setup_mailbox(struct cxl_mem *cxlm) > > > > > > > > +{ > > > > > > > > + const int cap = cxl_read_mbox_reg32(cxlm, CXLDEV_MB_CAPS_OFFSET); > > > > > > > > + > > > > > > > > + cxlm->mbox.payload_size = > > > > > > > > + 1 << CXL_GET_FIELD(cap, CXLDEV_MB_CAP_PAYLOAD_SIZE); > > > > > > > > + > > > > > > > > + /* 8.2.8.4.3 */ > > > > > > > > + if (cxlm->mbox.payload_size < 256) { > > > > > > > > + dev_err(&cxlm->pdev->dev, "Mailbox is too small (%zub)", > > > > > > > > + cxlm->mbox.payload_size); > > > > > > > > + return -ENXIO; > > > > > > > > + } > > > > > > > > > > > > > > Any reason not to check cxlm->mbox.payload_size > (1 << 20) as well and > > > > > > > return ENXIO if true? > > > > > > > > > > > > If some crazy vendor wanted to ship a mailbox larger than 1M, why should the > > > > > > driver not allow it? > > > > > > > > > > > > > > > > Because the spec disallows it :) > > > > > > > > I don't see it being the driver's responsibility to enforce spec correctness > > > > though. In certain cases, I need to use the spec, like I have to pick /some/ > > > > mailbox timeout. For other cases... > > > > > > > > I'm not too familiar with what other similar drivers may or may not do in > > > > situations like this. The current 256 limit is mostly a reflection of that being > > > > too small to even support advertised mandatory commands. So things can't work in > > > > that scenario, but things can work if they have a larger register size (so long > > > > as the BAR advertises enough space). > > > > > > > > > > I don't think things can work above 1MB, either, though. Section > > > 8.2.8.4.5 specifies 20 bits to define the payload length, if this is > > > larger than cxlm->mbox.payload_size it would venture into the reserved > > > bits of the command register. > > > > > > So is the idea to allow cxl_mem_setup_mailbox() to succeed with a payload > > > size > 1MB and then only check 20 bits for the command register? > > > > So it's probably a spec bug, but actually the payload size is 21 bits... I'll > > check if that was a mistake. > > Well I guess they wanted to be able to specify 1M exactly... Spec should > probably say you can't go over 1M > I think that's what 8.2.8.4.3 says, no? And then 8.2.8.4.5 says you can use up to Payload Size. That's why my recommendation was to enforce this in cxl_mem_setup_mailbox() up front.