Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4166118pxb; Mon, 1 Feb 2021 14:26:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJypZgklaHR2GS9vP26F9weNIdkVBlEbAXji3gT68H9G6JsC4O6fOTZSmyxvTBvsCDFJWOu3 X-Received: by 2002:a17:907:7605:: with SMTP id jx5mr2776545ejc.340.1612218404663; Mon, 01 Feb 2021 14:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612218404; cv=none; d=google.com; s=arc-20160816; b=WfEsYRmlRQ5/8jtpnaB6bVx1/OH+BpPQBWmDQysJEkh1TZQJH5L2NE9h7mXV+/yHmy ibR8AISgOxdVCpjpZPfkZzovu4WBC5QmUfDI3n62Tc4BdgeOuXFBm17EOF/x67n6629g RhGcj6hxlSHDWNo74vSY7ODZTCBsd/HUGuEPW5byCCT6dGJmPx/55m20wno26kNo+2c0 oeX84TadnXxDc1H3NDEF1tJrqP3PlrM/EQCJeWh8xlw0XnLJqneEilKN/GVkYXKNGtHQ A9eVXYXFf38kpNBBs3o7ofAPrQliG1Gq7Ib7VN9cgEfuMEBr/77B1Pet7/ohSmMePyvP 70DA== 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=bFIvq1iUBnF2uNTg/XXudUmq/LzMkpvkSS7sgQp5FVU=; b=ByjXsMXJPFoZXFYTqFxFMQICA7du2rwxjhtPIJSMG3FSSHU0S2sVJTbjAvLyMBPxu2 pLe4HQdZDye47qkUB3hxWDB2NehKjiMSTvmRn1sz0589Ob0M05si8oGwZkk9Obt2dxOC +g+SjI/EycskF7NuZU3y1HDO75zOKzUGAhDGxq8JUycdUksvD2MdI+MIG2kasreDpRyu fjTLsXQlEAAsvEB1SmEcPz4HTJt2d6NeAqObKSVkzvBqtajNK2lTVvnt47OwYGrJu9mI INAQo/REHdIcjlmYp0yXsC0DcSdyWBNU20UBIA0+8wxRIiSwCuTctQliH3SagTRb1I9Q gYDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DGUMvsvg; 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 o16si11690129eds.116.2021.02.01.14.26.19; Mon, 01 Feb 2021 14:26:44 -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=DGUMvsvg; 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 S229542AbhBAWYc (ORCPT + 99 others); Mon, 1 Feb 2021 17:24:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbhBAWYa (ORCPT ); Mon, 1 Feb 2021 17:24:30 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFFC5C0613D6 for ; Mon, 1 Feb 2021 14:23:49 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id gx20so549286pjb.1 for ; Mon, 01 Feb 2021 14:23:49 -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=bFIvq1iUBnF2uNTg/XXudUmq/LzMkpvkSS7sgQp5FVU=; b=DGUMvsvgtCsyOu5/4Ulasc7oslinB5t/JcszBUeqsrg01SmgO7CuSlAkMTB+IVPDpp +IMl/nxtXmJKqcIhqAuXke2BJIs0HW5Yg58xHGDP76qtLt4qwzAY1MRtIQHLT1+Aq5NR CV3XEEpjX5pMeXelmer6a1LbnGUxAaQdbTRN0p4wkVDvcm62X3B3VBkeA9U/4fwuiMI4 VXaJfjxQ0BUKSnQtejvqxOoV9J4EW5uG68o0W83kyDWnPe+dkNwgDX3kT9keZzcbAhPE TCIa13u2rHfK9e7QIsiEcep21m4J6m3rmoOHu1cjS9eRcMsh2adEd+ryF6V+ydIlwEGA UV9A== 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=bFIvq1iUBnF2uNTg/XXudUmq/LzMkpvkSS7sgQp5FVU=; b=TY81nLLTF7IS3m4zry1mOqBmOIvh6sOpjGLrxV6uUzxLEuB8eRURHqGSG6d/7Eu51W gLJvDfGbSW2GIf8VnNVkMHl0KNr4tO4mjZuc31yw/PSQvEysXJocOPVEx3tQM2gxWNdR AO1xoYleMQzYmHVY0FxZIhsbN2CoYcIMT6AR5yg01mNPe2dTPZaYQT+SNZhjBCN4firx TW1aO9WBYrFgmoZyP3SW1hg9aZ5yq9/cY2RYkyiEb/0m1W3ABLmDPswIS4kLeR7riczG sxIQBHNtzD9fbqu5Q7/etjW6pDC1Jkc77eBFBV8iV9jZzBNX16oVFc2Ssm7GtNFEwaNP KoYA== X-Gm-Message-State: AOAM532U/WAwWkBu3OXR3BIvmskVIYCla5iwWJ5IRgetc3pZs3PzNqv6 S2GJ1xUx/+UnzLsK7HWgKISdMw== X-Received: by 2002:a17:902:bf44:b029:df:f0eb:cb33 with SMTP id u4-20020a170902bf44b02900dff0ebcb33mr19537849pls.13.1612218229062; Mon, 01 Feb 2021 14:23:49 -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 123sm19531753pfd.91.2021.02.01.14.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 14:23:48 -0800 (PST) Date: Mon, 1 Feb 2021 14:23:47 -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: <20210201215857.ud5cpg7hbxj2j5bx@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> 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?