Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp35931lqs; Mon, 4 Mar 2024 14:09:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVhye3GlAf7JO2aiACR4CW062rWazrjB9aAKZqKPyVn55d6DN/0gYsv43G0PNzSRgFxvXm5mBzckNz97aQihGtcAg324NBwR8rII7zLMw== X-Google-Smtp-Source: AGHT+IFf6E/vIanmNf1E11c3CK7bYw9c/k7zYzDdTzmh/nzyW/MpgaJ3SUiVB7pD9w6YHYVaNtFt X-Received: by 2002:a17:90a:f68e:b0:29b:626a:1c43 with SMTP id cl14-20020a17090af68e00b0029b626a1c43mr586312pjb.5.1709590155452; Mon, 04 Mar 2024 14:09:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709590155; cv=pass; d=google.com; s=arc-20160816; b=CeXQgUucOErhjca7Sjvd1xhuEOyGplFpZRMM2xc0pEpGew+bXuv70ri8pwrHg+JsHW 0DeEjfkN/I5TnDT2O70UjgYOsRXo4cHI3algdD7UPKuq+w+z5q1xKmbixFLD2MbhtdUu UK/qUqW7xZbI1rAzfCAsah3Ho/48OQ72WqwXRUfVYy33N2SswAvUJz6iyNbNLiH7cIIF gcancCmHnH6KjHPnthOMi5gN7prsW+5JOGnOFmTVdaQFUTPc0tXQS+WuylE/BIFNoIun uf+OewO8NNgguf/ilI189kXTAzmBRR1SpWrHBriFE0TKtj/QmcuWdRtaCQxR19cHD6pS o6Rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=sk3CpW1nBlC9B2u3M2hZXqAOuqsrucoph9Nx8BkR6sY=; fh=Tlb8YVpUb/JFm9f8HaiFa3lfhhuwUcP+FSInIYYFOEQ=; b=AbfyqU4mqqulTsPgoLODLmsW2n4guh3QU+mIGXKNLzcXCrX/SPI6hfeEXFUOPWUkGq aZcMO+ePBUJ06YtQJOXEHJBmInr1UuTA8eYoEaHwzyQWaVv/ArXn8WY7F9ycfWkLPYG7 FXwN853jLbOF7GU3zjpUyTeT6ecjnWkzK+Oyd+suGxrqLxETPQdFQGXxlGpAjkmQgCY9 Y2cRUZKJocJsg27zCKJ20oPZL4yXdbs3k2yTtSk1nD1RPz+RjiFWaGbBZ+AMNJjuakGI TDASRmNZoTZpdyABs+8EMrgmu44WbxjBHPjOZoyLHlz5N0QIfOtS1DZ7ZV4IGUAnhn80 0CNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=mm3o2EGL; arc=pass (i=1 spf=pass spfdomain=flex--ipylypiv.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-91339-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o8-20020a17090a55c800b00299bceb07e2si10831942pjm.11.2024.03.04.14.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 14:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91339-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=mm3o2EGL; arc=pass (i=1 spf=pass spfdomain=flex--ipylypiv.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-91339-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91339-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 22F79281B49 for ; Mon, 4 Mar 2024 22:09:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A6027C6D5; Mon, 4 Mar 2024 22:08:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mm3o2EGL" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9469E7BB1E for ; Mon, 4 Mar 2024 22:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709590110; cv=none; b=Xpm778tevM7WENnbYRbW4raWxolkvrWzzNsp4lcUypucEhjeTS66LNYeZYBO24M7Ib0ntNy60tuRnBUv4XHv7jCTY2uwm7NLH49rGyPl4Ewf+PP3LGFJqi/n5gHVX1ByB5ApcHKPyvtdBVeuISKTDCde/XwgFPDSCb60tOMO3Jw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709590110; c=relaxed/simple; bh=3/t65CKOH2IM75rZtN+yfmvVZGp1YUepR4CA+qimXNQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IbqHQEtqVtzAmzbTmtc99RQO09/OYYPUbegeSd4Os3xKNbT3qXk4sW5DpyqA8QY7eyIBUwZrL2GrjI9riLc7R3UynGQejqOP/X0Mw2UOYZH04/M/CGZ9VBYlBYUVZET1GzgGRVJ2USBO3TKFlrtgIgoS7avzV+dYhKeGpHFNANs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mm3o2EGL; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ipylypiv.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-60971264c48so69492317b3.0 for ; Mon, 04 Mar 2024 14:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709590107; x=1710194907; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sk3CpW1nBlC9B2u3M2hZXqAOuqsrucoph9Nx8BkR6sY=; b=mm3o2EGLjKCvgfOjTd5TwuJ7fAFYzkmhabYRif73iE1bQrJGc3lu3uxcqR82e7QHz2 ZS6rQy8WZFZfcDUaZtgyIPMNSelAngJ3OJ629soDnktXAam3nlj4JH8scLxWlLDA0321 wi9V7PFb5uISCqHpCM5ttxprcSnwJ5n7PXzgmaQNjPZI//zgPl60isX8kk/kEMt+ypSS ZNoogYzc145NV1d70SCIrDyuYykf8JMRmCyvLXq/I8dTlhXXQWcy/8EVAoPeZF1oJIRs U9zfkTwT/eDEh4VCsmvJKK8/9cdkY5/ExL6p+hIc8bf6R1jY6GqdzLMfu4EwfKHFRtQH QB8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709590107; x=1710194907; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sk3CpW1nBlC9B2u3M2hZXqAOuqsrucoph9Nx8BkR6sY=; b=FmKXME+A/GvpMo4T+UCMCGm8q1wttwrUzDIWiKcsgUGhB7Rx6Q+8JJ/PSITmTEBHMD hN99US9m6MWUCWlmb/UFbNITr6cjWWDJrVVK48q9dsy5hbT7QikvjKhgW8fADRUaKE6O HvtHHwjh+vPyNs4BL/LBxlM3oDw5XuTlSTg0oc9iW8zVxsdDwbPIQq4NU9/iWktWzzCG MrCmpvDwG6dlTSrehVGXcz+E8ISZp/4aNd+5kI/S2o2OWdco/vyDJHUnA4OrvjAQg614 3hFz2Oz0vcpWwN3dFtVONtBED1r/ohRb2BdSlcZO6GbIXxAsVuUFtNyHJNK2Qh4T4vu2 3XjQ== X-Forwarded-Encrypted: i=1; AJvYcCXny3mIAAVASJdVFl/9EmoUddYvYTGPwxK4xrRkOF3n8/vVDM6odAWrXMnfITLqzStYhGxWP8Io4cLhbSWQ/JQmneiIHcT8h0PfwD6F X-Gm-Message-State: AOJu0Yzh/Z+2JbhPTGpSptRYzPZ2+V9aG4AgHilUbb6RzKvtLS1JoF3p dHzN7jPeHJwSR4+SJvQHWQhnzaMn3scu+hch5btPTUrx11kBj9MY/PgGu/B4SPjBvmvzTkjgMcA 9BIGzAXysXw== X-Received: from ipylypiv.svl.corp.google.com ([2620:15c:2c5:13:e901:e760:20cd:d870]) (user=ipylypiv job=sendgmr) by 2002:a05:690c:3581:b0:609:4293:23eb with SMTP id fr1-20020a05690c358100b00609429323ebmr2224960ywb.10.1709590107631; Mon, 04 Mar 2024 14:08:27 -0800 (PST) Date: Mon, 4 Mar 2024 14:08:10 -0800 In-Reply-To: <20240304220815.1766285-1-ipylypiv@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240304220815.1766285-1-ipylypiv@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240304220815.1766285-3-ipylypiv@google.com> Subject: [PATCH v4 2/7] scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices From: Igor Pylypiv To: Damien Le Moal , Niklas Cassel , John Garry , Jason Yan , "James E.J. Bottomley" , "Martin K. Petersen" , Jack Wang , Hannes Reinecke , Xiang Chen , Artur Paszkiewicz , Bart Van Assche Cc: TJ Adams , linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Igor Pylypiv Content-Type: text/plain; charset="UTF-8" Libata sysfs attributes cannot be used for libsas managed SATA devices because the ata_port location is different for libsas. Defined sysfs attributes (visible for SATA devices only): - /sys/block/sda/device/ncq_prio_enable - /sys/block/sda/device/ncq_prio_supported The newly defined attributes will pass the correct ata_port to libata helper functions. Reviewed-by: John Garry Signed-off-by: Igor Pylypiv --- drivers/scsi/libsas/sas_ata.c | 94 +++++++++++++++++++++++++++++++++++ include/scsi/sas_ata.h | 6 +++ 2 files changed, 100 insertions(+) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index 12e2653846e3..4ecdfa2a12c3 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -964,3 +964,97 @@ int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id) force_phy_id, &tmf_task); } EXPORT_SYMBOL_GPL(sas_execute_ata_cmd); + +static ssize_t sas_ncq_prio_supported_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + bool supported; + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = ata_ncq_prio_supported(ddev->sata_dev.ap, sdev, &supported); + if (rc) + return rc; + + return sysfs_emit(buf, "%d\n", supported); +} + +DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL); + +static ssize_t sas_ncq_prio_enable_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + bool enabled; + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = ata_ncq_prio_enabled(ddev->sata_dev.ap, sdev, &enabled); + if (rc) + return rc; + + return sysfs_emit(buf, "%d\n", enabled); +} + +static ssize_t sas_ncq_prio_enable_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct scsi_device *sdev = to_scsi_device(device); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + bool enable; + int rc; + + /* This attribute shall be visible for SATA devices only */ + if (WARN_ON(!dev_is_sata(ddev))) + return -EINVAL; + + rc = kstrtobool(buf, &enable); + if (rc) + return rc; + + rc = ata_ncq_prio_enable(ddev->sata_dev.ap, sdev, enable); + if (rc) + return rc; + + return len; +} + +DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR, + sas_ncq_prio_enable_show, sas_ncq_prio_enable_store); + +static struct attribute *sas_ata_sdev_attrs[] = { + &dev_attr_ncq_prio_supported.attr, + &dev_attr_ncq_prio_enable.attr, + NULL +}; + +static umode_t sas_ata_attr_is_visible(struct kobject *kobj, + struct attribute *attr, int i) +{ + struct device *dev = kobj_to_dev(kobj); + struct scsi_device *sdev = to_scsi_device(dev); + struct domain_device *ddev = sdev_to_domain_dev(sdev); + + if (!dev_is_sata(ddev)) + return 0; + + return attr->mode; +} + +const struct attribute_group sas_ata_sdev_attr_group = { + .attrs = sas_ata_sdev_attrs, + .is_visible = sas_ata_attr_is_visible, +}; +EXPORT_SYMBOL_GPL(sas_ata_sdev_attr_group); diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h index 2f8c719840a6..cded782fdf33 100644 --- a/include/scsi/sas_ata.h +++ b/include/scsi/sas_ata.h @@ -39,6 +39,8 @@ int smp_ata_check_ready_type(struct ata_link *link); int sas_discover_sata(struct domain_device *dev); int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, struct domain_device *child, int phy_id); + +extern const struct attribute_group sas_ata_sdev_attr_group; #else static inline void sas_ata_disabled_notice(void) @@ -123,6 +125,10 @@ static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *p sas_ata_disabled_notice(); return -ENODEV; } + +static const struct attribute_group sas_ata_sdev_attr_group = { + .attrs = NULL, +}; #endif #endif /* _SAS_ATA_H_ */ -- 2.44.0.278.ge034bb2e1d-goog